summaryrefslogtreecommitdiff
path: root/src-migrate/common
diff options
context:
space:
mode:
authorRafi Zadanly <zadanlyr@gmail.com>2023-12-15 17:15:32 +0700
committerRafi Zadanly <zadanlyr@gmail.com>2023-12-15 17:15:32 +0700
commitc9366090153e8aba3a673b2b77cbc8acc24e59a5 (patch)
tree9bad672e511d5585bb4be5b4e3190aca7c4a16af /src-migrate/common
parenta5321d82f4b5e8404f575f1d62e92d0322d78db9 (diff)
Update promotion program feature
Diffstat (limited to 'src-migrate/common')
-rw-r--r--src-migrate/common/libs/formatCurrency.ts5
-rw-r--r--src-migrate/common/types/cart.ts70
-rw-r--r--src-migrate/common/types/productVariant.ts13
-rw-r--r--src-migrate/common/types/promotion.ts28
-rw-r--r--src-migrate/common/types/solr.ts7
5 files changed, 123 insertions, 0 deletions
diff --git a/src-migrate/common/libs/formatCurrency.ts b/src-migrate/common/libs/formatCurrency.ts
new file mode 100644
index 00000000..41db4a6f
--- /dev/null
+++ b/src-migrate/common/libs/formatCurrency.ts
@@ -0,0 +1,5 @@
+const formatCurrency = (value: number) => {
+ return value.toLocaleString('id-ID');
+};
+
+export default formatCurrency;
diff --git a/src-migrate/common/types/cart.ts b/src-migrate/common/types/cart.ts
new file mode 100644
index 00000000..15e08093
--- /dev/null
+++ b/src-migrate/common/types/cart.ts
@@ -0,0 +1,70 @@
+type Price = {
+ price: number;
+ discount_percentage: number;
+ price_discount: number;
+};
+
+export type CartProduct = {
+ id: number;
+ image: string;
+ display_name: string;
+ name: string;
+ code: string;
+ price: Price;
+ qty: number;
+ weight: number;
+ package_weight: number;
+};
+
+export type CartItem = {
+ cart_id: number;
+ quantity: number;
+ selected: boolean;
+ can_buy: boolean;
+ cart_type: 'product' | 'promotion';
+ id: number;
+ name: string;
+ stock: number;
+ weight: number;
+ attributes: string[];
+ parent: {
+ id: number;
+ name: string;
+ image: string;
+ };
+ price: Price;
+ manufacture: {
+ id: number;
+ name: string;
+ };
+ has_flashsale: boolean;
+ subtotal: number;
+
+ code?: string;
+
+ image?: string;
+ remaining_time?: number;
+ promotion_type?: {
+ value?: string;
+ label?: string;
+ };
+ limit_qty?: {
+ all?: number;
+ user?: number;
+ transaction?: number;
+ };
+ remaining_qty?: {
+ all?: number;
+ user?: number;
+ transaction?: number;
+ };
+ used_percentage?: number;
+ products?: CartProduct[];
+ free_products?: CartProduct[];
+ package_price?: number;
+};
+
+export type CartProps = {
+ product_total: number;
+ products: CartItem[];
+};
diff --git a/src-migrate/common/types/productVariant.ts b/src-migrate/common/types/productVariant.ts
new file mode 100644
index 00000000..c4aa9534
--- /dev/null
+++ b/src-migrate/common/types/productVariant.ts
@@ -0,0 +1,13 @@
+export interface IProductVariant {
+ id: number;
+ parent_id: number;
+ display_name: string;
+ image: string;
+ name: string;
+ default_code: string;
+ price: {
+ price: number;
+ discount_percentage: number;
+ price_discount: number;
+ };
+}
diff --git a/src-migrate/common/types/promotion.ts b/src-migrate/common/types/promotion.ts
new file mode 100644
index 00000000..9e62cc3f
--- /dev/null
+++ b/src-migrate/common/types/promotion.ts
@@ -0,0 +1,28 @@
+import { IProductVariant } from './productVariant';
+
+export interface IPromotion {
+ id: number;
+ program_id: number;
+ name: string;
+ type: {
+ value: string;
+ label: string;
+ };
+ limit: number;
+ limit_user: number;
+ limit_trx: number;
+ price: number;
+ total_qty: number;
+ products: {
+ product_id: number;
+ qty: number;
+ }[];
+ free_products: {
+ product_id: number;
+ qty: number;
+ }[];
+}
+
+export interface IProductVariantPromo extends IProductVariant {
+ qty: number;
+}
diff --git a/src-migrate/common/types/solr.ts b/src-migrate/common/types/solr.ts
new file mode 100644
index 00000000..d231c305
--- /dev/null
+++ b/src-migrate/common/types/solr.ts
@@ -0,0 +1,7 @@
+export type SolrResponse<T> = {
+ response: {
+ numFound: number;
+ start: number;
+ docs: T;
+ };
+};