From 1561224dbb062926bc7d666f80b0a5bb965b072d Mon Sep 17 00:00:00 2001 From: zomars Date: Tue, 6 Sep 2022 21:24:12 -0600 Subject: [PATCH] Type fixes --- .../steps-views/UserProfile.tsx | 56 +++++++++---------- 1 file changed, 25 insertions(+), 31 deletions(-) diff --git a/apps/web/components/getting-started/steps-views/UserProfile.tsx b/apps/web/components/getting-started/steps-views/UserProfile.tsx index e7725e9da2..a05de87381 100644 --- a/apps/web/components/getting-started/steps-views/UserProfile.tsx +++ b/apps/web/components/getting-started/steps-views/UserProfile.tsx @@ -23,7 +23,7 @@ const UserProfile = (props: IUserProfile) => { const { user } = props; const { t } = useLocale(); const avatarRef = useRef(null!); - const bioRef = useRef(null); + const bioRef = useRef(null); const { register, setValue, @@ -36,36 +36,31 @@ const UserProfile = (props: IUserProfile) => { const router = useRouter(); const createEventType = trpc.useMutation("viewer.eventTypes.create"); - const onSuccess = async ( - _data: string | undefined, - context: Partial<{ bio: string; completedOnboarding: boolean; avatar: string }> - ) => { - if (context.avatar) { - showToast(t("your_user_profile_updated_successfully"), "success"); - await utils.refetchQueries(["viewer.me"]); - } else { - try { - if (eventTypes?.length === 0) { - await Promise.all( - DEFAULT_EVENT_TYPES.map(async (event) => { - return createEventType.mutate(event); - }) - ); - } - } catch (error) { - console.error(error); - } - - await utils.refetchQueries(["viewer.me"]); - router.push("/"); - } - }; - const onError = () => { - showToast(t("problem_saving_user_profile"), "error"); - }; const mutation = trpc.useMutation("viewer.updateProfile", { - onSuccess, - onError, + onSuccess: async (_data, context) => { + if (context.avatar) { + showToast(t("your_user_profile_updated_successfully"), "success"); + await utils.refetchQueries(["viewer.me"]); + } else { + try { + if (eventTypes?.length === 0) { + await Promise.all( + DEFAULT_EVENT_TYPES.map(async (event) => { + return createEventType.mutate(event); + }) + ); + } + } catch (error) { + console.error(error); + } + + await utils.refetchQueries(["viewer.me"]); + router.push("/"); + } + }, + onError: () => { + showToast(t("problem_saving_user_profile"), "error"); + }, }); const onSubmit = handleSubmit((data: { bio: string }) => { const { bio } = data; @@ -145,7 +140,6 @@ const UserProfile = (props: IUserProfile) => {