From fc55e9544d7b9e58009607288d0df3140781f949 Mon Sep 17 00:00:00 2001 From: "web@ppanel" Date: Sun, 16 Feb 2025 17:08:34 +0700 Subject: [PATCH] =?UTF-8?q?=F0=9F=90=9B=20fix(subscribe):=20Update=20forms?= =?UTF-8?q?=20to=20include=20refetch=20functionality=20and=20improve=20toa?= =?UTF-8?q?st=20messages?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- apps/admin/app/dashboard/subscribe/subscribe-config.tsx | 2 +- apps/admin/app/dashboard/subscribe/subscribe-form.tsx | 4 ++-- .../user/[id]/user-profile/auth-methods-form.tsx | 4 +++- .../dashboard/user/[id]/user-profile/basic-info-form.tsx | 3 ++- apps/admin/app/dashboard/user/[id]/user-profile/index.tsx | 8 ++++---- .../user/[id]/user-profile/notify-settings-form.tsx | 3 ++- 6 files changed, 14 insertions(+), 10 deletions(-) diff --git a/apps/admin/app/dashboard/subscribe/subscribe-config.tsx b/apps/admin/app/dashboard/subscribe/subscribe-config.tsx index 433ef14..4b78987 100644 --- a/apps/admin/app/dashboard/subscribe/subscribe-config.tsx +++ b/apps/admin/app/dashboard/subscribe/subscribe-config.tsx @@ -30,7 +30,7 @@ export default function SubscribeConfig() { ...data, [key]: value, } as API.SubscribeConfig); - toast.success(t('saveSuccess')); + toast.success(t('updateSuccess')); refetch(); } catch (error) { /* empty */ diff --git a/apps/admin/app/dashboard/subscribe/subscribe-form.tsx b/apps/admin/app/dashboard/subscribe/subscribe-form.tsx index 993cd24..314d2ff 100644 --- a/apps/admin/app/dashboard/subscribe/subscribe-form.tsx +++ b/apps/admin/app/dashboard/subscribe/subscribe-form.tsx @@ -105,7 +105,7 @@ export default function SubscribeForm>({ server_group: z.array(z.number()).optional().default([]), server: z.array(z.number()).optional().default([]), deduction_ratio: z.number().optional().default(0), - purchase_with_discount: z.boolean().optional().default(false), + allow_deduction: z.boolean().optional().default(false), reset_cycle: z.number().optional().default(0), renewal_reset: z.boolean().optional().default(false), }); @@ -639,7 +639,7 @@ export default function SubscribeForm>({ /> (
diff --git a/apps/admin/app/dashboard/user/[id]/user-profile/auth-methods-form.tsx b/apps/admin/app/dashboard/user/[id]/user-profile/auth-methods-form.tsx index 0efbf9e..7b97ddb 100644 --- a/apps/admin/app/dashboard/user/[id]/user-profile/auth-methods-form.tsx +++ b/apps/admin/app/dashboard/user/[id]/user-profile/auth-methods-form.tsx @@ -13,7 +13,7 @@ import { useTranslations } from 'next-intl'; import { useState } from 'react'; import { toast } from 'sonner'; -export function AuthMethodsForm({ user }: { user: API.User }) { +export function AuthMethodsForm({ user, refetch }: { user: API.User; refetch: () => void }) { const t = useTranslations('user'); const [emailChanges, setEmailChanges] = useState>({}); @@ -33,6 +33,7 @@ export function AuthMethodsForm({ user }: { user: API.User }) { auth_identifier: email, }); toast.success(t('updateSuccess')); + refetch(); }; const handleCreateEmail = async (email: string) => { @@ -42,6 +43,7 @@ export function AuthMethodsForm({ user }: { user: API.User }) { auth_identifier: email, }); toast.success(t('createSuccess')); + refetch(); }; const handleEmailChange = (authType: string, value: string) => { diff --git a/apps/admin/app/dashboard/user/[id]/user-profile/basic-info-form.tsx b/apps/admin/app/dashboard/user/[id]/user-profile/basic-info-form.tsx index ece80fc..752446f 100644 --- a/apps/admin/app/dashboard/user/[id]/user-profile/basic-info-form.tsx +++ b/apps/admin/app/dashboard/user/[id]/user-profile/basic-info-form.tsx @@ -37,7 +37,7 @@ const basicInfoSchema = z.object({ type BasicInfoValues = z.infer; -export function BasicInfoForm({ user }: { user: API.User }) { +export function BasicInfoForm({ user, refetch }: { user: API.User; refetch: () => void }) { const t = useTranslations('user'); const { common } = useGlobalStore(); @@ -64,6 +64,7 @@ export function BasicInfoForm({ user }: { user: API.User }) { ...data, } as API.UpdateUserBasiceInfoRequest); toast.success(t('updateSuccess')); + refetch(); } return ( diff --git a/apps/admin/app/dashboard/user/[id]/user-profile/index.tsx b/apps/admin/app/dashboard/user/[id]/user-profile/index.tsx index c269ca8..38611ca 100644 --- a/apps/admin/app/dashboard/user/[id]/user-profile/index.tsx +++ b/apps/admin/app/dashboard/user/[id]/user-profile/index.tsx @@ -10,7 +10,7 @@ import { NotifySettingsForm } from './notify-settings-form'; export function UserProfileForm() { const { id } = useParams<{ id: string }>(); - const { data: user } = useQuery({ + const { data: user, refetch } = useQuery({ queryKey: ['user', id], queryFn: async () => { const { data } = await getUserDetail({ @@ -25,13 +25,13 @@ export function UserProfileForm() { return (
- +
- +
- +
); diff --git a/apps/admin/app/dashboard/user/[id]/user-profile/notify-settings-form.tsx b/apps/admin/app/dashboard/user/[id]/user-profile/notify-settings-form.tsx index 4518ca7..1dbd341 100644 --- a/apps/admin/app/dashboard/user/[id]/user-profile/notify-settings-form.tsx +++ b/apps/admin/app/dashboard/user/[id]/user-profile/notify-settings-form.tsx @@ -20,7 +20,7 @@ const notifySettingsSchema = z.object({ type NotifySettingsValues = z.infer; -export function NotifySettingsForm({ user }: { user: API.User }) { +export function NotifySettingsForm({ user, refetch }: { user: API.User; refetch: () => void }) { const t = useTranslations('user'); const form = useForm({ @@ -39,6 +39,7 @@ export function NotifySettingsForm({ user }: { user: API.User }) { user_id: user.id, }); toast.success(t('updateSuccess')); + refetch(); } return (