Files
calendar/apps/web/lib/checkForEmptyAssignment.ts
T
8508a6f1a0 fix: #15697 Assignment warning modal poping up ,even when hosts are added . (#15699)
* removed reduntand check on assignedusers

* update for managed eventtype

* formatted

* comments

* Updated comments

* extracted checkForEmptyAssignment and added tests

* updated comments

* updated to show dialog also when not yet saved

* update translations

* updated comments

* updated translation

* updated types

* chore: update naming and comments

* Delete apps/web/lib/checkForEmptyAssignment.ts

deleted since file was renamed

* Delete apps/web/test/lib/checkForEmptyAssignment.test.ts

deleted as the file is renamed to be more descriptive

* update to do teamcheck before

* chore: revert name to CheckForEmptyAssignment

* updated check conditions

* updated useEffect dependencies

---------

Co-authored-by: Anik Dhabal Babu <81948346+anikdhabal@users.noreply.github.com>
2024-07-29 07:02:59 +03:00

30 lines
956 B
TypeScript

import type { EventTypeAssignedUsers, EventTypeHosts } from "~/event-types/views/event-types-single-view";
// This function checks if EventType requires assignment.
// returns true: if EventType requires assignment but there is no assignment yet done by the user.
// returns false: for all other scenarios.
export function checkForEmptyAssignment({
assignedUsers,
hosts,
isManagedEventType,
assignAllTeamMembers,
}: {
assignedUsers: EventTypeAssignedUsers;
hosts: EventTypeHosts;
isManagedEventType: boolean;
assignAllTeamMembers: boolean;
}): boolean {
// If Team-events have assignAllTeamMembers checked, return false as assignemnt is complete.
if (assignAllTeamMembers) {
return false;
}
// For managed eventtype check if assigned users are empty.
// For non-managed eventtype check if hosts are empty.
if (isManagedEventType ? assignedUsers.length === 0 : hosts.length === 0) {
return true;
}
return false;
}