diff --git a/core/type/src/customer-order-management.ts b/core/type/src/customer-order-management.ts new file mode 100644 index 000000000..cd69744f4 --- /dev/null +++ b/core/type/src/customer-order-management.ts @@ -0,0 +1,82 @@ +import {i18nString} from './i18n.js'; +import {Photo} from './photo.js'; + +import type {AlwatrDocumentObject} from './storage.js'; + +export type Product = AlwatrDocumentObject & { + /** + * Product global ID + * + * like product unique code + */ + id: string; + + /** + * Product title + */ + title: i18nString; + + /** + * Product image + */ + image: Photo; +}; + +export type ProductPrice = AlwatrDocumentObject & { + /** + * Displayed price before discount + */ + price: number; + + /** + * Final price after any discount + */ + finalPrice: number; +} + +export type Order = AlwatrDocumentObject & { + /** + * Order unique code + * + * customerId-orderId + */ + id: `${number}-${number}`; + + /** + * Products list with price and qty + */ + itemList: Array; + + /** + * Delivery info + */ + delivery: OrderDelivery; + + discount: number; + discountType: typeof discountTypeCS[number]; + + totalPrice: number; + shippingPrice: number; + finalPrice: number; +}; + +// FIXME: name and values +export const shipmentTypeCS = ['x', 'y'] as const; +export const carTypeCS = ['x', 'y'] as const; +export const timePeriodCS = ['1-2w', '2-3w', '3-4w'] as const; +export const discountTypeCS = ['number', 'percent'] as const; + +export type OrderDelivery = { + recipientName: string; + recipientNationalCode: string; + address: string; + shipmentType: typeof shipmentTypeCS[number]; + carType: typeof carTypeCS[number]; + timePeriod: typeof timePeriodCS[number]; +} + +export type OrderItem = { + productId: string; + price: ProductPrice; + qty: number; +}; diff --git a/core/type/src/order.ts b/core/type/src/order.ts deleted file mode 100644 index 2ab4ad31a..000000000 --- a/core/type/src/order.ts +++ /dev/null @@ -1,16 +0,0 @@ -import type {AlwatrDocumentObject} from './storage.js'; - -export type Order = AlwatrDocumentObject & { - description: string; - itemList: Array; -}; - -export type Product = AlwatrDocumentObject & { - name: string; - description: string; - price: number; -}; - -export type ProductValue = Product & { - value: number; -};