Added znzt web app
Deploy Manager App / deploy (push) Successful in 19s
Details
Deploy Manager App / deploy (push) Successful in 19s
Details
This commit is contained in:
parent
dfeee0ab5a
commit
c81aee374e
|
|
@ -1,7 +1,7 @@
|
||||||
import React, { useState, useEffect, useCallback } from 'react'
|
import React, { useState, useEffect, useCallback } from 'react'
|
||||||
import {
|
import {
|
||||||
Box, Table, Title, Text, Paper, Stack, Button, Group,
|
Box, Table, Title, Text, Paper, Stack, Button, Group,
|
||||||
NumberInput, Select, Textarea, Badge, LoadingOverlay, Card, Divider
|
Select, Textarea, Badge, LoadingOverlay, Card, Divider
|
||||||
} from '@mantine/core'
|
} from '@mantine/core'
|
||||||
import { useMediaQuery } from '@mantine/hooks'
|
import { useMediaQuery } from '@mantine/hooks'
|
||||||
import { notifications } from '@mantine/notifications'
|
import { notifications } from '@mantine/notifications'
|
||||||
|
|
@ -67,7 +67,6 @@ export default function OrdersPage({ onError }: OrdersPageProps) {
|
||||||
loadData(false)
|
loadData(false)
|
||||||
}, [])
|
}, [])
|
||||||
|
|
||||||
// Оптимизированный хендлер изменения количества с useCallback
|
|
||||||
const handleQuantityChange = useCallback((clientName: string, nomName: string, nomType: string, qty: number | null) => {
|
const handleQuantityChange = useCallback((clientName: string, nomName: string, nomType: string, qty: number | null) => {
|
||||||
setEditableOrders(prev => {
|
setEditableOrders(prev => {
|
||||||
const currentOrder = prev[clientName] || { client_name: clientName, items: [] }
|
const currentOrder = prev[clientName] || { client_name: clientName, items: [] }
|
||||||
|
|
@ -224,7 +223,7 @@ export default function OrdersPage({ onError }: OrdersPageProps) {
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
// 🚀 Мемоизированная строка таблицы для устранения лагов при вводе
|
// 🚀 Мемоизированная строка с ультрабыстрыми нативными инпутами
|
||||||
interface MemoizedTableRowProps {
|
interface MemoizedTableRowProps {
|
||||||
nom: NomenclatureItem;
|
nom: NomenclatureItem;
|
||||||
clients: any[];
|
clients: any[];
|
||||||
|
|
@ -243,22 +242,32 @@ const MemoizedTableRow = React.memo(({ nom, clients, editableOrders, isLocked, h
|
||||||
const clientName = c.google_data.name
|
const clientName = c.google_data.name
|
||||||
const order = editableOrders[clientName]
|
const order = editableOrders[clientName]
|
||||||
const item = order?.items?.find(i => i.nomenclature_name === nom.name)
|
const item = order?.items?.find(i => i.nomenclature_name === nom.name)
|
||||||
const qty = item ? item.quantity : ''
|
const qty = item && item.quantity !== null ? item.quantity : ''
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<Table.Td key={clientName} align="center">
|
<Table.Td key={clientName} align="center">
|
||||||
<NumberInput
|
<input
|
||||||
|
type="number"
|
||||||
disabled={isLocked}
|
disabled={isLocked}
|
||||||
value={qty === null ? '' : qty}
|
value={qty}
|
||||||
onChange={(val) => handleQuantityChange(
|
|
||||||
clientName,
|
|
||||||
nom.name,
|
|
||||||
nom.type,
|
|
||||||
val === '' ? null : Number(val)
|
|
||||||
)}
|
|
||||||
min={0}
|
min={0}
|
||||||
size="xs"
|
onChange={(e) => {
|
||||||
styles={{ input: { textAlign: 'center' } }}
|
const val = e.target.value;
|
||||||
|
handleQuantityChange(
|
||||||
|
clientName,
|
||||||
|
nom.name,
|
||||||
|
nom.type,
|
||||||
|
val === '' ? null : Number(val)
|
||||||
|
);
|
||||||
|
}}
|
||||||
|
style={{
|
||||||
|
width: '70px',
|
||||||
|
textAlign: 'center',
|
||||||
|
padding: '4px',
|
||||||
|
borderRadius: '4px',
|
||||||
|
border: '1px solid #ced4da',
|
||||||
|
backgroundColor: isLocked ? '#f1f3f5' : '#fff'
|
||||||
|
}}
|
||||||
/>
|
/>
|
||||||
</Table.Td>
|
</Table.Td>
|
||||||
)
|
)
|
||||||
|
|
@ -352,7 +361,7 @@ function ClientCardView({ clientName, nomenclatures, editableOrders, setEditable
|
||||||
<Stack gap="xs">
|
<Stack gap="xs">
|
||||||
{nomenclatures.map((nom) => {
|
{nomenclatures.map((nom) => {
|
||||||
const item = order?.items?.find((i) => i.nomenclature_name === nom.name)
|
const item = order?.items?.find((i) => i.nomenclature_name === nom.name)
|
||||||
const qty = item ? item.quantity : ''
|
const qty = item && item.quantity !== null ? item.quantity : ''
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<Group key={nom.name} justify="space-between" align="center">
|
<Group key={nom.name} justify="space-between" align="center">
|
||||||
|
|
@ -360,19 +369,28 @@ function ClientCardView({ clientName, nomenclatures, editableOrders, setEditable
|
||||||
<Text size="sm" fw={500}>{nom.name}</Text>
|
<Text size="sm" fw={500}>{nom.name}</Text>
|
||||||
<Text size="xs" c="dimmed">{nom.type}</Text>
|
<Text size="xs" c="dimmed">{nom.type}</Text>
|
||||||
</Box>
|
</Box>
|
||||||
<NumberInput
|
<input
|
||||||
|
type="number"
|
||||||
disabled={isLocked}
|
disabled={isLocked}
|
||||||
value={qty === null ? '' : qty}
|
value={qty}
|
||||||
onChange={(val) => handleQuantityChange(
|
|
||||||
clientName,
|
|
||||||
nom.name,
|
|
||||||
nom.type,
|
|
||||||
val === '' ? null : Number(val)
|
|
||||||
)}
|
|
||||||
min={0}
|
min={0}
|
||||||
size="sm"
|
onChange={(e) => {
|
||||||
style={{ width: 100 }}
|
const val = e.target.value;
|
||||||
styles={{ input: { textAlign: 'center' } }}
|
handleQuantityChange(
|
||||||
|
clientName,
|
||||||
|
nom.name,
|
||||||
|
nom.type,
|
||||||
|
val === '' ? null : Number(val)
|
||||||
|
);
|
||||||
|
}}
|
||||||
|
style={{
|
||||||
|
width: '80px',
|
||||||
|
textAlign: 'center',
|
||||||
|
padding: '6px',
|
||||||
|
borderRadius: '4px',
|
||||||
|
border: '1px solid #ced4da',
|
||||||
|
backgroundColor: isLocked ? '#f1f3f5' : '#fff'
|
||||||
|
}}
|
||||||
/>
|
/>
|
||||||
</Group>
|
</Group>
|
||||||
)
|
)
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue