diff --git a/dashboard/src/features/admins/components/dialogs/mutation/index.tsx b/dashboard/src/features/admins/components/dialogs/mutation/index.tsx index fba552b..ff7b88d 100644 --- a/dashboard/src/features/admins/components/dialogs/mutation/index.tsx +++ b/dashboard/src/features/admins/components/dialogs/mutation/index.tsx @@ -1,4 +1,4 @@ -import { type FC, useState, useEffect, useCallback } from "react"; +import { type FC, useState, useMemo } from "react"; import { DialogTitle, DialogContent, @@ -14,7 +14,6 @@ import { useAdminsCreationMutation, useAdminsUpdateMutation, AdminMutationSchema, - type AdminMutationType, AdminType, } from "@marzneshin/features/admins"; import { ServicesField } from "@marzneshin/features/services"; @@ -27,40 +26,29 @@ import { SudoPrivilageField, AllServicesAccessField, } from "./fields"; -import { useMutationDialog } from "@marzneshin/hooks"; +import { useMutationDialog, MutationDialogProps } from "@marzneshin/hooks"; -interface AdminsMutationDialogProps { - open: boolean; - onOpenChange: (state: boolean) => void; - onClose: () => void; - entity?: AdminType | null; -} - -export const AdminsMutationDialog: FC = ({ - open, - onOpenChange, +export const AdminsMutationDialog: FC> = ({ onClose, entity = null, }) => { const { t } = useTranslation(); - const getDefaultValues = useCallback( - (): AdminMutationType => ({ - service_ids: [], - username: "", - password: null, - is_sudo: false, - enabled: true, - }), - [], - ); - const { form, handleSubmit } = useMutationDialog({ + const defaultValue = useMemo(() => ({ + service_ids: [], + username: "", + password: null, + is_sudo: false, + enabled: true, + }), []) + + const { onOpenChange, open, form, handleSubmit } = useMutationDialog({ entity, - onOpenChange, + onClose, createMutation: useAdminsCreationMutation(), updateMutation: useAdminsUpdateMutation(), schema: AdminMutationSchema, - getDefaultValue: getDefaultValues, + defaultValue, }); const [change, setChange] = useState(entity === null); @@ -71,10 +59,6 @@ export const AdminsMutationDialog: FC = ({ shouldDirty: true, }); - useEffect(() => { - if (!open) onClose(); - }, [open, onClose]); - return ( diff --git a/dashboard/src/features/github-repo/github-repo.stories.tsx b/dashboard/src/features/github-repo/github-repo.stories.tsx index 9b8ecd5..1cdfeff 100644 --- a/dashboard/src/features/github-repo/github-repo.stories.tsx +++ b/dashboard/src/features/github-repo/github-repo.stories.tsx @@ -15,15 +15,19 @@ type Story = StoryObj; * Github repo present repo fullname, description, and repo stars. * */ export const GithubRepoStats: Story = { - args: {} + args: { + full_name: "marzneshin/marzneshin", + description: "Scalable and Comprehensive Backend Proxy Management", + stargazers_count: 1000, + } } - /** * Mini variant of Github repo present repo only the github logo and stars. * */ export const GithubRepoStatsMini: Story = { args: { + stargazers_count: 1000, variant: "mini" } } diff --git a/dashboard/src/features/github-repo/index.tsx b/dashboard/src/features/github-repo/github-repo.tsx similarity index 55% rename from dashboard/src/features/github-repo/index.tsx rename to dashboard/src/features/github-repo/github-repo.tsx index 1942960..34c6401 100644 --- a/dashboard/src/features/github-repo/index.tsx +++ b/dashboard/src/features/github-repo/github-repo.tsx @@ -5,9 +5,6 @@ import { CardDescription, Button, } from "@marzneshin/components" -import { - useGithubRepoStatsQuery -} from "./services"; import { type FC } from "react"; import { GithubIcon, @@ -17,32 +14,35 @@ import { projectInfo } from "@marzneshin/utils"; interface GithubRepoProps { variant?: "full" | "mini" + stargazers_count: number; + full_name?: string; + description?: string; } -export const GithubRepo: FC = ({ variant = "full" }) => { - const { data: stats } = useGithubRepoStatsQuery() +export const GithubRepo: FC = ({ variant = "full", stargazers_count, full_name, description }) => { return (