mirror of
https://github.com/perfect-panel/ppanel-web.git
synced 2026-02-06 11:40:28 -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,
|
||||
[key]: value,
|
||||
} as API.SubscribeConfig);
|
||||
toast.success(t('saveSuccess'));
|
||||
toast.success(t('updateSuccess'));
|
||||
refetch();
|
||||
} catch (error) {
|
||||
/* empty */
|
||||
|
||||
@ -105,7 +105,7 @@ export default function SubscribeForm<T extends Record<string, any>>({
|
||||
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<T extends Record<string, any>>({
|
||||
/>
|
||||
<FormField
|
||||
control={form.control}
|
||||
name='purchase_with_discount'
|
||||
name='allow_deduction'
|
||||
render={({ field }) => (
|
||||
<FormItem>
|
||||
<div className='flex items-center justify-between'>
|
||||
|
||||
@ -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<Record<string, string>>({});
|
||||
@ -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) => {
|
||||
|
||||
@ -37,7 +37,7 @@ const basicInfoSchema = z.object({
|
||||
|
||||
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 { common } = useGlobalStore();
|
||||
@ -64,6 +64,7 @@ export function BasicInfoForm({ user }: { user: API.User }) {
|
||||
...data,
|
||||
} as API.UpdateUserBasiceInfoRequest);
|
||||
toast.success(t('updateSuccess'));
|
||||
refetch();
|
||||
}
|
||||
|
||||
return (
|
||||
|
||||
@ -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 (
|
||||
<div className='grid gap-4 md:grid-cols-2 xl:grid-cols-3'>
|
||||
<div className='md:col-span-2 xl:col-span-1'>
|
||||
<BasicInfoForm user={user} />
|
||||
<BasicInfoForm user={user} refetch={refetch} />
|
||||
</div>
|
||||
<div>
|
||||
<NotifySettingsForm user={user} />
|
||||
<NotifySettingsForm user={user} refetch={refetch} />
|
||||
</div>
|
||||
<div>
|
||||
<AuthMethodsForm user={user} />
|
||||
<AuthMethodsForm user={user} refetch={refetch} />
|
||||
</div>
|
||||
</div>
|
||||
);
|
||||
|
||||
@ -20,7 +20,7 @@ const notifySettingsSchema = z.object({
|
||||
|
||||
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 form = useForm<NotifySettingsValues>({
|
||||
@ -39,6 +39,7 @@ export function NotifySettingsForm({ user }: { user: API.User }) {
|
||||
user_id: user.id,
|
||||
});
|
||||
toast.success(t('updateSuccess'));
|
||||
refetch();
|
||||
}
|
||||
|
||||
return (
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user