Hide prices until admin sends the invoice, enforce status transitions, add customer/admin SMS+in-app notifications, schedule cash invoice reminders, and ship updated dist/prisma-client/deploy-bundle for git-pull deploys. Co-authored-by: Cursor <cursoragent@cursor.com>
125 lines
6.8 KiB
JavaScript
125 lines
6.8 KiB
JavaScript
"use strict";
|
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
exports.CUSTOMER_EVENTS = void 0;
|
|
exports.eventForStatus = eventForStatus;
|
|
const client_1 = require("@prisma/client");
|
|
function money(amount) {
|
|
if (!amount)
|
|
return '—';
|
|
return `${Math.round(amount).toLocaleString('fa-IR')} تومان`;
|
|
}
|
|
function eventForStatus(status) {
|
|
switch (status) {
|
|
case client_1.OrderStatus.awaiting_settlement:
|
|
return 'invoice_priced';
|
|
case client_1.OrderStatus.preparing:
|
|
case client_1.OrderStatus.final_approved:
|
|
return 'order_preparing';
|
|
case client_1.OrderStatus.ready_to_ship:
|
|
return 'order_ready_to_ship';
|
|
case client_1.OrderStatus.shipped:
|
|
return 'order_shipped';
|
|
case client_1.OrderStatus.delivered:
|
|
return 'order_delivered';
|
|
case client_1.OrderStatus.cancelled:
|
|
case client_1.OrderStatus.rejected:
|
|
return 'order_cancelled';
|
|
case client_1.OrderStatus.expired:
|
|
return 'cash_invoice_expired';
|
|
default:
|
|
return null;
|
|
}
|
|
}
|
|
exports.CUSTOMER_EVENTS = {
|
|
order_submitted: {
|
|
title: 'سفارش شما ثبت شد',
|
|
body: (c) => `سفارش ${c.orderNumber} ثبت شد و برای بررسی و قیمتگذاری به کارشناسان ما رسید.`,
|
|
sms: (c) => `سفارش ${c.orderNumber} در ${c.appName} ثبت شد. پس از قیمتگذاری، فاکتور برای شما ارسال میشود.`,
|
|
tone: client_1.NotificationTone.info,
|
|
smsSwitch: 'smsOrderRegistered',
|
|
},
|
|
invoice_priced: {
|
|
title: 'فاکتور سفارش شما صادر شد',
|
|
body: (c) => `مبلغ فاکتور سفارش ${c.orderNumber} ${money(c.amount)} است. برای ادامه، روش تسویه را انتخاب کنید.`,
|
|
sms: (c) => `فاکتور سفارش ${c.orderNumber} به مبلغ ${money(c.amount)} صادر شد. برای انتخاب روش تسویه به پنل ${c.appName} مراجعه کنید.`,
|
|
tone: client_1.NotificationTone.success,
|
|
smsSwitch: 'smsPricingReady',
|
|
},
|
|
checks_approved: {
|
|
title: 'چکهای شما تایید شد',
|
|
body: (c) => `همه چکهای سفارش ${c.orderNumber} تایید شدند.`,
|
|
sms: (c) => `چکهای سفارش ${c.orderNumber} تایید شد و سفارش به مرحله آمادهسازی میرود.`,
|
|
tone: client_1.NotificationTone.success,
|
|
smsSwitch: 'smsCheckReview',
|
|
},
|
|
checks_need_fix: {
|
|
title: 'چک شما نیاز به اصلاح دارد',
|
|
body: (c) => `یک یا چند چک سفارش ${c.orderNumber} تایید نشد${c.note ? `: ${c.note}` : '.'} لطفاً چکها را اصلاح و مجدداً ارسال کنید.`,
|
|
sms: (c) => `چک سفارش ${c.orderNumber} تایید نشد. برای اصلاح چکها به پنل ${c.appName} مراجعه کنید.`,
|
|
tone: client_1.NotificationTone.danger,
|
|
smsSwitch: 'smsCheckReview',
|
|
},
|
|
receipt_approved: {
|
|
title: 'پرداخت شما تایید شد',
|
|
body: (c) => `رسید پرداخت سفارش ${c.orderNumber} تایید شد.`,
|
|
sms: (c) => `رسید پرداخت سفارش ${c.orderNumber} تایید شد. سفارش شما در حال آمادهسازی است.`,
|
|
tone: client_1.NotificationTone.success,
|
|
smsSwitch: 'smsPaymentReminder',
|
|
},
|
|
receipt_rejected: {
|
|
title: 'رسید پرداخت تایید نشد',
|
|
body: (c) => `رسید پرداخت سفارش ${c.orderNumber} تایید نشد${c.note ? `: ${c.note}` : '.'} لطفاً رسید صحیح را ثبت کنید.`,
|
|
sms: (c) => `رسید پرداخت سفارش ${c.orderNumber} تایید نشد. لطفاً در پنل ${c.appName} رسید را اصلاح کنید.`,
|
|
tone: client_1.NotificationTone.danger,
|
|
smsSwitch: 'smsPaymentReminder',
|
|
},
|
|
cash_invoice_reminder: {
|
|
title: 'یادآوری مهلت پرداخت',
|
|
body: (c) => `مهلت پرداخت فاکتور سفارش ${c.orderNumber} به پایان نزدیک است. مبلغ قابل پرداخت ${money(c.amount)}.`,
|
|
sms: (c) => `مهلت پرداخت فاکتور سفارش ${c.orderNumber} در حال پایان است. مبلغ ${money(c.amount)}.`,
|
|
tone: client_1.NotificationTone.warning,
|
|
smsSwitch: 'smsPaymentReminder',
|
|
},
|
|
cash_invoice_expired: {
|
|
title: 'مهلت پرداخت فاکتور تمام شد',
|
|
body: (c) => `مهلت پرداخت فاکتور سفارش ${c.orderNumber} به پایان رسید. برای ثبت سفارش تازه با پشتیبانی تماس بگیرید.`,
|
|
sms: (c) => `مهلت پرداخت فاکتور سفارش ${c.orderNumber} به پایان رسید.`,
|
|
tone: client_1.NotificationTone.danger,
|
|
smsSwitch: 'smsPaymentReminder',
|
|
},
|
|
order_preparing: {
|
|
title: 'سفارش در حال آمادهسازی',
|
|
body: (c) => `سفارش ${c.orderNumber} تایید نهایی شد و در حال آمادهسازی است.`,
|
|
tone: client_1.NotificationTone.info,
|
|
smsSwitch: null,
|
|
},
|
|
order_ready_to_ship: {
|
|
title: 'سفارش آماده ارسال است',
|
|
body: (c) => `سفارش ${c.orderNumber} آماده ارسال شد.`,
|
|
sms: (c) => `سفارش ${c.orderNumber} آماده ارسال شد.`,
|
|
tone: client_1.NotificationTone.info,
|
|
smsSwitch: 'smsShippingUpdate',
|
|
},
|
|
order_shipped: {
|
|
title: 'سفارش ارسال شد',
|
|
body: (c) => `سفارش ${c.orderNumber} ارسال شد${c.carrier ? ` (${c.carrier})` : ''}${c.trackingNumber ? ` با کد رهگیری ${c.trackingNumber}` : ''}.`,
|
|
sms: (c) => `سفارش ${c.orderNumber} ارسال شد${c.trackingNumber ? `. کد رهگیری: ${c.trackingNumber}` : '.'}`,
|
|
tone: client_1.NotificationTone.success,
|
|
smsSwitch: 'smsShippingUpdate',
|
|
},
|
|
order_delivered: {
|
|
title: 'سفارش تحویل شد',
|
|
body: (c) => `سفارش ${c.orderNumber} تحویل داده شد. از خرید شما سپاسگزاریم.`,
|
|
sms: (c) => `سفارش ${c.orderNumber} تحویل داده شد. از خرید شما سپاسگزاریم.`,
|
|
tone: client_1.NotificationTone.success,
|
|
smsSwitch: 'smsShippingUpdate',
|
|
},
|
|
order_cancelled: {
|
|
title: 'سفارش لغو شد',
|
|
body: (c) => `سفارش ${c.orderNumber} لغو شد${c.note ? `: ${c.note}` : '.'} برای اطلاعات بیشتر با پشتیبانی تماس بگیرید.`,
|
|
sms: (c) => `سفارش ${c.orderNumber} لغو شد.`,
|
|
tone: client_1.NotificationTone.danger,
|
|
smsSwitch: null,
|
|
},
|
|
};
|
|
//# sourceMappingURL=notification-events.js.map
|