diff --git a/dashboard/src/features/users/dialogs/mutation/fields/services.tsx b/dashboard/src/features/users/dialogs/mutation/fields/services.tsx index e51443b..ec19961 100644 --- a/dashboard/src/features/users/dialogs/mutation/fields/services.tsx +++ b/dashboard/src/features/users/dialogs/mutation/fields/services.tsx @@ -1,4 +1,7 @@ import { + Alert, + AlertDescription, + AlertTitle, Checkbox, FormControl, FormField, @@ -6,7 +9,10 @@ import { FormLabel, FormMessage, ScrollArea, + Skeleton, } from "@marzneshin/components"; +import { Link } from "@tanstack/react-router"; +import { ExclamationTriangleIcon } from '@radix-ui/react-icons'; import { useServicesQuery, type ServiceType, @@ -29,34 +35,81 @@ interface ServiceCheckboxCardProps { const ServiceCheckboxCard: FC = ({ service, field, -}) => { +}) => ( +
+ + checked + ? field.onChange([...field.value, service.id]) + : field.onChange( + field.value?.filter((value: number) => value !== service.id), + ) + } + /> + + + +
+); + +const ServiceSkeletons: FC = () => ( + <> + + + + +); + +const ServicesList: FC<{ services: ServiceType[] }> = ({ services }) => { + const form = useFormContext(); + return ( -
- { - return checked - ? field.onChange([...field.value, service.id]) - : field.onChange( - field.value?.filter((value: number) => value !== service.id), - ); - }} - /> - - - -
+ + {services.map((service) => ( + ( + + + + + + + )} + /> + ))} + + ); +}; + +const ServicesAlert: FC = () => { + const { t } = useTranslation(); + + return ( + + + {t('page.users.services-alert.title')} + + {t('page.users.services-alert.desc')} + + {t('page.users.services-alert.click')} + + + ); }; export const ServicesField: FC = () => { const form = useFormContext(); - const { data } = useServicesQuery({ page: 1, size: 100 }); + const { data, isFetching } = useServicesQuery({ page: 1, size: 100 }); const { t } = useTranslation(); return ( @@ -66,23 +119,13 @@ export const ServicesField: FC = () => { render={() => ( {t("services")} - - {data.entity.map((service) => ( - ( - - - - - - - )} - /> - ))} - + {isFetching ? ( + + ) : data.entity.length !== 0 ? ( + + ) : ( + + )} )} /> diff --git a/dashboard/src/features/users/dialogs/mutation/index.tsx b/dashboard/src/features/users/dialogs/mutation/index.tsx index 03e09d1..ce3deae 100644 --- a/dashboard/src/features/users/dialogs/mutation/index.tsx +++ b/dashboard/src/features/users/dialogs/mutation/index.tsx @@ -71,7 +71,7 @@ export const UsersMutationDialog: FC = ({ return ( - + {entity @@ -80,7 +80,7 @@ export const UsersMutationDialog: FC = ({
- +