Prefill logged in info (#10240)

This commit is contained in:
Hariom Balhara authored and GitHub committed 2023-07-19 06:44:13 +02:00
1 parent db021cc696
commit 902bb71273
1 file changed
+8 -2
@@ -1,6 +1,7 @@
import { zodResolver } from "@hookform/resolvers/zod";
import type { UseMutationResult } from "@tanstack/react-query";
import { useMutation } from "@tanstack/react-query";
import { useSession } from "next-auth/react";
import type { TFunction } from "next-i18next";
import { useRouter } from "next/router";
import { useEffect, useMemo, useRef } from "react";
@@ -40,6 +41,7 @@ type BookEventFormProps = {
};
export const BookEventForm = ({ onCancel }: BookEventFormProps) => {
const session = useSession();
const reserveSlotMutation = trpc.viewer.public.slots.reserveSlot.useMutation({
trpc: { context: { skipBatch: true } },
});
@@ -114,8 +116,12 @@ export const BookEventForm = ({ onCancel }: BookEventFormProps) => {
});
const defaultUserValues = {
email: rescheduleUid ? bookingData?.attendees[0].email : parsedQuery["email"] || "",
name: rescheduleUid ? bookingData?.attendees[0].name : parsedQuery["name"] || "",
email: rescheduleUid
? bookingData?.attendees[0].email
: parsedQuery["email"] || session.data?.user?.email || "",
name: rescheduleUid
? bookingData?.attendees[0].name
: parsedQuery["name"] || session.data?.user?.name || "",
};
if (!isRescheduling) {