Added znzt web app
Deploy Manager App / deploy (push) Successful in 18s
Details
Deploy Manager App / deploy (push) Successful in 18s
Details
This commit is contained in:
parent
d3c30ecb60
commit
f95bc5936a
|
|
@ -17,21 +17,22 @@ export default function OrdersPage({ onError }: OrdersPageProps) {
|
|||
const [data, setData] = useState<FrontendOrderMatrix | null>(null)
|
||||
const [loading, setLoading] = useState(true)
|
||||
const [saving, setSaving] = useState(false)
|
||||
const [pageError, setPageError] = useState<string | null>(null)
|
||||
const [editableOrders, setEditableOrders] = useState<Record<string, MonthlyOrderClient>>({})
|
||||
|
||||
const isMobile = useMediaQuery('(max-width: 768px)')
|
||||
const [activeClientName, setActiveClientName] = useState<string | null>(null)
|
||||
const [pageError, setPageError] = useState<string | null>(null);
|
||||
|
||||
const loadData = async (preserveActive = false) => {
|
||||
try {
|
||||
setLoading(true)
|
||||
setPageError(null)
|
||||
const res = await monthlyOrdersApi.getMatrix()
|
||||
const matrix = res.data
|
||||
setData(matrix)
|
||||
|
||||
const initialMap: Record<string, MonthlyOrderClient> = {}
|
||||
matrix.clients.forEach((c, idx) => {
|
||||
matrix.clients?.forEach((c, idx) => {
|
||||
const clientName = c.google_data.name
|
||||
if (!preserveActive && idx === 0) {
|
||||
setActiveClientName(clientName)
|
||||
|
|
@ -119,7 +120,16 @@ export default function OrdersPage({ onError }: OrdersPageProps) {
|
|||
}
|
||||
|
||||
if (loading) return <LoadingOverlay visible />
|
||||
if (!data) return null
|
||||
|
||||
if (pageError) {
|
||||
return (
|
||||
<Box p="xl" ta="center">
|
||||
<Text c="red" fw={500} mb="md">{pageError}</Text>
|
||||
</Box>
|
||||
);
|
||||
}
|
||||
|
||||
if (!data) return <Text ta="center" mt="xl">Нет данных</Text>
|
||||
|
||||
return (
|
||||
<Box p={{ base: 'xs', md: 'md' }} maw={1600} mx="auto">
|
||||
|
|
@ -155,7 +165,7 @@ export default function OrdersPage({ onError }: OrdersPageProps) {
|
|||
<Stack gap="md">
|
||||
<Select
|
||||
label="Выберите клиента"
|
||||
data={data.clients.map(c => c.google_data.name)}
|
||||
data={data.clients?.map(c => c.google_data.name) || []}
|
||||
value={activeClientName}
|
||||
onChange={setActiveClientName}
|
||||
/>
|
||||
|
|
@ -163,7 +173,7 @@ export default function OrdersPage({ onError }: OrdersPageProps) {
|
|||
{activeClientName && (
|
||||
<ClientCardView
|
||||
clientName={activeClientName}
|
||||
nomenclatures={data.nomenclatures}
|
||||
nomenclatures={data.nomenclatures || []}
|
||||
editableOrders={editableOrders}
|
||||
setEditableOrders={setEditableOrders}
|
||||
handleQuantityChange={handleQuantityChange}
|
||||
|
|
@ -179,7 +189,7 @@ export default function OrdersPage({ onError }: OrdersPageProps) {
|
|||
<Table.Th style={{ minWidth: 220, position: 'sticky', left: 0, background: 'var(--mantine-color-body)', zIndex: 2 }}>
|
||||
Номенклатура
|
||||
</Table.Th>
|
||||
{data.clients.map(c => (
|
||||
{data.clients?.map(c => (
|
||||
<Table.Th key={c.google_data.name} style={{ minWidth: 180, textAlign: 'center' }}>
|
||||
{c.google_data.name}
|
||||
<BlockMeta
|
||||
|
|
@ -193,12 +203,12 @@ export default function OrdersPage({ onError }: OrdersPageProps) {
|
|||
</Table.Tr>
|
||||
</Table.Thead>
|
||||
<Table.Tbody>
|
||||
{data.nomenclatures.map(nom => (
|
||||
{data.nomenclatures?.map(nom => (
|
||||
<Table.Tr key={nom.name}>
|
||||
<Table.Td style={{ position: 'sticky', left: 0, background: 'var(--mantine-color-body)', fontWeight: 500, zIndex: 1 }}>
|
||||
{nom.name} <Text span size="xs" c="dimmed">({nom.type})</Text>
|
||||
</Table.Td>
|
||||
{data.clients.map(c => {
|
||||
{data.clients?.map(c => {
|
||||
const clientName = c.google_data.name
|
||||
const order = editableOrders[clientName]
|
||||
const item = order?.items?.find(i => i.nomenclature_name === nom.name)
|
||||
|
|
|
|||
Loading…
Reference in New Issue