feat: update event types for default availability change (#13964)
* feat: update event types for default availability change * chore: add toast --------- Co-authored-by: sean-brydon <[email protected]> Co-authored-by: sean-brydon <[email protected]> Co-authored-by: Udit Takkar <[email protected]>
This commit is contained in:
6 files changed
+111
-13
No files matched your search
+8
-10
@@ -10,7 +10,12 @@ export const BulkUpdateEventSchema = z.object({
|
||||
eventTypeIds: z.array(z.number()),
|
||||
});
|
||||
|
||||
export function BulkEditDefaultConferencingModal(props: { open: boolean; setOpen: (open: boolean) => void }) {
|
||||
export function BulkEditDefaultForEventsModal(props: {
|
||||
open: boolean;
|
||||
setOpen: (open: boolean) => void;
|
||||
bulkUpdateFunction: ({ eventTypeIds }: { eventTypeIds: number[] }) => void;
|
||||
isPending: boolean;
|
||||
}) {
|
||||
const { t } = useLocale();
|
||||
const utils = trpc.useContext();
|
||||
const { data, isFetching } = trpc.viewer.eventTypes.bulkEventFetch.useQuery();
|
||||
@@ -21,13 +26,6 @@ export function BulkEditDefaultConferencingModal(props: { open: boolean; setOpen
|
||||
},
|
||||
});
|
||||
|
||||
const updateLocationsMutation = trpc.viewer.eventTypes.bulkUpdateToDefaultLocation.useMutation({
|
||||
onSuccess: () => {
|
||||
utils.viewer.getUsersDefaultConferencingApp.invalidate();
|
||||
props.setOpen(false);
|
||||
},
|
||||
});
|
||||
|
||||
const eventTypesSelected = form.watch("eventTypeIds");
|
||||
|
||||
if (isFetching || !open || !data?.eventTypes) return null;
|
||||
@@ -42,7 +40,7 @@ export function BulkEditDefaultConferencingModal(props: { open: boolean; setOpen
|
||||
<Form
|
||||
form={form}
|
||||
handleSubmit={(values) => {
|
||||
updateLocationsMutation.mutate(values);
|
||||
props.bulkUpdateFunction(values);
|
||||
}}>
|
||||
<div className="flex flex-col space-y-2">
|
||||
{data.eventTypes.length > 0 && (
|
||||
@@ -81,7 +79,7 @@ export function BulkEditDefaultConferencingModal(props: { open: boolean; setOpen
|
||||
utils.viewer.getUsersDefaultConferencingApp.invalidate();
|
||||
}}
|
||||
/>
|
||||
<Button type="submit" color="primary" loading={updateLocationsMutation.isPending}>
|
||||
<Button type="submit" color="primary" loading={props.isPending}>
|
||||
{t("update")}
|
||||
</Button>
|
||||
</DialogFooter>
|
||||
Reference in new issue
Block a user