refactor: search user inputs
This commit is contained in:
@@ -28,5 +28,7 @@
|
|||||||
|
|
||||||
"search_not_found": "Not found, or this user is not allowed to be searched.",
|
"search_not_found": "Not found, or this user is not allowed to be searched.",
|
||||||
"search_by_id": "Search by ID",
|
"search_by_id": "Search by ID",
|
||||||
"search_by_email": "Search by Email"
|
"search_by_id_ph": "Input user ID",
|
||||||
|
"search_by_email": "Search by Email",
|
||||||
|
"search_by_email_ph": "Input user email"
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -27,5 +27,7 @@
|
|||||||
|
|
||||||
"search_not_found": "用户不存在,或者不允许搜索",
|
"search_not_found": "用户不存在,或者不允许搜索",
|
||||||
"search_by_id": "用户ID",
|
"search_by_id": "用户ID",
|
||||||
"search_by_email": "用户邮箱"
|
"search_by_id_ph": "请输入用户ID",
|
||||||
|
"search_by_email": "用户邮箱",
|
||||||
|
"search_by_email_ph": "请输入用户邮箱"
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -25,7 +25,7 @@ const SearchUser: FC<Props> = ({ closeModal }) => {
|
|||||||
const { t } = useTranslation();
|
const { t } = useTranslation();
|
||||||
const navigateTo = useNavigate();
|
const navigateTo = useNavigate();
|
||||||
const inputRef = useRef(null);
|
const inputRef = useRef(null);
|
||||||
const [type, setType] = useState<Type>("id");
|
const [type, setType] = useState<Type>("email");
|
||||||
const [input, setInput] = useState({
|
const [input, setInput] = useState({
|
||||||
id: "",
|
id: "",
|
||||||
email: ""
|
email: ""
|
||||||
@@ -77,18 +77,18 @@ const SearchUser: FC<Props> = ({ closeModal }) => {
|
|||||||
<Modal>
|
<Modal>
|
||||||
<div className=" relative flex flex-col gap-2 w-96 px-4 py-3 rounded-lg bg-gray-100 dark:bg-gray-900 text-slate-900 dark:text-slate-100">
|
<div className=" relative flex flex-col gap-2 w-96 px-4 py-3 rounded-lg bg-gray-100 dark:bg-gray-900 text-slate-900 dark:text-slate-100">
|
||||||
<div className="flex items-center gap-2 py-2">
|
<div className="flex items-center gap-2 py-2">
|
||||||
<StyledButton
|
|
||||||
className={clsx("mini", type == "email" && "ghost !border-none !shadow-none")}
|
|
||||||
onClick={handleChangeKeyword.bind(null, "id")}
|
|
||||||
>
|
|
||||||
{t("search_by_id", { ns: "member" })}
|
|
||||||
</StyledButton>
|
|
||||||
<StyledButton
|
<StyledButton
|
||||||
className={clsx("mini", type == "id" && "ghost !border-none !shadow-none")}
|
className={clsx("mini", type == "id" && "ghost !border-none !shadow-none")}
|
||||||
onClick={handleChangeKeyword.bind(null, "email")}
|
onClick={handleChangeKeyword.bind(null, "email")}
|
||||||
>
|
>
|
||||||
{t("search_by_email", { ns: "member" })}
|
{t("search_by_email", { ns: "member" })}
|
||||||
</StyledButton>
|
</StyledButton>
|
||||||
|
<StyledButton
|
||||||
|
className={clsx("mini", type == "email" && "ghost !border-none !shadow-none")}
|
||||||
|
onClick={handleChangeKeyword.bind(null, "id")}
|
||||||
|
>
|
||||||
|
{t("search_by_id", { ns: "member" })}
|
||||||
|
</StyledButton>
|
||||||
</div>
|
</div>
|
||||||
<form className="w-full" ref={inputRef} action="/" onSubmit={handleSubmit}>
|
<form className="w-full" ref={inputRef} action="/" onSubmit={handleSubmit}>
|
||||||
<Input
|
<Input
|
||||||
@@ -98,7 +98,11 @@ const SearchUser: FC<Props> = ({ closeModal }) => {
|
|||||||
disabled={isLoading}
|
disabled={isLoading}
|
||||||
prefix={<IconSearch className="dark:fill-gray-400 w-6 h-6 shrink-0" />}
|
prefix={<IconSearch className="dark:fill-gray-400 w-6 h-6 shrink-0" />}
|
||||||
value={input[type]}
|
value={input[type]}
|
||||||
placeholder={`${t("action.search")}...`}
|
placeholder={`${
|
||||||
|
type == "email"
|
||||||
|
? t("search_by_email_ph", { ns: "member" })
|
||||||
|
: t("search_by_id_ph", { ns: "member" })
|
||||||
|
}...`}
|
||||||
onChange={handleInput}
|
onChange={handleInput}
|
||||||
/>
|
/>
|
||||||
</form>
|
</form>
|
||||||
|
|||||||
Reference in New Issue
Block a user