mirror of
https://github.com/Tria-plc/edr-platform.git
synced 2026-08-30 13:28:11 +00:00
shipping line
This commit is contained in:
@@ -0,0 +1,33 @@
|
||||
import { DataSource } from "typeorm";
|
||||
|
||||
import { ShippingLineCompany } from "../shipping-lines/entities/shipping-line-company.entity";
|
||||
|
||||
/**
|
||||
* Notification target for a shipping-line booking.
|
||||
*
|
||||
* A shipping line is NOT a `companies` row: the company IS the account — one
|
||||
* IAM user (`userId`), and the contact details live on the
|
||||
* `shipping_line_companies` row itself. So the customer resolvers
|
||||
* (external_profiles fan-out, company attributes email) never apply; this is
|
||||
* the one lookup every shipping-line notification routes through.
|
||||
*
|
||||
* Entity-only import — safe from any module graph: notifiers already own a
|
||||
* DataSource and need no service from the shipping-lines module.
|
||||
*/
|
||||
export async function resolveShippingLineNotifyTarget(
|
||||
dataSource: DataSource,
|
||||
shippingLineCompanyId: string,
|
||||
): Promise<{
|
||||
userId: string | null;
|
||||
phone: string | null;
|
||||
email: string | null;
|
||||
}> {
|
||||
const line = await dataSource
|
||||
.getRepository(ShippingLineCompany)
|
||||
.findOne({ where: { id: shippingLineCompanyId } });
|
||||
return {
|
||||
userId: line?.userId ?? null,
|
||||
phone: line?.phoneNumber ?? null,
|
||||
email: line?.email ?? null,
|
||||
};
|
||||
}
|
||||
Reference in New Issue
Block a user