feat: trpc v10 migration (#5332)
* migrate router * createTRPCReact * frontend 1 * random format change * frontend 2 * withQuery * form router * TS-ERROR: proxy on utils-client * inferance * ssg * reuse * trpc rc4 * Apply suggestions from code review * skip test * move skip one level up * whops * rc 6 with new setData func Co-authored-by: zomars <[email protected]>
This commit is contained in:
1 parent
6d67808627
commit
db7c3fb52f
157 files changed
+3062
-3144
No files matched your search
@@ -58,7 +58,7 @@ const CalendarSwitch = (props: ICalendarSwitchProps) => {
|
||||
},
|
||||
{
|
||||
async onSettled() {
|
||||
await utils.invalidateQueries(["viewer.integrations"]);
|
||||
await utils.viewer.integrations.invalidate();
|
||||
},
|
||||
onError() {
|
||||
showToast(`Something went wrong when toggling "${title}""`, "error");
|
||||
|
||||
@@ -1,16 +1,16 @@
|
||||
import { useLocale } from "@calcom/lib/hooks/useLocale";
|
||||
import { inferMutationInput, trpc } from "@calcom/trpc/react";
|
||||
import { RouterInputs, trpc } from "@calcom/trpc/react";
|
||||
|
||||
import DestinationCalendarSelector from "@components/DestinationCalendarSelector";
|
||||
|
||||
interface ICreateEventsOnCalendarSelectProps {
|
||||
calendar?: inferMutationInput<"viewer.setDestinationCalendar"> | null;
|
||||
calendar?: RouterInputs["viewer"]["setDestinationCalendar"] | null;
|
||||
}
|
||||
|
||||
const CreateEventsOnCalendarSelect = (props: ICreateEventsOnCalendarSelectProps) => {
|
||||
const { calendar } = props;
|
||||
const { t } = useLocale();
|
||||
const mutation = trpc.useMutation(["viewer.setDestinationCalendar"]);
|
||||
const mutation = trpc.viewer.setDestinationCalendar.useMutation();
|
||||
|
||||
return (
|
||||
<>
|
||||
|
||||
@@ -16,12 +16,9 @@ interface IConnectCalendarsProps {
|
||||
|
||||
const ConnectedCalendars = (props: IConnectCalendarsProps) => {
|
||||
const { nextStep } = props;
|
||||
const queryConnectedCalendars = trpc.useQuery(["viewer.connectedCalendars"]);
|
||||
const queryConnectedCalendars = trpc.viewer.connectedCalendars.useQuery();
|
||||
const { t } = useLocale();
|
||||
const queryIntegrations = trpc.useQuery([
|
||||
"viewer.integrations",
|
||||
{ variant: "calendar", onlyInstalled: false },
|
||||
]);
|
||||
const queryIntegrations = trpc.viewer.integrations.useQuery({ variant: "calendar", onlyInstalled: false });
|
||||
|
||||
const firstCalendar = queryConnectedCalendars.data?.connectedCalendars.find(
|
||||
(item) => item.calendars && item.calendars?.length > 0
|
||||
|
||||
@@ -24,9 +24,12 @@ const SetupAvailability = (props: ISetupAvailabilityProps) => {
|
||||
const router = useRouter();
|
||||
let queryAvailability;
|
||||
if (defaultScheduleId) {
|
||||
queryAvailability = trpc.useQuery(["viewer.availability.schedule", { scheduleId: defaultScheduleId }], {
|
||||
enabled: router.isReady,
|
||||
});
|
||||
queryAvailability = trpc.viewer.availability.schedule.get.useQuery(
|
||||
{ scheduleId: defaultScheduleId },
|
||||
{
|
||||
enabled: router.isReady,
|
||||
}
|
||||
);
|
||||
}
|
||||
|
||||
const availabilityForm = useForm({
|
||||
@@ -43,8 +46,8 @@ const SetupAvailability = (props: ISetupAvailabilityProps) => {
|
||||
nextStep();
|
||||
},
|
||||
};
|
||||
const createSchedule = trpc.useMutation("viewer.availability.schedule.create", mutationOptions);
|
||||
const updateSchedule = trpc.useMutation("viewer.availability.schedule.update", mutationOptions);
|
||||
const createSchedule = trpc.viewer.availability.schedule.create.useMutation(mutationOptions);
|
||||
const updateSchedule = trpc.viewer.availability.schedule.update.useMutation(mutationOptions);
|
||||
return (
|
||||
<Form
|
||||
className="w-full bg-white text-black dark:bg-opacity-5 dark:text-white"
|
||||
|
||||
@@ -32,17 +32,17 @@ const UserProfile = (props: IUserProfile) => {
|
||||
handleSubmit,
|
||||
formState: { errors },
|
||||
} = useForm<FormData>({ defaultValues: { bio: user?.bio || "" } });
|
||||
const { data: eventTypes } = trpc.useQuery(["viewer.eventTypes.list"]);
|
||||
const { data: eventTypes } = trpc.viewer.eventTypes.list.useQuery();
|
||||
const [imageSrc, setImageSrc] = useState<string>(user?.avatar || "");
|
||||
const utils = trpc.useContext();
|
||||
const router = useRouter();
|
||||
const createEventType = trpc.useMutation("viewer.eventTypes.create");
|
||||
const createEventType = trpc.viewer.eventTypes.create.useMutation();
|
||||
|
||||
const mutation = trpc.useMutation("viewer.updateProfile", {
|
||||
const mutation = trpc.viewer.updateProfile.useMutation({
|
||||
onSuccess: async (_data, context) => {
|
||||
if (context.avatar) {
|
||||
showToast(t("your_user_profile_updated_successfully"), "success");
|
||||
await utils.refetchQueries(["viewer.me"]);
|
||||
await utils.viewer.me.refetch();
|
||||
} else {
|
||||
try {
|
||||
if (eventTypes?.length === 0) {
|
||||
@@ -56,7 +56,7 @@ const UserProfile = (props: IUserProfile) => {
|
||||
console.error(error);
|
||||
}
|
||||
|
||||
await utils.refetchQueries(["viewer.me"]);
|
||||
await utils.viewer.me.refetch();
|
||||
router.push("/");
|
||||
}
|
||||
},
|
||||
|
||||
@@ -36,13 +36,13 @@ const UserSettings = (props: IUserSettingsProps) => {
|
||||
|
||||
const utils = trpc.useContext();
|
||||
const onSuccess = async () => {
|
||||
await utils.invalidateQueries(["viewer.me"]);
|
||||
await utils.viewer.me.invalidate();
|
||||
nextStep();
|
||||
};
|
||||
const mutation = trpc.useMutation("viewer.updateProfile", {
|
||||
const mutation = trpc.viewer.updateProfile.useMutation({
|
||||
onSuccess: onSuccess,
|
||||
});
|
||||
const { data: stripeCustomer } = trpc.useQuery(["viewer.stripeCustomer"]);
|
||||
const { data: stripeCustomer } = trpc.viewer.stripeCustomer.useQuery();
|
||||
const paymentRequired = stripeCustomer?.isPremium ? !stripeCustomer?.paidForPremium : false;
|
||||
const onSubmit = handleSubmit((data) => {
|
||||
if (paymentRequired) {
|
||||
|
||||
Reference in new issue
Block a user