Уведомления назначенным пользователям (#9)
Co-authored-by: gorbenko.pavel <gorbenko.pavel@tansu.kz> Reviewed-on: http://git.tnsu.kz/gorbenko.pavel/tnsu-approval-route/pulls/9
This commit was merged in pull request #9.
This commit is contained in:
+13
-1
@@ -10,6 +10,8 @@ export interface IManageRequestsApproverModalProps {
|
||||
initialEmail?: string;
|
||||
employees: Employee[];
|
||||
employeesLoading: boolean;
|
||||
/** Email'ы (в любом регистре), уже занятые другими шагами той же фазы — этот человек не может встать в фазу второй раз. */
|
||||
excludedEmails: string[];
|
||||
onSave: (email: string, position: string) => Promise<void>;
|
||||
onClose: () => void;
|
||||
}
|
||||
@@ -27,18 +29,28 @@ export const ManageRequestsApproverModal: React.FC<IManageRequestsApproverModalP
|
||||
initialEmail = '',
|
||||
employees,
|
||||
employeesLoading,
|
||||
excludedEmails,
|
||||
onSave,
|
||||
onClose
|
||||
}) => {
|
||||
const [email, setEmail] = React.useState(initialEmail);
|
||||
const submit = useAsyncSubmit();
|
||||
|
||||
// Тот, кто уже занят в этой фазе, исключён из списка выбора — дубликат
|
||||
// физически нельзя выбрать (см. excludedEmails в ManageRequestsScreen).
|
||||
const excludedSet = new Set(excludedEmails.map(e => e.toLowerCase()));
|
||||
const selectableEmployees = employees.filter(e => !excludedSet.has(e.email.toLowerCase()));
|
||||
|
||||
const handleSubmit = (): void => {
|
||||
const trimmedEmail = email.trim();
|
||||
if (!trimmedEmail) {
|
||||
submit.fail(texts.manageRequests.validationApprover);
|
||||
return;
|
||||
}
|
||||
if (excludedSet.has(trimmedEmail.toLowerCase())) {
|
||||
submit.fail(texts.manageRequests.validationDuplicateApprover);
|
||||
return;
|
||||
}
|
||||
const position = findEmployeeByEmail(employees, trimmedEmail)?.position || '';
|
||||
submit.run(() => onSave(trimmedEmail, position));
|
||||
};
|
||||
@@ -48,7 +60,7 @@ export const ManageRequestsApproverModal: React.FC<IManageRequestsApproverModalP
|
||||
<FormGrid>
|
||||
<Field label={texts.manageRequests.approverLabel} required full>
|
||||
<SearchableSelect
|
||||
options={employees.map(toEmployeeOption)}
|
||||
options={selectableEmployees.map(toEmployeeOption)}
|
||||
value={email}
|
||||
loading={employeesLoading}
|
||||
placeholder={texts.manageRequests.approverPlaceholder}
|
||||
|
||||
Reference in New Issue
Block a user