Files
alrahma_sunday_school_api/apps/api/dist/modules/auth/auth.presenter.js
T
2026-06-11 03:22:12 -04:00

43 lines
1.5 KiB
JavaScript

"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.presentEmployeeSession = presentEmployeeSession;
exports.presentCompanySignup = presentCompanySignup;
exports.presentRenterProfile = presentRenterProfile;
function presentEmployeeSession(employee, token) {
const data = {
employee: {
id: employee.id,
email: employee.email,
firstName: employee.firstName,
lastName: employee.lastName,
role: employee.role,
preferredLanguage: employee.preferredLanguage,
companyId: employee.companyId,
companyName: employee.company.name,
companySlug: employee.company.slug,
},
};
return token ? { token, ...data } : data;
}
function presentCompanySignup(result) {
return {
companyId: result.company.id,
companyName: result.company.name,
slug: result.company.slug,
invitationId: null,
trialEndsAt: result.trialEndAt.toISOString(),
nextStep: 'workspace_created',
emailDelivery: result.emailDelivery ?? { attempted: false, success: false, error: null },
};
}
function presentRenterProfile(renter, companies) {
const companyMap = new Map(companies.map((company) => [company.id, company]));
return {
...renter,
savedCompanies: renter.savedCompanies.map((savedCompany) => ({
id: savedCompany.companyId,
brand: companyMap.get(savedCompany.companyId)?.brand ?? null,
})),
};
}
//# sourceMappingURL=auth.presenter.js.map