= {
+ global: 'Глобальное',
+ category: 'Категория',
+ topic: 'Тема',
+}
+-----END src/features/hierarchies/utils.ts-----
+
+File: src/features/notifications/hooks/useNotifications.ts
+Lines: 55
+-----BEGIN src/features/notifications/hooks/useNotifications.ts-----
+import { useQuery, useMutation, useQueryClient } from '@tanstack/react-query'
+import {
+ notificationsApi,
+ type NotificationsListParams,
+ type CreateNotificationRequest,
+} from '@/api/notifications'
+import { notifications as mantineNotifications } from '@mantine/notifications'
+
+export const NOTIFICATIONS_QUERY_KEY = 'notifications'
+
+export function useNotifications(params: NotificationsListParams = {}) {
+ return useQuery({
+ queryKey: [NOTIFICATIONS_QUERY_KEY, params],
+ queryFn: async () => {
+ const response = await notificationsApi.getList(params)
+ return response.data
+ },
+ })
+}
+
+export function useNotification(id: number | null) {
+ return useQuery({
+ queryKey: ['notification', id],
+ queryFn: async () => {
+ if (!id) return null
+ const response = await notificationsApi.getById(id)
+ return response.data
+ },
+ enabled: !!id,
+ })
+}
+
+export function useCreateNotification() {
+ const queryClient = useQueryClient()
+
+ return useMutation({
+ mutationFn: (data: CreateNotificationRequest) => notificationsApi.create(data),
+ onSuccess: (response) => {
+ queryClient.invalidateQueries({ queryKey: [NOTIFICATIONS_QUERY_KEY] })
+ const n = response.data
+ const hasFailed = (n.failed_count ?? 0) > 0
+ mantineNotifications.show({
+ title: hasFailed ? 'Отправлено с ошибками' : 'Отправлено',
+ message: `Доставлено: ${n.sent_count ?? 0} из ${n.total_count ?? 0}`,
+ color: hasFailed ? 'yellow' : 'green',
+ })
+ },
+ onError: (error: any) => {
+ mantineNotifications.show({
+ title: 'Ошибка',
+ message: error.response?.data?.error_description || 'Не удалось отправить уведомление',
+ color: 'red',
+ })
+ },
+ })
+}
+-----END src/features/notifications/hooks/useNotifications.ts-----
+
+File: src/features/notifications/utils/telegramHtml.ts
+Lines: 30
+-----BEGIN src/features/notifications/utils/telegramHtml.ts-----
+// Приводит HTML из Tiptap-редактора к набору тегов, которые понимает Telegram ParseMode=HTML.
+// Разрешённые теги: b, i, u, s, a, code, pre, tg-spoiler
+const ALLOWED_TAGS = new Set(['b', 'i', 'u', 's', 'a', 'code', 'pre', 'tg-spoiler'])
+
+export function convertHtmlToTelegram(html: string): string {
+ let result = html
+
+ // Абзацы и переносы строк -> двойной/одинарный \n
+ result = result.replace(/<\/p>\s*/gi, '\n\n')
+ result = result.replace(/<\/?p>/gi, '')
+ result = result.replace(/
/gi, '\n')
+
+ // Синонимы тегов из Tiptap -> Telegram-теги
+ result = result
+ .replace(//gi, '').replace(/<\/strong>/gi, '')
+ .replace(//gi, '').replace(/<\/em>/gi, '')
+ .replace(//gi, '').replace(/<\/strike>/gi, '')
+
+ // Ссылки: сохраняем только href, убираем target/rel/class и т.п.
+ result = result.replace(/]*href="([^"]*)"[^>]*>/gi, '')
+
+ // Убираем все теги, не входящие в белый список Telegram
+ result = result.replace(/<(\/?)([a-zA-Z0-9-]+)([^>]*)>/g, (match, closing, rawTag) => {
+ const tag = rawTag.toLowerCase()
+ if (!ALLOWED_TAGS.has(tag)) return ''
+ if (tag === 'a' && !closing) return match // href уже нормализован выше
+ return closing ? `${tag}>` : `<${tag}>`
+ })
+
+ return result.trim()
+}
+-----END src/features/notifications/utils/telegramHtml.ts-----
+
+File: src/features/permissions/constants.ts
+Lines: 28
+-----BEGIN src/features/permissions/constants.ts-----
+export const PERMISSION_ACTIONS = [
+ { value: 'create', label: 'Создание', description: 'Создание заявок по теме', color: 'blue' },
+ { value: 'read', label: 'Просмотр', description: 'Просмотр заявок', color: 'gray' },
+ { value: 'update', label: 'Редактирование', description: 'Редактирование заявок', color: 'cyan' },
+ { value: 'delete', label: 'Удаление', description: 'Удаление заявок', color: 'red' },
+ { value: 'approve', label: 'Согласование', description: 'Согласование заявок', color: 'green' },
+ { value: 'revoke', label: 'Отзыв', description: 'Отзыв заявок', color: 'orange' },
+ { value: 'observe', label: 'Наблюдение', description: 'Наблюдение за заявками', color: 'violet' },
+] as const
+
+export const ACTION_COLORS: Record = {
+ create: 'blue',
+ read: 'gray',
+ update: 'cyan',
+ delete: 'red',
+ approve: 'green',
+ revoke: 'orange',
+ observe: 'violet',
+}
+
+export const ACTION_LABELS: Record = {
+ create: 'Создание',
+ read: 'Просмотр',
+ update: 'Редактирование',
+ delete: 'Удаление',
+ approve: 'Согласование',
+ revoke: 'Отзыв',
+ observe: 'Наблюдение',
+}
+-----END src/features/permissions/constants.ts-----
+
+File: src/features/permissions/hooks/usePermissions.ts
+Lines: 100
+-----BEGIN src/features/permissions/hooks/usePermissions.ts-----
+import { useQuery, useMutation, useQueryClient } from '@tanstack/react-query'
+import {
+ permissionsApi,
+ type PermissionsListParams,
+ type CreatePermissionRequest,
+ type UpdatePermissionRequest
+} from '@/api/permissions'
+import { notifications } from '@mantine/notifications'
+
+export const PERMISSIONS_QUERY_KEY = 'permissions'
+
+export function usePermissions(params: PermissionsListParams = {}) {
+ return useQuery({
+ queryKey: [PERMISSIONS_QUERY_KEY, params],
+ queryFn: async () => {
+ const response = await permissionsApi.getList(params)
+ return response.data
+ },
+ })
+}
+
+export function usePermission(id: number | null) {
+ return useQuery({
+ queryKey: ['permission', id],
+ queryFn: async () => {
+ if (!id) return null
+ const response = await permissionsApi.getById(id)
+ return response.data
+ },
+ enabled: !!id,
+ })
+}
+
+export function useCreatePermission() {
+ const queryClient = useQueryClient()
+
+ return useMutation({
+ mutationFn: (data: CreatePermissionRequest) => permissionsApi.create(data),
+ onSuccess: () => {
+ queryClient.invalidateQueries({ queryKey: [PERMISSIONS_QUERY_KEY] })
+ notifications.show({
+ title: 'Успешно',
+ message: 'Право создано',
+ color: 'green',
+ })
+ },
+ onError: (error: any) => {
+ notifications.show({
+ title: 'Ошибка',
+ message: error.response?.data?.error_description || 'Не удалось создать право',
+ color: 'red',
+ })
+ },
+ })
+}
+
+export function useUpdatePermission() {
+ const queryClient = useQueryClient()
+
+ return useMutation({
+ mutationFn: (data: UpdatePermissionRequest) => permissionsApi.update(data),
+ onSuccess: () => {
+ queryClient.invalidateQueries({ queryKey: [PERMISSIONS_QUERY_KEY] })
+ notifications.show({
+ title: 'Успешно',
+ message: 'Право обновлено',
+ color: 'green',
+ })
+ },
+ onError: (error: any) => {
+ notifications.show({
+ title: 'Ошибка',
+ message: error.response?.data?.error_description || 'Не удалось обновить право',
+ color: 'red',
+ })
+ },
+ })
+}
+
+export function useDeletePermission() {
+ const queryClient = useQueryClient()
+
+ return useMutation({
+ mutationFn: (id: number) => permissionsApi.delete(id),
+ onSuccess: () => {
+ queryClient.invalidateQueries({ queryKey: [PERMISSIONS_QUERY_KEY] })
+ notifications.show({
+ title: 'Успешно',
+ message: 'Право удалено',
+ color: 'green',
+ })
+ },
+ onError: (error: any) => {
+ notifications.show({
+ title: 'Ошибка',
+ message: error.response?.data?.error_description || 'Не удалось удалить право',
+ color: 'red',
+ })
+ },
+ })
+}
+-----END src/features/permissions/hooks/usePermissions.ts-----
+
+File: src/features/roles/hooks/useAllRoles.ts
+Lines: 14
+-----BEGIN src/features/roles/hooks/useAllRoles.ts-----
+import { useQuery } from '@tanstack/react-query'
+import { rolesApi } from '@/api/roles.ts'
+import type { Role } from '@/types/api'
+
+export const ALL_ROLES_QUERY_KEY = 'roles-all'
+
+export function useAllRoles() {
+ return useQuery({
+ queryKey: [ALL_ROLES_QUERY_KEY],
+ queryFn: async (): Promise => {
+ const response = await rolesApi.getList({ limit: 1000 })
+ return response.data.data || []
+ },
+ })
+}
+-----END src/features/roles/hooks/useAllRoles.ts-----
+
+File: src/features/roles/hooks/useRoles.ts
+Lines: 102
+-----BEGIN src/features/roles/hooks/useRoles.ts-----
+import { useQuery, useMutation, useQueryClient } from '@tanstack/react-query'
+import {
+ rolesApi,
+ type RolesListParams,
+ type CreateRoleRequest,
+ type UpdateRoleRequest
+} from '@/api/roles'
+import { notifications } from '@mantine/notifications'
+
+export const ROLES_QUERY_KEY = 'roles'
+
+export function useRoles(params: RolesListParams = {}) {
+ return useQuery({
+ queryKey: [ROLES_QUERY_KEY, params],
+ queryFn: async () => {
+ const response = await rolesApi.getList(params)
+ return response.data
+ },
+ })
+}
+
+export function useRole(id: number | null) {
+ return useQuery({
+ queryKey: ['role', id],
+ queryFn: async () => {
+ if (!id) return null
+ const response = await rolesApi.getById(id)
+ return response.data
+ },
+ enabled: !!id,
+ })
+}
+
+export function useCreateRole() {
+ const queryClient = useQueryClient()
+
+ return useMutation({
+ mutationFn: (data: CreateRoleRequest) => rolesApi.create(data),
+ onSuccess: () => {
+ queryClient.invalidateQueries({ queryKey: [ROLES_QUERY_KEY] })
+ notifications.show({
+ title: 'Успешно',
+ message: 'Роль создана',
+ color: 'green',
+ })
+ },
+ onError: (error: any) => {
+ notifications.show({
+ title: 'Ошибка',
+ message: error.response?.data?.error_description || 'Не удалось создать роль',
+ color: 'red',
+ })
+ },
+ })
+}
+
+export function useUpdateRole() {
+ const queryClient = useQueryClient()
+
+ return useMutation({
+ mutationFn: (data: UpdateRoleRequest) => rolesApi.update(data),
+ onSuccess: () => {
+ queryClient.invalidateQueries({ queryKey: [ROLES_QUERY_KEY] })
+ queryClient.invalidateQueries({ queryKey: ['users'] }) // Обновляем пользователей, т.к. у них есть роли
+ notifications.show({
+ title: 'Успешно',
+ message: 'Роль обновлена',
+ color: 'green',
+ })
+ },
+ onError: (error: any) => {
+ notifications.show({
+ title: 'Ошибка',
+ message: error.response?.data?.error_description || 'Не удалось обновить роль',
+ color: 'red',
+ })
+ },
+ })
+}
+
+export function useDeleteRole() {
+ const queryClient = useQueryClient()
+
+ return useMutation({
+ mutationFn: (id: number) => rolesApi.delete(id),
+ onSuccess: () => {
+ queryClient.invalidateQueries({ queryKey: [ROLES_QUERY_KEY] })
+ queryClient.invalidateQueries({ queryKey: ['users'] })
+ notifications.show({
+ title: 'Успешно',
+ message: 'Роль удалена',
+ color: 'green',
+ })
+ },
+ onError: (error: any) => {
+ notifications.show({
+ title: 'Ошибка',
+ message: error.response?.data?.error_description || 'Не удалось удалить роль',
+ color: 'red',
+ })
+ },
+ })
+}
+-----END src/features/roles/hooks/useRoles.ts-----
+
+File: src/features/topicExecutors/hooks/useTopicExecutors.ts
+Lines: 88
+-----BEGIN src/features/topicExecutors/hooks/useTopicExecutors.ts-----
+import { useQuery, useMutation, useQueryClient } from '@tanstack/react-query'
+import {
+ topicExecutorsApi,
+ type TopicExecutorsListParams,
+ type CreateTopicExecutorRequest,
+ type UpdateTopicExecutorRequest
+} from '@/api/topicExecutors'
+import { notifications } from '@mantine/notifications'
+
+export const TOPIC_EXECUTORS_QUERY_KEY = 'topic-executors'
+
+export function useTopicExecutors(params: TopicExecutorsListParams = {}) {
+ return useQuery({
+ queryKey: [TOPIC_EXECUTORS_QUERY_KEY, params],
+ queryFn: async () => {
+ const response = await topicExecutorsApi.getList({ limit: 1000, ...params })
+ return response.data
+ },
+ })
+}
+
+export function useCreateTopicExecutor() {
+ const queryClient = useQueryClient()
+
+ return useMutation({
+ mutationFn: (data: CreateTopicExecutorRequest) => topicExecutorsApi.create(data),
+ onSuccess: () => {
+ queryClient.invalidateQueries({ queryKey: [TOPIC_EXECUTORS_QUERY_KEY] })
+ notifications.show({
+ title: 'Успешно',
+ message: 'Исполнитель добавлен',
+ color: 'green',
+ })
+ },
+ onError: (error: any) => {
+ notifications.show({
+ title: 'Ошибка',
+ message: error.response?.data?.error_description || 'Не удалось добавить исполнителя',
+ color: 'red',
+ })
+ },
+ })
+}
+
+export function useUpdateTopicExecutor() {
+ const queryClient = useQueryClient()
+
+ return useMutation({
+ mutationFn: (data: UpdateTopicExecutorRequest) => topicExecutorsApi.update(data),
+ onSuccess: () => {
+ queryClient.invalidateQueries({ queryKey: [TOPIC_EXECUTORS_QUERY_KEY] })
+ notifications.show({
+ title: 'Успешно',
+ message: 'Исполнитель обновлен',
+ color: 'green',
+ })
+ },
+ onError: (error: any) => {
+ notifications.show({
+ title: 'Ошибка',
+ message: error.response?.data?.error_description || 'Не удалось обновить исполнителя',
+ color: 'red',
+ })
+ },
+ })
+}
+
+export function useDeleteTopicExecutor() {
+ const queryClient = useQueryClient()
+
+ return useMutation({
+ mutationFn: (id: number) => topicExecutorsApi.delete(id),
+ onSuccess: () => {
+ queryClient.invalidateQueries({ queryKey: [TOPIC_EXECUTORS_QUERY_KEY] })
+ notifications.show({
+ title: 'Успешно',
+ message: 'Исполнитель удален',
+ color: 'green',
+ })
+ },
+ onError: (error: any) => {
+ notifications.show({
+ title: 'Ошибка',
+ message: error.response?.data?.error_description || 'Не удалось удалить исполнителя',
+ color: 'red',
+ })
+ },
+ })
+}
+-----END src/features/topicExecutors/hooks/useTopicExecutors.ts-----
+
+File: src/features/topicExecutors/utils.ts
+Lines: 58
+-----BEGIN src/features/topicExecutors/utils.ts-----
+import type { ApprovalTopicExecutor } from '@/types/api'
+
+// Группа исполнителей по теме
+export interface TopicExecutorsGroup {
+ topicId: number
+ topicName: string
+ topicCode: string
+ categoryName?: string
+ executors: ApprovalTopicExecutor[] // Отсортированы по step_order
+}
+
+// Константы для целевых систем
+export const TARGET_SYSTEMS = [
+ { value: 'all', label: 'Все системы', color: 'blue' },
+ { value: 'okb', label: 'ОКБ', color: 'green' },
+ { value: '1c', label: '1С', color: 'orange' },
+] as const
+
+export const TARGET_SYSTEM_LABELS: Record = {
+ all: 'Все системы',
+ okb: 'ОКБ',
+ '1c': '1С',
+}
+
+export const TARGET_SYSTEM_COLORS: Record = {
+ all: 'blue',
+ okb: 'green',
+ '1c': 'orange',
+}
+
+// Группируем исполнителей по темам
+export function groupExecutorsByTopic(
+ executors: ApprovalTopicExecutor[]
+): TopicExecutorsGroup[] {
+ const groups = new Map()
+
+ for (const executor of executors) {
+ if (!executor.topic_id) continue
+
+ if (!groups.has(executor.topic_id)) {
+ groups.set(executor.topic_id, {
+ topicId: executor.topic_id,
+ topicName: executor.topic?.name || `Тема #${executor.topic_id}`,
+ topicCode: executor.topic?.code || '',
+ categoryName: executor.topic?.category?.name,
+ executors: [],
+ })
+ }
+
+ groups.get(executor.topic_id)!.executors.push(executor)
+ }
+
+ // Сортируем исполнителей по step_order внутри каждой группы
+ for (const group of groups.values()) {
+ group.executors.sort((a, b) => (a.step_order || 0) - (b.step_order || 0))
+ }
+
+ return Array.from(groups.values())
+}
+-----END src/features/topicExecutors/utils.ts-----
+
+File: src/features/topics/constants.ts
+Lines: 37
+-----BEGIN src/features/topics/constants.ts-----
+export const DURATION_TYPES = [
+ { value: 'single_day', label: 'Один день' },
+ { value: 'multi_day', label: 'Несколько дней' },
+ { value: 'date_range', label: 'Диапазон дат' },
+]
+
+export const TIME_TYPES = [
+ { value: 'partial', label: 'Частично (с указанием времени)' },
+ { value: 'full_day', label: 'Весь день' },
+]
+
+export const PAYMENT_TYPES = [
+ { value: 'own_expense', label: 'За свой счёт' },
+ { value: 'vacation_account', label: 'В счёт отпуска' },
+ { value: 'official', label: 'Официально (больничный)' },
+]
+
+export const APPROVAL_MODES = [
+ { value: 'sequential', label: 'Последовательное' },
+ { value: 'parallel', label: 'Параллельное' },
+]
+
+export const DURATION_LABELS: Record = {
+ single_day: 'Один день',
+ multi_day: 'Несколько дней',
+ date_range: 'Диапазон',
+}
+
+export const TIME_LABELS: Record = {
+ partial: 'Частично',
+ full_day: 'Весь день',
+}
+
+export const PAYMENT_LABELS: Record = {
+ own_expense: 'За свой счёт',
+ vacation_account: 'В счёт отпуска',
+ official: 'Официально',
+}
+-----END src/features/topics/constants.ts-----
+
+File: src/features/topics/hooks/useTopics.ts
+Lines: 100
+-----BEGIN src/features/topics/hooks/useTopics.ts-----
+import { useQuery, useMutation, useQueryClient } from '@tanstack/react-query'
+import {
+ topicsApi,
+ type TopicsListParams,
+ type CreateTopicRequest,
+ type UpdateTopicRequest
+} from '@/api/topics'
+import { notifications } from '@mantine/notifications'
+
+export const TOPICS_QUERY_KEY = 'topics'
+
+export function useTopics(params: TopicsListParams = {}) {
+ return useQuery({
+ queryKey: [TOPICS_QUERY_KEY, params],
+ queryFn: async () => {
+ const response = await topicsApi.getList(params)
+ return response.data
+ },
+ })
+}
+
+export function useTopic(id: number | null) {
+ return useQuery({
+ queryKey: ['topic', id],
+ queryFn: async () => {
+ if (!id) return null
+ const response = await topicsApi.getById(id)
+ return response.data
+ },
+ enabled: !!id,
+ })
+}
+
+export function useCreateTopic() {
+ const queryClient = useQueryClient()
+
+ return useMutation({
+ mutationFn: (data: CreateTopicRequest) => topicsApi.create(data),
+ onSuccess: () => {
+ queryClient.invalidateQueries({ queryKey: [TOPICS_QUERY_KEY] })
+ notifications.show({
+ title: 'Успешно',
+ message: 'Тема создана',
+ color: 'green',
+ })
+ },
+ onError: (error: any) => {
+ notifications.show({
+ title: 'Ошибка',
+ message: error.response?.data?.error_description || 'Не удалось создать тему',
+ color: 'red',
+ })
+ },
+ })
+}
+
+export function useUpdateTopic() {
+ const queryClient = useQueryClient()
+
+ return useMutation({
+ mutationFn: (data: UpdateTopicRequest) => topicsApi.update(data),
+ onSuccess: () => {
+ queryClient.invalidateQueries({ queryKey: [TOPICS_QUERY_KEY] })
+ notifications.show({
+ title: 'Успешно',
+ message: 'Тема обновлена',
+ color: 'green',
+ })
+ },
+ onError: (error: any) => {
+ notifications.show({
+ title: 'Ошибка',
+ message: error.response?.data?.error_description || 'Не удалось обновить тему',
+ color: 'red',
+ })
+ },
+ })
+}
+
+export function useDeleteTopic() {
+ const queryClient = useQueryClient()
+
+ return useMutation({
+ mutationFn: (id: number) => topicsApi.delete(id),
+ onSuccess: () => {
+ queryClient.invalidateQueries({ queryKey: [TOPICS_QUERY_KEY] })
+ notifications.show({
+ title: 'Успешно',
+ message: 'Тема удалена',
+ color: 'green',
+ })
+ },
+ onError: (error: any) => {
+ notifications.show({
+ title: 'Ошибка',
+ message: error.response?.data?.error_description || 'Не удалось удалить тему',
+ color: 'red',
+ })
+ },
+ })
+}
+-----END src/features/topics/hooks/useTopics.ts-----
+
+File: src/features/users/hooks/useDepartments.ts
+Lines: 13
+-----BEGIN src/features/users/hooks/useDepartments.ts-----
+import { useQuery } from '@tanstack/react-query'
+import { departmentsApi } from '@/api/departments.ts'
+
+export const DEPARTMENTS_QUERY_KEY = 'departments'
+
+export function useDepartments() {
+ return useQuery({
+ queryKey: [DEPARTMENTS_QUERY_KEY],
+ queryFn: async () => {
+ const response = await departmentsApi.getList()
+ return response.data.data || []
+ },
+ })
+}
+-----END src/features/users/hooks/useDepartments.ts-----
+
+File: src/features/users/hooks/useRoles.ts
+Lines: 13
+-----BEGIN src/features/users/hooks/useRoles.ts-----
+import { useQuery } from '@tanstack/react-query'
+import { rolesApi } from '@/api/roles.ts'
+
+export const ROLES_QUERY_KEY = 'roles'
+
+export function useRoles(params: import('@/api/roles').RolesListParams = {}) {
+ return useQuery({
+ queryKey: [ROLES_QUERY_KEY, params],
+ queryFn: async () => {
+ const response = await rolesApi.getList(params)
+ return response.data.data || []
+ },
+ })
+}
+-----END src/features/users/hooks/useRoles.ts-----
+
+File: src/features/users/hooks/useUserRoles.ts
+Lines: 39
+-----BEGIN src/features/users/hooks/useUserRoles.ts-----
+import { useQuery, useMutation, useQueryClient } from '@tanstack/react-query'
+import { userRolesApi } from '@/api/userRoles.ts'
+import { notifications } from '@mantine/notifications'
+import { USERS_QUERY_KEY } from './useUsers.ts'
+
+export function useUserRoles(userId: number | null) {
+ return useQuery({
+ queryKey: ['user-roles', userId],
+ queryFn: async () => {
+ if (!userId) return []
+ const response = await userRolesApi.getByUserId(userId)
+ return response.data.data || []
+ },
+ enabled: !!userId,
+ })
+}
+
+export function useBulkAssignRoles() {
+ const queryClient = useQueryClient()
+
+ return useMutation({
+ mutationFn: userRolesApi.bulkAssign,
+ onSuccess: () => {
+ queryClient.invalidateQueries({ queryKey: [USERS_QUERY_KEY] })
+ queryClient.invalidateQueries({ queryKey: ['user-roles'] })
+ notifications.show({
+ title: 'Успешно',
+ message: 'Роли обновлены',
+ color: 'green',
+ })
+ },
+ onError: (error: any) => {
+ notifications.show({
+ title: 'Ошибка',
+ message: error.response?.data?.error_description || 'Не удалось обновить роли',
+ color: 'red',
+ })
+ },
+ })
+}
+-----END src/features/users/hooks/useUserRoles.ts-----
+
+File: src/features/users/hooks/useUsers.ts
+Lines: 73
+-----BEGIN src/features/users/hooks/useUsers.ts-----
+import { useQuery, useMutation, useQueryClient } from '@tanstack/react-query'
+import { usersApi, type UsersListParams, type UpdateUserRequest } from '@/api/users.ts'
+import { notifications } from '@mantine/notifications'
+
+export const USERS_QUERY_KEY = 'users'
+
+export function useUsers(params: UsersListParams = {}) {
+ return useQuery({
+ queryKey: [USERS_QUERY_KEY, params],
+ queryFn: async () => {
+ const response = await usersApi.getList(params)
+ return response.data
+ },
+ })
+}
+
+export function useUser(id: number | null) {
+ return useQuery({
+ queryKey: ['user', id],
+ queryFn: async () => {
+ if (!id) return null
+ const response = await usersApi.getById(id)
+ return response.data
+ },
+ enabled: !!id,
+ })
+}
+
+export function useUpdateUser() {
+ const queryClient = useQueryClient()
+
+ return useMutation({
+ mutationFn: (data: UpdateUserRequest) => usersApi.update(data),
+ onSuccess: () => {
+ queryClient.invalidateQueries({ queryKey: [USERS_QUERY_KEY] })
+ notifications.show({
+ title: 'Успешно',
+ message: 'Пользователь обновлен',
+ color: 'green',
+ })
+ },
+ onError: (error: any) => {
+ notifications.show({
+ title: 'Ошибка',
+ message: error.response?.data?.error_description || 'Не удалось обновить пользователя',
+ color: 'red',
+ })
+ },
+ })
+}
+
+// ✅ Новый хук для удаления пользователя
+export function useDeleteUser() {
+ const queryClient = useQueryClient()
+
+ return useMutation({
+ mutationFn: (id: number) => usersApi.delete(id),
+ onSuccess: () => {
+ queryClient.invalidateQueries({ queryKey: [USERS_QUERY_KEY] })
+ notifications.show({
+ title: 'Успешно',
+ message: 'Пользователь удален',
+ color: 'green',
+ })
+ },
+ onError: (error: any) => {
+ notifications.show({
+ title: 'Ошибка',
+ message: error.response?.data?.error_description || 'Не удалось удалить пользователя',
+ color: 'red',
+ })
+ },
+ })
+}
+-----END src/features/users/hooks/useUsers.ts-----
+
+File: src/hooks/useAuth.ts
+Lines: 57
+-----BEGIN src/hooks/useAuth.ts-----
+import { useState, useEffect } from 'react'
+import { useNavigate } from 'react-router-dom'
+import { authApi } from '@/api/auth'
+import type { Admin } from '@/types/api'
+
+export function useAuth() {
+ const [user, setUser] = useState(null)
+ const [loading, setLoading] = useState(true)
+ const navigate = useNavigate()
+
+ useEffect(() => {
+ const token = localStorage.getItem('token')
+ if (token) {
+ loadUser()
+ } else {
+ setLoading(false)
+ }
+ }, [])
+
+ const loadUser = async () => {
+ try {
+ const response = await authApi.getProfile()
+ setUser(response.data)
+ } catch (error) {
+ console.error('Failed to load user:', error)
+ localStorage.removeItem('token')
+ } finally {
+ setLoading(false)
+ }
+ }
+
+ const login = async (login: string, password: string) => {
+ const response = await authApi.login({ login, password })
+ localStorage.setItem('token', response.data.token)
+
+ // ✅ НЕ создаём новый device_id здесь!
+ // Он уже создан в client.ts и сохранён в localStorage
+ // localStorage.setItem('device_id', crypto.randomUUID()) // ← УДАЛЕНО
+
+ await loadUser()
+ navigate('/')
+ }
+
+ const logout = async () => {
+ try {
+ await authApi.logout()
+ } catch (error) {
+ console.error('Logout error:', error)
+ } finally {
+ localStorage.removeItem('token')
+ localStorage.removeItem('user')
+ setUser(null)
+ navigate('/login')
+ }
+ }
+
+ return { user, loading, login, logout, isAuthenticated: !!user }
+}
+-----END src/hooks/useAuth.ts-----
+
+File: src/index.css
+Lines: 111
+-----BEGIN src/index.css-----
+:root {
+ --text: #6b6375;
+ --text-h: #08060d;
+ --bg: #fff;
+ --border: #e5e4e7;
+ --code-bg: #f4f3ec;
+ --accent: #aa3bff;
+ --accent-bg: rgba(170, 59, 255, 0.1);
+ --accent-border: rgba(170, 59, 255, 0.5);
+ --social-bg: rgba(244, 243, 236, 0.5);
+ --shadow:
+ rgba(0, 0, 0, 0.1) 0 10px 15px -3px, rgba(0, 0, 0, 0.05) 0 4px 6px -2px;
+
+ --sans: system-ui, 'Segoe UI', Roboto, sans-serif;
+ --heading: system-ui, 'Segoe UI', Roboto, sans-serif;
+ --mono: ui-monospace, Consolas, monospace;
+
+ font: 18px/145% var(--sans);
+ letter-spacing: 0.18px;
+ color-scheme: light dark;
+ color: var(--text);
+ background: var(--bg);
+ font-synthesis: none;
+ text-rendering: optimizeLegibility;
+ -webkit-font-smoothing: antialiased;
+ -moz-osx-font-smoothing: grayscale;
+
+ @media (max-width: 1024px) {
+ font-size: 16px;
+ }
+}
+
+@media (prefers-color-scheme: dark) {
+ :root {
+ --text: #9ca3af;
+ --text-h: #f3f4f6;
+ --bg: #16171d;
+ --border: #2e303a;
+ --code-bg: #1f2028;
+ --accent: #c084fc;
+ --accent-bg: rgba(192, 132, 252, 0.15);
+ --accent-border: rgba(192, 132, 252, 0.5);
+ --social-bg: rgba(47, 48, 58, 0.5);
+ --shadow:
+ rgba(0, 0, 0, 0.4) 0 10px 15px -3px, rgba(0, 0, 0, 0.25) 0 4px 6px -2px;
+ }
+
+ #social .button-icon {
+ filter: invert(1) brightness(2);
+ }
+}
+
+#root {
+ width: 1126px;
+ max-width: 100%;
+ margin: 0 auto;
+ text-align: center;
+ border-inline: 1px solid var(--border);
+ min-height: 100svh;
+ display: flex;
+ flex-direction: column;
+ box-sizing: border-box;
+}
+
+body {
+ margin: 0;
+}
+
+h1,
+h2 {
+ font-family: var(--heading);
+ font-weight: 500;
+ color: var(--text-h);
+}
+
+h1 {
+ font-size: 56px;
+ letter-spacing: -1.68px;
+ margin: 32px 0;
+ @media (max-width: 1024px) {
+ font-size: 36px;
+ margin: 20px 0;
+ }
+}
+h2 {
+ font-size: 24px;
+ line-height: 118%;
+ letter-spacing: -0.24px;
+ margin: 0 0 8px;
+ @media (max-width: 1024px) {
+ font-size: 20px;
+ }
+}
+p {
+ margin: 0;
+}
+
+code,
+.counter {
+ font-family: var(--mono);
+ display: inline-flex;
+ border-radius: 4px;
+ color: var(--text-h);
+}
+
+code {
+ font-size: 15px;
+ line-height: 135%;
+ padding: 4px 8px;
+ background: var(--code-bg);
+}
+
+-----END src/index.css-----
+
+File: src/theme.ts
+Lines: 17
+-----BEGIN src/theme.ts-----
+import { createTheme } from '@mantine/core'
+
+export const theme = createTheme({
+ primaryColor: 'blue',
+ fontFamily: '-apple-system, BlinkMacSystemFont, Segoe UI, Roboto, sans-serif',
+ components: {
+ Button: {
+ defaultProps: {
+ size: 'sm',
+ },
+ },
+ Table: {
+ defaultProps: {
+ fontSize: 'sm',
+ },
+ },
+ },
+})
+-----END src/theme.ts-----
+
+File: src/types/api.ts
+Lines: 333
+-----BEGIN src/types/api.ts-----
+export interface User {
+ id?: number
+ telegram_id?: number
+ username?: string
+ full_name: string
+ language_code?: string
+ department_id?: number
+ is_blocked?: boolean
+ is_fired?: boolean
+ blocked_at?: string
+ last_login?: string
+ created_at?: string
+ updated_at?: string
+ department?: Department
+ user_roles?: UserRole[]
+}
+
+export interface Department {
+ id?: number
+ name: string
+ code: string
+ description?: string
+ is_active?: boolean
+ created_at?: string
+ updated_at?: string
+}
+
+export interface Role {
+ id?: number
+ name: string
+ code: string
+ is_default?: boolean
+ is_director?: boolean
+ is_approver?: boolean
+ is_controller?: boolean
+ is_observer?: boolean
+ is_executor?: boolean
+ description?: string
+ created_at?: string
+ updated_at?: string
+}
+
+export interface UserRole {
+ id?: number
+ user_id: number
+ role_id: number
+ created_at?: string
+ updated_at?: string
+ role?: Role
+}
+
+export interface Admin {
+ id?: number
+ login: string
+ name?: string
+ is_root?: boolean
+ is_observer?: boolean // 🆕
+ telegram_id?: number // 🆕
+ telegram_user?: User // 🆕
+ created_at?: string
+ last_login?: string
+ last_ip_login?: string
+ is_blocked?: boolean
+ password?: string
+}
+
+
+// 🆕 Типы для заявок
+export interface ApprovalFile {
+ id?: number
+ approval_id?: number
+ file_base64?: string
+ file_name?: string
+ attached_by_id?: number
+ created_at?: string
+}
+
+export interface ApprovalStep {
+ id?: number
+ approval_id?: number
+ approver_id?: number
+ step_order?: number
+ status?: string
+ comment?: string
+ approver_name_snapshot?: string
+ approver_department_snapshot?: string
+ acted_at?: string
+ created_at?: string
+ updated_at?: string
+ returned_at?: string
+ approver?: User
+}
+
+export interface ApprovalTopicCategory {
+ id?: number
+ name: string
+ code: string
+ description?: string
+ is_active?: boolean
+ created_at?: string
+ updated_at?: string
+ topics?: ApprovalTopic[]
+}
+
+export interface ApprovalTopic {
+ id?: number
+ category_id?: number
+ name: string
+ code: string
+ approval_mode?: string
+ duration_type?: string
+ time_type?: string
+ payment_type?: string
+ template?: string
+ first_approver_role_code?: string
+ allows_file?: boolean
+ allow_approver_selection?: boolean
+ allow_observer_selection?: boolean
+ require_approver_comment?: boolean
+ requires_file?: boolean
+ require_observer_selection?: boolean
+ is_active?: boolean
+ created_at?: string
+ updated_at?: string
+ instructions?: string
+ category?: ApprovalTopicCategory
+}
+
+export interface Approval {
+ id?: number
+ initiator_id?: number
+ topic_id?: number
+ department_id?: number
+ content?: string
+ status?: string
+ revoked_by_id?: number
+ revoked_at?: string
+ created_at?: string
+ updated_at?: string
+ metadata?: string
+ revision_comment?: string
+ revision_by_id?: number
+ revision_at?: string
+ revision_count?: number
+ files?: ApprovalFile[]
+ initiator?: User
+ topic?: ApprovalTopic
+ department?: Department
+ revoked_by?: User
+ steps?: ApprovalStep[]
+}
+
+export interface ApiResponse {
+ data: T
+ total_count?: number
+}
+
+export interface LoginRequest {
+ login: string
+ password: string
+}
+
+export interface LoginResponse {
+ token: string
+}
+
+export interface Permission {
+ id?: number
+ role_id?: number
+ topic_category_id?: number | null
+ topic_id?: number | null
+ action?: string
+ created_at?: string
+ updated_at?: string
+ role?: Role
+ topic_category?: ApprovalTopicCategory
+ topic?: ApprovalTopic
+}
+
+export interface UserHierarchy {
+ id?: number
+ subordinate_id?: number
+ approver_id?: number
+ department_id?: number
+ topic_category_id?: number | null
+ topic_id?: number | null
+ priority?: number
+ created_at?: string
+ updated_at?: string
+ subordinate?: User
+ approver?: User
+ department?: Department
+ target_system?: string | null
+}
+
+export interface ApprovalTopicExecutor {
+ id?: number
+ topic_id?: number
+ user_id?: number
+ step_order?: number
+ require_file?: boolean
+ task_text?: string
+ is_active?: boolean
+ target_system?: string
+ created_at?: string
+ updated_at?: string
+ topic?: ApprovalTopic
+ user?: User
+}
+
+export interface ApprovalTopic {
+ id?: number
+ category_id?: number
+ name: string
+ code: string
+ duration_type?: string
+ time_type?: string
+ payment_type?: string
+ template?: string
+ allows_file?: boolean
+ is_active?: boolean
+ allow_approver_selection?: boolean
+ first_approver_role_code?: string
+ allow_observer_selection?: boolean
+ approval_mode?: string
+ allow_delegation_selection?: boolean
+ require_approver_comment?: boolean
+ requires_file?: boolean
+ require_observer_selection?: boolean
+ instructions?: string
+ created_at?: string
+ updated_at?: string
+ category?: ApprovalTopicCategory
+}
+
+export interface Admin {
+ id?: number
+ login: string
+ name?: string
+ is_root?: boolean
+ created_at?: string
+ last_login?: string
+ last_ip_login?: string
+ is_blocked?: boolean
+ password?: string
+}
+
+export interface ApprovalFile {
+ id?: number
+ approval_id?: number
+ file_base64?: string
+ file_name?: string
+ attached_by_id?: number
+ task_id?: number
+ created_at?: string
+}
+
+export interface ApprovalTask {
+ id?: number
+ approval_id?: number
+ executor_id?: number
+ task_text?: string
+ status?: string
+ step_order?: number
+ require_file?: boolean
+ topic_executor_id?: number
+ completed_at?: string
+ created_at?: string
+ updated_at?: string
+ approval?: Approval
+ executor?: User
+ files?: ApprovalFile[]
+}
+
+export interface ApprovalFlowNode {
+ id?: number
+ topic_id?: number
+ parent_id?: number | null
+ key: string
+ category_id: number
+ message_template?: string | null
+ code_template?: string | null
+ label: string
+ data_key?: string | null
+ data_value?: string | null
+ is_input?: boolean
+ input_key?: string | null
+ input_hint?: string | null
+ is_multi_select?: boolean
+ multi_select_key?: string | null
+ multi_select_value?: string | null
+ topic_code?: string | null
+ sort_order?: number
+ created_at?: string
+ updated_at?: string
+ children?: ApprovalFlowNode[]
+}
+
+export interface TargetFilters {
+ user_ids?: number[]
+ role_ids?: number[]
+ role_type_flags?: string[] // 'director' | 'approver' | 'observer' | 'executor' | 'controller'
+ department_ids?: number[]
+}
+
+export interface NotificationRecipient {
+ id?: number
+ notification_id?: number
+ user_id?: number
+ status?: string // pending | sent | failed
+ error_message?: string
+ telegram_message_id?: number
+ sent_at?: string
+ created_at?: string
+ user?: User
+}
+
+export interface Notification {
+ id?: number
+ title: string
+ message_html: string
+ photo_base64?: string
+ photo_file_name?: string
+ target_filters?: string // JSON-строка от бэкенда
+ status?: string // pending | sending | completed | failed
+ total_count?: number
+ sent_count?: number
+ failed_count?: number
+ created_by_id?: number
+ created_at?: string
+ updated_at?: string
+ sent_at?: string
+ recipients?: NotificationRecipient[]
+}
+-----END src/types/api.ts-----
+
+File: src/utils/date.ts
+Lines: 26
+-----BEGIN src/utils/date.ts-----
+import dayjs from 'dayjs'
+import utc from 'dayjs/plugin/utc'
+import timezone from 'dayjs/plugin/timezone'
+import 'dayjs/locale/ru'
+
+dayjs.extend(utc)
+dayjs.extend(timezone)
+dayjs.locale('ru')
+
+export const MSK_TZ = 'Europe/Moscow'
+
+// Даты с бэкенда обычно приходят в UTC (ISO-строка с 'Z') — если форматировать
+// их через голый dayjs(date).format(...), время покажется в часовом поясе
+// БРАУЗЕРА администратора, а не по МСК. Эта функция всегда приводит к
+// Europe/Moscow независимо от того, где физически находится админ.
+export function formatMsk(
+ date: string | Date | null | undefined,
+ fmt: string = 'DD.MM.YYYY HH:mm'
+): string {
+ if (!date) return '—'
+ return dayjs(date).tz(MSK_TZ).format(fmt)
+}
+
+// Текущее время по МСК — например, для имени скачиваемого файла отчёта.
+export function mskNow() {
+ return dayjs().tz(MSK_TZ)
+}
+-----END src/utils/date.ts-----
+
+File: src/vite-env.d.ts
+Lines: 11
+-----BEGIN src/vite-env.d.ts-----
+///
+
+interface ImportMetaEnv {
+ readonly VITE_API_BASE_URL: string
+ readonly VITE_API_KEY: string
+ readonly VITE_APP_NAME: string
+ readonly VITE_APP_VERSION: string
+}
+
+interface ImportMeta {
+ readonly env: ImportMetaEnv
+}
+-----END src/vite-env.d.ts-----
+
+File: vite.config.ts
+Lines: 50
+-----BEGIN vite.config.ts-----
+import { defineConfig } from 'vite'
+import react from '@vitejs/plugin-react'
+import path from 'path'
+
+export default defineConfig({
+ plugins: [react()],
+ resolve: {
+ alias: {
+ '@': path.resolve(__dirname, './src'),
+ },
+ },
+ server: {
+ port: 3000,
+ allowedHosts: true,
+ proxy: {
+ '/api': {
+ target: 'http://0.0.0.0:1726', // Порт твоего бэкенда
+ changeOrigin: true,
+ secure: false,
+ // Раскомментируй, если нужно видеть реальные запросы:
+ // configure: (proxy, options) => {
+ // proxy.on('proxyReq', (proxyReq, req, res) => {
+ // console.log('Proxying:', req.method, req.url)
+ // })
+ // },
+ },
+ },
+ },
+ build: {
+ outDir: 'dist',
+ sourcemap: false,
+ rollupOptions: {
+ output: {
+ manualChunks(id) {
+ if (id.includes('node_modules')) {
+ if (id.includes('react') || id.includes('react-dom') || id.includes('react-router-dom')) {
+ return 'vendor'
+ }
+ if (id.includes('@mantine')) {
+ return 'ui'
+ }
+ if (id.includes('@tanstack') || id.includes('axios')) {
+ return 'query'
+ }
+ return 'vendor-misc'
+ }
+ },
+ },
+ },
+ },
+})
+-----END vite.config.ts-----
+
diff --git a/src/App.tsx b/src/App.tsx
index 7bc6c87..d2e487b 100644
--- a/src/App.tsx
+++ b/src/App.tsx
@@ -21,6 +21,7 @@ import FlowTreePage from "@/pages/flowNodes/FlowTreePage.tsx"
import FlowTreeGuidePage from './pages/flowNodes/FlowTreeGuidePage'
import NotificationsPage from "@/pages/notifications/NotificationsPage.tsx"
import AdminLogsPage from './pages/adminLogs/AdminLogsPage'
+import MonthlyOrdersSettingsPage from "@/pages/monthlyOrders/MonthlyOrdersSettingsPage.tsx";
const Placeholder = ({ title }: { title: string }) => (
@@ -58,6 +59,7 @@ function App() {
} />
} />
} />
+
} />
} />
} />
} />
diff --git a/src/api/admins.ts b/src/api/admins.ts
index ec2bd68..d32504f 100644
--- a/src/api/admins.ts
+++ b/src/api/admins.ts
@@ -13,6 +13,7 @@ export interface CreateAdminRequest {
name?: string
is_root?: boolean
is_observer?: boolean // 🆕
+ is_analyst?: boolean
telegram_id?: number // 🆕
}
@@ -22,6 +23,7 @@ export interface UpdateAdminRequest {
is_blocked?: boolean
is_root?: boolean
is_observer?: boolean // 🆕
+ is_analyst?: boolean
telegram_id?: number | null // 🆕
}
diff --git a/src/api/monthlyOrders.ts b/src/api/monthlyOrders.ts
new file mode 100644
index 0000000..44b0600
--- /dev/null
+++ b/src/api/monthlyOrders.ts
@@ -0,0 +1,10 @@
+import apiClient from './client'
+import type { MonthlyOrderSetting } from '@/types/api'
+
+export const monthlyOrdersApi = {
+ getSettings: () =>
+ apiClient.get
('/monthly-orders/settings'),
+
+ saveSettings: (data: MonthlyOrderSetting) =>
+ apiClient.post<{status: string}>('/monthly-orders/settings', data),
+}
\ No newline at end of file
diff --git a/src/components/Layout/Sidebar.tsx b/src/components/Layout/Sidebar.tsx
index 42b3c86..e4be7eb 100644
--- a/src/components/Layout/Sidebar.tsx
+++ b/src/components/Layout/Sidebar.tsx
@@ -18,7 +18,7 @@ import {
IconCheck,
IconBellRinging,
IconBlocks,
- IconHistory,
+ IconHistory, IconChartBar,
} from '@tabler/icons-react'
import { useLocation, useNavigate } from 'react-router-dom'
import { useAuth } from '@/hooks/useAuth'
@@ -36,6 +36,13 @@ const menuItems: MenuItem[] = [
{ label: 'Администраторы', icon: IconUserCog, path: '/admins', adminOnly: true },
{ label: 'Уведомления', icon: IconBellRinging, path: '/notifications', adminOnly: true },
{ label: 'Журнал действий', icon: IconHistory, path: '/logs', adminOnly: true },
+ {
+ label: 'Заказы на месяц',
+ icon: IconChartBar,
+ path: '/monthly-orders-settings',
+ adminOnly: true, // Скрываем от наблюдателей
+ // Если нужно скрыть от менеджеров, можно добавить флаг analystOnly: true и фильтровать
+ },
{
label: 'Система согласований',
icon: IconFileCheck,
@@ -164,6 +171,7 @@ function MenuItemLink({ item, level }: { item: MenuItem; level: number }) {
export default function Sidebar() {
const { user } = useAuth()
const isObserver = user?.is_observer === true
+ const isAnalyst = user?.is_analyst === true || user?.is_root === true
// 🆕 Фильтруем меню в зависимости от роли
const filteredMenuItems = useMemo(
diff --git a/src/features/monthlyOrders/hooks/useMonthlyOrderSettings.ts b/src/features/monthlyOrders/hooks/useMonthlyOrderSettings.ts
new file mode 100644
index 0000000..a110edf
--- /dev/null
+++ b/src/features/monthlyOrders/hooks/useMonthlyOrderSettings.ts
@@ -0,0 +1,39 @@
+import { useQuery, useMutation, useQueryClient } from '@tanstack/react-query'
+import { monthlyOrdersApi } from '@/api/monthlyOrders'
+import { notifications } from '@mantine/notifications'
+import type { MonthlyOrderSetting } from '@/types/api'
+
+export const MO_SETTINGS_QUERY_KEY = 'mo-settings'
+
+export function useMonthlyOrderSettings() {
+ return useQuery({
+ queryKey: [MO_SETTINGS_QUERY_KEY],
+ queryFn: async () => {
+ const response = await monthlyOrdersApi.getSettings()
+ return response.data
+ },
+ })
+}
+
+export function useSaveMonthlyOrderSettings() {
+ const queryClient = useQueryClient()
+
+ return useMutation({
+ mutationFn: (data: MonthlyOrderSetting) => monthlyOrdersApi.saveSettings(data),
+ onSuccess: () => {
+ queryClient.invalidateQueries({ queryKey: [MO_SETTINGS_QUERY_KEY] })
+ notifications.show({
+ title: 'Успешно',
+ message: 'Настройки заказов на месяц сохранены',
+ color: 'green',
+ })
+ },
+ onError: (error: any) => {
+ notifications.show({
+ title: 'Ошибка',
+ message: error.response?.data?.error_description || 'Не удалось сохранить настройки',
+ color: 'red',
+ })
+ },
+ })
+}
\ No newline at end of file
diff --git a/src/pages/admins/AdminsPage.tsx b/src/pages/admins/AdminsPage.tsx
index 4cc3b55..037840e 100644
--- a/src/pages/admins/AdminsPage.tsx
+++ b/src/pages/admins/AdminsPage.tsx
@@ -24,7 +24,7 @@ import {
IconLockOpen,
IconPencil,
IconShield,
- IconUser,
+ IconUser, IconChartBar,
} from '@tabler/icons-react'
import { modals } from '@mantine/modals'
import { notifications } from '@mantine/notifications'
@@ -263,14 +263,19 @@ export default function AdminsPage() {
ROOT
)}
+ {admin.is_analyst && (
+ }>
+ Аналитик
+
+ )}
{admin.is_observer && (
}>
Наблюдатель
)}
- {!isAdminRoot && !admin.is_observer && (
+ {!isAdminRoot && !admin.is_observer && !admin.is_analyst && (
- Админ
+ Менеджер / Админ
)}
diff --git a/src/pages/admins/components/CreateAdminModal.tsx b/src/pages/admins/components/CreateAdminModal.tsx
index 0faaa7d..ff0ff0e 100644
--- a/src/pages/admins/components/CreateAdminModal.tsx
+++ b/src/pages/admins/components/CreateAdminModal.tsx
@@ -16,7 +16,7 @@ import {
Select,
} from '@mantine/core'
import { useForm } from '@mantine/form'
-import { IconCheck, IconCopy, IconKey, IconAlertCircle, IconShield, IconUser } from '@tabler/icons-react'
+import {IconCheck, IconCopy, IconKey, IconAlertCircle, IconShield, IconUser, IconChartBar} from '@tabler/icons-react'
import { useCreateAdmin } from '@/features/admins/hooks/useAdmins'
import { useUsers } from '@/features/users/hooks/useUsers'
import type { Admin } from '@/types/api'
@@ -37,6 +37,7 @@ export default function CreateAdminModal({ opened, onClose }: CreateAdminModalPr
name: '',
is_root: false,
is_observer: false,
+ is_analyst: false,
telegram_id: null as number | null,
},
validate: {
@@ -75,6 +76,7 @@ export default function CreateAdminModal({ opened, onClose }: CreateAdminModalPr
login: values.login,
name: values.name || undefined,
is_root: values.is_root,
+ is_analyst: values.is_analyst,
is_observer: values.is_observer,
telegram_id: values.is_observer ? values.telegram_id! : undefined,
})
@@ -196,6 +198,22 @@ export default function CreateAdminModal({ opened, onClose }: CreateAdminModalPr
/>
+
+
+
+ Аналитик (Заказы)
+
+ }
+ description="Имеет доступ к настройкам и просмотру всех заказов на месяц."
+ checked={form.values.is_analyst}
+ onChange={(e) => form.setFieldValue('is_analyst', e.currentTarget.checked)}
+ color="grape"
+ disabled={form.values.is_root || form.values.is_observer}
+ />
+
+
- {form.values.is_observer && (
+ {form.values.is_observer || form.values.is_observer && (