diff --git a/compose.yaml b/compose.yaml index c6c50c4..ef3e03a 100644 --- a/compose.yaml +++ b/compose.yaml @@ -95,8 +95,6 @@ services: dockerfile: docker/Dockerfile.frontend ports: - "${PORTAL_PORT:-3000}:80" - volumes: - - ./frontend/dist:/usr/share/nginx/html:ro depends_on: backend: condition: service_healthy diff --git a/frontend/src/features/receiving/GateEntryView.tsx b/frontend/src/features/receiving/GateEntryView.tsx index bfe5ad1..1a6fe00 100644 --- a/frontend/src/features/receiving/GateEntryView.tsx +++ b/frontend/src/features/receiving/GateEntryView.tsx @@ -86,6 +86,8 @@ export const GateEntryView: React.FC = () => { const [acceptedMt, setAcceptedMt] = useState(25.0); const [acceptedBags, setAcceptedBags] = useState(500); + const [saudas, setSaudas] = useState([]); + const fetchGatePasses = useCallback(async () => { setIsLoading(true); try { @@ -109,9 +111,21 @@ export const GateEntryView: React.FC = () => { } }, []); + const fetchSaudas = useCallback(async () => { + try { + const res = await apiClient.get('/api/v1/procurement/sauda'); + if (res && res.saudas) { + setSaudas(res.saudas); + } + } catch (err) { + console.error('Failed to fetch saudas for gate entry', err); + } + }, []); + useEffect(() => { fetchGatePasses(); - }, [fetchGatePasses]); + fetchSaudas(); + }, [fetchGatePasses, fetchSaudas]); const handleCreateGatePass = async (e: React.FormEvent) => { e.preventDefault(); @@ -147,14 +161,17 @@ export const GateEntryView: React.FC = () => { e.preventDefault(); if (!selectedPass) return; + const rawGross = Number(grossWeight); + const normalizedGross = rawGross > 500 ? rawGross / 1000 : rawGross; + try { await apiClient.post('/api/v1/receiving/weighments', { gate_pass_id: selectedPass.gate_pass_id, - gross_weight_mt: Number(grossWeight), + gross_weight_mt: normalizedGross, weighbridge_operator: 'Weighbridge Operator 01', }); - setNotification({ type: 'success', message: `Gross weighment of ${grossWeight} MT recorded for ${selectedPass.vehicle_number}` }); + setNotification({ type: 'success', message: `Gross weighment of ${normalizedGross.toFixed(3)} MT recorded for ${selectedPass.vehicle_number}` }); setIsGrossModalOpen(false); fetchGatePasses(); } catch (err: any) { @@ -166,14 +183,17 @@ export const GateEntryView: React.FC = () => { e.preventDefault(); if (!selectedPass) return; + const rawTare = Number(tareWeight); + const normalizedTare = rawTare > 500 ? rawTare / 1000 : rawTare; + try { await apiClient.post(`/api/v1/receiving/weighments/${selectedPass.gate_pass_id}/tare`, { - tare_weight_mt: Number(tareWeight), + tare_weight_mt: normalizedTare, bag_tare_kg: Number(bagTareKg), packaging_material: packagingType, }); - setNotification({ type: 'success', message: `Tare weighment captured. Net weight computed for ${selectedPass.vehicle_number}` }); + setNotification({ type: 'success', message: `Tare weighment captured (${normalizedTare.toFixed(3)} MT). Net weight computed for ${selectedPass.vehicle_number}` }); setIsTareModalOpen(false); fetchGatePasses(); } catch (err: any) { @@ -533,14 +553,42 @@ export const GateEntryView: React.FC = () => { />
- - setSaudaId(e.target.value)} - className="w-full px-3 py-2 border border-card-border rounded font-mono bg-surface text-text-primary focus:outline-none focus:border-sidebar-surface" - /> + + {saudas.length > 0 ? ( + + ) : ( + setSaudaId(e.target.value)} + className="w-full px-3 py-2 border border-card-border rounded font-mono bg-surface text-text-primary focus:outline-none focus:border-sidebar-surface" + /> + )}