develop #7

Merged
prashant merged 13 commits from develop into main 2026-10-23 06:48:47 +00:00
2 changed files with 61 additions and 15 deletions
Showing only changes of commit 586dcd8b95 - Show all commits

View File

@ -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

View File

@ -86,6 +86,8 @@ export const GateEntryView: React.FC = () => {
const [acceptedMt, setAcceptedMt] = useState<number>(25.0);
const [acceptedBags, setAcceptedBags] = useState<number>(500);
const [saudas, setSaudas] = useState<any[]>([]);
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<any>('/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 = () => {
/>
</div>
<div>
<label className="block font-medium text-text-muted mb-1">Sauda Contract ID (Optional)</label>
<input
type="text"
placeholder="e.g. SAUDA-001"
value={saudaId}
onChange={(e) => 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"
/>
<label className="block font-medium text-text-muted mb-1">Active Sauda (Playbook: SDA-2026-001)</label>
{saudas.length > 0 ? (
<select
value={saudaId}
onChange={(e) => {
const val = e.target.value;
setSaudaId(val);
const match = saudas.find((s: any) => (s.sauda_number === val || s.sauda_id === val));
if (match) {
const qtl = Number(match.quantity_quintals || 250);
const mt = qtl / 10;
setDispatchWeight(mt);
setBagCount(Math.round(mt * 20));
if (match.sauda_number) {
setInvoiceNo(`INV-${match.sauda_number}`);
}
}
}}
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"
>
<option value="">-- Direct Gate-In (No Sauda) --</option>
{saudas.map((s: any) => (
<option key={s.sauda_id || s.sauda_number} value={s.sauda_number || s.sauda_id}>
{s.sauda_number || s.sauda_id} — {s.supplier_name || 'Farmer'} ({((s.quantity_quintals || 0) / 10).toFixed(3)} MT / {s.commodity_code || 'SOY'})
</option>
))}
</select>
) : (
<input
type="text"
placeholder="e.g. SDA-2026-001"
value={saudaId}
onChange={(e) => 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"
/>
)}
</div>
</div>