Add znzt module
Deploy Manager App / deploy (push) Failing after 19s
Details
Deploy Manager App / deploy (push) Failing after 19s
Details
This commit is contained in:
parent
d4b20990e1
commit
054638ed0d
|
|
@ -4,9 +4,13 @@ import {
|
||||||
LoadingOverlay, Select, TextInput, HoverCard, ActionIcon, Stack, Textarea, Checkbox
|
LoadingOverlay, Select, TextInput, HoverCard, ActionIcon, Stack, Textarea, Checkbox
|
||||||
} from '@mantine/core'
|
} from '@mantine/core'
|
||||||
import { notifications } from '@mantine/notifications'
|
import { notifications } from '@mantine/notifications'
|
||||||
import { IconDeviceFloppy, IconLock, IconSettings, IconSearch, IconFilter, IconUserSearch, IconRefresh, IconArrowLeft } from '@tabler/icons-react'
|
import {
|
||||||
|
IconDeviceFloppy, IconLock, IconSettings, IconSearch,
|
||||||
|
IconFilter, IconUserSearch, IconRefresh, IconArrowLeft,
|
||||||
|
IconFileExport, IconPaperclip, IconExternalLink
|
||||||
|
} from '@tabler/icons-react'
|
||||||
import { useVirtualizer } from '@tanstack/react-virtual'
|
import { useVirtualizer } from '@tanstack/react-virtual'
|
||||||
import { useNavigate, useParams } from 'react-router-dom' // 👈 Добавили для роутинга
|
import { useNavigate, useParams } from 'react-router-dom'
|
||||||
import { monthlyOrdersApi } from "../api/monthlyOrders.ts"
|
import { monthlyOrdersApi } from "../api/monthlyOrders.ts"
|
||||||
import type { FrontendOrderMatrix, MonthlyOrderClient, NomenclatureItem } from "../types/orders.ts"
|
import type { FrontendOrderMatrix, MonthlyOrderClient, NomenclatureItem } from "../types/orders.ts"
|
||||||
|
|
||||||
|
|
@ -56,16 +60,16 @@ export default function OrdersPage({ onError }: { onError: (msg: string) => void
|
||||||
|
|
||||||
const tableContainerRef = useRef<HTMLDivElement>(null);
|
const tableContainerRef = useRef<HTMLDivElement>(null);
|
||||||
|
|
||||||
// 🟢 Логика Аналитика
|
// Логика Аналитика
|
||||||
const navigate = useNavigate();
|
const navigate = useNavigate();
|
||||||
const { id } = useParams();
|
const { id } = useParams();
|
||||||
const targetManagerId = id ? Number(id) : undefined;
|
const targetManagerId = id ? Number(id) : undefined;
|
||||||
const isReadOnly = !!targetManagerId; // Если смотрим чужую, то только чтение
|
const isReadOnly = !!targetManagerId;
|
||||||
|
|
||||||
const loadData = async (ignoreDraft = false) => {
|
const loadData = async (ignoreDraft = false) => {
|
||||||
try {
|
try {
|
||||||
setLoading(true)
|
setLoading(true)
|
||||||
const res = await monthlyOrdersApi.getMatrix(targetManagerId) // 👈 Передаем ID, если есть
|
const res = await monthlyOrdersApi.getMatrix(targetManagerId)
|
||||||
const matrix = res.data
|
const matrix = res.data
|
||||||
setData(matrix)
|
setData(matrix)
|
||||||
|
|
||||||
|
|
@ -84,7 +88,6 @@ export default function OrdersPage({ onError }: { onError: (msg: string) => void
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
// Черновик не загружаем, если мы Аналитик (isReadOnly = true)
|
|
||||||
const draft = localStorage.getItem(DRAFT_KEY);
|
const draft = localStorage.getItem(DRAFT_KEY);
|
||||||
const draftTime = localStorage.getItem(DRAFT_TIME_KEY);
|
const draftTime = localStorage.getItem(DRAFT_TIME_KEY);
|
||||||
|
|
||||||
|
|
@ -103,8 +106,6 @@ export default function OrdersPage({ onError }: { onError: (msg: string) => void
|
||||||
}
|
}
|
||||||
} catch (err: any) {
|
} catch (err: any) {
|
||||||
const errorMsg = err.response?.data?.error_description || 'Ошибка загрузки';
|
const errorMsg = err.response?.data?.error_description || 'Ошибка загрузки';
|
||||||
|
|
||||||
// 🟢 Если бэкенд требует ID менеджера, значит зашел аналитик -> Редирект на дашборд!
|
|
||||||
if (errorMsg.includes('аналитику необходимо передать manager_id')) {
|
if (errorMsg.includes('аналитику необходимо передать manager_id')) {
|
||||||
navigate('/analyst');
|
navigate('/analyst');
|
||||||
return;
|
return;
|
||||||
|
|
@ -115,9 +116,8 @@ export default function OrdersPage({ onError }: { onError: (msg: string) => void
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
useEffect(() => { loadData() }, [targetManagerId]) // 👈 Перезагружаем при смене ID
|
useEffect(() => { loadData() }, [targetManagerId])
|
||||||
|
|
||||||
// Автосохранение черновика (только если не аналитик!)
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
if (loading || saving || isReadOnly) return;
|
if (loading || saving || isReadOnly) return;
|
||||||
|
|
||||||
|
|
@ -130,7 +130,7 @@ export default function OrdersPage({ onError }: { onError: (msg: string) => void
|
||||||
}, [editableOrders, data, loading, saving, isReadOnly]);
|
}, [editableOrders, data, loading, saving, isReadOnly]);
|
||||||
|
|
||||||
const handleQuantityChange = useCallback((clientName: string, nom: NomenclatureItem, qty: number | null) => {
|
const handleQuantityChange = useCallback((clientName: string, nom: NomenclatureItem, qty: number | null) => {
|
||||||
if (isReadOnly) return; // Блокировка
|
if (isReadOnly) return;
|
||||||
setEditableOrders(prev => {
|
setEditableOrders(prev => {
|
||||||
const currentOrder = prev[clientName];
|
const currentOrder = prev[clientName];
|
||||||
const items = [...(currentOrder.items || [])];
|
const items = [...(currentOrder.items || [])];
|
||||||
|
|
@ -147,17 +147,18 @@ export default function OrdersPage({ onError }: { onError: (msg: string) => void
|
||||||
}, [isReadOnly]);
|
}, [isReadOnly]);
|
||||||
|
|
||||||
const updateClientMeta = useCallback((clientName: string, field: keyof MonthlyOrderClient, value: string | null) => {
|
const updateClientMeta = useCallback((clientName: string, field: keyof MonthlyOrderClient, value: string | null) => {
|
||||||
if (isReadOnly) return; // Блокировка
|
if (isReadOnly) return;
|
||||||
setEditableOrders(prev => ({
|
setEditableOrders(prev => ({
|
||||||
...prev, [clientName]: { ...prev[clientName], [field]: value }
|
...prev, [clientName]: { ...prev[clientName], [field]: value }
|
||||||
}))
|
}))
|
||||||
}, [isReadOnly]);
|
}, [isReadOnly]);
|
||||||
|
|
||||||
|
|
||||||
const handleSave = async () => {
|
const handleSave = async () => {
|
||||||
if (isReadOnly) return;
|
if (isReadOnly) return;
|
||||||
for (const [clientName, order] of Object.entries(editableOrders)) {
|
for (const [clientName, order] of Object.entries(editableOrders)) {
|
||||||
if (order.items && order.items.length > 0 && !order.manager_comment?.trim()) {
|
if (!order.manager_comment || order.manager_comment.trim() === '') {
|
||||||
return notifications.show({ title: 'Внимание', message: `Укажите комментарий для клиента "${clientName}"!`, color: 'yellow' })
|
return notifications.show({ title: 'Внимание', message: `Комментарий обязателен для клиента "${clientName}"!`, color: 'yellow' })
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
try {
|
try {
|
||||||
|
|
@ -243,13 +244,11 @@ export default function OrdersPage({ onError }: { onError: (msg: string) => void
|
||||||
if (loading) return <LoadingOverlay visible />
|
if (loading) return <LoadingOverlay visible />
|
||||||
if (!data) return <Text ta="center">Нет данных</Text>
|
if (!data) return <Text ta="center">Нет данных</Text>
|
||||||
|
|
||||||
// Общий флаг отключения элементов
|
|
||||||
const inputsDisabled = data.is_locked || isReadOnly;
|
const inputsDisabled = data.is_locked || isReadOnly;
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<Box display="flex" style={{ flexDirection: 'column', flexGrow: 1, overflow: 'hidden' }}>
|
<Box display="flex" style={{ flexDirection: 'column', flexGrow: 1, overflow: 'hidden' }}>
|
||||||
|
|
||||||
{/* 🟢 Кнопка возврата для аналитика */}
|
|
||||||
{isReadOnly && (
|
{isReadOnly && (
|
||||||
<Group mb="sm">
|
<Group mb="sm">
|
||||||
<Button variant="subtle" leftSection={<IconArrowLeft size={16} />} onClick={() => navigate('/analyst')}>
|
<Button variant="subtle" leftSection={<IconArrowLeft size={16} />} onClick={() => navigate('/analyst')}>
|
||||||
|
|
@ -313,27 +312,28 @@ export default function OrdersPage({ onError }: { onError: (msg: string) => void
|
||||||
</Group>
|
</Group>
|
||||||
</Stack>
|
</Stack>
|
||||||
|
|
||||||
{/* Если Аналитик — прячем кнопки управления данными */}
|
<Group align="center" gap="md">
|
||||||
{!isReadOnly && (
|
{!isReadOnly && (
|
||||||
data.is_locked ? (
|
data.is_locked ? (
|
||||||
<Badge color="red" size="lg" leftSection={<IconLock size={14} />}>Прием закрыт</Badge>
|
<Badge color="red" size="lg" leftSection={<IconLock size={14} />}>Прием закрыт</Badge>
|
||||||
) : (
|
) : (
|
||||||
<Group align="center" gap="md">
|
<>
|
||||||
{draftSavedAt && (
|
{draftSavedAt && (
|
||||||
<Text size="xs" c="dimmed">
|
<Text size="xs" c="dimmed">
|
||||||
Локальный черновик:<br/>
|
Локальный черновик:<br/>
|
||||||
<Text span fw={500} c="gray.7">{formatMSKTime(draftSavedAt)} (МСК)</Text>
|
<Text span fw={500} c="gray.7">{formatMSKTime(draftSavedAt)} (МСК)</Text>
|
||||||
</Text>
|
</Text>
|
||||||
)}
|
)}
|
||||||
<Button variant="default" onClick={handleResetDraft} leftSection={<IconRefresh size={16} />}>
|
<Button variant="default" onClick={handleResetDraft} leftSection={<IconRefresh size={16} />}>
|
||||||
Сбросить черновик
|
Сбросить черновик
|
||||||
</Button>
|
</Button>
|
||||||
<Button onClick={handleSave} loading={saving} leftSection={<IconDeviceFloppy size={16} />}>
|
<Button onClick={handleSave} loading={saving} leftSection={<IconDeviceFloppy size={16} />}>
|
||||||
Сохранить в базу
|
Сохранить в базу
|
||||||
</Button>
|
</Button>
|
||||||
</Group>
|
</>
|
||||||
)
|
)
|
||||||
)}
|
)}
|
||||||
|
</Group>
|
||||||
</Group>
|
</Group>
|
||||||
|
|
||||||
<Paper withBorder shadow="sm" style={{ flexGrow: 1, display: 'flex', flexDirection: 'column', overflow: 'hidden' }}>
|
<Paper withBorder shadow="sm" style={{ flexGrow: 1, display: 'flex', flexDirection: 'column', overflow: 'hidden' }}>
|
||||||
|
|
@ -349,21 +349,47 @@ export default function OrdersPage({ onError }: { onError: (msg: string) => void
|
||||||
const clientName = c.google_data.name;
|
const clientName = c.google_data.name;
|
||||||
const branch = c.google_data.branch;
|
const branch = c.google_data.branch;
|
||||||
const order = editableOrders[clientName];
|
const order = editableOrders[clientName];
|
||||||
const hasOrderItems = order?.items && order.items.length > 0;
|
|
||||||
const isCommentMissing = hasOrderItems && (!order.manager_comment || order.manager_comment.trim() === '');
|
// Проверка обязательности комментария
|
||||||
|
const hasComment = !!order?.manager_comment && order.manager_comment.trim() !== '';
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<Table.Th key={clientName} w={240} style={{ textAlign: 'center', verticalAlign: 'top', padding: '10px 8px' }}>
|
<Table.Th key={clientName} w={240} style={{ textAlign: 'center', verticalAlign: 'top', padding: '10px 8px' }}>
|
||||||
<Group justify="center" gap={4} wrap="nowrap" mb={2}>
|
<Group justify="space-between" align="center" mb={2} wrap="nowrap">
|
||||||
<Text size="sm" fw={600} style={{ whiteSpace: 'normal', wordBreak: 'break-word', lineHeight: 1.2 }}>
|
<Text size="sm" fw={600} style={{ whiteSpace: 'normal', wordBreak: 'break-word', lineHeight: 1.2, flex: 1 }}>
|
||||||
{clientName}
|
{clientName}
|
||||||
</Text>
|
</Text>
|
||||||
<ClientSettingsPopover
|
|
||||||
clientName={clientName}
|
<Group gap={4} wrap="nowrap">
|
||||||
order={order}
|
{/* Скрытый инпут для прикрепления файла-скрина */}
|
||||||
updateClientMeta={updateClientMeta}
|
<input
|
||||||
isLocked={inputsDisabled} // 👈 Передаем флаг блокировки
|
type="file"
|
||||||
/>
|
id={`file-${clientName}`}
|
||||||
|
style={{ display: 'none' }}
|
||||||
|
onChange={(e) => {
|
||||||
|
const file = e.target.files?.[0];
|
||||||
|
if (file) {
|
||||||
|
notifications.show({ title: 'Файл выбран', message: `Скрин для ${clientName}: ${file.name}`, color: 'blue' });
|
||||||
|
}
|
||||||
|
}}
|
||||||
|
/>
|
||||||
|
<ActionIcon
|
||||||
|
variant="light"
|
||||||
|
color={order?.files && order.files.length > 0 ? "teal" : "gray"}
|
||||||
|
size="sm"
|
||||||
|
title="Прикрепить скрин подтверждения заказа"
|
||||||
|
onClick={() => document.getElementById(`file-${clientName}`)?.click()}
|
||||||
|
>
|
||||||
|
<IconPaperclip size={14} />
|
||||||
|
</ActionIcon>
|
||||||
|
|
||||||
|
<ClientSettingsPopover
|
||||||
|
clientName={clientName}
|
||||||
|
order={order}
|
||||||
|
updateClientMeta={updateClientMeta}
|
||||||
|
isLocked={inputsDisabled}
|
||||||
|
/>
|
||||||
|
</Group>
|
||||||
</Group>
|
</Group>
|
||||||
|
|
||||||
{branch && (
|
{branch && (
|
||||||
|
|
@ -380,15 +406,20 @@ export default function OrdersPage({ onError }: { onError: (msg: string) => void
|
||||||
|
|
||||||
<Textarea
|
<Textarea
|
||||||
size="xs"
|
size="xs"
|
||||||
placeholder={hasOrderItems && !isReadOnly ? "Обязательный коммент *" : "Комментарий..."}
|
placeholder="Комментарий (обязательно) *"
|
||||||
disabled={inputsDisabled} // 👈 Блокируем коммент для аналитика
|
disabled={inputsDisabled}
|
||||||
value={order?.manager_comment || ''}
|
value={order?.manager_comment || ''}
|
||||||
onChange={e => updateClientMeta(clientName, 'manager_comment', e.currentTarget.value)}
|
onChange={e => updateClientMeta(clientName, 'manager_comment', e.currentTarget.value)}
|
||||||
autosize
|
autosize
|
||||||
minRows={1}
|
minRows={1}
|
||||||
maxRows={3}
|
maxRows={3}
|
||||||
error={!isReadOnly && isCommentMissing} // Ошибку аналитику тоже не светим
|
error={!hasComment}
|
||||||
/>
|
/>
|
||||||
|
{!hasComment && (
|
||||||
|
<Text size="10px" c="red" mt={2} ta="left">
|
||||||
|
Заполните комментарий для разблокировки
|
||||||
|
</Text>
|
||||||
|
)}
|
||||||
</Table.Th>
|
</Table.Th>
|
||||||
)
|
)
|
||||||
})}
|
})}
|
||||||
|
|
@ -427,12 +458,18 @@ export default function OrdersPage({ onError }: { onError: (msg: string) => void
|
||||||
|
|
||||||
{filteredClients.map(c => {
|
{filteredClients.map(c => {
|
||||||
const clientName = c.google_data.name;
|
const clientName = c.google_data.name;
|
||||||
const item = editableOrders[clientName]?.items?.find(i => i.nomenclature_name === nom.name);
|
const order = editableOrders[clientName];
|
||||||
|
const hasComment = !!order?.manager_comment && order.manager_comment.trim() !== '';
|
||||||
|
|
||||||
|
// Блокируем инпуты номенклатуры, если дедлайн/чтение ИЛИ не заполнен комментарий
|
||||||
|
const isNomenclatureDisabled = inputsDisabled || !hasComment;
|
||||||
|
|
||||||
|
const item = order?.items?.find(i => i.nomenclature_name === nom.name);
|
||||||
return (
|
return (
|
||||||
<Table.Td key={clientName} align="center">
|
<Table.Td key={clientName} align="center">
|
||||||
<CellInput
|
<CellInput
|
||||||
initialValue={item?.quantity || null}
|
initialValue={item?.quantity || null}
|
||||||
disabled={inputsDisabled} // 👈 Блокируем инпуты
|
disabled={isNomenclatureDisabled}
|
||||||
onCommit={(val) => handleQuantityChange(clientName, nom, val)}
|
onCommit={(val) => handleQuantityChange(clientName, nom, val)}
|
||||||
/>
|
/>
|
||||||
</Table.Td>
|
</Table.Td>
|
||||||
|
|
@ -455,7 +492,6 @@ export default function OrdersPage({ onError }: { onError: (msg: string) => void
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
// Меню параметров (отключается, если isLocked = true)
|
|
||||||
function ClientSettingsPopover({ clientName, order, updateClientMeta, isLocked }: any) {
|
function ClientSettingsPopover({ clientName, order, updateClientMeta, isLocked }: any) {
|
||||||
return (
|
return (
|
||||||
<HoverCard width={300} position="bottom" withArrow shadow="md" openDelay={200} closeDelay={300}>
|
<HoverCard width={300} position="bottom" withArrow shadow="md" openDelay={200} closeDelay={300}>
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue