fix: bulk-update-in-scheduleId-in-detailed-view (#19295)

* fix: bulk-update-in-scheduleId-in-detailed-view

* minor-change

---------

Co-authored-by: Anik Dhabal Babu <81948346+anikdhabal@users.noreply.github.com>
This commit is contained in:
Tushar Bhatt
2025-02-17 14:39:27 +00:00
committed by GitHub
co-authored by Anik Dhabal Babu
parent 63d26c4fba
commit f28c605b50
3 changed files with 5 additions and 3 deletions
@@ -57,6 +57,7 @@ export const AvailabilitySettingsWebWrapper = ({
bulkUpdateDefaultAvailabilityMutation.mutate(
{
eventTypeIds,
selectedDefaultScheduleId: scheduleData?.id,
},
{
onSuccess: () => {
@@ -16,10 +16,10 @@ export const bulkUpdateToDefaultAvailabilityHandler = async ({
ctx,
input,
}: BulkUpdateToDefaultAvailabilityOptions) => {
const { eventTypeIds } = input;
const { eventTypeIds, selectedDefaultScheduleId } = input;
const defaultScheduleId = ctx.user.defaultScheduleId;
if (!defaultScheduleId) {
if (!selectedDefaultScheduleId && !defaultScheduleId) {
throw new TRPCError({
code: "BAD_REQUEST",
message: "Default schedule not set",
@@ -34,7 +34,7 @@ export const bulkUpdateToDefaultAvailabilityHandler = async ({
userId: ctx.user.id,
},
data: {
scheduleId: defaultScheduleId,
scheduleId: selectedDefaultScheduleId || defaultScheduleId,
},
});
};
@@ -2,6 +2,7 @@ import { z } from "zod";
export const ZBulkUpdateToDefaultAvailabilityInputSchema = z.object({
eventTypeIds: z.array(z.number()),
selectedDefaultScheduleId: z.number().nullable().optional(),
});
export type TBulkUpdateToDefaultAvailabilityInputSchema = z.infer<