-
Notifications
You must be signed in to change notification settings - Fork 10
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
10 changed files
with
160 additions
and
25 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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<OrderItem>; | ||
|
||
/** | ||
* 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; | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
export type LocalCode = `${Lowercase<string>}-${Uppercase<string>}`; | ||
|
||
export type L10Resource = Record<string, string> & { | ||
_code: LocalCode; | ||
}; | ||
|
||
export type Locale = { | ||
/** | ||
* fa-IR, en-US, ... | ||
*/ | ||
code: LocalCode; | ||
|
||
/** | ||
* fa, en, ... | ||
*/ | ||
language: Lowercase<string>; | ||
|
||
/** | ||
* ltr, rtl | ||
*/ | ||
direction: 'rtl' | 'ltr'; | ||
}; | ||
|
||
/** | ||
* Multi language string | ||
* | ||
* {fa: 'سلام', en: 'hello'} | ||
*/ | ||
export type i18nString = Record<Lowercase<string>, string>; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
import {AlwatrDocumentObject} from './storage.js'; | ||
|
||
export type Photo = AlwatrDocumentObject & { | ||
/** | ||
* Primary Photo ID | ||
* | ||
* like full relative path (include extension) to image CDN (temporary) | ||
*/ | ||
id: string; // path/file-name.png | ||
|
||
/** | ||
* Photo extra meta information for future maintenances | ||
*/ | ||
meta: Record<string, string | number>; // meta: {order: 1233, customer: 1334} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
import type {AlwatrDocumentObject} from './storage.js'; | ||
|
||
export const genderCS = ['male', 'female'] as const; | ||
export type Gender = typeof genderCS[number]; | ||
|
||
export type User = AlwatrDocumentObject & { | ||
/** | ||
* User global unique id (verifiable) | ||
*/ | ||
id: string; | ||
|
||
/** | ||
* User full name | ||
*/ | ||
fullName: string; | ||
|
||
gender?: Gender; | ||
|
||
email?: string; | ||
phoneNumber?: string; | ||
}; |