From fde930563294a9d65b912aee77f7a55c326b86d2 Mon Sep 17 00:00:00 2001 From: Vlad Chikalkin Date: Wed, 23 Jul 2025 13:15:08 +0300 Subject: [PATCH] Fix/bugs features pt 3 (#64) * chore(docker): add healthcheck to service in docker-compose.yml and update deploy workflow to include docker compose down * refactor(orders): add useOrdersInfiniteQuery for improved pagination and add load more button in orders list components * refactor(graphql): remove NotifyService and related notification logic from orders and API, clean up unused dependencies * refactor(api): streamline customer, order, service, and slot actions by wrapping server functions with client action utility to rethrow error messages to client --- .github/workflows/deploy.yml | 1 + apps/web/actions/api/customers.ts | 42 ++----- apps/web/actions/api/orders.ts | 35 +----- apps/web/actions/api/server/customers.ts | 37 ++++++ apps/web/actions/api/server/orders.ts | 31 +++++ apps/web/actions/api/server/services.ts | 19 +++ apps/web/actions/api/server/slots.ts | 45 ++++++++ apps/web/actions/api/services.ts | 21 +--- apps/web/actions/api/slots.ts | 51 ++------- .../components/orders/orders-list/index.tsx | 41 +++++-- apps/web/components/profile/orders-list.tsx | 22 +++- apps/web/hooks/api/orders.ts | 30 ++++- apps/web/utils/actions.ts | 23 ++++ docker-compose.yml | 5 + packages/graphql/api/notify.ts | 108 ------------------ packages/graphql/api/orders.ts | 9 -- packages/graphql/package.json | 1 - .../graphql/types/operations.generated.ts | 4 - packages/graphql/utils/notify.ts | 9 -- packages/graphql/utils/telegram.ts | 4 - pnpm-lock.yaml | 3 - 21 files changed, 261 insertions(+), 280 deletions(-) create mode 100644 apps/web/actions/api/server/customers.ts create mode 100644 apps/web/actions/api/server/orders.ts create mode 100644 apps/web/actions/api/server/services.ts create mode 100644 apps/web/actions/api/server/slots.ts create mode 100644 apps/web/utils/actions.ts delete mode 100644 packages/graphql/api/notify.ts delete mode 100644 packages/graphql/utils/notify.ts delete mode 100644 packages/graphql/utils/telegram.ts diff --git a/.github/workflows/deploy.yml b/.github/workflows/deploy.yml index 6c4d101..5336d11 100644 --- a/.github/workflows/deploy.yml +++ b/.github/workflows/deploy.yml @@ -98,5 +98,6 @@ jobs: cd /home/${{ secrets.VPS_USER }}/zapishis && \ docker login -u ${{ secrets.DOCKERHUB_USERNAME }} -p ${{ secrets.DOCKERHUB_TOKEN }} && \ docker compose pull && \ + docker compose down && \ docker compose up -d " diff --git a/apps/web/actions/api/customers.ts b/apps/web/actions/api/customers.ts index 5f2cf8d..f39b0e1 100644 --- a/apps/web/actions/api/customers.ts +++ b/apps/web/actions/api/customers.ts @@ -1,36 +1,8 @@ -'use server'; +import * as customers from './server/customers'; +import { wrapClientAction } from '@/utils/actions'; -import { useService } from './lib/service'; -import { CustomersService } from '@repo/graphql/api/customers'; - -const getService = useService(CustomersService); - -export async function addMasters(...variables: Parameters) { - const service = await getService(); - - return service.addMasters(...variables); -} - -export async function getClients(...variables: Parameters) { - const service = await getService(); - - return service.getClients(...variables); -} - -export async function getCustomer(...variables: Parameters) { - const service = await getService(); - - return service.getCustomer(...variables); -} - -export async function getMasters(...variables: Parameters) { - const service = await getService(); - - return service.getMasters(...variables); -} - -export async function updateCustomer(...variables: Parameters) { - const service = await getService(); - - return service.updateCustomer(...variables); -} +export const addMasters = wrapClientAction(customers.addMasters); +export const getClients = wrapClientAction(customers.getClients); +export const getCustomer = wrapClientAction(customers.getCustomer); +export const getMasters = wrapClientAction(customers.getMasters); +export const updateCustomer = wrapClientAction(customers.updateCustomer); diff --git a/apps/web/actions/api/orders.ts b/apps/web/actions/api/orders.ts index 5a4b4da..8d7fc31 100644 --- a/apps/web/actions/api/orders.ts +++ b/apps/web/actions/api/orders.ts @@ -1,30 +1,7 @@ -'use server'; +import * as orders from './server/orders'; +import { wrapClientAction } from '@/utils/actions'; -import { useService } from './lib/service'; -import { OrdersService } from '@repo/graphql/api/orders'; - -const getServicesService = useService(OrdersService); - -export async function createOrder(...variables: Parameters) { - const service = await getServicesService(); - - return service.createOrder(...variables); -} - -export async function getOrder(...variables: Parameters) { - const service = await getServicesService(); - - return service.getOrder(...variables); -} - -export async function getOrders(...variables: Parameters) { - const service = await getServicesService(); - - return service.getOrders(...variables); -} - -export async function updateOrder(...variables: Parameters) { - const service = await getServicesService(); - - return service.updateOrder(...variables); -} +export const createOrder = wrapClientAction(orders.createOrder); +export const getOrder = wrapClientAction(orders.getOrder); +export const getOrders = wrapClientAction(orders.getOrders); +export const updateOrder = wrapClientAction(orders.updateOrder); diff --git a/apps/web/actions/api/server/customers.ts b/apps/web/actions/api/server/customers.ts new file mode 100644 index 0000000..6739e23 --- /dev/null +++ b/apps/web/actions/api/server/customers.ts @@ -0,0 +1,37 @@ +'use server'; + +import { useService } from '../lib/service'; +import { wrapServerAction } from '@/utils/actions'; +import { CustomersService } from '@repo/graphql/api/customers'; + +const getService = useService(CustomersService); + +export async function addMasters(...variables: Parameters) { + const service = await getService(); + + return wrapServerAction(() => service.addMasters(...variables)); +} + +export async function getClients(...variables: Parameters) { + const service = await getService(); + + return wrapServerAction(() => service.getClients(...variables)); +} + +export async function getCustomer(...variables: Parameters) { + const service = await getService(); + + return wrapServerAction(() => service.getCustomer(...variables)); +} + +export async function getMasters(...variables: Parameters) { + const service = await getService(); + + return wrapServerAction(() => service.getMasters(...variables)); +} + +export async function updateCustomer(...variables: Parameters) { + const service = await getService(); + + return wrapServerAction(() => service.updateCustomer(...variables)); +} diff --git a/apps/web/actions/api/server/orders.ts b/apps/web/actions/api/server/orders.ts new file mode 100644 index 0000000..3fb8d21 --- /dev/null +++ b/apps/web/actions/api/server/orders.ts @@ -0,0 +1,31 @@ +'use server'; + +import { useService } from '../lib/service'; +import { wrapServerAction } from '@/utils/actions'; +import { OrdersService } from '@repo/graphql/api/orders'; + +const getServicesService = useService(OrdersService); + +export async function createOrder(...variables: Parameters) { + const service = await getServicesService(); + + return wrapServerAction(() => service.createOrder(...variables)); +} + +export async function getOrder(...variables: Parameters) { + const service = await getServicesService(); + + return wrapServerAction(() => service.getOrder(...variables)); +} + +export async function getOrders(...variables: Parameters) { + const service = await getServicesService(); + + return wrapServerAction(() => service.getOrders(...variables)); +} + +export async function updateOrder(...variables: Parameters) { + const service = await getServicesService(); + + return wrapServerAction(() => service.updateOrder(...variables)); +} diff --git a/apps/web/actions/api/server/services.ts b/apps/web/actions/api/server/services.ts new file mode 100644 index 0000000..0bbef3b --- /dev/null +++ b/apps/web/actions/api/server/services.ts @@ -0,0 +1,19 @@ +'use server'; + +import { useService } from '../lib/service'; +import { wrapServerAction } from '@/utils/actions'; +import { ServicesService } from '@repo/graphql/api/services'; + +const getServicesService = useService(ServicesService); + +export async function getService(...variables: Parameters) { + const service = await getServicesService(); + + return wrapServerAction(() => service.getService(...variables)); +} + +export async function getServices(...variables: Parameters) { + const service = await getServicesService(); + + return wrapServerAction(() => service.getServices(...variables)); +} diff --git a/apps/web/actions/api/server/slots.ts b/apps/web/actions/api/server/slots.ts new file mode 100644 index 0000000..5407c88 --- /dev/null +++ b/apps/web/actions/api/server/slots.ts @@ -0,0 +1,45 @@ +'use server'; + +import { useService } from '../lib/service'; +import { wrapServerAction } from '@/utils/actions'; +import { SlotsService } from '@repo/graphql/api/slots'; + +const getService = useService(SlotsService); + +export async function createSlot(...variables: Parameters) { + const service = await getService(); + + return wrapServerAction(() => service.createSlot(...variables)); +} + +export async function deleteSlot(...variables: Parameters) { + const service = await getService(); + + return wrapServerAction(() => service.deleteSlot(...variables)); +} + +export async function getAvailableTimeSlots( + ...variables: Parameters +) { + const service = await getService(); + + return wrapServerAction(() => service.getAvailableTimeSlots(...variables)); +} + +export async function getSlot(...variables: Parameters) { + const service = await getService(); + + return wrapServerAction(() => service.getSlot(...variables)); +} + +export async function getSlots(...variables: Parameters) { + const service = await getService(); + + return wrapServerAction(() => service.getSlots(...variables)); +} + +export async function updateSlot(...variables: Parameters) { + const service = await getService(); + + return wrapServerAction(() => service.updateSlot(...variables)); +} diff --git a/apps/web/actions/api/services.ts b/apps/web/actions/api/services.ts index 577a04d..b208bce 100644 --- a/apps/web/actions/api/services.ts +++ b/apps/web/actions/api/services.ts @@ -1,18 +1,5 @@ -'use server'; +import * as services from './server/services'; +import { wrapClientAction } from '@/utils/actions'; -import { useService } from './lib/service'; -import { ServicesService } from '@repo/graphql/api/services'; - -const getServicesService = useService(ServicesService); - -export async function getService(...variables: Parameters) { - const service = await getServicesService(); - - return service.getService(...variables); -} - -export async function getServices(...variables: Parameters) { - const service = await getServicesService(); - - return service.getServices(...variables); -} +export const getServices = wrapClientAction(services.getServices); +export const getService = wrapClientAction(services.getService); diff --git a/apps/web/actions/api/slots.ts b/apps/web/actions/api/slots.ts index d469909..7a0d6c9 100644 --- a/apps/web/actions/api/slots.ts +++ b/apps/web/actions/api/slots.ts @@ -1,44 +1,9 @@ -'use server'; +import * as slots from './server/slots'; +import { wrapClientAction } from '@/utils/actions'; -import { useService } from './lib/service'; -import { SlotsService } from '@repo/graphql/api/slots'; - -const getService = useService(SlotsService); - -export async function createSlot(...variables: Parameters) { - const service = await getService(); - - return service.createSlot(...variables); -} - -export async function deleteSlot(...variables: Parameters) { - const service = await getService(); - - return service.deleteSlot(...variables); -} - -export async function getAvailableTimeSlots( - ...variables: Parameters -) { - const service = await getService(); - - return service.getAvailableTimeSlots(...variables); -} - -export async function getSlot(...variables: Parameters) { - const service = await getService(); - - return service.getSlot(...variables); -} - -export async function getSlots(...variables: Parameters) { - const service = await getService(); - - return service.getSlots(...variables); -} - -export async function updateSlot(...variables: Parameters) { - const service = await getService(); - - return service.updateSlot(...variables); -} +export const getSlot = wrapClientAction(slots.getSlot); +export const getSlots = wrapClientAction(slots.getSlots); +export const createSlot = wrapClientAction(slots.createSlot); +export const updateSlot = wrapClientAction(slots.updateSlot); +export const deleteSlot = wrapClientAction(slots.deleteSlot); +export const getAvailableTimeSlots = wrapClientAction(slots.getAvailableTimeSlots); diff --git a/apps/web/components/orders/orders-list/index.tsx b/apps/web/components/orders/orders-list/index.tsx index d53916a..6457199 100644 --- a/apps/web/components/orders/orders-list/index.tsx +++ b/apps/web/components/orders/orders-list/index.tsx @@ -2,8 +2,9 @@ import { OrderCard } from '@/components/shared/order-card'; import { useCustomerQuery, useIsMaster } from '@/hooks/api/customers'; -import { useOrdersQuery } from '@/hooks/api/orders'; +import { useOrdersInfiniteQuery } from '@/hooks/api/orders'; import { useDateTimeStore } from '@/stores/datetime'; +import { Button } from '@repo/ui/components/ui/button'; import { getDateUTCRange } from '@repo/utils/datetime-format'; export function ClientsOrdersList() { @@ -14,7 +15,12 @@ export function ClientsOrdersList() { const selectedDate = useDateTimeStore((store) => store.date); const { endOfDay, startOfDay } = getDateUTCRange(selectedDate).day(); - const { data: { orders } = {}, isLoading } = useOrdersQuery( + const { + data: { pages } = {}, + fetchNextPage, + hasNextPage, + isLoading, + } = useOrdersInfiniteQuery( { filters: { slot: { @@ -31,19 +37,23 @@ export function ClientsOrdersList() { }, }, }, - pagination: { - limit: selectedDate ? undefined : 10, - }, }, - Boolean(customer?.documentId) && isMaster, + { enabled: Boolean(customer?.documentId) && isMaster }, ); + const orders = pages?.flatMap((page) => page.orders) ?? []; + if (!orders?.length || isLoading || !isMaster) return null; return (

Записи клиентов

{orders?.map((order) => order && )} + {hasNextPage && ( + + )}
); } @@ -54,7 +64,12 @@ export function OrdersList() { const selectedDate = useDateTimeStore((store) => store.date); const { endOfDay, startOfDay } = getDateUTCRange(selectedDate).day(); - const { data: { orders } = {}, isLoading } = useOrdersQuery( + const { + data: { pages } = {}, + fetchNextPage, + hasNextPage, + isLoading, + } = useOrdersInfiniteQuery( { filters: { client: { @@ -71,13 +86,12 @@ export function OrdersList() { : undefined, }, }, - pagination: { - limit: selectedDate ? undefined : 10, - }, }, - Boolean(customer?.documentId), + { enabled: Boolean(customer?.documentId) }, ); + const orders = pages?.flatMap((page) => page.orders) ?? []; + if (!orders?.length || isLoading) return null; return ( @@ -87,6 +101,11 @@ export function OrdersList() { (order) => order && , )} + {hasNextPage && ( + + )} ); } diff --git a/apps/web/components/profile/orders-list.tsx b/apps/web/components/profile/orders-list.tsx index 75b1ea7..1133a6d 100644 --- a/apps/web/components/profile/orders-list.tsx +++ b/apps/web/components/profile/orders-list.tsx @@ -3,7 +3,8 @@ import { OrderCard } from '../shared/order-card'; import { type ProfileProps } from './types'; import { useCustomerQuery, useIsMaster } from '@/hooks/api/customers'; -import { useOrdersQuery } from '@/hooks/api/orders'; +import { useOrdersInfiniteQuery } from '@/hooks/api/orders'; +import { Button } from '@repo/ui/components/ui/button'; export function ProfileOrdersList({ telegramId }: Readonly) { const { data: { customer } = {} } = useCustomerQuery(); @@ -11,7 +12,12 @@ export function ProfileOrdersList({ telegramId }: Readonly) { const { data: { customer: profile } = {} } = useCustomerQuery({ telegramId }); - const { data: { orders } = {}, isLoading } = useOrdersQuery( + const { + data: { pages } = {}, + fetchNextPage, + hasNextPage, + isLoading, + } = useOrdersInfiniteQuery( { filters: { client: { @@ -27,13 +33,12 @@ export function ProfileOrdersList({ telegramId }: Readonly) { }, }, }, - pagination: { - limit: 5, - }, }, - Boolean(profile?.documentId) && Boolean(customer?.documentId), + { enabled: Boolean(profile?.documentId) && Boolean(customer?.documentId) }, ); + const orders = pages?.flatMap((page) => page.orders) ?? []; + if (!orders?.length || isLoading) return null; return ( @@ -50,6 +55,11 @@ export function ProfileOrdersList({ telegramId }: Readonly) { /> ), )} + {hasNextPage && ( + + )} ); } diff --git a/apps/web/hooks/api/orders.ts b/apps/web/hooks/api/orders.ts index a622f88..d54f22d 100644 --- a/apps/web/hooks/api/orders.ts +++ b/apps/web/hooks/api/orders.ts @@ -1,7 +1,8 @@ +/* eslint-disable unicorn/prevent-abbreviations */ 'use client'; import { createOrder, getOrder, getOrders, updateOrder } from '@/actions/api/orders'; -import { useMutation, useQuery, useQueryClient } from '@tanstack/react-query'; +import { useInfiniteQuery, useMutation, useQuery, useQueryClient } from '@tanstack/react-query'; export const useOrderQuery = ({ documentId }: Parameters[0]) => useQuery({ @@ -37,6 +38,33 @@ export const useOrdersQuery = (variables: Parameters[0], enabl staleTime: 60 * 1_000, }); +export const useOrdersInfiniteQuery = ( + variables: Omit[0], 'pagination'>, + { enabled = true, pageSize = 5 }, +) => { + const queryFn = ({ pageParam: page = 1 }) => + getOrders({ + ...variables, + pagination: { + page, + pageSize, + }, + }); + + return useInfiniteQuery({ + enabled, + getNextPageParam: (lastPage, _allPages, lastPageParameter) => { + if (!lastPage?.orders?.length) return undefined; + + return lastPageParameter + 1; + }, + initialPageParam: 1, + queryFn, + queryKey: ['orders', variables, 'infinite'], + staleTime: 60 * 1_000, + }); +}; + export const useOrderMutation = ({ documentId, }: Pick[0], 'documentId'>) => { diff --git a/apps/web/utils/actions.ts b/apps/web/utils/actions.ts new file mode 100644 index 0000000..f02a35e --- /dev/null +++ b/apps/web/utils/actions.ts @@ -0,0 +1,23 @@ +/* eslint-disable unicorn/prevent-abbreviations */ + +export function wrapClientAction( + fn: (...args: Args) => Promise<{ data?: Return; error?: string; ok: boolean }>, +): (...args: Args) => Promise { + return async (...args: Args): Promise => { + const res = await fn(...args); + if (!res.ok) throw new Error(res.error ?? 'Неизвестная ошибка'); + return res.data as Return; + }; +} + +export async function wrapServerAction( + action: () => Promise, +): Promise<{ data: T; ok: true } | { error: string; ok: false }> { + try { + const data = await action(); + return { data, ok: true }; + } catch (error) { + const message = error instanceof Error ? error.message : 'Неизвестная ошибка сервера'; + return { error: message, ok: false }; + } +} diff --git a/docker-compose.yml b/docker-compose.yml index 823d516..abb13ac 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -4,6 +4,11 @@ services: env_file: - .env restart: always + healthcheck: + test: ["CMD", "curl", "-f", "http://localhost:3000/"] + interval: 10s + timeout: 3s + retries: 5 # ports: # - 3000:3000 networks: diff --git a/packages/graphql/api/notify.ts b/packages/graphql/api/notify.ts deleted file mode 100644 index e23ed93..0000000 --- a/packages/graphql/api/notify.ts +++ /dev/null @@ -1,108 +0,0 @@ -/* eslint-disable complexity */ -import * as GQL from '../types'; -import { notifyByTelegramId } from '../utils/notify'; -import { BaseService } from './base'; -import { CustomersService } from './customers'; -import { OrdersService } from './orders'; -import { ServicesService } from './services'; -import { SlotsService } from './slots'; -import { type VariablesOf } from '@graphql-typed-document-node/core'; -import { formatDate, formatTime, getMinutes, sumTime } from '@repo/utils/datetime-format'; - -const STATE_MAP = { - approved: 'Одобрено', - cancelled: 'Отменено', - cancelling: 'Отменяется', - completed: 'Завершено', - created: 'Создано', - scheduled: 'Запланировано', - unknown: 'Неизвестно', -}; -export class NotifyService extends BaseService { - async orderCreated( - variables: VariablesOf, - createdByMaster: boolean, - ) { - const customersService = new CustomersService(this.customer); - const slotsService = new SlotsService(this.customer); - const servicesService = new ServicesService(this.customer); - - const slotId = String(variables.input.slot ?? ''); - const serviceId = String(variables.input.services?.[0] ?? ''); - const clientId = String(variables.input.client ?? ''); - - if (!serviceId || !clientId || !slotId) return; - - let emoji = '🆕'; - let confirmText = ''; - if (createdByMaster) { - emoji = '✅'; - confirmText = ' и подтверждена'; - } - - const { slot } = await slotsService.getSlot({ documentId: slotId }); - const { service } = await servicesService.getService({ documentId: serviceId }); - const { customer: master } = await customersService.getCustomer({ - documentId: slot?.master?.documentId ?? '', - }); - const { customer: client } = await customersService.getCustomer({ documentId: clientId }); - - if (!slot?.datetime_start || !variables.input.datetime_start || !service?.duration) return; - - const slotDate = formatDate(slot?.datetime_start).user(); - const timeStartString = formatTime(variables.input.datetime_start).user(); - const timeEndString = formatTime( - sumTime(variables.input.datetime_start, getMinutes(service?.duration)), - ).user(); - - // Мастеру - if (master?.telegramId) { - 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 = `${emoji} Запись создана${confirmText}!\nДата: ${slotDate}\nВремя: ${timeStartString} - ${timeEndString}\nМастер: ${master?.name ?? '-'}\nУслуга: ${service?.name ?? '-'}`; - await notifyByTelegramId(String(client.telegramId), message); - } - } - - async orderUpdated(variables: VariablesOf) { - // Получаем order через OrdersService - const ordersService = new OrdersService(this.customer); - const { order } = await ordersService.getOrder({ documentId: variables.documentId }); - if (!order) return; - - const slot = order.slot; - if (!slot) return; - - const service = order.services[0]; - const master = slot?.master; - const client = order.client; - - const orderStateString = STATE_MAP[order.state || 'unknown']; - const slotDate = formatDate(slot?.datetime_start).user(); - const timeStartString = formatTime(order.datetime_start ?? '').user(); - const timeEndString = formatTime(order.datetime_end ?? '').user(); - - let emoji = '✏️'; - if (order.state === GQL.Enum_Order_State.Cancelled) { - emoji = '❌'; - } else if (order.state === GQL.Enum_Order_State.Approved) { - emoji = '✅'; - } - - // Мастеру - if (master?.telegramId) { - const message = `${emoji} Запись изменена!\nДата: ${slotDate}\nВремя: ${timeStartString} - ${timeEndString}\nКлиент: ${client?.name ?? '-'}\nУслуга: ${service?.name ?? '-'}\nСтатус: ${orderStateString}`; - await notifyByTelegramId(String(master.telegramId), message); - } - - // Клиенту - if (client?.telegramId) { - const message = `${emoji} Запись изменена!\nДата: ${slotDate}\nВремя: ${timeStartString} - ${timeEndString}\nМастер: ${master?.name ?? '-'}\nУслуга: ${service?.name ?? '-'}\nСтатус: ${orderStateString}`; - await notifyByTelegramId(String(client.telegramId), message); - } - } -} diff --git a/packages/graphql/api/orders.ts b/packages/graphql/api/orders.ts index 696f8e5..044ec11 100644 --- a/packages/graphql/api/orders.ts +++ b/packages/graphql/api/orders.ts @@ -2,7 +2,6 @@ import { getClientWithToken } from '../apollo/client'; import * as GQL from '../types'; import { BaseService } from './base'; import { CustomersService } from './customers'; -import { NotifyService } from './notify'; import { ServicesService } from './services'; import { type VariablesOf } from '@graphql-typed-document-node/core'; import { isCustomerMaster } from '@repo/utils/customer'; @@ -64,10 +63,6 @@ export class OrdersService extends BaseService { const error = mutationResult.errors?.at(0); if (error) throw new Error(error.message); - // Уведомление об создании заказа - const notifyService = new NotifyService(this.customer); - notifyService.orderCreated(variables, isCustomerMaster(customer)); - return mutationResult.data; } @@ -136,10 +131,6 @@ export class OrdersService extends BaseService { const error = mutationResult.errors?.at(0); if (error) throw new Error(error.message); - // Уведомление об изменении заказа - const notifyService = new NotifyService(this.customer); - notifyService.orderUpdated(variables); - return mutationResult.data; } } diff --git a/packages/graphql/package.json b/packages/graphql/package.json index c3d8381..9715fe3 100644 --- a/packages/graphql/package.json +++ b/packages/graphql/package.json @@ -16,7 +16,6 @@ "dayjs": "catalog:", "jsonwebtoken": "catalog:", "radashi": "catalog:", - "telegraf": "catalog:", "vite-tsconfig-paths": "catalog:", "vitest": "catalog:", "zod": "catalog:" diff --git a/packages/graphql/types/operations.generated.ts b/packages/graphql/types/operations.generated.ts index dece7ba..f8b43a0 100644 --- a/packages/graphql/types/operations.generated.ts +++ b/packages/graphql/types/operations.generated.ts @@ -317,9 +317,7 @@ export type OrderFiltersInput = { not?: InputMaybe; or?: InputMaybe>>; order_number?: InputMaybe; - price?: InputMaybe; publishedAt?: InputMaybe; - service_description?: InputMaybe; services?: InputMaybe; slot?: InputMaybe; state?: InputMaybe; @@ -332,9 +330,7 @@ export type OrderInput = { datetime_end?: InputMaybe; datetime_start?: InputMaybe; order_number?: InputMaybe; - price?: InputMaybe; publishedAt?: InputMaybe; - service_description?: InputMaybe; services?: InputMaybe>>; slot?: InputMaybe; state?: InputMaybe; diff --git a/packages/graphql/utils/notify.ts b/packages/graphql/utils/notify.ts deleted file mode 100644 index c6394f4..0000000 --- a/packages/graphql/utils/notify.ts +++ /dev/null @@ -1,9 +0,0 @@ -import { bot } from './telegram'; - -export async function notifyByTelegramId(telegramId: string | undefined, message: string) { - if (!telegramId) return; - - await bot.telegram.sendMessage(telegramId, message, { - parse_mode: 'HTML', - }); -} diff --git a/packages/graphql/utils/telegram.ts b/packages/graphql/utils/telegram.ts deleted file mode 100644 index 754d6c0..0000000 --- a/packages/graphql/utils/telegram.ts +++ /dev/null @@ -1,4 +0,0 @@ -import { env as environment } from '../config/env'; -import { Telegraf } from 'telegraf'; - -export const bot = new Telegraf(environment.BOT_TOKEN); diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index fb1ebf6..a0a03f4 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -299,9 +299,6 @@ importers: radashi: specifier: 'catalog:' version: 12.6.0 - telegraf: - specifier: 'catalog:' - version: 4.16.3 vite-tsconfig-paths: specifier: 'catalog:' version: 5.1.4(typescript@5.8.3)(vite@5.4.19(@types/node@24.0.10))