diff --git a/dashboard/src/features/hosts/dialogs/mutation/fields/fragment.tsx b/dashboard/src/features/hosts/dialogs/mutation/fields/fragment.tsx index 87a0204..2ad049b 100644 --- a/dashboard/src/features/hosts/dialogs/mutation/fields/fragment.tsx +++ b/dashboard/src/features/hosts/dialogs/mutation/fields/fragment.tsx @@ -1,198 +1,194 @@ import { - FormControl, - FormField, - FormItem, - FormLabel, - Input, - Button, - Popover, - PopoverContent, - PopoverTrigger, + FormControl, + FormField, + FormItem, + FormLabel, + Input, + Button, + Popover, + PopoverContent, + PopoverTrigger, } from "@marzneshin/components"; -import { - useWatch, - useFormContext, - FieldErrors, - FieldError, -} from "react-hook-form"; +import type { FieldErrors, FieldError } from "react-hook-form"; +import { useWatch, useFormContext } from "react-hook-form"; import { useTranslation } from "react-i18next"; import { MailWarning, TrashIcon } from "lucide-react"; -import { FC } from "react"; +import type { FC } from "react"; interface FragmentForm { - fragment: { - packets: FieldError; - length: FieldError; - interval: FieldError; - }; + fragment: { + packets: FieldError; + length: FieldError; + interval: FieldError; + }; } const FragmentErrorPopover: FC = () => { - const form = useFormContext(); - const { t } = useTranslation(); - const errors = form.formState.errors as FieldErrors; - return ( - - - - - -
    - {errors.fragment?.length?.message && ( -
  • - Length: {t(errors.fragment.length.message as string)} -
  • - )} - {errors.fragment?.packets?.message && ( -
  • - Packets: {t(errors.fragment.packets.message as string)} -
  • - )} - {errors.fragment?.interval?.message && ( -
  • - Interval: {t(errors.fragment.interval.message as string)} -
  • - )} -
-
-
- ); + const form = useFormContext(); + const { t } = useTranslation(); + const errors = form.formState.errors as FieldErrors; + return ( + + + + + +
    + {errors.fragment?.length?.message && ( +
  • + Length: {t(errors.fragment.length.message as string)} +
  • + )} + {errors.fragment?.packets?.message && ( +
  • + Packets: {t(errors.fragment.packets.message as string)} +
  • + )} + {errors.fragment?.interval?.message && ( +
  • + Interval: {t(errors.fragment.interval.message as string)} +
  • + )} +
+
+
+ ); }; export const FragmentField = () => { - const { t } = useTranslation(); - const form = useFormContext(); - const errors = form.formState.errors as FieldErrors; - const fragment = useWatch({ name: "fragment" }); - const disabled = fragment === null; + const { t } = useTranslation(); + const form = useFormContext(); + const errors = form.formState.errors as FieldErrors; + const fragment = useWatch({ name: "fragment" }); + const disabled = fragment === null || fragment === undefined; - const enable = () => { - form.setValue( - "fragment", - { length: "", packets: "", interval: "" }, - { - shouldTouch: true, - shouldDirty: true, - }, - ); - }; + const enable = () => { + form.setValue( + "fragment", + { length: "", packets: "", interval: "" }, + { + shouldTouch: true, + shouldDirty: true, + }, + ); + }; - const disable = () => { - form.setValue("fragment.length", ""); - form.setValue("fragment.packets", ""); - form.setValue("fragment.interval", ""); - form.setValue("fragment", null, { - shouldValidate: true, - shouldTouch: false, - shouldDirty: false, - }); - }; + const disable = () => { + form.setValue("fragment.length", ""); + form.setValue("fragment.packets", ""); + form.setValue("fragment.interval", ""); + form.setValue("fragment", null, { + shouldValidate: true, + shouldTouch: false, + shouldDirty: false, + }); + }; - const hasFragmentErrors = (errors: FieldErrors) => - errors.fragment?.packets || - errors.fragment?.length || - errors.fragment?.interval; + const hasFragmentErrors = (errors: FieldErrors) => + errors.fragment?.packets || + errors.fragment?.length || + errors.fragment?.interval; - return ( - ( - - - {t("fragment")} -
- {hasFragmentErrors(errors) && } - {!disabled && ( - - )} -
-
+ return ( + ( + + + {t("fragment")} +
+ {hasFragmentErrors(errors) && } + {!disabled && ( + + )} +
+
- -
- {!disabled ? ( - <> - ( -
- - - {t("page.hosts.fragment.packets")} - - - - - -
- )} - /> - ( -
- - - {t("page.hosts.fragment.length")} - - - - - -
- )} - /> - ( -
- - - {t("page.hosts.fragment.interval")} - - - - - -
- )} - /> - - ) : ( - - )} -
-
-
- )} - /> - ); + +
+ {!disabled ? ( + <> + ( +
+ + + {t("page.hosts.fragment.packets")} + + + + + +
+ )} + /> + ( +
+ + + {t("page.hosts.fragment.length")} + + + + + +
+ )} + /> + ( +
+ + + {t("page.hosts.fragment.interval")} + + + + + +
+ )} + /> + + ) : ( + + )} +
+
+
+ )} + /> + ); }; diff --git a/dashboard/src/features/hosts/dialogs/mutation/index.tsx b/dashboard/src/features/hosts/dialogs/mutation/index.tsx index 9428b92..35ada51 100644 --- a/dashboard/src/features/hosts/dialogs/mutation/index.tsx +++ b/dashboard/src/features/hosts/dialogs/mutation/index.tsx @@ -1,4 +1,5 @@ -import { FC, useEffect } from "react"; +import { useEffect } from "react"; +import type { FC } from "react"; import { DialogTitle, DialogContent, @@ -10,17 +11,19 @@ import { AccordionContent, AccordionItem, AccordionTrigger, + ScrollArea, + HStack, } from "@marzneshin/components"; import { useForm } from "react-hook-form"; import { zodResolver } from "@hookform/resolvers/zod"; import { useTranslation } from "react-i18next"; import { HostSchema, - HostType, getDefaultValues, useHostsCreationMutation, useHostsUpdateMutation, } from "@marzneshin/features/hosts"; +import type { HostType } from "@marzneshin/features/hosts"; import { RemarkField } from "./fields/remark"; import { AddressField, @@ -76,44 +79,49 @@ export const HostsMutationDialog: FC = ({ return ( - - - - {entity - ? t("page.hosts.dialogs.edition.title") - : t("page.hosts.dialogs.creation.title")} - - -
- - -
- - -
- - - {t("advanced-options")} - -
- - -
- - - -
-
-
- - - + + + + + + + + {t("advanced-options")} + +
+ + +
+ + + +
+
+
+ + + +
); diff --git a/dashboard/src/features/users/dialogs/mutation/index.tsx b/dashboard/src/features/users/dialogs/mutation/index.tsx index 180ed74..a39844c 100644 --- a/dashboard/src/features/users/dialogs/mutation/index.tsx +++ b/dashboard/src/features/users/dialogs/mutation/index.tsx @@ -65,7 +65,7 @@ export const UsersMutationDialog: FC = ({ return ( - +