gitscope
← marzneshin / v0.7.3 / dashboard/src/modules/users/components/form-fields/username.tsx
https://dev.kronoz.win/r/marzneshin.git
dashboard/src/modules/users/components/form-fields/username.tsx · TypeScript
Blame Raw
 1import {
 2    FormControl,
 3    FormField,
 4    FormItem,
 5    Input,
 6    FormLabel,
 7    FormMessage,
 8} from "@marzneshin/common/components";
 9import type { FC, InputHTMLAttributes } from "react";
10import { useFormContext } from "react-hook-form";
11import { useTranslation } from "react-i18next";
12
13export const UsernameField: FC<InputHTMLAttributes<HTMLElement>> = ({
14    disabled,
15}) => {
16    const form = useFormContext();
17    const { t } = useTranslation();
18
19    return (
20        <FormField
21            control={form.control}
22            name="username"
23            render={({ field }) => (
24                <FormItem>
25                    <FormLabel>{t("username")}</FormLabel>
26                    <FormControl>
27                        <Input disabled={disabled} {...field} />
28                    </FormControl>
29                    <FormMessage />
30                </FormItem>
31            )}
32        />
33    );
34};