mirror of
https://github.com/perfect-panel/ppanel-web.git
synced 2026-02-15 21:01:10 -05:00
🐛 fix(subscribe): Update forms to include refetch functionality and improve toast messages
This commit is contained in:
parent
855d1b096f
commit
fc55e9544d
@ -30,7 +30,7 @@ export default function SubscribeConfig() {
|
|||||||
...data,
|
...data,
|
||||||
[key]: value,
|
[key]: value,
|
||||||
} as API.SubscribeConfig);
|
} as API.SubscribeConfig);
|
||||||
toast.success(t('saveSuccess'));
|
toast.success(t('updateSuccess'));
|
||||||
refetch();
|
refetch();
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
/* empty */
|
/* empty */
|
||||||
|
|||||||
@ -105,7 +105,7 @@ export default function SubscribeForm<T extends Record<string, any>>({
|
|||||||
server_group: z.array(z.number()).optional().default([]),
|
server_group: z.array(z.number()).optional().default([]),
|
||||||
server: z.array(z.number()).optional().default([]),
|
server: z.array(z.number()).optional().default([]),
|
||||||
deduction_ratio: z.number().optional().default(0),
|
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),
|
reset_cycle: z.number().optional().default(0),
|
||||||
renewal_reset: z.boolean().optional().default(false),
|
renewal_reset: z.boolean().optional().default(false),
|
||||||
});
|
});
|
||||||
@ -639,7 +639,7 @@ export default function SubscribeForm<T extends Record<string, any>>({
|
|||||||
/>
|
/>
|
||||||
<FormField
|
<FormField
|
||||||
control={form.control}
|
control={form.control}
|
||||||
name='purchase_with_discount'
|
name='allow_deduction'
|
||||||
render={({ field }) => (
|
render={({ field }) => (
|
||||||
<FormItem>
|
<FormItem>
|
||||||
<div className='flex items-center justify-between'>
|
<div className='flex items-center justify-between'>
|
||||||
|
|||||||
@ -13,7 +13,7 @@ import { useTranslations } from 'next-intl';
|
|||||||
import { useState } from 'react';
|
import { useState } from 'react';
|
||||||
import { toast } from 'sonner';
|
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 t = useTranslations('user');
|
||||||
|
|
||||||
const [emailChanges, setEmailChanges] = useState<Record<string, string>>({});
|
const [emailChanges, setEmailChanges] = useState<Record<string, string>>({});
|
||||||
@ -33,6 +33,7 @@ export function AuthMethodsForm({ user }: { user: API.User }) {
|
|||||||
auth_identifier: email,
|
auth_identifier: email,
|
||||||
});
|
});
|
||||||
toast.success(t('updateSuccess'));
|
toast.success(t('updateSuccess'));
|
||||||
|
refetch();
|
||||||
};
|
};
|
||||||
|
|
||||||
const handleCreateEmail = async (email: string) => {
|
const handleCreateEmail = async (email: string) => {
|
||||||
@ -42,6 +43,7 @@ export function AuthMethodsForm({ user }: { user: API.User }) {
|
|||||||
auth_identifier: email,
|
auth_identifier: email,
|
||||||
});
|
});
|
||||||
toast.success(t('createSuccess'));
|
toast.success(t('createSuccess'));
|
||||||
|
refetch();
|
||||||
};
|
};
|
||||||
|
|
||||||
const handleEmailChange = (authType: string, value: string) => {
|
const handleEmailChange = (authType: string, value: string) => {
|
||||||
|
|||||||
@ -37,7 +37,7 @@ const basicInfoSchema = z.object({
|
|||||||
|
|
||||||
type BasicInfoValues = z.infer<typeof basicInfoSchema>;
|
type BasicInfoValues = z.infer<typeof basicInfoSchema>;
|
||||||
|
|
||||||
export function BasicInfoForm({ user }: { user: API.User }) {
|
export function BasicInfoForm({ user, refetch }: { user: API.User; refetch: () => void }) {
|
||||||
const t = useTranslations('user');
|
const t = useTranslations('user');
|
||||||
|
|
||||||
const { common } = useGlobalStore();
|
const { common } = useGlobalStore();
|
||||||
@ -64,6 +64,7 @@ export function BasicInfoForm({ user }: { user: API.User }) {
|
|||||||
...data,
|
...data,
|
||||||
} as API.UpdateUserBasiceInfoRequest);
|
} as API.UpdateUserBasiceInfoRequest);
|
||||||
toast.success(t('updateSuccess'));
|
toast.success(t('updateSuccess'));
|
||||||
|
refetch();
|
||||||
}
|
}
|
||||||
|
|
||||||
return (
|
return (
|
||||||
|
|||||||
@ -10,7 +10,7 @@ import { NotifySettingsForm } from './notify-settings-form';
|
|||||||
export function UserProfileForm() {
|
export function UserProfileForm() {
|
||||||
const { id } = useParams<{ id: string }>();
|
const { id } = useParams<{ id: string }>();
|
||||||
|
|
||||||
const { data: user } = useQuery({
|
const { data: user, refetch } = useQuery({
|
||||||
queryKey: ['user', id],
|
queryKey: ['user', id],
|
||||||
queryFn: async () => {
|
queryFn: async () => {
|
||||||
const { data } = await getUserDetail({
|
const { data } = await getUserDetail({
|
||||||
@ -25,13 +25,13 @@ export function UserProfileForm() {
|
|||||||
return (
|
return (
|
||||||
<div className='grid gap-4 md:grid-cols-2 xl:grid-cols-3'>
|
<div className='grid gap-4 md:grid-cols-2 xl:grid-cols-3'>
|
||||||
<div className='md:col-span-2 xl:col-span-1'>
|
<div className='md:col-span-2 xl:col-span-1'>
|
||||||
<BasicInfoForm user={user} />
|
<BasicInfoForm user={user} refetch={refetch} />
|
||||||
</div>
|
</div>
|
||||||
<div>
|
<div>
|
||||||
<NotifySettingsForm user={user} />
|
<NotifySettingsForm user={user} refetch={refetch} />
|
||||||
</div>
|
</div>
|
||||||
<div>
|
<div>
|
||||||
<AuthMethodsForm user={user} />
|
<AuthMethodsForm user={user} refetch={refetch} />
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
);
|
);
|
||||||
|
|||||||
@ -20,7 +20,7 @@ const notifySettingsSchema = z.object({
|
|||||||
|
|
||||||
type NotifySettingsValues = z.infer<typeof notifySettingsSchema>;
|
type NotifySettingsValues = z.infer<typeof notifySettingsSchema>;
|
||||||
|
|
||||||
export function NotifySettingsForm({ user }: { user: API.User }) {
|
export function NotifySettingsForm({ user, refetch }: { user: API.User; refetch: () => void }) {
|
||||||
const t = useTranslations('user');
|
const t = useTranslations('user');
|
||||||
|
|
||||||
const form = useForm<NotifySettingsValues>({
|
const form = useForm<NotifySettingsValues>({
|
||||||
@ -39,6 +39,7 @@ export function NotifySettingsForm({ user }: { user: API.User }) {
|
|||||||
user_id: user.id,
|
user_id: user.id,
|
||||||
});
|
});
|
||||||
toast.success(t('updateSuccess'));
|
toast.success(t('updateSuccess'));
|
||||||
|
refetch();
|
||||||
}
|
}
|
||||||
|
|
||||||
return (
|
return (
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user