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 {
|
||||
Box, Table, Title, Text, Paper, Stack, Button, Group,
|
||||
NumberInput, Select, Textarea, Badge, LoadingOverlay, Card, Divider
|
||||
Select, Textarea, Badge, LoadingOverlay, Card, Divider
|
||||
} from '@mantine/core'
|
||||
import { useMediaQuery } from '@mantine/hooks'
|
||||
import { notifications } from '@mantine/notifications'
|
||||
|
|
@ -67,7 +67,6 @@ export default function OrdersPage({ onError }: OrdersPageProps) {
|
|||
loadData(false)
|
||||
}, [])
|
||||
|
||||
// Оптимизированный хендлер изменения количества с useCallback
|
||||
const handleQuantityChange = useCallback((clientName: string, nomName: string, nomType: string, qty: number | null) => {
|
||||
setEditableOrders(prev => {
|
||||
const currentOrder = prev[clientName] || { client_name: clientName, items: [] }
|
||||
|
|
@ -224,7 +223,7 @@ export default function OrdersPage({ onError }: OrdersPageProps) {
|
|||
)
|
||||
}
|
||||
|
||||
// 🚀 Мемоизированная строка таблицы для устранения лагов при вводе
|
||||
// 🚀 Мемоизированная строка с ультрабыстрыми нативными инпутами
|
||||
interface MemoizedTableRowProps {
|
||||
nom: NomenclatureItem;
|
||||
clients: any[];
|
||||
|
|
@ -243,22 +242,32 @@ const MemoizedTableRow = React.memo(({ nom, clients, editableOrders, isLocked, h
|
|||
const clientName = c.google_data.name
|
||||
const order = editableOrders[clientName]
|
||||
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 (
|
||||
<Table.Td key={clientName} align="center">
|
||||
<NumberInput
|
||||
<input
|
||||
type="number"
|
||||
disabled={isLocked}
|
||||
value={qty === null ? '' : qty}
|
||||
onChange={(val) => handleQuantityChange(
|
||||
clientName,
|
||||
nom.name,
|
||||
nom.type,
|
||||
val === '' ? null : Number(val)
|
||||
)}
|
||||
value={qty}
|
||||
min={0}
|
||||
size="xs"
|
||||
styles={{ input: { textAlign: 'center' } }}
|
||||
onChange={(e) => {
|
||||
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>
|
||||
)
|
||||
|
|
@ -352,7 +361,7 @@ function ClientCardView({ clientName, nomenclatures, editableOrders, setEditable
|
|||
<Stack gap="xs">
|
||||
{nomenclatures.map((nom) => {
|
||||
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 (
|
||||
<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="xs" c="dimmed">{nom.type}</Text>
|
||||
</Box>
|
||||
<NumberInput
|
||||
<input
|
||||
type="number"
|
||||
disabled={isLocked}
|
||||
value={qty === null ? '' : qty}
|
||||
onChange={(val) => handleQuantityChange(
|
||||
clientName,
|
||||
nom.name,
|
||||
nom.type,
|
||||
val === '' ? null : Number(val)
|
||||
)}
|
||||
value={qty}
|
||||
min={0}
|
||||
size="sm"
|
||||
style={{ width: 100 }}
|
||||
styles={{ input: { textAlign: 'center' } }}
|
||||
onChange={(e) => {
|
||||
const val = e.target.value;
|
||||
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>
|
||||
)
|
||||
|
|
|
|||
Loading…
Reference in New Issue