* add reassign host to edit dropdown * add dialog to reassign rr host * Design improvements * add translations * only show reassign for admin/owner * add first version of email template * Init rr assign endpoint * Pass booking information to rr assign endpoint * Only allow attendee of booking to reassign themselves * Send email to reassigned and cancelled member * On reassign change calendar events * Add workflows for new host * On reassign new host - rr * Fix icon * Abstract reassignment logic * Update calendar invite * Add tests * Clean up * Merge with `main` * Type fixes * Add back dialog and handle no available hosts * Handle if rr host is not organizer * Fix calendar invites when organizer doesn't change * Clean up * Clean up * Type fixes * Type fixes * Type fixes * Type fixes * Type fix * Type fixes * Type fixes * Add custom responses to evt object * Type fixes * Type fix * Type fix * Type fixes * Type fixes * Type fix * Type fix * Update tests * Type fixes * Fix tests * Fix tests * Add booking repository * Fix tests * Fix tests * Add doesUserIdHaveAccessToBooking for user * Add check if user is team admin * Check user permission tRPC route * Type fixes * Correct Promise.all * UI fixes * UI fixes * Remove unused assigned hosts prop * Type fix * Remove unused frontend code * Include user priority * Fallback to event type users for older event types * Get booking workflow reminder * Revert back to eventType.hosts * Fix lint * Handle changing workflows * Type fixes * Type fixes * Type fix * Fix tests * Update new booking imports * Fix imports * Type fix * Type fix * Fix adding all members to reassignment emails * Fix cancelled RR emails to show old host * Ensure consistent event titles * Send new event workflows to new host * Change event name if organizer changed * Fix query error * Delete old booking reference when reassigning * Type fixes * Type fixes * Fix test * Rename func isAdminOfTeamOrParentOrg * Select specific workflow fields * Address workflow feedback * Delete const * Address feedback --------- Co-authored-by: CarinaWolli <wollencarina@gmail.com>
57 lines
1.8 KiB
TypeScript
57 lines
1.8 KiB
TypeScript
import type { Dispatch, SetStateAction } from "react";
|
|
|
|
import { ErrorCode } from "@calcom/lib/errorCodes";
|
|
import { useLocale } from "@calcom/lib/hooks/useLocale";
|
|
import { trpc } from "@calcom/trpc/react";
|
|
import { Button, Dialog, DialogClose, DialogContent, DialogFooter, showToast } from "@calcom/ui";
|
|
|
|
type ReassignDialog = {
|
|
isOpenDialog: boolean;
|
|
setIsOpenDialog: Dispatch<SetStateAction<boolean>>;
|
|
teamId: number;
|
|
bookingId: number;
|
|
};
|
|
|
|
export const ReassignDialog = ({ isOpenDialog, setIsOpenDialog, teamId, bookingId }: ReassignDialog) => {
|
|
const { t } = useLocale();
|
|
const utils = trpc.useUtils();
|
|
|
|
const roundRobinReassignMutation = trpc.viewer.teams.roundRobinReassign.useMutation({
|
|
onSuccess: async () => {
|
|
await utils.viewer.bookings.get.invalidate();
|
|
setIsOpenDialog(false);
|
|
showToast(t("booking_reassigned"), "success");
|
|
},
|
|
onError: async (error) => {
|
|
if (error.message.includes(ErrorCode.NoAvailableUsersFound)) {
|
|
showToast(t("no_available_hosts"), "error");
|
|
} else {
|
|
showToast(t("unexpected_error_try_again"), "error");
|
|
}
|
|
},
|
|
});
|
|
|
|
return (
|
|
<Dialog
|
|
open={isOpenDialog}
|
|
onOpenChange={(open) => {
|
|
setIsOpenDialog(open);
|
|
}}>
|
|
<DialogContent title={t("reassign_round_robin_host")} description={t("reassign_to_another_rr_host")}>
|
|
{/* TODO add team member reassignment*/}
|
|
<DialogFooter>
|
|
<DialogClose />
|
|
<Button
|
|
data-testid="rejection-confirm"
|
|
loading={roundRobinReassignMutation.isPending}
|
|
onClick={() => {
|
|
roundRobinReassignMutation.mutate({ teamId, bookingId });
|
|
}}>
|
|
{t("reassign")}
|
|
</Button>
|
|
</DialogFooter>
|
|
</DialogContent>
|
|
</Dialog>
|
|
);
|
|
};
|