feat: #15416 Expand round robin availability beyond default schedule (#15618)

* add feature to change host schedule

* update for type-check:ci

* Update SingleForm.tsx for linterr

* update as per design review

* update for rerendering

* migration files

* On Delete set null for schedule

if schedule is deleted, no need to delete the host

* updated schema

* added testcases

* checking permissions before

* updated for comments

* update for initial value

* updated and cleanup

* set initial value

* update after merge

* updated nit style

* update for console warning and added comments

* nit/chore

* chore

* update for typechecks

* update for scheduleId param after merge

* update after merge or new changes in metadata.config

* update after weights functionality

* updated description text and column name as per review suggestion

* resolved merge conflicts

* fix typecheck due to changes in getScheduleSchema

* update after merge having refactor

* update refactored EventTypeWebWrapper after merge

* updated props

* updated trpc err code and added log

* update due to refactor in EventAvailabilityTab

* perf: Optimise TS type + select only the data that's needed for a specific function

---------

Co-authored-by: Amit Sharma <[email protected]>
Co-authored-by: Syed Ali Shahbaz <[email protected]>
Co-authored-by: Alex van Andel <[email protected]>
This commit is contained in:
authored and GitHub committed 2024-10-15 17:36:00 +01:00
1 parent c21f0caecf
commit a48d190af3
27 files changed
+600 -67

No files matched your search

+11 -8
View File
@@ -44,7 +44,7 @@
"event_request_cancelled": "Your scheduled event was canceled",
"organizer": "Organizer",
"need_to_reschedule_or_cancel": "Need to reschedule or cancel?",
"you_can_view_booking_details_with_this_url":"You can view the booking details from this url {{url}} and add the event to your calendar",
"you_can_view_booking_details_with_this_url": "You can view the booking details from this url {{url}} and add the event to your calendar",
"no_options_available": "No options available",
"cancellation_reason": "Reason for cancellation (optional)",
"cancellation_reason_placeholder": "Why are you cancelling?",
@@ -601,7 +601,7 @@
"enter_address": "Enter address",
"in_person_attendee_address": "In Person (Attendee Address)",
"somewhere_else": "Somewhere Else",
"custom_attendee_location":"Custom attendee location",
"custom_attendee_location": "Custom attendee location",
"any_location": "Any location",
"yes": "Yes",
"no": "No",
@@ -1702,7 +1702,7 @@
"invalid_credential_action": "Reinstall app",
"reschedule_reason": "Reschedule reason",
"choose_common_schedule_team_event": "Choose a common schedule",
"choose_common_schedule_team_event_description": "Enable this if you want to use a common schedule between hosts. When disabled, each host will be booked based on their default schedule.",
"choose_common_schedule_team_event_description": "Enable this if you want to use a common schedule between hosts. When disabled, each host will be booked based on their default schedule or their choosen schedule.",
"reason": "Reason",
"sender_id": "Sender ID",
"sender_id_error_message": "Only letters, numbers and spaces allowed (max. 11 characters)",
@@ -2484,7 +2484,7 @@
"add_emails": "Add Emails",
"add_email_description": "Add an email address to replace your primary or to use as an alternative email on your event types.",
"confirm_email": "Confirm your email",
"confirming_your_booking_sms":"$t(hey_there) {{name}}, confirming your booking on {{date}}.",
"confirming_your_booking_sms": "$t(hey_there) {{name}}, confirming your booking on {{date}}.",
"scheduler_first_name": "The first name of the person booking",
"scheduler_last_name": "The last name of the person booking",
"scheduler_name": "Scheduler Name",
@@ -2592,19 +2592,19 @@
"event_expired": "This event is expired",
"skip_contact_creation": "Skip creating contacts if they do not exist in {{appName}} ",
"skip_writing_to_calendar_note": "If your ICS link is read-only (e.g., Proton Calendar), check the box above to avoid errors. You'll also need to manually update your calendar for changes.",
"attributes":"Attributes",
"attributes": "Attributes",
"new_attribute": "New attribute",
"add_attributes": "Add attributes",
"add_attributes_description": "Add attributes to your team members",
"new_option": "New option",
"update_profile":"Update member",
"update_profile": "Update member",
"attribute_updated_successfully": "Attribute updated successfully",
"attributes_edited_successfully": "Attributes edited successfully",
"attribute_meta_description": "Manage attributes for your team members",
"attributes_edit_description": "Edit attributes for your team members",
"back_to_attributes": "Back to attributes",
"delete_attribute": "Are you sure you want to delete this option?",
"delete_attribute_description":"This option is assigned to {{numberOfUsers}} members. Deleting it will remove it from their profile.",
"delete_attribute_description": "This option is assigned to {{numberOfUsers}} members. Deleting it will remove it from their profile.",
"disable_all_emails_to_attendees": "Disable standard emails to attendees related to this event type",
"disable_all_emails_description": "Disables standard email communication related to this event type, including booking confirmations, reminders, and cancellations.",
"disable_all_emails_to_hosts": "Disable standard emails to hosts related to this event type",
@@ -2627,7 +2627,7 @@
"stripe_connect_atom_loading_label": "Checking Stripe credentials",
"booking_question_response_variables": "Booking question response variables",
"managed_by_teamAdmins": "Managed by {{teamAdmins}}",
"number_of_options":"{{count}} options",
"number_of_options": "{{count}} options",
"reschedule_with_same_round_robin_host_title": "Reschedule with same Round-Robin host",
"reschedule_with_same_round_robin_host_description": "Rescheduled events will be assigned to the same host as initially scheduled",
"disable_input_if_prefilled": "Disable input if the URL identifier is prefilled",
@@ -2654,5 +2654,8 @@
"salesforce_book_directly_with_attendee_owner": "If attendee exists in Salesforce, book directly with the owner",
"salesforce_check_owner_of": "Entity to check owner of to book directly",
"account": "Account",
"choose_hosts_schedule": "Choose host schedules",
"hosts_schedule_description": "You can select a different schedule for each host. Each host's default schedule is chosen by default.",
"no_hosts_description": "No hosts assigned, add hosts in assignment tab.",
"ADD_NEW_STRINGS_ABOVE_THIS_LINE_TO_PREVENT_MERGE_CONFLICTS": "↑↑↑↑↑↑↑↑↑↑↑↑↑ Add your new strings above here ↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑"
}
@@ -8,7 +8,9 @@ describe("Tests to Check if Event Types have empty Assignment", () => {
checkForEmptyAssignment({
assignedUsers: [],
assignAllTeamMembers: false,
hosts: [{ userId: 101, isFixed: false, priority: 2, weight: 100, weightAdjustment: 0 }],
hosts: [
{ userId: 101, isFixed: false, priority: 2, weight: 100, weightAdjustment: 0, scheduleId: null },
],
isManagedEventType: true,
})
).toBe(true);
@@ -61,7 +63,9 @@ describe("Tests to Check if Event Types have empty Assignment", () => {
checkForEmptyAssignment({
assignedUsers: [],
assignAllTeamMembers: false,
hosts: [{ userId: 101, isFixed: false, priority: 2, weight: 100, weightAdjustment: 0 }],
hosts: [
{ userId: 101, isFixed: false, priority: 2, weight: 100, weightAdjustment: 0, scheduleId: null },
],
isManagedEventType: false,
})
).toBe(false);
+137
View File
@@ -1896,4 +1896,141 @@ describe("getSchedule", () => {
);
});
});
describe("Round robin event", async () => {
test("correctly get slots for event with round robin hosts choosen schedule (non-default)", async () => {
vi.setSystemTime("2024-05-21T00:00:13Z");
const plus1DateString = "2024-05-22";
const plus2DateString = "2024-05-23";
// An event with no common schedule and hosts choosen schedule (non-default schedule)
await createBookingScenario({
eventTypes: [
{
id: 1,
slotInterval: 60,
length: 60,
hosts: [
{
userId: 101,
isFixed: false,
scheduleId: 2,
},
{
userId: 102,
isFixed: false,
scheduleId: 3,
},
],
schedulingType: "ROUND_ROBIN",
schedule: null,
},
],
users: [
{
...TestData.users.example,
email: "[email protected]",
id: 101,
schedules: [TestData.schedules.IstMorningShift, TestData.schedules.IstEveningShift],
defaultScheduleId: 1,
},
{
...TestData.users.example,
email: "[email protected]",
id: 102,
schedules: [TestData.schedules.IstEveningShift, TestData.schedules.IstMorningShift],
defaultScheduleId: 4,
},
],
bookings: [],
});
const scheduleWithHostChoosenSch = await getSchedule({
input: {
eventTypeId: 1,
eventTypeSlug: "",
startTime: `${plus1DateString}T18:30:00.000Z`,
endTime: `${plus2DateString}T18:29:59.999Z`,
timeZone: Timezones["+5:30"],
isTeamEvent: true,
teamMemberEmail: "[email protected]",
},
});
// expect only slots of IstEveningShift , as this is the choosen schedule for hosts
expect(scheduleWithHostChoosenSch).toHaveTimeSlots(
[`11:30:00.000Z`, `12:30:00.000Z`, `13:30:00.000Z`, `14:30:00.000Z`, `15:30:00.000Z`],
{
dateString: plus2DateString,
}
);
});
test("correctly get slots for event with commom schedule", async () => {
vi.setSystemTime("2024-05-21T00:00:13Z");
const plus1DateString = "2024-05-22";
const plus2DateString = "2024-05-23";
// An event with common schedule
await createBookingScenario({
eventTypes: [
{
id: 1,
slotInterval: 60,
length: 60,
hosts: [
{
userId: 101,
isFixed: false,
},
{
userId: 102,
isFixed: false,
},
],
schedule: TestData.schedules.IstEveningShift,
schedulingType: "ROUND_ROBIN",
},
],
users: [
{
...TestData.users.example,
email: "[email protected]",
id: 101,
schedules: [TestData.schedules.IstMorningShift],
defaultScheduleId: 1,
},
{
...TestData.users.example,
email: "[email protected]",
id: 102,
schedules: [TestData.schedules.IstMidShift],
defaultScheduleId: 2,
},
],
bookings: [],
});
const scheduleWithEventCommonSch = await getSchedule({
input: {
eventTypeId: 1,
eventTypeSlug: "",
startTime: `${plus1DateString}T18:30:00.000Z`,
endTime: `${plus2DateString}T18:29:59.999Z`,
timeZone: Timezones["+5:30"],
isTeamEvent: true,
teamMemberEmail: "[email protected]",
},
});
// expect only slots of IstEveningShift , as this is the common schedule of event
expect(scheduleWithEventCommonSch).toHaveTimeSlots(
[`11:30:00.000Z`, `12:30:00.000Z`, `13:30:00.000Z`, `14:30:00.000Z`, `15:30:00.000Z`],
{
dateString: plus2DateString,
}
);
});
});
});
@@ -78,6 +78,7 @@ type InputWorkflowReminder = {
type InputHost = {
userId: number;
isFixed?: boolean;
scheduleId?: number | null;
};
/**
* Data to be mocked
@@ -165,7 +166,7 @@ export type InputEventType = {
};
requiresConfirmation?: boolean;
destinationCalendar?: Prisma.DestinationCalendarCreateInput;
schedule?: InputUser["schedules"][number];
schedule?: InputUser["schedules"][number] | null;
bookingLimits?: IntervalLimit;
durationLimits?: IntervalLimit;
owner?: number;
@@ -222,6 +223,13 @@ async function addHostsToDb(eventTypes: InputEventType[]) {
id: host.userId,
},
},
schedule: host.scheduleId
? {
connect: {
id: host.scheduleId,
},
}
: undefined,
};
await prismock.host.create({