UNPKG

@ideal-photography/shared

Version:

Shared MongoDB and utility logic for Ideal Photography PWAs: users, products, services, bookings, orders/cart, galleries, reviews, notifications, campaigns, settings, audit logs, minimart items/orders, and push notification subscriptions.

31 lines (28 loc) 1.11 kB
import { format } from 'date-fns'; /** * Handler for 'booking.created' trigger * @param {{ booking: Object, user: Object, product: Object }} payload */ export function created({ booking, user, product }) { return { title: 'Booking received', message: `Your booking #${booking.shortId} is confirmed for ${format(new Date(booking.date), 'PPP')}.`, type: 'booking', recipients: { users: [user._id] }, channels: { inApp: true, email: true, push: true }, emailTemplate: 'booking-confirmation', emailData: { name: user.name, booking, product } }; } export function reminder6h({ booking, product, user }) { return { title: 'Session Reminder', message: `Reminder: Your session starts in 6 hours at ${booking.time}.`, type: 'reminder', recipients: { users: [user._id] }, channels: { inApp: true, email: true, push: true }, emailTemplate: 'booking-reminder', emailData: { name: user.name, booking, product, reminderType: '6h' }, priority: 'normal' }; }