Connected frontend new contact, new address and shipments to backend
This commit is contained in:
@ -38,9 +38,9 @@ class Proposal(BaseModel):
|
||||
number: str
|
||||
|
||||
class Dewar(BaseModel):
|
||||
id: str
|
||||
id: Optional[str] = None
|
||||
dewar_name: str
|
||||
tracking_number: str
|
||||
tracking_number: Optional[str] = None
|
||||
number_of_pucks: int
|
||||
number_of_samples: int
|
||||
return_address: List[Address]
|
||||
@ -218,11 +218,25 @@ async def get_proposals():
|
||||
async def get_shipments():
|
||||
return shipments
|
||||
|
||||
@app.delete("/shipments/{shipment_id}", status_code=status.HTTP_204_NO_CONTENT)
|
||||
async def delete_shipment(shipment_id: str):
|
||||
global shipments # Use global variable to access the shipments list
|
||||
shipments = [shipment for shipment in shipments if shipment.shipment_id != shipment_id]
|
||||
|
||||
|
||||
@app.get("/dewars", response_model=List[Dewar])
|
||||
async def get_dewars():
|
||||
return dewars
|
||||
|
||||
@app.post("/dewars", response_model=List[Dewar], status_code=status.HTTP_201_CREATED)
|
||||
async def create_dewar(shipment: Dewar):
|
||||
dewar_id = f'SHIP-{uuid.uuid4().hex[:8].upper()}' # Generates a unique shipment ID
|
||||
shipment.id = dewar_id # Set the generated ID on the shipment object
|
||||
|
||||
dewars.append(shipment) # Add the modified shipment object to the list
|
||||
|
||||
return dewars # Return the list of all dewars
|
||||
|
||||
|
||||
# Endpoint to get the number of dewars in each shipment
|
||||
@app.get("/shipment_dewars")
|
||||
|
Reference in New Issue
Block a user