- Changed asset status label from "status" to "technicalStatus" in AssetForm component. - Added help text for technical status in AssetForm. - Updated test cases to reflect changes in asset status from "available" to "operational". - Enhanced workstation form to utilize new asset status checks and display appropriate messages. - Refactored asset context to replace "available" with "notRetired" across various application policies and repositories. - Introduced new utility functions for asset status management, including technical status determination and assignment validation. - Added integration tests for asset state verification and unlinking assets from workstations.
33 lines
1021 B
TypeScript
33 lines
1021 B
TypeScript
import type { MailConfigurationValues } from "../domain/value-objects/mail-configuration-values.vo";
|
|
|
|
import type { MailContext } from "./mail-configuration.repository";
|
|
|
|
export function mailAuthorized(values: MailConfigurationValues, context: MailContext) {
|
|
const profile = context.profiles.find((item) =>
|
|
item.id.equals(values.profileId.getOrUndefined())
|
|
);
|
|
const mailbox = context.mailboxes.find((item) =>
|
|
item.id.equals(values.mailboxId.getOrUndefined())
|
|
);
|
|
|
|
if (
|
|
!(
|
|
profile &&
|
|
profile.values.active &&
|
|
mailbox &&
|
|
mailbox.values.active &&
|
|
context.people.some((person) => person.id.equals(profile.values.personId) && person.active) &&
|
|
context.assets.some((asset) => asset.id.equals(profile.values.assetId) && asset.notRetired)
|
|
)
|
|
) {
|
|
return false;
|
|
}
|
|
|
|
return context.uses.some(
|
|
(use) =>
|
|
use.values.mailboxId.equals(mailbox.id) &&
|
|
use.values.personId.equals(profile.values.personId) &&
|
|
use.values.current(context.today)
|
|
);
|
|
}
|