add customer name, service info, second pickup location, and structured address fields to deliveries

This commit is contained in:
Egor Pozharov
2026-04-16 20:16:21 +06:00
parent 7f775abf6a
commit ce6ea377ce
16 changed files with 852 additions and 77 deletions

View File

@@ -7,11 +7,20 @@ interface BackendDelivery {
id: string;
date: string; // YYYY-MM-DD from pgtype.Date
pickup_location: PickupLocation;
pickup_location_2: PickupLocation | null;
product_name: string;
product_name_2: string | null;
customer_name: string;
address: string;
street: string;
house: string;
apartment: string | null;
entrance: string | null;
floor: string | null;
phone: string;
additional_phone: string | null;
has_elevator: boolean;
service_info: string | null;
comment: string;
status: DeliveryStatus;
created_at: string; // ISO timestamp
@@ -51,11 +60,20 @@ function mapBackendToFrontend(backend: BackendDelivery): Delivery {
id: backend.id,
date: backendDateToFrontend(backend.date),
pickupLocation: backend.pickup_location,
pickupLocation2: backend.pickup_location_2 || undefined,
productName: backend.product_name,
productName2: backend.product_name_2 || undefined,
customerName: backend.customer_name,
address: backend.address,
street: backend.street,
house: backend.house,
apartment: backend.apartment || undefined,
entrance: backend.entrance || undefined,
floor: backend.floor || undefined,
phone: backend.phone,
additionalPhone: backend.additional_phone || undefined,
hasElevator: backend.has_elevator,
serviceInfo: backend.service_info || undefined,
comment: backend.comment,
status: backend.status,
createdAt: new Date(backend.created_at).getTime(),
@@ -96,11 +114,20 @@ export const deliveriesApi = {
const payload = {
date: data.date,
pickup_location: data.pickupLocation,
pickup_location_2: data.pickupLocation2 || null,
product_name: data.productName,
product_name_2: data.productName2 || null,
customer_name: data.customerName,
address: data.address,
street: data.street,
house: data.house,
apartment: data.apartment || null,
entrance: data.entrance || null,
floor: data.floor || null,
phone: data.phone,
additional_phone: data.additionalPhone || '',
additional_phone: data.additionalPhone || null,
has_elevator: data.hasElevator,
service_info: data.serviceInfo || null,
comment: data.comment,
};
const response = await api.post<CreateDeliveryResponse>('/api/deliveries', payload);
@@ -115,11 +142,20 @@ export const deliveriesApi = {
const payload = {
date: data.date,
pickup_location: data.pickupLocation,
pickup_location_2: data.pickupLocation2 || null,
product_name: data.productName,
product_name_2: data.productName2 || null,
customer_name: data.customerName,
address: data.address,
street: data.street,
house: data.house,
apartment: data.apartment || null,
entrance: data.entrance || null,
floor: data.floor || null,
phone: data.phone,
additional_phone: data.additionalPhone || '',
additional_phone: data.additionalPhone || null,
has_elevator: data.hasElevator,
service_info: data.serviceInfo || null,
comment: data.comment,
};
await api.patch<UpdateDeliveryResponse>(`/api/deliveries/${id}`, payload);