diff --git a/packages/graphql/api/notify.ts b/packages/graphql/api/notify.ts index dff2de2..ba31aa4 100644 --- a/packages/graphql/api/notify.ts +++ b/packages/graphql/api/notify.ts @@ -20,7 +20,7 @@ const STATE_MAP = { export class NotifyService extends BaseService { async orderCreated(variables: { input: Omit['input'], 'time_end'>; - }) { + }, createdByMaster: boolean) { const customersService = new CustomersService(this.customer); const slotsService = new SlotsService(this.customer); const servicesService = new ServicesService(this.customer); @@ -31,7 +31,12 @@ export class NotifyService extends BaseService { const clientId = String(variables.input.client ?? ''); const state = String(variables.input.state ?? ''); - const isApproved = state === GQL.Enum_Order_State.Approved; + let emoji = '🆕'; + let confirmText = ''; + if (createdByMaster) { + emoji = '✅'; + confirmText = ' и подтверждена'; + } const { slot } = await slotsService.getSlot({ documentId: slotId }); const { service } = await servicesService.getService({ documentId: serviceId }); @@ -48,13 +53,13 @@ export class NotifyService extends BaseService { // Мастеру if (master?.telegramId) { - const message = `🆕 Запись создана${isApproved ? ' и подтверждена' : ''}!\nДата: ${slotDate}\nВремя: ${timeStartString} - ${timeEndString}\nКлиент: ${client?.name ?? '-'}\nУслуга: ${service?.name ?? '-'}`; + const message = `${emoji} Запись создана${confirmText}!\nДата: ${slotDate}\nВремя: ${timeStartString} - ${timeEndString}\nКлиент: ${client?.name ?? '-'}\nУслуга: ${service?.name ?? '-'}`; await notifyByTelegramId(String(master.telegramId), message); } // Клиенту if (client?.telegramId) { - const message = `🆕 Запись создана${isApproved ? ' и подтверждена' : ''}!\nДата: ${slotDate}\nВремя: ${timeStartString} - ${timeEndString}\nМастер: ${master?.name ?? '-'}\nУслуга: ${service?.name ?? '-'}`; + const message = `${emoji} Запись создана${confirmText}!\nДата: ${slotDate}\nВремя: ${timeStartString} - ${timeEndString}\nМастер: ${master?.name ?? '-'}\nУслуга: ${service?.name ?? '-'}`; await notifyByTelegramId(String(client.telegramId), message); } } diff --git a/packages/graphql/api/orders.ts b/packages/graphql/api/orders.ts index f9b55fa..1702a6a 100644 --- a/packages/graphql/api/orders.ts +++ b/packages/graphql/api/orders.ts @@ -107,7 +107,7 @@ export class OrdersService extends BaseService { // Уведомление об создании заказа const notifyService = new NotifyService(this.customer); - notifyService.orderCreated(variables); + notifyService.orderCreated(variables, isMaster); return mutationResult.data; }