Type fixes
parent
f3bedabf92
commit
1561224dbb
|
@ -23,7 +23,7 @@ const UserProfile = (props: IUserProfile) => {
|
||||||
const { user } = props;
|
const { user } = props;
|
||||||
const { t } = useLocale();
|
const { t } = useLocale();
|
||||||
const avatarRef = useRef<HTMLInputElement>(null!);
|
const avatarRef = useRef<HTMLInputElement>(null!);
|
||||||
const bioRef = useRef<HTMLInputElement>(null);
|
const bioRef = useRef<HTMLTextAreaElement>(null);
|
||||||
const {
|
const {
|
||||||
register,
|
register,
|
||||||
setValue,
|
setValue,
|
||||||
|
@ -36,10 +36,8 @@ const UserProfile = (props: IUserProfile) => {
|
||||||
const router = useRouter();
|
const router = useRouter();
|
||||||
const createEventType = trpc.useMutation("viewer.eventTypes.create");
|
const createEventType = trpc.useMutation("viewer.eventTypes.create");
|
||||||
|
|
||||||
const onSuccess = async (
|
const mutation = trpc.useMutation("viewer.updateProfile", {
|
||||||
_data: string | undefined,
|
onSuccess: async (_data, context) => {
|
||||||
context: Partial<{ bio: string; completedOnboarding: boolean; avatar: string }>
|
|
||||||
) => {
|
|
||||||
if (context.avatar) {
|
if (context.avatar) {
|
||||||
showToast(t("your_user_profile_updated_successfully"), "success");
|
showToast(t("your_user_profile_updated_successfully"), "success");
|
||||||
await utils.refetchQueries(["viewer.me"]);
|
await utils.refetchQueries(["viewer.me"]);
|
||||||
|
@ -59,13 +57,10 @@ const UserProfile = (props: IUserProfile) => {
|
||||||
await utils.refetchQueries(["viewer.me"]);
|
await utils.refetchQueries(["viewer.me"]);
|
||||||
router.push("/");
|
router.push("/");
|
||||||
}
|
}
|
||||||
};
|
},
|
||||||
const onError = () => {
|
onError: () => {
|
||||||
showToast(t("problem_saving_user_profile"), "error");
|
showToast(t("problem_saving_user_profile"), "error");
|
||||||
};
|
},
|
||||||
const mutation = trpc.useMutation("viewer.updateProfile", {
|
|
||||||
onSuccess,
|
|
||||||
onError,
|
|
||||||
});
|
});
|
||||||
const onSubmit = handleSubmit((data: { bio: string }) => {
|
const onSubmit = handleSubmit((data: { bio: string }) => {
|
||||||
const { bio } = data;
|
const { bio } = data;
|
||||||
|
@ -145,7 +140,6 @@ const UserProfile = (props: IUserProfile) => {
|
||||||
<TextArea
|
<TextArea
|
||||||
{...register("bio", { required: true })}
|
{...register("bio", { required: true })}
|
||||||
ref={bioRef}
|
ref={bioRef}
|
||||||
type="text"
|
|
||||||
name="bio"
|
name="bio"
|
||||||
id="bio"
|
id="bio"
|
||||||
className="mt-1 block h-[60px] w-full rounded-sm border border-gray-300 px-3 py-2 focus:border-neutral-500 focus:outline-none focus:ring-neutral-500 sm:text-sm"
|
className="mt-1 block h-[60px] w-full rounded-sm border border-gray-300 px-3 py-2 focus:border-neutral-500 focus:outline-none focus:ring-neutral-500 sm:text-sm"
|
||||||
|
|
Loading…
Reference in New Issue