230 lines
16 KiB
JavaScript
230 lines
16 KiB
JavaScript
"use strict";
|
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
exports.reviewRequestEmail = exports.bookingConfirmedNotif = exports.marketplaceReservationEmail = exports.resetPasswordEmail = exports.signupEmail = void 0;
|
|
exports.formatDate = formatDate;
|
|
function t(map, lang) {
|
|
return map[lang] ?? map['fr'];
|
|
}
|
|
const dateLocale = { en: 'en-GB', fr: 'fr-FR', ar: 'ar-MA' };
|
|
function formatDate(date, lang, opts) {
|
|
return date.toLocaleDateString(dateLocale[lang], opts ?? { year: 'numeric', month: 'long', day: 'numeric' });
|
|
}
|
|
// ─── Signup confirmation ──────────────────────────────────────────────────────
|
|
exports.signupEmail = {
|
|
subject: (lang) => t({
|
|
en: 'Your workspace is ready — RentalDriveGo',
|
|
fr: 'Votre espace de travail est prêt — RentalDriveGo',
|
|
ar: 'مساحة عملك جاهزة — RentalDriveGo',
|
|
}, lang),
|
|
text: (opts, lang) => {
|
|
const trialStr = formatDate(opts.trialEnd, lang);
|
|
return t({
|
|
en: [
|
|
`Hi ${opts.firstName},`,
|
|
'',
|
|
`Your RentalDriveGo workspace for ${opts.companyName} has been created successfully.`,
|
|
`Plan: ${opts.plan} (${opts.billingPeriod.toLowerCase()})`,
|
|
`Currency: ${opts.currency}`,
|
|
`Primary payment provider: ${opts.paymentProvider}`,
|
|
`Free trial ends on ${trialStr}.`,
|
|
'',
|
|
'Your workspace is ready. Sign in with the email and password you chose during signup.',
|
|
'',
|
|
'RentalDriveGo',
|
|
].join('\n'),
|
|
fr: [
|
|
`Bonjour ${opts.firstName},`,
|
|
'',
|
|
`Votre espace de travail RentalDriveGo pour ${opts.companyName} a été créé avec succès.`,
|
|
`Forfait : ${opts.plan} (${opts.billingPeriod === 'MONTHLY' ? 'mensuel' : 'annuel'})`,
|
|
`Devise : ${opts.currency}`,
|
|
`Fournisseur de paiement principal : ${opts.paymentProvider}`,
|
|
`La période d'essai gratuit se termine le ${trialStr}.`,
|
|
'',
|
|
"Votre espace de travail est prêt. Connectez-vous avec l'e-mail et le mot de passe choisis lors de l'inscription.",
|
|
'',
|
|
'RentalDriveGo',
|
|
].join('\n'),
|
|
ar: [
|
|
`مرحباً ${opts.firstName}،`,
|
|
'',
|
|
`تم إنشاء مساحة عمل RentalDriveGo الخاصة بـ ${opts.companyName} بنجاح.`,
|
|
`الخطة: ${opts.plan} (${opts.billingPeriod === 'MONTHLY' ? 'شهري' : 'سنوي'})`,
|
|
`العملة: ${opts.currency}`,
|
|
`مزود الدفع الرئيسي: ${opts.paymentProvider}`,
|
|
`تنتهي الفترة التجريبية المجانية في ${trialStr}.`,
|
|
'',
|
|
'مساحة عملك جاهزة. سجّل الدخول باستخدام البريد الإلكتروني وكلمة المرور التي اخترتهما عند التسجيل.',
|
|
'',
|
|
'RentalDriveGo',
|
|
].join('\n'),
|
|
}, lang);
|
|
},
|
|
};
|
|
// ─── Password reset ───────────────────────────────────────────────────────────
|
|
exports.resetPasswordEmail = {
|
|
subject: (lang) => t({
|
|
en: 'Reset your RentalDriveGo password',
|
|
fr: 'Réinitialisez votre mot de passe RentalDriveGo',
|
|
ar: 'إعادة تعيين كلمة مرور RentalDriveGo',
|
|
}, lang),
|
|
html: (resetUrl, firstName, expireMinutes, lang) => {
|
|
const isRtl = lang === 'ar';
|
|
const dir = isRtl ? 'rtl' : 'ltr';
|
|
return t({
|
|
en: `<div dir="ltr" style="font-family:sans-serif;max-width:560px;margin:auto;padding:32px;color:#1c1917">
|
|
<p>Hi ${firstName},</p>
|
|
<p>You requested a password reset for your RentalDriveGo workspace account.</p>
|
|
<p><a href="${resetUrl}" style="background:#1d4ed8;color:#fff;padding:12px 24px;border-radius:8px;text-decoration:none;display:inline-block;font-weight:600;">Reset your password</a></p>
|
|
<p>This link expires in ${expireMinutes} minutes. If you did not request this, you can safely ignore this email.</p>
|
|
<p>RentalDriveGo</p>
|
|
</div>`,
|
|
fr: `<div dir="ltr" style="font-family:sans-serif;max-width:560px;margin:auto;padding:32px;color:#1c1917">
|
|
<p>Bonjour ${firstName},</p>
|
|
<p>Vous avez demandé la réinitialisation du mot de passe de votre compte RentalDriveGo.</p>
|
|
<p><a href="${resetUrl}" style="background:#1d4ed8;color:#fff;padding:12px 24px;border-radius:8px;text-decoration:none;display:inline-block;font-weight:600;">Réinitialiser mon mot de passe</a></p>
|
|
<p>Ce lien expire dans ${expireMinutes} minutes. Si vous n'avez pas fait cette demande, ignorez simplement cet e-mail.</p>
|
|
<p>RentalDriveGo</p>
|
|
</div>`,
|
|
ar: `<div dir="rtl" style="font-family:sans-serif;max-width:560px;margin:auto;padding:32px;color:#1c1917">
|
|
<p>مرحباً ${firstName}،</p>
|
|
<p>طلبت إعادة تعيين كلمة مرور حساب RentalDriveGo الخاص بك.</p>
|
|
<p><a href="${resetUrl}" style="background:#1d4ed8;color:#fff;padding:12px 24px;border-radius:8px;text-decoration:none;display:inline-block;font-weight:600;">إعادة تعيين كلمة المرور</a></p>
|
|
<p>تنتهي صلاحية هذا الرابط خلال ${expireMinutes} دقيقة. إذا لم تطلب ذلك، يمكنك تجاهل هذا البريد الإلكتروني بأمان.</p>
|
|
<p>RentalDriveGo</p>
|
|
</div>`,
|
|
}, lang);
|
|
},
|
|
text: (resetUrl, firstName, expireMinutes, lang) => t({
|
|
en: `Hi ${firstName},\n\nReset your password here: ${resetUrl}\n\nThis link expires in ${expireMinutes} minutes.\n\nRentalDriveGo`,
|
|
fr: `Bonjour ${firstName},\n\nRéinitialisez votre mot de passe ici : ${resetUrl}\n\nCe lien expire dans ${expireMinutes} minutes.\n\nRentalDriveGo`,
|
|
ar: `مرحباً ${firstName}،\n\nأعد تعيين كلمة مرورك هنا: ${resetUrl}\n\nينتهي هذا الرابط خلال ${expireMinutes} دقيقة.\n\nRentalDriveGo`,
|
|
}, lang),
|
|
};
|
|
// ─── Marketplace reservation request ─────────────────────────────────────────
|
|
exports.marketplaceReservationEmail = {
|
|
subject: (vehicleName, lang) => t({
|
|
en: `Reservation Request Received — ${vehicleName}`,
|
|
fr: `Demande de réservation reçue — ${vehicleName}`,
|
|
ar: `تم استلام طلب الحجز — ${vehicleName}`,
|
|
}, lang),
|
|
html: (opts, lang) => {
|
|
const startStr = formatDate(opts.startDate, lang);
|
|
const endStr = formatDate(opts.endDate, lang);
|
|
const isRtl = lang === 'ar';
|
|
const l = t({
|
|
en: {
|
|
greeting: `Hi ${opts.firstName},`,
|
|
intro: 'Your reservation request has been received and is pending company confirmation.',
|
|
company: 'Company', pickup: 'Pick-up date', returnD: 'Return date',
|
|
duration: 'Duration', daily: 'Daily rate', total: 'Estimated total', days: 'day(s)',
|
|
footer: `The company will review your request and get in touch shortly. You may be contacted at ${opts.email}${opts.phone ? ` or ${opts.phone}` : ''}.`,
|
|
},
|
|
fr: {
|
|
greeting: `Bonjour ${opts.firstName},`,
|
|
intro: 'Votre demande de réservation a été reçue et est en attente de confirmation.',
|
|
company: 'Société', pickup: 'Date de prise en charge', returnD: 'Date de retour',
|
|
duration: 'Durée', daily: 'Tarif journalier', total: 'Total estimé', days: 'jour(s)',
|
|
footer: `La société examinera votre demande et vous contactera prochainement. Vous pouvez être contacté à ${opts.email}${opts.phone ? ` ou ${opts.phone}` : ''}.`,
|
|
},
|
|
ar: {
|
|
greeting: `مرحباً ${opts.firstName}،`,
|
|
intro: 'تم استلام طلب الحجز وهو في انتظار تأكيد الشركة.',
|
|
company: 'الشركة', pickup: 'تاريخ الاستلام', returnD: 'تاريخ الإرجاع',
|
|
duration: 'المدة', daily: 'السعر اليومي', total: 'الإجمالي التقديري', days: 'يوم',
|
|
footer: `ستراجع الشركة طلبك وستتواصل معك قريباً. يمكن التواصل معك على ${opts.email}${opts.phone ? ` أو ${opts.phone}` : ''}.`,
|
|
},
|
|
}, lang);
|
|
return `
|
|
<div style="font-family:sans-serif;max-width:560px;margin:auto;padding:32px;color:#1c1917;direction:${isRtl ? 'rtl' : 'ltr'}">
|
|
<h2 style="margin-bottom:4px">${l.greeting}</h2>
|
|
<p style="color:#57534e">${l.intro}</p>
|
|
<hr style="border:none;border-top:1px solid #e7e5e4;margin:24px 0"/>
|
|
<h3 style="margin-bottom:12px">${opts.vehicleYear} ${opts.vehicleMake} ${opts.vehicleModel}</h3>
|
|
<p><strong>${l.company}:</strong> ${opts.companyName}</p>
|
|
<p><strong>${l.pickup}:</strong> ${startStr}</p>
|
|
<p><strong>${l.returnD}:</strong> ${endStr}</p>
|
|
<p><strong>${l.duration}:</strong> ${opts.totalDays} ${l.days}</p>
|
|
<p><strong>${l.daily}:</strong> ${opts.rateDisplay} MAD</p>
|
|
<p><strong>${l.total}:</strong> ${opts.totalDisplay} MAD</p>
|
|
<hr style="border:none;border-top:1px solid #e7e5e4;margin:24px 0"/>
|
|
<p style="color:#57534e;font-size:13px">${l.footer}</p>
|
|
</div>
|
|
`;
|
|
},
|
|
text: (opts, lang) => {
|
|
const startStr = formatDate(opts.startDate, lang);
|
|
const endStr = formatDate(opts.endDate, lang);
|
|
return t({
|
|
en: `Hi ${opts.firstName},\n\nYour reservation request for the ${opts.vehicleYear} ${opts.vehicleMake} ${opts.vehicleModel} from ${opts.companyName} has been received.\n\nDates: ${startStr} → ${endStr}\nDuration: ${opts.totalDays} day(s)\nDaily rate: ${opts.rateDisplay} MAD\nEstimated total: ${opts.totalDisplay} MAD\n\nThe company will confirm your request shortly.\n\nThank you!`,
|
|
fr: `Bonjour ${opts.firstName},\n\nVotre demande de réservation pour la ${opts.vehicleYear} ${opts.vehicleMake} ${opts.vehicleModel} auprès de ${opts.companyName} a été reçue.\n\nDates : ${startStr} → ${endStr}\nDurée : ${opts.totalDays} jour(s)\nTarif journalier : ${opts.rateDisplay} MAD\nTotal estimé : ${opts.totalDisplay} MAD\n\nLa société confirmera votre demande prochainement.\n\nMerci !`,
|
|
ar: `مرحباً ${opts.firstName}،\n\nتم استلام طلب حجزك لسيارة ${opts.vehicleYear} ${opts.vehicleMake} ${opts.vehicleModel} من ${opts.companyName}.\n\nالتواريخ: ${startStr} → ${endStr}\nالمدة: ${opts.totalDays} يوم\nالسعر اليومي: ${opts.rateDisplay} MAD\nالإجمالي التقديري: ${opts.totalDisplay} MAD\n\nستؤكد الشركة طلبك قريباً.\n\nشكراً!`,
|
|
}, lang);
|
|
},
|
|
};
|
|
// ─── Booking confirmed ────────────────────────────────────────────────────────
|
|
exports.bookingConfirmedNotif = {
|
|
title: (lang) => t({
|
|
en: 'Booking Confirmed',
|
|
fr: 'Réservation confirmée',
|
|
ar: 'تم تأكيد الحجز',
|
|
}, lang),
|
|
body: (lang) => t({
|
|
en: 'Your booking has been confirmed.',
|
|
fr: 'Votre réservation a été confirmée.',
|
|
ar: 'تم تأكيد حجزك.',
|
|
}, lang),
|
|
};
|
|
// ─── Post-rental review request ───────────────────────────────────────────────
|
|
exports.reviewRequestEmail = {
|
|
subject: (vehicleLabel, lang) => t({
|
|
en: `How was your rental? — ${vehicleLabel}`,
|
|
fr: `Comment s'est passée votre location ? — ${vehicleLabel}`,
|
|
ar: `كيف كانت تجربة الإيجار؟ — ${vehicleLabel}`,
|
|
}, lang),
|
|
html: (opts, lang) => {
|
|
const isRtl = lang === 'ar';
|
|
const l = t({
|
|
en: {
|
|
greeting: `Hi ${opts.firstName},`,
|
|
body1: `Thank you for renting with <strong>${opts.companyName}</strong>. We hope you enjoyed your <strong>${opts.vehicleLabel}</strong>.`,
|
|
body2: 'Your feedback helps the company improve and helps other customers make informed choices. It only takes 30 seconds.',
|
|
cta: 'Leave a review',
|
|
disclaimer: 'This link is unique to your reservation and can only be used once. If you did not rent a vehicle recently, you can ignore this email.',
|
|
},
|
|
fr: {
|
|
greeting: `Bonjour ${opts.firstName},`,
|
|
body1: `Merci d'avoir loué chez <strong>${opts.companyName}</strong>. Nous espérons que vous avez apprécié votre <strong>${opts.vehicleLabel}</strong>.`,
|
|
body2: "Votre avis aide la société à s'améliorer et aide les autres clients à faire des choix éclairés. Cela ne prend que 30 secondes.",
|
|
cta: 'Laisser un avis',
|
|
disclaimer: "Ce lien est unique à votre réservation et ne peut être utilisé qu'une seule fois. Si vous n'avez pas loué de véhicule récemment, vous pouvez ignorer cet e-mail.",
|
|
},
|
|
ar: {
|
|
greeting: `مرحباً ${opts.firstName}،`,
|
|
body1: `شكراً لاختيار <strong>${opts.companyName}</strong>. نأمل أنك استمتعت بـ <strong>${opts.vehicleLabel}</strong>.`,
|
|
body2: 'تساعد ملاحظاتك الشركة على التحسين وتساعد العملاء الآخرين على اتخاذ قرارات مستنيرة. لا يستغرق الأمر سوى 30 ثانية.',
|
|
cta: 'اترك تقييماً',
|
|
disclaimer: 'هذا الرابط فريد لحجزك ولا يمكن استخدامه إلا مرة واحدة. إذا لم تستأجر مركبة مؤخراً، يمكنك تجاهل هذا البريد الإلكتروني.',
|
|
},
|
|
}, lang);
|
|
return `
|
|
<div style="font-family:sans-serif;max-width:560px;margin:auto;padding:32px;color:#1c1917;direction:${isRtl ? 'rtl' : 'ltr'}">
|
|
<h2 style="margin-bottom:4px">${l.greeting}</h2>
|
|
<p style="color:#57534e">${l.body1}</p>
|
|
<p style="color:#57534e">${l.body2}</p>
|
|
<div style="margin:32px 0;text-align:center">
|
|
<a href="${opts.reviewUrl}" style="background:#1c1917;color:#ffffff;padding:14px 32px;border-radius:999px;text-decoration:none;font-weight:600;font-size:15px;display:inline-block">
|
|
${l.cta}
|
|
</a>
|
|
</div>
|
|
<p style="color:#a8a29e;font-size:12px">${l.disclaimer}</p>
|
|
</div>
|
|
`;
|
|
},
|
|
text: (opts, lang) => t({
|
|
en: `Hi ${opts.firstName},\n\nThank you for renting with ${opts.companyName}. We hope you enjoyed your ${opts.vehicleLabel}.\n\nLeave a review here (one-time link):\n${opts.reviewUrl}\n\nThank you!`,
|
|
fr: `Bonjour ${opts.firstName},\n\nMerci d'avoir loué chez ${opts.companyName}. Nous espérons que vous avez apprécié votre ${opts.vehicleLabel}.\n\nLaissez un avis ici (lien unique) :\n${opts.reviewUrl}\n\nMerci !`,
|
|
ar: `مرحباً ${opts.firstName}،\n\nشكراً لاختيار ${opts.companyName}. نأمل أنك استمتعت بـ ${opts.vehicleLabel}.\n\nاترك تقييماً هنا (رابط فريد):\n${opts.reviewUrl}\n\nشكراً!`,
|
|
}, lang),
|
|
};
|
|
//# sourceMappingURL=emailTranslations.js.map
|