diff --git a/app/(protected)/admin/system/app-configs.tsx b/app/(protected)/admin/system/app-configs.tsx index 3feffcf..c06bc2b 100644 --- a/app/(protected)/admin/system/app-configs.tsx +++ b/app/(protected)/admin/system/app-configs.tsx @@ -8,26 +8,28 @@ import useSWR from "swr"; import { fetcher } from "@/lib/utils"; import { Badge } from "@/components/ui/badge"; import { Button } from "@/components/ui/button"; -import { Card, CardContent, CardHeader, CardTitle } from "@/components/ui/card"; +import { Card } from "@/components/ui/card"; import { Collapsible, CollapsibleContent, CollapsibleTrigger, } from "@/components/ui/collapsible"; +import { Skeleton } from "@/components/ui/skeleton"; import { Switch } from "@/components/ui/switch"; import { Textarea } from "@/components/ui/textarea"; import { Icons } from "@/components/shared/icons"; -import { SkeletonSection } from "@/components/shared/section-skeleton"; export default function AppConfigs({}: {}) { const [isPending, startTransition] = useTransition(); const [loginMethodCount, setLoginMethodCount] = useState(0); - const { data: configs, isLoading } = useSWR>( - "/api/admin/configs", - fetcher, - ); + const { + data: configs, + isLoading, + mutate, + } = useSWR>("/api/admin/configs", fetcher); const [notification, setNotification] = useState(""); + const [catchAllEmails, setCatchAllEmails] = useState(""); const t = useTranslations("Setting"); @@ -35,6 +37,9 @@ export default function AppConfigs({}: {}) { if (!isLoading && configs?.system_notification) { setNotification(configs.system_notification); } + if (!isLoading && configs?.catch_all_emails) { + setCatchAllEmails(configs.catch_all_emails); + } // 计算登录方式数量 if (!isLoading) { let count = 0; @@ -55,6 +60,7 @@ export default function AppConfigs({}: {}) { }); if (res.ok) { toast.success("Updated!"); + mutate(); } else { toast.error("Failed!", { description: await res.text(), @@ -66,180 +72,329 @@ export default function AppConfigs({}: {}) { if (isLoading) { return ( <> - - + ); } return ( - - - {t("App Configs")} - - -
-
-
-

{t("User Registration")}

-

- {t("Allow users to sign up")} -

-
- {configs && ( - - handleChange(v, "enable_user_registration", "BOOLEAN") - } - /> - )} -
- - - -
-

{t("Login Methods")}

- + + + +
{t("App Configs")}
+ + +
+ +
+
+
+

{t("User Registration")}

- {t("Select the login methods that users can use to log in")} + {t("Allow users to sign up")}

- - - {loginMethodCount} - - {configs && ( - <> -
-

- GitHub OAuth -

- - handleChange(v, "enable_github_oauth", "BOOLEAN") - } - /> -
-
-

- - Google OAuth -

- - handleChange(v, "enable_google_oauth", "BOOLEAN") - } - /> -
-
-

- linuxdo - LinuxDo OAuth -

- - handleChange(v, "enable_liunxdo_oauth", "BOOLEAN") - } - /> -
-
-

- - {t("Resend Email")} -

- - handleChange(v, "enable_resend_email_login", "BOOLEAN") - } - /> -
-
-

- - {t("Email Password")} -

- - handleChange( - v, - "enable_email_password_login", - "BOOLEAN", - ) - } - /> -
- - )} -
- - -
-
-

{t("Subdomain Apply Mode")}

-

- {t( - "Enable subdomain apply mode, each submission requires administrator review", - )} -

-
- {configs && ( - - handleChange(v, "enable_subdomain_apply", "BOOLEAN") - } - /> - )} -
-
-
-

{t("Notification")}

-

- {t( - "Set system notification, this will be displayed in the header", - )} -

-
- {configs && ( -
-