summaryrefslogtreecommitdiff
path: root/src-migrate/common
diff options
context:
space:
mode:
Diffstat (limited to 'src-migrate/common')
-rw-r--r--src-migrate/common/components/elements/Modal.tsx2
-rw-r--r--src-migrate/common/libs/formatCurrency.ts5
-rw-r--r--src-migrate/common/libs/parse0
-rw-r--r--src-migrate/common/types/cart.ts72
-rw-r--r--src-migrate/common/types/checkout.ts16
-rw-r--r--src-migrate/common/types/productVariant.ts13
-rw-r--r--src-migrate/common/types/promotion.ts35
-rw-r--r--src-migrate/common/types/promotionProgram.ts8
-rw-r--r--src-migrate/common/types/solr.ts7
9 files changed, 157 insertions, 1 deletions
diff --git a/src-migrate/common/components/elements/Modal.tsx b/src-migrate/common/components/elements/Modal.tsx
index b8491d2f..c9c621e0 100644
--- a/src-migrate/common/components/elements/Modal.tsx
+++ b/src-migrate/common/components/elements/Modal.tsx
@@ -37,7 +37,7 @@ const Modal = ({
const modalClassNames = clsxm(
"fixed bg-white max-h-[80vh] overflow-auto p-4 pt-0 z-[60] border-gray_r-6",
{
- "left-1/2 -translate-x-1/2 translate-y-1/2 bottom-1/2 w-11/12 md:w-1/4 lg:w-1/3 border rounded-xl": mode === 'desktop',
+ "left-1/2 -translate-x-1/2 translate-y-1/2 bottom-1/2 w-11/12 md:w-[500px] border rounded-xl": mode === 'desktop',
"left-0 w-full border-t bottom-0 rounded-t-xl": mode === 'mobile'
},
className
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/libs/parse b/src-migrate/common/libs/parse
new file mode 100644
index 00000000..e69de29b
--- /dev/null
+++ b/src-migrate/common/libs/parse
diff --git a/src-migrate/common/types/cart.ts b/src-migrate/common/types/cart.ts
new file mode 100644
index 00000000..3aceeac4
--- /dev/null
+++ b/src-migrate/common/types/cart.ts
@@ -0,0 +1,72 @@
+import { CategoryPromo } from "./promotion";
+
+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?: CategoryPromo;
+ 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/checkout.ts b/src-migrate/common/types/checkout.ts
new file mode 100644
index 00000000..dc1365d8
--- /dev/null
+++ b/src-migrate/common/types/checkout.ts
@@ -0,0 +1,16 @@
+import { CartItem } from './cart';
+
+export interface ICheckout {
+ total_purchase: number;
+ total_discount: number;
+ discount_voucher: number;
+ subtotal: number;
+ tax: number;
+ grand_total: number;
+ total_weight: {
+ kg: number;
+ g: number;
+ };
+ has_product_without_weight: boolean;
+ 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..1f8316cf
--- /dev/null
+++ b/src-migrate/common/types/promotion.ts
@@ -0,0 +1,35 @@
+import { IProductVariant } from './productVariant';
+
+export interface IPromotion {
+ id: number;
+ program_id: number;
+ name: string;
+ type: {
+ value: CategoryPromo;
+ 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;
+}
+
+export type CategoryPromo = 'bundling' | 'discount_loading' | 'merchandise';
+
+export interface ICategoryPromo {
+ value: CategoryPromo;
+ label: string;
+}
diff --git a/src-migrate/common/types/promotionProgram.ts b/src-migrate/common/types/promotionProgram.ts
new file mode 100644
index 00000000..205884b6
--- /dev/null
+++ b/src-migrate/common/types/promotionProgram.ts
@@ -0,0 +1,8 @@
+export type IPromotionProgram = {
+ id: number;
+ name: string;
+ start_time: string;
+ end_time: string;
+ applies_to: string;
+ time_left: 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;
+ };
+};