feat: managed event reassignment (#24809)
* init * -- * update dialog * reassignment * further changes * add unit test * fix * type fix?? * fix type?? * emails * workflows * reason recorder * refactor reassigned email * fix reassigned reason * fix type * improve dialog * add integration tests * - * remove unnecessary comments --1 * removed unnecessary comments * fix type? * address cubic * address feedback * -- * fix type? * address cubic * type-fix? * fix type * further fixes * fix location update * type fix * propagate error to top * fix mocking * fix reported bugs * fix * fix success page video URL * remove PII from logs * persist video URL * better audit trail * revert email function name change * fix test * fix flake * di * fixes * extract logic and other repo access from BookingRepository * fixes * (☞゚∀゚)☞ udit * integration test fixes * mroe fixes * extract to repo * extract to repo --2 * fix type * cubic * address feedback --1 * --2 * wip * addressed feedback * type fixes * type fixes * fix issues * feedback --1 * feedback --2 * BookingAccessService DI * fix * break down function into small functions * fixes --1 * fixes * typefix * addressing feedback * fix merge conflict lost change
This commit is contained in:
1 parent
38890dad30
commit
0103321b71
54 files changed
+4259
-443
No files matched your search
@@ -113,6 +113,12 @@ export const schemaBookingReadPublic = Booking.extend({
|
||||
)
|
||||
.optional(),
|
||||
responses: z.record(z.any()).nullable(),
|
||||
// Override metadata to handle reassignment objects from Round Robin/Managed Events
|
||||
// Safe to use z.any() here because:
|
||||
// 1. API v1 POST only accepts z.record(z.string()) for metadata (user input restricted)
|
||||
// 2. API v1 PATCH does not accept metadata changes at all
|
||||
// 3. Complex metadata (objects) are only set by trusted internal features
|
||||
metadata: z.record(z.any()).nullable(),
|
||||
}).pick({
|
||||
id: true,
|
||||
userId: true,
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
import type { Request, Response } from "express";
|
||||
import type { NextApiRequest, NextApiResponse } from "next";
|
||||
import { createMocks } from "node-mocks-http";
|
||||
import { describe, it, expect, beforeAll } from "vitest";
|
||||
import { describe, it, expect, beforeAll, afterAll } from "vitest";
|
||||
|
||||
import prisma from "@calcom/prisma";
|
||||
|
||||
@@ -11,69 +11,114 @@ type CustomNextApiRequest = NextApiRequest & Request;
|
||||
type CustomNextApiResponse = NextApiResponse & Response;
|
||||
|
||||
describe("PATCH /api/bookings", () => {
|
||||
let member1Booking: Awaited<ReturnType<typeof prisma.booking.create>>;
|
||||
let member0Booking: Awaited<ReturnType<typeof prisma.booking.create>>;
|
||||
const createdBookingIds: number[] = [];
|
||||
let testAdminUserId: number | null = null;
|
||||
|
||||
beforeAll(async () => {
|
||||
const acmeOrg = await prisma.team.findFirst({
|
||||
where: {
|
||||
slug: "acme",
|
||||
isOrganization: true,
|
||||
},
|
||||
const member1 = await prisma.user.findFirstOrThrow({
|
||||
where: { email: "[email protected]" },
|
||||
});
|
||||
|
||||
if (acmeOrg) {
|
||||
await prisma.organizationSettings.upsert({
|
||||
where: {
|
||||
organizationId: acmeOrg.id,
|
||||
},
|
||||
update: {
|
||||
isAdminAPIEnabled: true,
|
||||
},
|
||||
create: {
|
||||
organizationId: acmeOrg.id,
|
||||
orgAutoAcceptEmail: "acme.com",
|
||||
isAdminAPIEnabled: true,
|
||||
},
|
||||
const member0 = await prisma.user.findFirstOrThrow({
|
||||
where: { email: "[email protected]" },
|
||||
});
|
||||
|
||||
// Create bookings for testing
|
||||
member1Booking = await prisma.booking.create({
|
||||
data: {
|
||||
uid: `test-member1-booking-${Date.now()}`,
|
||||
title: "Member 1 Test Booking",
|
||||
startTime: new Date(Date.now() + 86400000), // Tomorrow
|
||||
endTime: new Date(Date.now() + 90000000), // Tomorrow + 1 hour
|
||||
userId: member1.id,
|
||||
status: "ACCEPTED",
|
||||
},
|
||||
});
|
||||
createdBookingIds.push(member1Booking.id);
|
||||
|
||||
member0Booking = await prisma.booking.create({
|
||||
data: {
|
||||
uid: `test-member0-booking-${Date.now()}`,
|
||||
title: "Member 0 Test Booking",
|
||||
startTime: new Date(Date.now() + 172800000), // Day after tomorrow
|
||||
endTime: new Date(Date.now() + 176400000), // Day after tomorrow + 1 hour
|
||||
userId: member0.id,
|
||||
status: "ACCEPTED",
|
||||
},
|
||||
});
|
||||
createdBookingIds.push(member0Booking.id);
|
||||
});
|
||||
|
||||
afterAll(async () => {
|
||||
if (createdBookingIds.length > 0) {
|
||||
await prisma.booking.deleteMany({
|
||||
where: { id: { in: createdBookingIds } },
|
||||
});
|
||||
}
|
||||
|
||||
// Clean up test admin user if created
|
||||
if (testAdminUserId) {
|
||||
await prisma.user.delete({
|
||||
where: { id: testAdminUserId },
|
||||
});
|
||||
}
|
||||
});
|
||||
it("Returns 403 when user has no permission to the booking", async () => {
|
||||
const memberUser = await prisma.user.findFirstOrThrow({ where: { email: "[email protected]" } });
|
||||
const proUser = await prisma.user.findFirstOrThrow({ where: { email: "pro@example.com" } });
|
||||
const booking = await prisma.booking.findFirstOrThrow({ where: { userId: proUser.id } });
|
||||
// Member2 tries to access Member0's booking - should fail
|
||||
const member2 = await prisma.user.findFirstOrThrow({ where: { email: "member2-acme@example.com" } });
|
||||
|
||||
const { req, res } = createMocks<CustomNextApiRequest, CustomNextApiResponse>({
|
||||
method: "PATCH",
|
||||
body: {
|
||||
title: booking.title,
|
||||
startTime: booking.startTime.toISOString(),
|
||||
endTime: booking.endTime.toISOString(),
|
||||
userId: memberUser.id,
|
||||
title: member0Booking.title,
|
||||
startTime: member0Booking.startTime.toISOString(),
|
||||
endTime: member0Booking.endTime.toISOString(),
|
||||
userId: member2.id,
|
||||
},
|
||||
query: {
|
||||
id: booking.id,
|
||||
id: member0Booking.id,
|
||||
},
|
||||
});
|
||||
|
||||
req.userId = memberUser.id;
|
||||
req.userId = member2.id;
|
||||
|
||||
await handler(req, res);
|
||||
expect(res.statusCode).toBe(403);
|
||||
});
|
||||
|
||||
it("Allows PATCH when user is system-wide admin", async () => {
|
||||
const adminUser = await prisma.user.findFirstOrThrow({ where: { email: "[email protected]" } });
|
||||
const proUser = await prisma.user.findFirstOrThrow({ where: { email: "pro@example.com" } });
|
||||
const booking = await prisma.booking.findFirstOrThrow({ where: { userId: proUser.id } });
|
||||
// Check if admin user already exists before upserting
|
||||
const existingAdmin = await prisma.user.findUnique({ where: { email: "test-admin@example.com" } });
|
||||
|
||||
// Create a system-wide admin user for this test
|
||||
const adminUser = await prisma.user.upsert({
|
||||
where: { email: "[email protected]" },
|
||||
update: { role: "ADMIN" },
|
||||
create: {
|
||||
email: "[email protected]",
|
||||
username: "test-admin",
|
||||
name: "Test Admin",
|
||||
role: "ADMIN",
|
||||
},
|
||||
});
|
||||
|
||||
// Only track for cleanup if we created it (not if it already existed)
|
||||
if (!existingAdmin) {
|
||||
testAdminUserId = adminUser.id;
|
||||
}
|
||||
|
||||
const { req, res } = createMocks<CustomNextApiRequest, CustomNextApiResponse>({
|
||||
method: "PATCH",
|
||||
body: {
|
||||
title: booking.title,
|
||||
startTime: booking.startTime.toISOString(),
|
||||
endTime: booking.endTime.toISOString(),
|
||||
userId: proUser.id,
|
||||
title: member0Booking.title,
|
||||
startTime: member0Booking.startTime.toISOString(),
|
||||
endTime: member0Booking.endTime.toISOString(),
|
||||
userId: member0Booking.userId,
|
||||
},
|
||||
query: {
|
||||
id: booking.id,
|
||||
id: member0Booking.id,
|
||||
},
|
||||
});
|
||||
|
||||
@@ -86,19 +131,17 @@ describe("PATCH /api/bookings", () => {
|
||||
|
||||
it("Allows PATCH when user is org-wide admin", async () => {
|
||||
const adminUser = await prisma.user.findFirstOrThrow({ where: { email: "[email protected]" } });
|
||||
const memberUser = await prisma.user.findFirstOrThrow({ where: { email: "[email protected]" } });
|
||||
const booking = await prisma.booking.findFirstOrThrow({ where: { userId: memberUser.id } });
|
||||
|
||||
const { req, res } = createMocks<CustomNextApiRequest, CustomNextApiResponse>({
|
||||
method: "PATCH",
|
||||
body: {
|
||||
title: booking.title,
|
||||
startTime: booking.startTime.toISOString(),
|
||||
endTime: booking.endTime.toISOString(),
|
||||
userId: memberUser.id,
|
||||
title: member1Booking.title,
|
||||
startTime: member1Booking.startTime.toISOString(),
|
||||
endTime: member1Booking.endTime.toISOString(),
|
||||
userId: member1Booking.userId,
|
||||
},
|
||||
query: {
|
||||
id: booking.id,
|
||||
id: member1Booking.id,
|
||||
},
|
||||
});
|
||||
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
import type { Request, Response } from "express";
|
||||
import type { NextApiRequest, NextApiResponse } from "next";
|
||||
import { createMocks } from "node-mocks-http";
|
||||
import { describe, expect, it, beforeAll } from "vitest";
|
||||
import { describe, expect, it, beforeAll, afterAll } from "vitest";
|
||||
import { ZodError } from "zod";
|
||||
|
||||
import { prisma } from "@calcom/prisma";
|
||||
@@ -16,51 +16,67 @@ const DefaultPagination = {
|
||||
skip: 0,
|
||||
};
|
||||
|
||||
describe("GET /api/bookings", async () => {
|
||||
describe("GET /api/bookings", () => {
|
||||
let proUser: Awaited<ReturnType<typeof prisma.user.findFirstOrThrow>>;
|
||||
let proUserBooking: Awaited<ReturnType<typeof prisma.booking.findFirstOrThrow>>;
|
||||
let memberUser: Awaited<ReturnType<typeof prisma.user.findFirstOrThrow>>;
|
||||
let memberUserBooking: Awaited<ReturnType<typeof prisma.booking.create>>;
|
||||
|
||||
beforeAll(async () => {
|
||||
const acmeOrg = await prisma.team.findFirst({
|
||||
proUser = await prisma.user.findFirstOrThrow({ where: { email: "[email protected]" } });
|
||||
proUserBooking = await prisma.booking.findFirstOrThrow({ where: { userId: proUser.id } });
|
||||
|
||||
memberUser = await prisma.user.findFirstOrThrow({ where: { email: "[email protected]" } });
|
||||
|
||||
// Find an event type for memberUser or use a simple booking
|
||||
const memberEventType = await prisma.eventType.findFirst({
|
||||
where: {
|
||||
slug: "acme",
|
||||
isOrganization: true,
|
||||
},
|
||||
OR: [
|
||||
{ userId: memberUser.id },
|
||||
{ team: { members: { some: { userId: memberUser.id } } } }
|
||||
]
|
||||
}
|
||||
});
|
||||
|
||||
if (acmeOrg) {
|
||||
await prisma.organizationSettings.upsert({
|
||||
where: {
|
||||
organizationId: acmeOrg.id,
|
||||
},
|
||||
update: {
|
||||
isAdminAPIEnabled: true,
|
||||
},
|
||||
create: {
|
||||
organizationId: acmeOrg.id,
|
||||
orgAutoAcceptEmail: "acme.com",
|
||||
isAdminAPIEnabled: true,
|
||||
},
|
||||
memberUserBooking = await prisma.booking.create({
|
||||
data: {
|
||||
uid: `test-member-booking-${Date.now()}`,
|
||||
title: "Member Test Booking",
|
||||
startTime: new Date(Date.now() + 86400000), // Tomorrow
|
||||
endTime: new Date(Date.now() + 90000000), // Tomorrow + 1 hour
|
||||
userId: memberUser.id,
|
||||
eventTypeId: memberEventType?.id,
|
||||
status: "ACCEPTED",
|
||||
},
|
||||
});
|
||||
});
|
||||
|
||||
afterAll(async () => {
|
||||
// Clean up the test booking created in beforeAll
|
||||
if (memberUserBooking?.id) {
|
||||
await prisma.booking.delete({
|
||||
where: { id: memberUserBooking.id },
|
||||
});
|
||||
}
|
||||
});
|
||||
const proUser = await prisma.user.findFirstOrThrow({ where: { email: "[email protected]" } });
|
||||
const proUserBooking = await prisma.booking.findFirstOrThrow({ where: { userId: proUser.id } });
|
||||
|
||||
it("Does not return bookings of other users when user has no permission", async () => {
|
||||
const memberUser = await prisma.user.findFirstOrThrow({ where: { email: "[email protected]" } });
|
||||
|
||||
const { req } = createMocks<CustomNextApiRequest, CustomNextApiResponse>({
|
||||
method: "GET",
|
||||
query: {
|
||||
userId: proUser.id,
|
||||
userId: proUser.id, // Try to access proUser's bookings
|
||||
},
|
||||
pagination: DefaultPagination,
|
||||
});
|
||||
|
||||
req.userId = memberUser.id;
|
||||
req.userId = memberUser.id; // But request is from memberUser
|
||||
|
||||
const responseData = await handler(req);
|
||||
const groupedUsers = new Set(responseData.bookings.map((b) => b.userId));
|
||||
|
||||
// Should only return memberUser's own bookings, not proUser's
|
||||
expect(responseData.bookings.find((b) => b.userId === memberUser.id)).toBeDefined();
|
||||
expect(responseData.bookings.find((b) => b.id === memberUserBooking.id)).toBeDefined();
|
||||
expect(groupedUsers.size).toBe(1);
|
||||
const firstEntry = groupedUsers.entries().next().value;
|
||||
expect(firstEntry?.[0]).toBe(memberUser.id);
|
||||
|
||||
@@ -427,6 +427,7 @@ export function BookingActionsDropdown({
|
||||
bookingId={booking.id}
|
||||
teamId={booking.eventType?.team?.id || 0}
|
||||
bookingFromRoutingForm={isBookingFromRoutingForm}
|
||||
isManagedEvent={booking.eventType?.parentId != null}
|
||||
/>
|
||||
)}
|
||||
<EditLocationDialog
|
||||
|
||||
@@ -109,6 +109,12 @@ export function getEditEventActions(context: BookingActionContext): ActionType[]
|
||||
} = context;
|
||||
const seatReferenceUid = getSeatReferenceUid();
|
||||
|
||||
const isReassignableRoundRobin =
|
||||
booking.eventType.schedulingType === SchedulingType.ROUND_ROBIN &&
|
||||
(!booking.eventType.hostGroups || booking.eventType.hostGroups.length <= 1);
|
||||
const isManagedChildEvent = booking.eventType.parentId != null;
|
||||
const isReassignable = isReassignableRoundRobin || isManagedChildEvent;
|
||||
|
||||
const actions: (ActionType | null)[] = [
|
||||
{
|
||||
id: "reschedule",
|
||||
@@ -154,9 +160,7 @@ export function getEditEventActions(context: BookingActionContext): ActionType[]
|
||||
icon: "user-plus",
|
||||
disabled: false,
|
||||
},
|
||||
// Reassign if round robin with no or one host groups
|
||||
booking.eventType.schedulingType === SchedulingType.ROUND_ROBIN &&
|
||||
(!booking.eventType.hostGroups || booking.eventType.hostGroups?.length <= 1)
|
||||
isReassignable
|
||||
? {
|
||||
id: "reassign",
|
||||
label: t("reassign"),
|
||||
|
||||
@@ -25,7 +25,7 @@ import { RadioAreaGroup as RadioArea } from "@calcom/ui/components/radio";
|
||||
import { showToast } from "@calcom/ui/components/toast";
|
||||
|
||||
enum ReassignType {
|
||||
ROUND_ROBIN = "round_robin",
|
||||
AUTO = "auto",
|
||||
TEAM_MEMBER = "team_member",
|
||||
}
|
||||
|
||||
@@ -35,10 +35,11 @@ type ReassignDialog = {
|
||||
teamId: number;
|
||||
bookingId: number;
|
||||
bookingFromRoutingForm: boolean;
|
||||
isManagedEvent: boolean;
|
||||
};
|
||||
|
||||
type FormValues = {
|
||||
reassignType: ReassignType.ROUND_ROBIN | ReassignType.TEAM_MEMBER;
|
||||
reassignType: ReassignType.AUTO | ReassignType.TEAM_MEMBER;
|
||||
teamMemberId?: number;
|
||||
reassignReason?: string;
|
||||
};
|
||||
@@ -66,6 +67,7 @@ export const ReassignDialog = ({
|
||||
teamId,
|
||||
bookingId,
|
||||
bookingFromRoutingForm,
|
||||
isManagedEvent,
|
||||
}: ReassignDialog) => {
|
||||
const { t } = useLocale();
|
||||
const utils = trpc.useUtils();
|
||||
@@ -76,18 +78,34 @@ export const ReassignDialog = ({
|
||||
const [searchTerm, setSearchTerm] = useState("");
|
||||
const debouncedSearch = useDebounce(searchTerm, 500);
|
||||
|
||||
const { data, fetchNextPage, hasNextPage, isFetching, isFetchingNextPage } =
|
||||
trpc.viewer.teams.getRoundRobinHostsToReassign.useInfiniteQuery(
|
||||
{
|
||||
bookingId,
|
||||
exclude: "fixedHosts",
|
||||
limit: 10,
|
||||
searchTerm: debouncedSearch,
|
||||
},
|
||||
{
|
||||
getNextPageParam: (lastPage) => lastPage.nextCursor,
|
||||
}
|
||||
);
|
||||
const managedEventQuery = trpc.viewer.teams.getManagedEventUsersToReassign.useInfiniteQuery(
|
||||
{
|
||||
bookingId,
|
||||
limit: 10,
|
||||
searchTerm: debouncedSearch,
|
||||
},
|
||||
{
|
||||
enabled: isManagedEvent,
|
||||
getNextPageParam: (lastPage) => lastPage.nextCursor,
|
||||
}
|
||||
);
|
||||
|
||||
const roundRobinQuery = trpc.viewer.teams.getRoundRobinHostsToReassign.useInfiniteQuery(
|
||||
{
|
||||
bookingId,
|
||||
exclude: "fixedHosts",
|
||||
limit: 10,
|
||||
searchTerm: debouncedSearch,
|
||||
},
|
||||
{
|
||||
enabled: !isManagedEvent,
|
||||
getNextPageParam: (lastPage) => lastPage.nextCursor,
|
||||
}
|
||||
);
|
||||
|
||||
const { data, fetchNextPage, hasNextPage, isFetching, isFetchingNextPage } = isManagedEvent
|
||||
? managedEventQuery
|
||||
: roundRobinQuery;
|
||||
|
||||
const allRows = useMemo(() => {
|
||||
return data?.pages.flatMap((page) => page.items) ?? [];
|
||||
@@ -110,7 +128,7 @@ export const ReassignDialog = ({
|
||||
const form = useForm<FormValues>({
|
||||
resolver: zodResolver(formSchema),
|
||||
defaultValues: {
|
||||
reassignType: bookingFromRoutingForm ? ReassignType.TEAM_MEMBER : ReassignType.ROUND_ROBIN,
|
||||
reassignType: bookingFromRoutingForm ? ReassignType.TEAM_MEMBER : ReassignType.AUTO,
|
||||
},
|
||||
});
|
||||
|
||||
@@ -124,7 +142,22 @@ export const ReassignDialog = ({
|
||||
if (error.message.includes(ErrorCode.NoAvailableUsersFound)) {
|
||||
showToast(t("no_available_hosts"), "error");
|
||||
} else {
|
||||
showToast(t("unexpected_error_try_again"), "error");
|
||||
showToast(t(error.message), "error");
|
||||
}
|
||||
},
|
||||
});
|
||||
|
||||
const managedEventReassignMutation = trpc.viewer.teams.managedEventReassign.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(error.message), "error");
|
||||
}
|
||||
},
|
||||
});
|
||||
@@ -144,6 +177,21 @@ export const ReassignDialog = ({
|
||||
},
|
||||
});
|
||||
|
||||
const managedEventManualReassignMutation = trpc.viewer.teams.managedEventManualReassign.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(error.message), "error");
|
||||
}
|
||||
},
|
||||
});
|
||||
|
||||
const [confirmationModal, setConfirmationModal] = useState<{
|
||||
show: boolean;
|
||||
membersStatus: "unavailable" | "available" | null;
|
||||
@@ -153,8 +201,12 @@ export const ReassignDialog = ({
|
||||
});
|
||||
|
||||
const handleSubmit = (values: FormValues) => {
|
||||
if (values.reassignType === ReassignType.ROUND_ROBIN) {
|
||||
roundRobinReassignMutation.mutate({ teamId, bookingId });
|
||||
if (values.reassignType === ReassignType.AUTO) {
|
||||
if (isManagedEvent) {
|
||||
managedEventReassignMutation.mutate({ bookingId });
|
||||
} else {
|
||||
roundRobinReassignMutation.mutate({ teamId, bookingId });
|
||||
}
|
||||
} else {
|
||||
if (values.teamMemberId) {
|
||||
const selectedMember = teamMemberOptions?.find((member) => member.value === values.teamMemberId);
|
||||
@@ -179,8 +231,8 @@ export const ReassignDialog = ({
|
||||
setIsOpenDialog(open);
|
||||
}}>
|
||||
<DialogContent
|
||||
title={t("reassign_round_robin_host")}
|
||||
description={t("reassign_to_another_rr_host")}
|
||||
title={isManagedEvent ? t("reassign_booking") : t("reassign_round_robin_host")}
|
||||
description={isManagedEvent ? t("reassign_to_another_user") : t("reassign_to_another_rr_host")}
|
||||
enableOverflow>
|
||||
<Form form={form} handleSubmit={handleSubmit} ref={animationParentRef}>
|
||||
<RadioArea.Group
|
||||
@@ -188,24 +240,34 @@ export const ReassignDialog = ({
|
||||
const reassignType: ReassignType = z.nativeEnum(ReassignType).parse(val);
|
||||
form.setValue("reassignType", reassignType);
|
||||
}}
|
||||
defaultValue={bookingFromRoutingForm ? ReassignType.TEAM_MEMBER : ReassignType.ROUND_ROBIN}
|
||||
defaultValue={bookingFromRoutingForm ? ReassignType.TEAM_MEMBER : ReassignType.AUTO}
|
||||
className="mt-1 flex flex-col gap-4">
|
||||
{!bookingFromRoutingForm ? (
|
||||
<RadioArea.Item
|
||||
value={ReassignType.ROUND_ROBIN}
|
||||
value={ReassignType.AUTO}
|
||||
className="w-full text-sm"
|
||||
classNames={{ container: "w-full" }}
|
||||
disabled={bookingFromRoutingForm}>
|
||||
<strong className="mb-1 block">{t("round_robin")}</strong>
|
||||
<p>{t("round_robin_reassign_description")}</p>
|
||||
disabled={bookingFromRoutingForm}
|
||||
data-testid="reassign-option-auto">
|
||||
<strong className="mb-1 block">
|
||||
{isManagedEvent ? t("auto_reassign") : t("round_robin")}
|
||||
</strong>
|
||||
<p>{isManagedEvent ? t("auto_reassign_description") : t("round_robin_reassign_description")}</p>
|
||||
</RadioArea.Item>
|
||||
) : null}
|
||||
<RadioArea.Item
|
||||
value={ReassignType.TEAM_MEMBER}
|
||||
className="text-sm"
|
||||
classNames={{ container: "w-full" }}>
|
||||
<strong className="mb-1 block">{t("team_member_round_robin_reassign")}</strong>
|
||||
<p>{t("team_member_round_robin_reassign_description")}</p>
|
||||
classNames={{ container: "w-full" }}
|
||||
data-testid="reassign-option-specific">
|
||||
<strong className="mb-1 block">
|
||||
{isManagedEvent ? t("specific_team_member") : t("team_member_round_robin_reassign")}
|
||||
</strong>
|
||||
<p>
|
||||
{isManagedEvent
|
||||
? t("specific_team_member_description")
|
||||
: t("team_member_round_robin_reassign_description")}
|
||||
</p>
|
||||
</RadioArea.Item>
|
||||
</RadioArea.Group>
|
||||
|
||||
@@ -217,9 +279,22 @@ export const ReassignDialog = ({
|
||||
type="text"
|
||||
placeholder={t("search")}
|
||||
onChange={(e) => setSearchTerm(e.target.value)}
|
||||
data-testid="reassign-user-search"
|
||||
/>
|
||||
<div className="scroll-bar mt-2 flex h-[150px] flex-col gap-0.5 overflow-y-scroll rounded-md border p-1">
|
||||
{teamMemberOptions.map((member) => (
|
||||
{isFetching && teamMemberOptions.length === 0 ? (
|
||||
<div className="flex h-full items-center justify-center">
|
||||
<div className="flex flex-col items-center gap-2">
|
||||
<Icon name="loader" className="text-subtle h-5 w-5 animate-spin" />
|
||||
<p className="text-subtle text-sm">{t("loading")}</p>
|
||||
</div>
|
||||
</div>
|
||||
) : teamMemberOptions.length === 0 ? (
|
||||
<div className="flex h-full items-center justify-center">
|
||||
<p className="text-subtle text-sm">{t("no_available_users_found_input")}</p>
|
||||
</div>
|
||||
) : (
|
||||
teamMemberOptions.map((member) => (
|
||||
<label
|
||||
key={member.value}
|
||||
tabIndex={watchedTeamMemberId === member.value ? -1 : 0}
|
||||
@@ -232,7 +307,7 @@ export const ReassignDialog = ({
|
||||
}
|
||||
}}
|
||||
className={classNames(
|
||||
"hover:bg-subtle focus:bg-subtle focus:ring-emphasis cursor-pointer items-center justify-between gap-0.5 rounded-sm py-2 outline-none focus:ring focus:ring-2",
|
||||
"hover:bg-subtle focus:bg-subtle focus:ring-emphasis cursor-pointer items-center justify-between gap-0.5 rounded-sm py-2 outline-none focus:ring-2",
|
||||
watchedTeamMemberId === member.value && "bg-subtle"
|
||||
)}>
|
||||
<div className="flex flex-1 items-center space-x-3">
|
||||
@@ -256,16 +331,19 @@ export const ReassignDialog = ({
|
||||
)}
|
||||
</div>
|
||||
</label>
|
||||
))}
|
||||
<div className="text-default text-center" ref={observerRef}>
|
||||
<Button
|
||||
color="minimal"
|
||||
loading={isFetchingNextPage}
|
||||
disabled={!hasNextPage}
|
||||
onClick={() => fetchNextPage()}>
|
||||
{hasNextPage ? t("load_more_results") : t("no_more_results")}
|
||||
</Button>
|
||||
</div>
|
||||
))
|
||||
)}
|
||||
{teamMemberOptions.length > 0 && (
|
||||
<div className="text-default text-center" ref={observerRef}>
|
||||
<Button
|
||||
color="minimal"
|
||||
loading={isFetchingNextPage}
|
||||
disabled={!hasNextPage}
|
||||
onClick={() => fetchNextPage()}>
|
||||
{hasNextPage ? t("load_more_results") : t("no_more_results")}
|
||||
</Button>
|
||||
</div>
|
||||
)}
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
@@ -275,7 +353,12 @@ export const ReassignDialog = ({
|
||||
<Button
|
||||
type="submit"
|
||||
data-testid="rejection-confirm"
|
||||
loading={roundRobinReassignMutation.isPending || roundRobinManualReassignMutation.isPending}>
|
||||
loading={
|
||||
roundRobinReassignMutation.isPending ||
|
||||
roundRobinManualReassignMutation.isPending ||
|
||||
managedEventReassignMutation.isPending ||
|
||||
managedEventManualReassignMutation.isPending
|
||||
}>
|
||||
{t("reassign")}
|
||||
</Button>
|
||||
</DialogFooter>
|
||||
@@ -300,11 +383,19 @@ export const ReassignDialog = ({
|
||||
if (!teamMemberId) {
|
||||
return;
|
||||
}
|
||||
roundRobinManualReassignMutation.mutate({
|
||||
bookingId,
|
||||
teamMemberId,
|
||||
reassignReason: form.getValues("reassignReason"),
|
||||
});
|
||||
if (isManagedEvent) {
|
||||
managedEventManualReassignMutation.mutate({
|
||||
bookingId,
|
||||
teamMemberId,
|
||||
reassignReason: form.getValues("reassignReason"),
|
||||
});
|
||||
} else {
|
||||
roundRobinManualReassignMutation.mutate({
|
||||
bookingId,
|
||||
teamMemberId,
|
||||
reassignReason: form.getValues("reassignReason"),
|
||||
});
|
||||
}
|
||||
setConfirmationModal({
|
||||
show: false,
|
||||
membersStatus: null,
|
||||
|
||||
@@ -73,6 +73,7 @@
|
||||
"event_request_cancelled": "Your scheduled event was canceled",
|
||||
"event_request_reassigned": "Your scheduled event was reassigned",
|
||||
"event_reassigned_subtitle": "You will no longer have the event on your calendar and your round robin likelihood will not be negatively impacted",
|
||||
"event_reassigned_subtitle_generic": "You will no longer have the event on your calendar",
|
||||
"organizer": "Organizer",
|
||||
"reassigned_to": "Reassigned to",
|
||||
"need_to_reschedule_or_cancel": "Need to reschedule or cancel?",
|
||||
@@ -3039,6 +3040,12 @@
|
||||
"booking_reassigned": "Booking has been reassigned",
|
||||
"reassign": "Reassign",
|
||||
"reassign_to_another_rr_host": "Reassign booking to another available round robin host",
|
||||
"reassign_booking": "Reassign booking",
|
||||
"reassign_to_another_user": "Reassign booking to another available team member",
|
||||
"auto_reassign": "Auto Reassign",
|
||||
"auto_reassign_description": "Automatically reassign to another available team member",
|
||||
"specific_team_member": "Specific Team Member",
|
||||
"specific_team_member_description": "Manually reassign to a specific team member",
|
||||
"assign_team_member": "Assign team member",
|
||||
"override_team_member_to_assign": "Override which team member you want to assign to.",
|
||||
"no_available_hosts": "No available hosts",
|
||||
@@ -3996,6 +4003,7 @@
|
||||
"slots_taken": "{{takenSeats}}/{{totalSeats}} slots taken",
|
||||
"team_invite_subtitle": "Invite team members to collaborate and schedule together",
|
||||
"team_onboarding_details_subtitle": "Add your team's name and create a unique URL for your team",
|
||||
"no_available_users_found_input": "No available users found",
|
||||
"repeats_num_times": "Repeats {{count}} times",
|
||||
"view_booking_details": "View Booking Details",
|
||||
"recurring_booking_description": "Recurring {{frequency}} event with {{count}} occurrences",
|
||||
|
||||
Reference in new issue
Block a user