78 lines
3.3 KiB
JavaScript
78 lines
3.3 KiB
JavaScript
"use strict";
|
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
exports.presentBrand = presentBrand;
|
|
exports.presentPublicBooking = presentPublicBooking;
|
|
function presentBrand(company) {
|
|
const brand = company.brand;
|
|
return {
|
|
company: { id: company.id, slug: company.slug, name: company.name, phone: company.phone },
|
|
brand: brand ? {
|
|
displayName: brand.displayName,
|
|
tagline: brand.tagline,
|
|
logoUrl: brand.logoUrl,
|
|
faviconUrl: brand.faviconUrl,
|
|
heroImageUrl: brand.heroImageUrl,
|
|
primaryColor: brand.primaryColor,
|
|
accentColor: brand.accentColor,
|
|
subdomain: brand.subdomain,
|
|
customDomain: brand.customDomain,
|
|
customDomainVerified: brand.customDomainVerified,
|
|
customDomainAddedAt: brand.customDomainAddedAt,
|
|
publicEmail: brand.publicEmail,
|
|
publicPhone: brand.publicPhone,
|
|
publicAddress: brand.publicAddress,
|
|
publicCity: brand.publicCity,
|
|
publicCountry: brand.publicCountry,
|
|
websiteUrl: brand.websiteUrl,
|
|
whatsappNumber: brand.whatsappNumber,
|
|
facebookUrl: brand.facebookUrl,
|
|
instagramUrl: brand.instagramUrl,
|
|
defaultLocale: brand.defaultLocale,
|
|
defaultCurrency: brand.defaultCurrency,
|
|
paypalEmail: brand.paypalEmail,
|
|
paypalMerchantId: brand.paypalMerchantId,
|
|
paymentMethodsEnabled: brand.paymentMethodsEnabled,
|
|
isListedOnMarketplace: brand.isListedOnMarketplace,
|
|
marketplaceRating: brand.marketplaceRating,
|
|
homePageConfig: brand.homePageConfig,
|
|
menuConfig: brand.menuConfig,
|
|
} : null,
|
|
};
|
|
}
|
|
function maskEmail(email) {
|
|
if (!email || !email.includes('@'))
|
|
return undefined;
|
|
const [name = '', domain = ''] = email.split('@');
|
|
return `${name.slice(0, 1)}***@${domain}`;
|
|
}
|
|
function maskPhone(phone) {
|
|
if (!phone)
|
|
return undefined;
|
|
const visible = phone.replace(/\D/g, '').slice(-4);
|
|
return visible ? `***${visible}` : undefined;
|
|
}
|
|
function presentPublicBooking(reservation) {
|
|
return {
|
|
id: reservation.id,
|
|
status: reservation.status,
|
|
pickupAt: reservation.startDate instanceof Date ? reservation.startDate.toISOString() : reservation.startDate,
|
|
returnAt: reservation.endDate instanceof Date ? reservation.endDate.toISOString() : reservation.endDate,
|
|
vehicle: {
|
|
make: reservation.vehicle?.make,
|
|
model: reservation.vehicle?.model,
|
|
year: reservation.vehicle?.year,
|
|
imageUrl: Array.isArray(reservation.vehicle?.images) ? reservation.vehicle.images[0] : reservation.vehicle?.imageUrl,
|
|
},
|
|
customer: {
|
|
displayName: [reservation.customer?.firstName, reservation.customer?.lastName?.slice(0, 1)].filter(Boolean).join(' '),
|
|
maskedEmail: maskEmail(reservation.customer?.email),
|
|
maskedPhone: maskPhone(reservation.customer?.phone),
|
|
},
|
|
totals: {
|
|
amountDue: reservation.totalAmount - (reservation.paidAmount ?? 0),
|
|
currency: 'MAD',
|
|
},
|
|
paymentStatus: reservation.paymentStatus,
|
|
};
|
|
}
|
|
//# sourceMappingURL=site.presenter.js.map
|