From befec16a843da52e7011f6bf6e5d6add3fdeaea4 Mon Sep 17 00:00:00 2001 From: Ruslan Bakiev <572431+veikab@users.noreply.github.com> Date: Mon, 6 Apr 2026 15:04:45 +0700 Subject: [PATCH] Build notification template registry from backend code --- app/composables/graphql/generated.ts | 59 +++ app/pages/bonus-system/index.vue | 12 +- app/pages/messages.vue | 355 +++--------------- app/pages/notifications.vue | 21 -- app/pages/profile/index.vue | 12 - app/pages/profile/notifications.vue | 15 - .../notification-templates.graphql | 14 + graphql/schema.graphql | 16 + 8 files changed, 142 insertions(+), 362 deletions(-) create mode 100644 graphql/operations/notifications/notification-templates.graphql diff --git a/app/composables/graphql/generated.ts b/app/composables/graphql/generated.ts index f309ad6..dec2654 100644 --- a/app/composables/graphql/generated.ts +++ b/app/composables/graphql/generated.ts @@ -444,6 +444,23 @@ export type NotificationHistoryItem = { title: Scalars['String']['output']; }; +export type NotificationTemplate = { + __typename?: 'NotificationTemplate'; + channels: Array; + id: Scalars['ID']['output']; + title: Scalars['String']['output']; +}; + +export type NotificationTemplateChannel = { + __typename?: 'NotificationTemplateChannel'; + body: Array; + buttonText?: Maybe; + buttonUrl?: Maybe; + channel: LoginChannel; + implemented: Scalars['Boolean']['output']; + subject?: Maybe; +}; + export type Order = { __typename?: 'Order'; blockReason?: Maybe; @@ -549,6 +566,7 @@ export type Query = { myMessengerConnections: Array; myNotificationHistory: Array; myOrders: Array; + notificationTemplates: Array; order?: Maybe; referralStats: ReferralStats; registrationRequests: Array; @@ -959,6 +977,11 @@ export type MyNotificationHistoryQueryVariables = Exact<{ export type MyNotificationHistoryQuery = { __typename?: 'Query', myNotificationHistory: Array<{ __typename?: 'NotificationHistoryItem', id: string, channel: MessengerType, title: string, message: string, createdAt: any, orderId?: string | null }> }; +export type NotificationTemplatesQueryVariables = Exact<{ [key: string]: never; }>; + + +export type NotificationTemplatesQuery = { __typename?: 'Query', notificationTemplates: Array<{ __typename?: 'NotificationTemplate', id: string, title: string, channels: Array<{ __typename?: 'NotificationTemplateChannel', channel: LoginChannel, implemented: boolean, subject?: string | null, body: Array, buttonText?: string | null, buttonUrl?: string | null }> }> }; + export type SendTestMessengerMessageMutationVariables = Exact<{ type: MessengerType; channelId?: InputMaybe; @@ -2273,6 +2296,42 @@ export function useMyNotificationHistoryLazyQuery(variables?: MyNotificationHist return VueApolloComposable.useLazyQuery(MyNotificationHistoryDocument, variables, options); } export type MyNotificationHistoryQueryCompositionFunctionResult = VueApolloComposable.UseQueryReturn; +export const NotificationTemplatesDocument = gql` + query NotificationTemplates { + notificationTemplates { + id + title + channels { + channel + implemented + subject + body + buttonText + buttonUrl + } + } +} + `; + +/** + * __useNotificationTemplatesQuery__ + * + * To run a query within a Vue component, call `useNotificationTemplatesQuery` and pass it any options that fit your needs. + * When your component renders, `useNotificationTemplatesQuery` returns an object from Apollo Client that contains result, loading and error properties + * you can use to render your UI. + * + * @param options that will be passed into the query, supported options are listed on: https://v4.apollo.vuejs.org/guide-composable/query.html#options; + * + * @example + * const { result, loading, error } = useNotificationTemplatesQuery(); + */ +export function useNotificationTemplatesQuery(options: VueApolloComposable.UseQueryOptions | VueCompositionApi.Ref> | ReactiveFunction> = {}) { + return VueApolloComposable.useQuery(NotificationTemplatesDocument, {}, options); +} +export function useNotificationTemplatesLazyQuery(options: VueApolloComposable.UseQueryOptions | VueCompositionApi.Ref> | ReactiveFunction> = {}) { + return VueApolloComposable.useLazyQuery(NotificationTemplatesDocument, {}, options); +} +export type NotificationTemplatesQueryCompositionFunctionResult = VueApolloComposable.UseQueryReturn; export const SendTestMessengerMessageDocument = gql` mutation SendTestMessengerMessage($type: MessengerType!, $channelId: String, $message: String) { sendTestMessengerMessage(type: $type, channelId: $channelId, message: $message) { diff --git a/app/pages/bonus-system/index.vue b/app/pages/bonus-system/index.vue index 9679719..58c2ccb 100644 --- a/app/pages/bonus-system/index.vue +++ b/app/pages/bonus-system/index.vue @@ -247,13 +247,13 @@ function formatAmount(value: number) { -

Client view

-

Открыть бонусный экран клиента

-

- Посмотреть, куда ведёт бонусное уведомление и как выглядит отдельный интерфейс программы. +

Шаблоны

+

Открыть реестр уведомлений

+

+ Посмотреть реальные шаблоны из backend-кода и быстро понять, что именно мы отправляем клиенту.

diff --git a/app/pages/messages.vue b/app/pages/messages.vue index 8d9310a..4920316 100644 --- a/app/pages/messages.vue +++ b/app/pages/messages.vue @@ -1,227 +1,22 @@ diff --git a/app/pages/profile/notifications.vue b/app/pages/profile/notifications.vue index 87aee5b..b9159c1 100644 --- a/app/pages/profile/notifications.vue +++ b/app/pages/profile/notifications.vue @@ -75,21 +75,6 @@ async function connectMessenger(channel: 'TELEGRAM' | 'MAX') { Подключите Telegram и Max, чтобы получать статусы заказов и важные уведомления в удобном канале.

-
-

Бонусная программа теперь может жить в отдельном экране

-

- Для бонусных начислений и выводов можно отправлять отдельное сообщение с кнопкой, которое ведёт в специальный бонусный интерфейс. -

-
- - Message board - - - Открыть бонусный экран - -
-
-

Telegram

diff --git a/graphql/operations/notifications/notification-templates.graphql b/graphql/operations/notifications/notification-templates.graphql new file mode 100644 index 0000000..fb95aa1 --- /dev/null +++ b/graphql/operations/notifications/notification-templates.graphql @@ -0,0 +1,14 @@ +query NotificationTemplates { + notificationTemplates { + id + title + channels { + channel + implemented + subject + body + buttonText + buttonUrl + } + } +} diff --git a/graphql/schema.graphql b/graphql/schema.graphql index 6ee668d..db87ebd 100644 --- a/graphql/schema.graphql +++ b/graphql/schema.graphql @@ -178,6 +178,21 @@ type NotificationHistoryItem { orderId: ID } +type NotificationTemplateChannel { + channel: LoginChannel! + implemented: Boolean! + subject: String + body: [String!]! + buttonText: String + buttonUrl: String +} + +type NotificationTemplate { + id: ID! + title: String! + channels: [NotificationTemplateChannel!]! +} + type Warehouse { id: ID! code: String! @@ -364,6 +379,7 @@ type Query { myDeliveryAddresses: [DeliveryAddress!]! myMessengerConnections: [MessengerConnection!]! myNotificationHistory(channel: MessengerType!, limit: Int = 50): [NotificationHistoryItem!]! + notificationTemplates: [NotificationTemplate!]! managerNotificationHistory(userId: ID!, channel: MessengerType!, limit: Int = 50): [NotificationHistoryItem!]! clientProducts: [Product!]! order(id: ID!): Order