48 lines
1.7 KiB
TypeScript
48 lines
1.7 KiB
TypeScript
|
|
//Dispatch Represents:
|
|
//- a connection between two locations
|
|
//- An agreement between a courier, a maker and a retailer to transport goods (Products) from point A (maker) to point B (retailer)
|
|
//- A dispatch has 4 statuses: offered (by a courier), requested (by a maker/retailer), accepted and archived
|
|
//- An offered dispatch will not yet have a Product, Maker, or Retailer.
|
|
//- A requested dispatch will have a Product, Maker and Retailer, but not a courier
|
|
//- A dispatch is accepted (moved from offered/requested) once all parties have accepted the conditions
|
|
//- A retailer accepts an offered route by responding with products (courier must then also confirm, but does not provide further data)
|
|
//- A courier accepts a requested route by responding with a date of arrival (the retailer must then confirm, but does not provide further data)
|
|
//- A retailer requests a dispatch by requesting a product they want to stock
|
|
//- A maker requests a dispatch by requesting to stock a product with a retailer
|
|
|
|
|
|
const DISPATCH_STATUS = ['requested', 'accepted', 'archived'] as const;
|
|
type DispatchStatus = typeof DISPATCH_STATUS[number];
|
|
|
|
type Dispatch = {
|
|
id: string;
|
|
dispatchesCode: string; //Human readable id
|
|
createdAt: string;
|
|
updatedAt: string;
|
|
|
|
maker: Maker;
|
|
retailer: Retailer;
|
|
products: Product[];
|
|
|
|
courier: User;
|
|
|
|
timeSensitive: boolean;
|
|
status: DispatchStatus[];
|
|
|
|
departureDate: string;
|
|
arrivalDate: string;
|
|
weightAllowance: number;
|
|
}
|
|
|
|
//Courier is just a person (User) and doesn't need to be its own thing. A user is a courier when they accept a dispatch as a courier
|
|
// Delete the couriers collection
|
|
|
|
type Product = {
|
|
id: string;
|
|
productTitle: string;
|
|
weight: number;
|
|
img: string;
|
|
createdAt: string;
|
|
updatedAt: string;
|
|
}; |