Connected frontend new contact, new address and shipments to backend

This commit is contained in:
GotthardG
2024-10-30 00:27:01 +01:00
parent c34c117a15
commit 930d551464
2 changed files with 58 additions and 21 deletions

View File

@ -1,16 +1,14 @@
// ShipmentPanel.tsx
import * as React from 'react';
import { useEffect, useState } from 'react';
import { Button, Box, Typography, IconButton } from '@mui/material';
import { Add as AddIcon, Delete as DeleteIcon, UploadFile as UploadFileIcon, Refresh as RefreshIcon } from '@mui/icons-material';
import UploadDialog from './UploadDialog'; // Ensure the file extension is correct
import UploadDialog from './UploadDialog';
import { Shipment_Input, DefaultService, OpenAPI, Dewar } from '../../openapi'; // Import relevant types
import { SxProps } from '@mui/material';
import bottleGrey from '../assets/icons/bottle-svgrepo-com-grey.svg';
import bottleYellow from '../assets/icons/bottle-svgrepo-com-yellow.svg';
import bottleGreen from '../assets/icons/bottle-svgrepo-com-green.svg';
import bottleRed from '../assets/icons/bottle-svgrepo-com-red.svg';
import { Shipment_Input, DefaultService, OpenAPI } from '../../openapi';
import bottleGrey from '/src/assets/icons/bottle-svgrepo-com-grey.svg'
import bottleYellow from '/src/assets/icons/bottle-svgrepo-com-yellow.svg'
import bottleGreen from '/src/assets/icons/bottle-svgrepo-com-green.svg'
import bottleRed from '/src/assets/icons/bottle-svgrepo-com-red.svg'
interface ShipmentPanelProps {
setCreatingShipment: (value: boolean) => void;
@ -81,6 +79,10 @@ const ShipmentPanel: React.FC<ShipmentPanelProps> = ({ setCreatingShipment, sele
const closeUploadDialog = () => setUploadDialogOpen(false);
const refreshShipments = () => fetchAndSetShipments();
const getNumberOfDewars = (shipment: Shipment_Input): number => {
return shipment.dewars ? shipment.dewars.length : 0;
};
return (
<Box sx={{ width: '90%', borderRight: '1px solid #ccc', padding: 2, ...sx }}>
{error && <Typography color="error">{error}</Typography>}
@ -151,14 +153,14 @@ const ShipmentPanel: React.FC<ShipmentPanelProps> = ({ setCreatingShipment, sele
borderRadius: '50%',
padding: '0 2px',
}}>
{shipment.number_of_dewars}
{getNumberOfDewars(shipment)} {/* Calculate number of dewars */}
</span>
</div>
<div>
<div>{shipment.shipment_name}</div>
<div style={{ fontSize: '0.6rem', color: '#ccc' }}>{shipment.shipment_date}</div>
<div style={{ fontSize: '0.6rem', color: '#ccc' }}>
Total Pucks: {shipment.dewars.reduce((total, dewar) => total + dewar.number_of_pucks, 0)}
Total Pucks: {shipment.dewars.reduce((total, dewar: Dewar) => total + dewar.number_of_pucks, 0)}
</div>
</div>
</div>