@jsdev_ninja/core 0.12.4 → 0.12.6
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/core.cjs.js +1 -1
- package/dist/core.cjs.js.map +1 -1
- package/dist/core.es.js +54 -55
- package/dist/core.es.js.map +1 -1
- package/dist/core.umd.js +1 -1
- package/dist/core.umd.js.map +1 -1
- package/dist/entities/Cart.js +1 -1
- package/dist/entities/Order.d.ts +0 -3
- package/dist/entities/Order.d.ts.map +1 -1
- package/dist/entities/Order.js +0 -1
- package/dist/entities/Store.d.ts +2 -2
- package/dist/entities/Store.d.ts.map +1 -1
- package/dist/entities/Store.js +2 -2
- package/lib/entities/Cart.ts +1 -1
- package/lib/entities/Store.ts +4 -2
- package/lib/utils/index.ts +3 -0
- package/package.json +1 -1
package/dist/entities/Cart.js
CHANGED
|
@@ -5,7 +5,7 @@ export const CartItemProductSchema = z.object({
|
|
|
5
5
|
originalPrice: z.number().optional(),
|
|
6
6
|
finalPrice: z.number().optional(),
|
|
7
7
|
finalDiscount: z.number().optional(),
|
|
8
|
-
amount: z.number().
|
|
8
|
+
amount: z.number().positive({ message: "Quantity must be a positive number." }),
|
|
9
9
|
});
|
|
10
10
|
export const CartSchema = z.object({
|
|
11
11
|
type: z.literal("Cart"),
|
package/dist/entities/Order.d.ts
CHANGED
|
@@ -746,7 +746,6 @@ export declare const OrderSchema: z.ZodObject<{
|
|
|
746
746
|
actualAmount: z.ZodOptional<z.ZodNumber>;
|
|
747
747
|
date: z.ZodNumber;
|
|
748
748
|
deliveryDate: z.ZodOptional<z.ZodNumber>;
|
|
749
|
-
createdAt: z.ZodOptional<z.ZodNumber>;
|
|
750
749
|
client: z.ZodObject<{
|
|
751
750
|
type: z.ZodLiteral<"Profile">;
|
|
752
751
|
id: z.ZodString;
|
|
@@ -974,7 +973,6 @@ export declare const OrderSchema: z.ZodObject<{
|
|
|
974
973
|
originalAmount?: number | undefined;
|
|
975
974
|
actualAmount?: number | undefined;
|
|
976
975
|
deliveryDate?: number | undefined;
|
|
977
|
-
createdAt?: number | undefined;
|
|
978
976
|
nameOnInvoice?: string | undefined;
|
|
979
977
|
clientComment?: string | undefined;
|
|
980
978
|
}, {
|
|
@@ -1113,7 +1111,6 @@ export declare const OrderSchema: z.ZodObject<{
|
|
|
1113
1111
|
originalAmount?: number | undefined;
|
|
1114
1112
|
actualAmount?: number | undefined;
|
|
1115
1113
|
deliveryDate?: number | undefined;
|
|
1116
|
-
createdAt?: number | undefined;
|
|
1117
1114
|
nameOnInvoice?: string | undefined;
|
|
1118
1115
|
clientComment?: string | undefined;
|
|
1119
1116
|
}>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Order.d.ts","sourceRoot":"","sources":["../../lib/entities/Order.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAcxB,eAAO,MAAM,WAAW
|
|
1
|
+
{"version":3,"file":"Order.d.ts","sourceRoot":"","sources":["../../lib/entities/Order.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAcxB,eAAO,MAAM,WAAW;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EA+BtB,CAAC;AAEH,MAAM,MAAM,MAAM,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,WAAW,CAAC,CAAC"}
|
package/dist/entities/Order.js
CHANGED
|
@@ -36,7 +36,6 @@ export const OrderSchema = z.object({
|
|
|
36
36
|
actualAmount: z.number().positive().optional(), // what store charge
|
|
37
37
|
date: z.number(),
|
|
38
38
|
deliveryDate: z.coerce.number().optional(),
|
|
39
|
-
createdAt: z.number().optional(),
|
|
40
39
|
client: ProfileSchema.required({}),
|
|
41
40
|
nameOnInvoice: z.string().optional(),
|
|
42
41
|
clientComment: z.string().optional(),
|
package/dist/entities/Store.d.ts
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { z } from "zod";
|
|
2
|
-
declare const
|
|
2
|
+
export declare const clientTypesSchema: z.ZodEnum<["individual", "company"]>;
|
|
3
|
+
export declare const StoreSchema: z.ZodObject<{
|
|
3
4
|
id: z.ZodString;
|
|
4
5
|
companyId: z.ZodString;
|
|
5
6
|
name: z.ZodString;
|
|
@@ -43,5 +44,4 @@ declare const StoreSchema: z.ZodObject<{
|
|
|
43
44
|
deliveryPrice?: number | undefined;
|
|
44
45
|
}>;
|
|
45
46
|
export type TStore = z.infer<typeof StoreSchema>;
|
|
46
|
-
export {};
|
|
47
47
|
//# sourceMappingURL=Store.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Store.d.ts","sourceRoot":"","sources":["../../lib/entities/Store.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;
|
|
1
|
+
{"version":3,"file":"Store.d.ts","sourceRoot":"","sources":["../../lib/entities/Store.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAExB,eAAO,MAAM,iBAAiB,sCAAoC,CAAC;AAEnE,eAAO,MAAM,WAAW;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EActB,CAAC;AAEH,MAAM,MAAM,MAAM,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,WAAW,CAAC,CAAC"}
|
package/dist/entities/Store.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { z } from "zod";
|
|
2
|
-
const clientTypesSchema = z.enum(["individual", "company"]);
|
|
3
|
-
const StoreSchema = z.object({
|
|
2
|
+
export const clientTypesSchema = z.enum(["individual", "company"]);
|
|
3
|
+
export const StoreSchema = z.object({
|
|
4
4
|
id: z.string(),
|
|
5
5
|
companyId: z.string(),
|
|
6
6
|
name: z.string(),
|
package/lib/entities/Cart.ts
CHANGED
|
@@ -6,7 +6,7 @@ export const CartItemProductSchema = z.object({
|
|
|
6
6
|
originalPrice: z.number().optional(),
|
|
7
7
|
finalPrice: z.number().optional(),
|
|
8
8
|
finalDiscount: z.number().optional(),
|
|
9
|
-
amount: z.number().
|
|
9
|
+
amount: z.number().positive({ message: "Quantity must be a positive number." }),
|
|
10
10
|
});
|
|
11
11
|
|
|
12
12
|
export type TCartItemProduct = z.infer<typeof CartItemProductSchema>;
|
package/lib/entities/Store.ts
CHANGED
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
import { z } from "zod";
|
|
2
2
|
|
|
3
|
-
const clientTypesSchema = z.enum(["individual", "company"]);
|
|
4
|
-
|
|
3
|
+
export const clientTypesSchema = z.enum(["individual", "company"]);
|
|
4
|
+
|
|
5
|
+
export const StoreSchema = z.object({
|
|
5
6
|
id: z.string(),
|
|
6
7
|
companyId: z.string(),
|
|
7
8
|
name: z.string(),
|
|
@@ -16,4 +17,5 @@ const StoreSchema = z.object({
|
|
|
16
17
|
freeDeliveryPrice: z.number().optional(),
|
|
17
18
|
deliveryPrice: z.number().optional(),
|
|
18
19
|
});
|
|
20
|
+
|
|
19
21
|
export type TStore = z.infer<typeof StoreSchema>;
|
package/lib/utils/index.ts
CHANGED
|
@@ -51,6 +51,9 @@ export function getCartCost({
|
|
|
51
51
|
};
|
|
52
52
|
});
|
|
53
53
|
|
|
54
|
+
// calculate delivery price before
|
|
55
|
+
// check if cart cost is greater than free delivery price
|
|
56
|
+
|
|
54
57
|
const activeDiscounts = discounts.filter((discount) => {
|
|
55
58
|
if (discount.variant.variantType === "bundle") {
|
|
56
59
|
const productsTotal =
|