- Add mailbox persistence mapper for domain object mapping. - Create Sequelize repository for mailbox data access. - Define common mailbox schemas and types for validation. - Implement mailbox API for frontend communication. - Develop mailbox form component for creating and editing mailboxes. - Add internationalization support for mailbox labels and messages. - Create mailbox use form for managing mailbox usage periods. - Build mailboxes page to display and manage mailboxes and their usage.
30 lines
1014 B
TypeScript
30 lines
1014 B
TypeScript
import type { MailConfigurationValues } from "../domain/value-objects/mail-configuration-values";
|
|
|
|
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.available)
|
|
)
|
|
) {
|
|
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)
|
|
);
|
|
}
|