🐛 fix(subscribe): Update forms to include refetch functionality and improve toast messages
This commit is contained in:
@@ -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 (
|
||||
|
||||
Reference in New Issue
Block a user