Refactor Dewar service methods and improve field handling

Updated Dewar API methods to use protected endpoints for enhanced security and consistency. Added `pgroups` handling in various frontend components and modified the LogisticsView contact field for clarity. Simplified backend router imports for better readability.
This commit is contained in:
GotthardG
2025-01-30 13:39:49 +01:00
parent 44582cf38e
commit c2215860bf
20 changed files with 304 additions and 262 deletions

View File

@ -48,11 +48,6 @@ const ShipmentDetails: React.FC<ShipmentDetailsProps> = ({
tracking_number: '',
number_of_pucks: 0,
number_of_samples: 0,
status: 'In preparation',
ready_date: null,
shipping_date: null,
arrival_date: null,
returning_date: null,
contact_id: selectedShipment?.contact?.id,
return_address_id: selectedShipment?.return_address?.id,
};
@ -126,16 +121,18 @@ const ShipmentDetails: React.FC<ShipmentDetailsProps> = ({
const newDewarToPost: Dewar = {
...initialNewDewarState,
...newDewar,
pgroups:activePgroup,
dewar_name: newDewar.dewar_name.trim(),
contact_id: selectedShipment?.contact?.id,
return_address_id: selectedShipment?.return_address?.id
return_address_id: selectedShipment?.return_address?.id,
status: 'active',
} as Dewar;
if (!newDewarToPost.dewar_name || !newDewarToPost.status) {
throw new Error('Missing required fields');
}
const createdDewar = await DewarsService.createOrUpdateDewarDewarsPost(selectedShipment.id, newDewarToPost);
const createdDewar = await DewarsService.createOrUpdateDewarProtectedDewarsPost(selectedShipment.id, newDewarToPost);
if (createdDewar && selectedShipment) {
const updatedShipment = await ShipmentsService.addDewarToShipmentProtectedShipmentsShipmentIdAddDewarPost(selectedShipment.id, createdDewar.id);