fix: add reassignedBy and reassign reason to both status (#17418)
* add reassignedBy and reassign reason to both status * fix w-full issue in dialog * fix types --------- Co-authored-by: Peer Richelsen <peeroke@gmail.com>
This commit is contained in:
1 parent
64551a506a
commit
e728ed74ce
8 files changed
+46
-15
No files matched your search
@@ -135,7 +135,13 @@ export const ReassignDialog = ({ isOpenDialog, setIsOpenDialog, teamId, bookingI
|
||||
},
|
||||
});
|
||||
|
||||
const [showConfirmation, setShowConfirmation] = useState(false);
|
||||
const [confirmationModal, setConfirmationModal] = useState<{
|
||||
show: boolean;
|
||||
membersStatus: "unavailable" | "available" | null;
|
||||
}>({
|
||||
show: false,
|
||||
membersStatus: null,
|
||||
});
|
||||
|
||||
const handleSubmit = (values: FormValues) => {
|
||||
if (values.reassignType === "round_robin") {
|
||||
@@ -143,13 +149,10 @@ export const ReassignDialog = ({ isOpenDialog, setIsOpenDialog, teamId, bookingI
|
||||
} else {
|
||||
if (values.teamMemberId) {
|
||||
const selectedMember = teamMemberOptions?.find((member) => member.value === values.teamMemberId);
|
||||
if (selectedMember && selectedMember.status === "unavailable") {
|
||||
setShowConfirmation(true);
|
||||
} else {
|
||||
roundRobinManualReassignMutation.mutate({
|
||||
bookingId,
|
||||
teamMemberId: values.teamMemberId,
|
||||
reassignReason: values.reassignReason,
|
||||
if (selectedMember) {
|
||||
setConfirmationModal({
|
||||
show: true,
|
||||
membersStatus: selectedMember.status as "available" | "unavailable",
|
||||
});
|
||||
}
|
||||
}
|
||||
@@ -263,10 +266,16 @@ export const ReassignDialog = ({ isOpenDialog, setIsOpenDialog, teamId, bookingI
|
||||
</DialogContent>
|
||||
</Dialog>
|
||||
|
||||
<Dialog open={showConfirmation} onOpenChange={setShowConfirmation}>
|
||||
<Dialog
|
||||
open={confirmationModal?.show}
|
||||
onOpenChange={(open) => setConfirmationModal({ ...confirmationModal, show: open })}>
|
||||
<ConfirmationDialogContent
|
||||
variety="warning"
|
||||
title={t("confirm_reassign_unavailable")}
|
||||
variety={confirmationModal?.membersStatus === "unavailable" ? "warning" : "success"}
|
||||
title={
|
||||
confirmationModal?.membersStatus === "unavailable"
|
||||
? t("confirm_reassign_unavailable")
|
||||
: t("confirm_reassign_available")
|
||||
}
|
||||
confirmBtnText={t("yes_reassign")}
|
||||
cancelBtnText={t("cancel")}
|
||||
onConfirm={() => {
|
||||
@@ -279,14 +288,21 @@ export const ReassignDialog = ({ isOpenDialog, setIsOpenDialog, teamId, bookingI
|
||||
teamMemberId,
|
||||
reassignReason: form.getValues("reassignReason"),
|
||||
});
|
||||
setShowConfirmation(false);
|
||||
setConfirmationModal({
|
||||
show: false,
|
||||
membersStatus: null,
|
||||
});
|
||||
}}>
|
||||
<p className="mb-4">{t("reassign_unavailable_team_member_description")}</p>
|
||||
<p className="mb-4">
|
||||
{confirmationModal?.membersStatus === "unavailable"
|
||||
? t("reassign_unavailable_team_member_description")
|
||||
: t("reassign_available_team_member_description")}
|
||||
</p>
|
||||
<TextAreaField
|
||||
name="reassignReason"
|
||||
label={t("reassign_reason")}
|
||||
onChange={(e) => form.setValue("reassignReason", e.target.value)}
|
||||
required
|
||||
required={confirmationModal?.membersStatus === "unavailable"}
|
||||
/>
|
||||
</ConfirmationDialogContent>
|
||||
</Dialog>
|
||||
|
||||
@@ -2708,7 +2708,9 @@
|
||||
"you_dont_have_access_to_reroute_this_booking": "You don't have access to reroute this booking",
|
||||
"form_response_not_found": "Form response not found",
|
||||
"confirm_reassign_unavailable": "Host unavailable",
|
||||
"confirm_reassign_available": "Host available",
|
||||
"reassign_unavailable_team_member_description": "Are you sure you want to reassign this booking to an unavailable host?",
|
||||
"reassign_available_team_member_description": "Are you sure you want to reassign this booking?",
|
||||
"yes_reassign": "Yes, reassign",
|
||||
"reassign_reason": "Reason for reassigning",
|
||||
"reassigned_by": "Reassigned by",
|
||||
|
||||
@@ -42,11 +42,13 @@ export const roundRobinManualReassignment = async ({
|
||||
newUserId,
|
||||
orgId,
|
||||
reassignReason,
|
||||
reassignedById,
|
||||
}: {
|
||||
bookingId: number;
|
||||
newUserId: number;
|
||||
orgId: number | null;
|
||||
reassignReason?: string;
|
||||
reassignedById: number;
|
||||
}) => {
|
||||
const roundRobinReassignLogger = logger.getSubLogger({
|
||||
prefix: ["roundRobinManualReassign", `${bookingId}`],
|
||||
@@ -164,6 +166,7 @@ export const roundRobinManualReassignment = async ({
|
||||
title: newBookingTitle,
|
||||
userPrimaryEmail: newUser.email,
|
||||
reassignReason,
|
||||
reassignById: reassignedById,
|
||||
},
|
||||
select: bookingSelect,
|
||||
});
|
||||
|
||||
@@ -64,6 +64,7 @@ export const buildBooking = (
|
||||
fromReschedule: null,
|
||||
recurringEventId: null,
|
||||
smsReminderNumber: null,
|
||||
reassignById: null,
|
||||
scheduledJobs: [],
|
||||
metadata: null,
|
||||
responses: null,
|
||||
|
||||
+5
@@ -0,0 +1,5 @@
|
||||
-- AlterTable
|
||||
ALTER TABLE "Booking" ADD COLUMN "reassignById" INTEGER;
|
||||
|
||||
-- AddForeignKey
|
||||
ALTER TABLE "Booking" ADD CONSTRAINT "Booking_reassignById_fkey" FOREIGN KEY ("reassignById") REFERENCES "users"("id") ON DELETE SET NULL ON UPDATE CASCADE;
|
||||
@@ -343,6 +343,7 @@ model User {
|
||||
NotificationsSubscriptions NotificationsSubscriptions[]
|
||||
referralLinkId String?
|
||||
features UserFeatures[]
|
||||
reassignedBookings Booking[] @relation("reassignByUser")
|
||||
|
||||
@@unique([email])
|
||||
@@unique([email, username])
|
||||
@@ -608,6 +609,8 @@ model Booking {
|
||||
cancellationReason String?
|
||||
rejectionReason String?
|
||||
reassignReason String?
|
||||
reassignBy User? @relation("reassignByUser", fields: [reassignById], references: [id])
|
||||
reassignById Int?
|
||||
dynamicEventSlugRef String?
|
||||
dynamicGroupSlugRef String?
|
||||
rescheduled Boolean?
|
||||
|
||||
+1
@@ -28,6 +28,7 @@ export const roundRobinManualReassignHandler = async ({ ctx, input }: RoundRobin
|
||||
newUserId: teamMemberId,
|
||||
orgId: ctx.user.organizationId,
|
||||
reassignReason,
|
||||
reassignedById: ctx.user.id,
|
||||
});
|
||||
|
||||
return { success: true };
|
||||
|
||||
@@ -64,7 +64,7 @@ export const ConfirmationContent = (props: PropsWithChildren<ConfirmationDialogC
|
||||
)}
|
||||
</div>
|
||||
)}
|
||||
<div>
|
||||
<div className="w-full">
|
||||
<DialogPrimitive.Title className="font-cal text-emphasis mt-2 text-xl">
|
||||
{title}
|
||||
</DialogPrimitive.Title>
|
||||
|
||||
Reference in new issue
Block a user