diff --git a/client/modules/profile/edit/template.tsx b/client/modules/profile/edit/template.tsx index 6972be4a..97e01fd2 100644 --- a/client/modules/profile/edit/template.tsx +++ b/client/modules/profile/edit/template.tsx @@ -2,7 +2,6 @@ import React, { useEffect, useMemo, useState } from "react" import { StaticImport } from "next/dist/shared/lib/get-img-props" -import { useRouter } from "next/navigation" import { conditionalValidation } from "@/modules/profile/form/validation.ts/conditional" import { maximumWordValidation } from "@/modules/profile/form/validation.ts/max-word" import { nameValidation } from "@/modules/profile/form/validation.ts/name" @@ -48,6 +47,7 @@ interface IEdiProfileTemplate { isReferer: boolean isReferee: boolean setIsEditMode: (value: boolean) => void + refetchProfile: () => void } const EditProfileTemplate: React.FunctionComponent = ({ @@ -66,6 +66,7 @@ const EditProfileTemplate: React.FunctionComponent = ({ isReferee, isProfileLoading, setIsEditMode, + refetchProfile, }) => { const formSchema = z .object({ @@ -144,7 +145,6 @@ const EditProfileTemplate: React.FunctionComponent = ({ } ) - const router = useRouter() const { toast } = useToast() const [image, setImage] = useState(null) const [base64Image, setBase64Image] = useState( @@ -280,7 +280,8 @@ const EditProfileTemplate: React.FunctionComponent = ({ toast({ title: "個人檔案更改成功!", }) - router.push("/") + setIsEditMode(false) + refetchProfile() }, onSettled: () => { setIsSubmitting(false) diff --git a/client/modules/profile/template.tsx b/client/modules/profile/template.tsx index 42d7626c..484a2444 100644 --- a/client/modules/profile/template.tsx +++ b/client/modules/profile/template.tsx @@ -12,7 +12,7 @@ import CommonPageLayout from "@/components/layouts/common" const ProfileTemplate = ({ userUuid }: { userUuid: string }) => { const [isEditMode, setIsEditMode] = useState(false) - const { data: profile, isLoading } = useGetUserprofile(userUuid) + const { data: profile, isLoading, refetch } = useGetUserprofile(userUuid) if (!userUuid || (!isLoading && !profile)) return ( @@ -76,6 +76,7 @@ const ProfileTemplate = ({ userUuid }: { userUuid: string }) => { isReferer={profile.is_referer} isProfileLoading={isLoading} setIsEditMode={setIsEditMode} + refetchProfile={refetch} /> )}