@tapcart/mobile-components 0.8.35 → 0.8.37
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/components/hooks/use-reviews.d.ts +1 -0
- package/dist/components/hooks/use-reviews.d.ts.map +1 -1
- package/dist/components/hooks/use-reviews.js +8 -2
- package/dist/components/ui/virtual-grid.d.ts +1 -2
- package/dist/components/ui/virtual-grid.d.ts.map +1 -1
- package/dist/components/ui/virtual-grid.js +2 -3
- package/dist/index.d.ts +0 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +0 -1
- package/package.json +1 -1
- package/dist/components/hooks/use-loyalty.d.ts +0 -22
- package/dist/components/hooks/use-loyalty.d.ts.map +0 -1
- package/dist/components/hooks/use-loyalty.js +0 -117
- package/dist/components/libs/loyalty/LoyaltyAdapter.d.ts +0 -101
- package/dist/components/libs/loyalty/LoyaltyAdapter.d.ts.map +0 -1
- package/dist/components/libs/loyalty/LoyaltyAdapter.js +0 -119
- package/dist/components/libs/loyalty/YotpoLoyalty.d.ts +0 -20
- package/dist/components/libs/loyalty/YotpoLoyalty.d.ts.map +0 -1
- package/dist/components/libs/loyalty/YotpoLoyalty.js +0 -527
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"use-reviews.d.ts","sourceRoot":"","sources":["../../../components/hooks/use-reviews.ts"],"names":[],"mappings":"AAIA,OAAO,EACL,iBAAiB,EACjB,cAAc,EACd,gBAAgB,EACjB,MAAM,kBAAkB,CAAA;AAGzB,KAAK,eAAe,GAAG;IACrB,OAAO,EAAE,MAAM,CAAA;IACf,SAAS,EAAE,MAAM,CAAA;IACjB,QAAQ,EAAE,MAAM,CAAA;IAChB,OAAO,CAAC,EAAE,CAAC,GAAG,EAAE,MAAM,KAAK,OAAO,CAAC,GAAG,CAAC,CAAA;IACvC,QAAQ,EAAE,SAAS,GAAG,UAAU,GAAG,QAAQ,CAAA;IAC3C,UAAU,EAAE,MAAM,CAAA;IA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;IAClB,eAAe,CAAC,EAAE,GAAG,CAAA;IACrB,oBAAoB,CAAC,EAAE,GAAG,CAAA;IAC1B,eAAe,CAAC,EAAE;QAChB,YAAY,EAAE,MAAM,CAAA;QACpB,gBAAgB,EAAE,MAAM,CAAA;KACzB,CAAA;CACF,CAAA;AAqED,wBAAgB,UAAU,CAAC,KAAK,EAAE,eAAe,GAAG,IAAI,GAAG,gBAAgB,CA6E1E;AAED,KAAK,wBAAwB,GAAG,gBAAgB,GAAG;IACjD,GAAG,EAAE,CAAC,IAAI,CAAC,EAAE,OAAO,GAAG,IAAI,KAAK,IAAI,CAAA;CACrC,CAAA;AAED,wBAAgB,kBAAkB,CAChC,KAAK,EAAE,eAAe,GAAG,IAAI,GAC5B,wBAAwB,CAuK1B"}
|
|
@@ -58,7 +58,7 @@ const mockSummaryData = {
|
|
|
58
58
|
export function useReviews(props) {
|
|
59
59
|
let url = null;
|
|
60
60
|
if (props) {
|
|
61
|
-
const { baseURL, productId, provider, dataType, searchText, ratings, topics, sortBy, ascending, perPage, page, limit, } = props;
|
|
61
|
+
const { baseURL, productId, provider, dataType, searchText, ratings, topics, sortBy, ascending, perPage, page, limit, pictured, } = props;
|
|
62
62
|
let queryParams = new URLSearchParams();
|
|
63
63
|
if (productId.length > 0) {
|
|
64
64
|
queryParams.set("id", productId);
|
|
@@ -91,6 +91,9 @@ export function useReviews(props) {
|
|
|
91
91
|
if (limit) {
|
|
92
92
|
queryParams.set("limit", String(limit));
|
|
93
93
|
}
|
|
94
|
+
if (pictured) {
|
|
95
|
+
queryParams.set("pictured", String(pictured));
|
|
96
|
+
}
|
|
94
97
|
if (dataType === null || productId === null || productId.length === 0) {
|
|
95
98
|
url = null;
|
|
96
99
|
}
|
|
@@ -116,7 +119,7 @@ export function useReviewsInfinite(props) {
|
|
|
116
119
|
let baseURL = "";
|
|
117
120
|
let queryParams = new URLSearchParams();
|
|
118
121
|
if (props) {
|
|
119
|
-
const { productId, provider, dataType, searchText, ratings, topics, sortBy, ascending, perPage, limit, } = props;
|
|
122
|
+
const { productId, provider, dataType, searchText, ratings, topics, sortBy, ascending, perPage, limit, pictured, } = props;
|
|
120
123
|
baseURL = props.baseURL;
|
|
121
124
|
if (productId.length > 0) {
|
|
122
125
|
queryParams.set("id", productId);
|
|
@@ -146,6 +149,9 @@ export function useReviewsInfinite(props) {
|
|
|
146
149
|
if (limit) {
|
|
147
150
|
queryParams.set("limit", String(limit));
|
|
148
151
|
}
|
|
152
|
+
if (pictured) {
|
|
153
|
+
queryParams.set("pictured", String(pictured));
|
|
154
|
+
}
|
|
149
155
|
if (dataType === null || productId === null || productId.length === 0) {
|
|
150
156
|
url = null;
|
|
151
157
|
}
|
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import * as React from "react";
|
|
2
2
|
import { type VariantProps } from "class-variance-authority";
|
|
3
3
|
interface GridType {
|
|
4
|
-
className: any;
|
|
5
4
|
children: React.ReactNode;
|
|
6
5
|
isLoadingMore: boolean;
|
|
7
6
|
isReachingEnd: boolean;
|
|
@@ -19,6 +18,6 @@ declare const virtualGridVariants: (props?: ({
|
|
|
19
18
|
} & import("class-variance-authority/dist/types").ClassProp) | undefined) => string;
|
|
20
19
|
export interface VirtualGridProps extends GridType, VariantProps<typeof virtualGridVariants> {
|
|
21
20
|
}
|
|
22
|
-
declare function VirtualGrid({
|
|
21
|
+
declare function VirtualGrid({ columns, children, overscan, estimatedHeight, isReachingEnd, LoaderItem, spacing, style, }: VirtualGridProps): import("react/jsx-runtime").JSX.Element;
|
|
23
22
|
export { VirtualGrid, virtualGridVariants };
|
|
24
23
|
//# sourceMappingURL=virtual-grid.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"virtual-grid.d.ts","sourceRoot":"","sources":["../../../components/ui/virtual-grid.tsx"],"names":[],"mappings":"AAEA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAA;AAC9B,OAAO,EAAO,KAAK,YAAY,EAAE,MAAM,0BAA0B,CAAA;AAMjE,UAAU,QAAQ;IAChB,
|
|
1
|
+
{"version":3,"file":"virtual-grid.d.ts","sourceRoot":"","sources":["../../../components/ui/virtual-grid.tsx"],"names":[],"mappings":"AAEA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAA;AAC9B,OAAO,EAAO,KAAK,YAAY,EAAE,MAAM,0BAA0B,CAAA;AAMjE,UAAU,QAAQ;IAChB,QAAQ,EAAE,KAAK,CAAC,SAAS,CAAA;IACzB,aAAa,EAAE,OAAO,CAAA;IACtB,aAAa,EAAE,OAAO,CAAA;IACtB,UAAU,EAAE,KAAK,CAAC,iBAAiB,CAAA;IACnC,QAAQ,CAAC,EAAE,MAAM,CAAA;IACjB,eAAe,CAAC,EAAE,MAAM,CAAA;IACxB,OAAO,CAAC,EAAE;QACR,aAAa,EAAE,MAAM,CAAA;QACrB,WAAW,EAAE,MAAM,CAAA;KACpB,CAAA;IACD,KAAK,CAAC,EAAE,KAAK,CAAC,aAAa,CAAA;CAC5B;AAED,QAAA,MAAM,mBAAmB;;mFAYvB,CAAA;AAEF,MAAM,WAAW,gBACf,SAAQ,QAAQ,EACd,YAAY,CAAC,OAAO,mBAAmB,CAAC;CAAG;AAE/C,iBAAS,WAAW,CAAC,EACnB,OAAO,EACP,QAAQ,EACR,QAAY,EACZ,eAAqB,EACrB,aAAa,EACb,UAAU,EACV,OAGC,EACD,KAAK,GACN,EAAE,gBAAgB,2CAoElB;AAED,OAAO,EAAE,WAAW,EAAE,mBAAmB,EAAE,CAAA"}
|
|
@@ -18,11 +18,10 @@ const virtualGridVariants = cva("grid", {
|
|
|
18
18
|
columns: 2,
|
|
19
19
|
},
|
|
20
20
|
});
|
|
21
|
-
function VirtualGrid({
|
|
21
|
+
function VirtualGrid({ columns, children, overscan = 4, estimatedHeight = 375, isReachingEnd, LoaderItem, spacing = {
|
|
22
22
|
horizontalGap: 7,
|
|
23
23
|
verticalGap: 16,
|
|
24
24
|
}, style, }) {
|
|
25
|
-
const NUM_LOADER_ITEMS = columns || 2;
|
|
26
25
|
const col = columns || 2;
|
|
27
26
|
const parentRef = React.useRef(document.getElementById("tc-vgsl"));
|
|
28
27
|
const childrenArray = React.Children.toArray(children);
|
|
@@ -41,7 +40,7 @@ function VirtualGrid({ className, columns, children, overscan = 4, estimatedHeig
|
|
|
41
40
|
position: "relative",
|
|
42
41
|
} }, { children: rowVirtualizer.getVirtualItems().map((virtualRow) => {
|
|
43
42
|
const rowStartIndex = virtualRow.index * col;
|
|
44
|
-
return (_jsx("div", Object.assign({ className: cn(virtualGridVariants({ columns })), style: {
|
|
43
|
+
return (_jsx("div", Object.assign({ ref: rowVirtualizer.measureElement, "data-index": virtualRow.index, className: cn(virtualGridVariants({ columns })), style: {
|
|
45
44
|
position: "absolute",
|
|
46
45
|
top: 0,
|
|
47
46
|
left: 0,
|
package/dist/index.d.ts
CHANGED
|
@@ -14,7 +14,6 @@ export * from "./components/hooks/use-shop";
|
|
|
14
14
|
export * from "./components/hooks/use-mock-products";
|
|
15
15
|
export * from "./components/hooks/use-block-conditional-rendering";
|
|
16
16
|
export * from "./components/hooks/use-mock-cart";
|
|
17
|
-
export * from "./components/hooks/use-infinite-wishlist";
|
|
18
17
|
export * from "./components/ui/accordion";
|
|
19
18
|
export * from "./components/ui/animate-container";
|
|
20
19
|
export * from "./components/ui/animate-number";
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../index.ts"],"names":[],"mappings":"AACA,OAAO,EACL,EAAE,EACF,GAAG,EACH,QAAQ,EACR,4BAA4B,EAC5B,cAAc,EACd,mBAAmB,EACnB,YAAY,EACZ,yBAAyB,EACzB,4BAA4B,EAC5B,YAAY,EACZ,gBAAgB,EAChB,gBAAgB,EAChB,eAAe,EACf,cAAc,EACd,oBAAoB,EACpB,kBAAkB,EAClB,kBAAkB,EAClB,gBAAgB,EAChB,eAAe,EACf,gBAAgB,EAChB,qBAAqB,EACrB,qBAAqB,EACr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A;AAC3C,cAAc,8BAA8B,CAAA;AAC5C,cAAc,wBAAwB,CAAA;AACtC,cAAc,sBAAsB,CAAA;AACpC,cAAc,sBAAsB,CAAA;AACpC,cAAc,0BAA0B,CAAA;AACxC,cAAc,uBAAuB,CAAA;AACrC,cAAc,yBAAyB,CAAA;AACvC,cAAc,8BAA8B,CAAA;AAC5C,cAAc,wBAAwB,CAAA;AACtC,cAAc,2BAA2B,CAAA;AACzC,cAAc,uBAAuB,CAAA;AACrC,cAAc,gCAAgC,CAAA;AAC9C,cAAc,0BAA0B,CAAA;AACxC,cAAc,iCAAiC,CAAA;AAC/C,cAAc,sBAAsB,CAAA;AACpC,cAAc,6BAA6B,CAAA;AAC3C,cAAc,kDAAkD,CAAA;AAChE,cAAc,gCAAgC,CAAA;AAC9C,cAAc,oCAAoC,CAAA;AAClD,cAAc,mCAAmC,CAAA;AACjD,cAAc,aAAa,CAAA;AAC3B,cAAc,6CAA6C,CAAA;AAC3D,cAAc,kDAAkD,CAAA;AAChE,cAAc,qBAAqB,CAAA;AACnC,cAAc,mCAAmC,CAAA;AACjD,cAAc,qCAAqC,CAAA;AACnD,cAAc,wBAAwB,CAAA"}
|
package/dist/index.js
CHANGED
|
@@ -15,7 +15,6 @@ export * from "./components/hooks/use-shop";
|
|
|
15
15
|
export * from "./components/hooks/use-mock-products";
|
|
16
16
|
export * from "./components/hooks/use-block-conditional-rendering";
|
|
17
17
|
export * from "./components/hooks/use-mock-cart";
|
|
18
|
-
export * from "./components/hooks/use-infinite-wishlist";
|
|
19
18
|
export * from "./components/ui/accordion";
|
|
20
19
|
export * from "./components/ui/animate-container";
|
|
21
20
|
export * from "./components/ui/animate-number";
|
package/package.json
CHANGED
|
@@ -1,22 +0,0 @@
|
|
|
1
|
-
import { LoyaltyCustomer, LoyaltyPoints, LoyaltyReward, LoyaltyReferral, LoyaltyTier, LoyaltyActivity } from "../libs/loyalty/LoyaltyAdapter";
|
|
2
|
-
type useLoyaltyOptions = {
|
|
3
|
-
integrationProvider?: "yotpo" | "custom";
|
|
4
|
-
};
|
|
5
|
-
declare function useLoyalty({ integrationProvider }: useLoyaltyOptions): {
|
|
6
|
-
customer: LoyaltyCustomer<Record<string, any>> | null;
|
|
7
|
-
customerTier: LoyaltyTier<Record<string, any>> | null;
|
|
8
|
-
availableActivities: LoyaltyActivity<Record<string, any>>[] | null;
|
|
9
|
-
activityHistory: LoyaltyActivity<Record<string, any>>[] | null;
|
|
10
|
-
points: LoyaltyPoints<Record<string, any>> | null;
|
|
11
|
-
rewards: LoyaltyReward<Record<string, any>>[] | null;
|
|
12
|
-
referrals: LoyaltyReferral<Record<string, any>>[] | null;
|
|
13
|
-
tiers: LoyaltyTier<Record<string, any>>[] | null;
|
|
14
|
-
createCustomer: () => Promise<void>;
|
|
15
|
-
updateCustomer: () => Promise<void>;
|
|
16
|
-
addPoints: () => Promise<void>;
|
|
17
|
-
redeemReward: () => Promise<void>;
|
|
18
|
-
recordActivity: () => Promise<void>;
|
|
19
|
-
createReferral: () => Promise<void>;
|
|
20
|
-
};
|
|
21
|
-
export { useLoyalty };
|
|
22
|
-
//# sourceMappingURL=use-loyalty.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"use-loyalty.d.ts","sourceRoot":"","sources":["../../../components/hooks/use-loyalty.ts"],"names":[],"mappings":"AAEA,OAAuB,EACrB,eAAe,EACf,aAAa,EACb,aAAa,EACb,eAAe,EACf,WAAW,EACX,eAAe,EAChB,MAAM,gCAAgC,CAAA;AAGvC,KAAK,iBAAiB,GAAG;IACvB,mBAAmB,CAAC,EAAE,OAAO,GAAG,QAAQ,CAAA;CACzC,CAAA;AAED,iBAAS,UAAU,CAAC,EAAE,mBAA6B,EAAE,EAAE,iBAAiB;;;;;;;;;;;;;;;EAmHvE;AAED,OAAO,EAAE,UAAU,EAAE,CAAA"}
|
|
@@ -1,117 +0,0 @@
|
|
|
1
|
-
"use client";
|
|
2
|
-
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
-
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
|
-
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
-
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
-
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
-
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
-
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
-
});
|
|
10
|
-
};
|
|
11
|
-
import YotpoLoyalty from "../libs/loyalty/YotpoLoyalty";
|
|
12
|
-
import { useState, useEffect, useRef } from "react";
|
|
13
|
-
function useLoyalty({ integrationProvider = "yotpo" }) {
|
|
14
|
-
const loyalty = useRef(null);
|
|
15
|
-
const [customer, setCustomer] = useState(null);
|
|
16
|
-
const [customerTier, setCustomerTier] = useState(null);
|
|
17
|
-
const [availableActivities, setAvailableActivities] = useState(null);
|
|
18
|
-
const [activityHistory, setActivityHistory] = useState(null);
|
|
19
|
-
const [points, setPoints] = useState(null);
|
|
20
|
-
const [rewards, setRewards] = useState(null);
|
|
21
|
-
const [referrals, setReferrals] = useState(null);
|
|
22
|
-
const [tiers, setTiers] = useState(null);
|
|
23
|
-
useEffect(() => {
|
|
24
|
-
if (!loyalty.current) {
|
|
25
|
-
// initialize loyalty adapter
|
|
26
|
-
if (integrationProvider === "yotpo") {
|
|
27
|
-
loyalty.current = new YotpoLoyalty();
|
|
28
|
-
}
|
|
29
|
-
else {
|
|
30
|
-
// TODO: Implement custom loyalty adapter
|
|
31
|
-
throw new Error("Custom loyalty adapter not implemented");
|
|
32
|
-
}
|
|
33
|
-
}
|
|
34
|
-
}, [integrationProvider]);
|
|
35
|
-
useEffect(() => {
|
|
36
|
-
const initData = () => __awaiter(this, void 0, void 0, function* () {
|
|
37
|
-
if (!loyalty.current) {
|
|
38
|
-
console.error("Loyalty adapter not initialized");
|
|
39
|
-
return;
|
|
40
|
-
}
|
|
41
|
-
setCustomer(yield loyalty.current.getCustomer());
|
|
42
|
-
setCustomerTier(yield loyalty.current.getCustomerTier());
|
|
43
|
-
setActivityHistory(yield loyalty.current.getActivityHistory());
|
|
44
|
-
setAvailableActivities(yield loyalty.current.getAvailableActivities());
|
|
45
|
-
setPoints(yield loyalty.current.getPointsBalance());
|
|
46
|
-
setRewards(yield loyalty.current.getRewards());
|
|
47
|
-
setReferrals(yield loyalty.current.getReferrals());
|
|
48
|
-
setTiers(yield loyalty.current.getTiers());
|
|
49
|
-
});
|
|
50
|
-
initData();
|
|
51
|
-
}, [loyalty.current]);
|
|
52
|
-
const createCustomer = () => __awaiter(this, void 0, void 0, function* () {
|
|
53
|
-
if (!loyalty.current) {
|
|
54
|
-
console.error("createCustomer: Loyalty adapter not initialized");
|
|
55
|
-
return;
|
|
56
|
-
}
|
|
57
|
-
const newCustomer = yield loyalty.current.createCustomer();
|
|
58
|
-
setCustomer(newCustomer);
|
|
59
|
-
});
|
|
60
|
-
const updateCustomer = () => __awaiter(this, void 0, void 0, function* () {
|
|
61
|
-
if (!loyalty.current) {
|
|
62
|
-
console.error("updateCustomer: Loyalty adapter not initialized");
|
|
63
|
-
return;
|
|
64
|
-
}
|
|
65
|
-
const updatedCustomer = yield loyalty.current.updateCustomer();
|
|
66
|
-
setCustomer(updatedCustomer);
|
|
67
|
-
});
|
|
68
|
-
const addPoints = () => __awaiter(this, void 0, void 0, function* () {
|
|
69
|
-
if (!loyalty.current) {
|
|
70
|
-
console.error("addPoints: Loyalty adapter not initialized");
|
|
71
|
-
return;
|
|
72
|
-
}
|
|
73
|
-
const updatedPoints = yield loyalty.current.addPoints();
|
|
74
|
-
setPoints(updatedPoints);
|
|
75
|
-
});
|
|
76
|
-
const redeemReward = () => __awaiter(this, void 0, void 0, function* () {
|
|
77
|
-
if (!loyalty.current) {
|
|
78
|
-
console.error("redeemReward: Loyalty adapter not initialized");
|
|
79
|
-
return;
|
|
80
|
-
}
|
|
81
|
-
const updatedRewards = yield loyalty.current.redeemReward();
|
|
82
|
-
setRewards(updatedRewards);
|
|
83
|
-
});
|
|
84
|
-
const recordActivity = () => __awaiter(this, void 0, void 0, function* () {
|
|
85
|
-
if (!loyalty.current) {
|
|
86
|
-
console.error("recordActivity: Loyalty adapter not initialized");
|
|
87
|
-
return;
|
|
88
|
-
}
|
|
89
|
-
const updatedActivities = yield loyalty.current.recordActivity();
|
|
90
|
-
setActivityHistory(updatedActivities);
|
|
91
|
-
});
|
|
92
|
-
const createReferral = () => __awaiter(this, void 0, void 0, function* () {
|
|
93
|
-
if (!loyalty.current) {
|
|
94
|
-
console.error("Loyalty adapter not initialized");
|
|
95
|
-
return;
|
|
96
|
-
}
|
|
97
|
-
const updatedReferrals = yield loyalty.current.createReferral();
|
|
98
|
-
setReferrals(updatedReferrals);
|
|
99
|
-
});
|
|
100
|
-
return {
|
|
101
|
-
customer,
|
|
102
|
-
customerTier,
|
|
103
|
-
availableActivities,
|
|
104
|
-
activityHistory,
|
|
105
|
-
points,
|
|
106
|
-
rewards,
|
|
107
|
-
referrals,
|
|
108
|
-
tiers,
|
|
109
|
-
createCustomer,
|
|
110
|
-
updateCustomer,
|
|
111
|
-
addPoints,
|
|
112
|
-
redeemReward,
|
|
113
|
-
recordActivity,
|
|
114
|
-
createReferral,
|
|
115
|
-
};
|
|
116
|
-
}
|
|
117
|
-
export { useLoyalty };
|
|
@@ -1,101 +0,0 @@
|
|
|
1
|
-
export interface LoyaltyCustomer<T = Record<string, any>> {
|
|
2
|
-
id: string;
|
|
3
|
-
email?: string;
|
|
4
|
-
firstName?: string;
|
|
5
|
-
lastName?: string;
|
|
6
|
-
phoneNumber?: string;
|
|
7
|
-
externalId?: string;
|
|
8
|
-
metadata?: Record<string, any>;
|
|
9
|
-
createdAt?: Date;
|
|
10
|
-
updatedAt?: Date;
|
|
11
|
-
customAttributes?: T;
|
|
12
|
-
}
|
|
13
|
-
export interface LoyaltyPoints<T = Record<string, any>> {
|
|
14
|
-
balance: number;
|
|
15
|
-
lifetimePoints?: number;
|
|
16
|
-
pendingPoints?: number;
|
|
17
|
-
expiringPoints?: {
|
|
18
|
-
amount: number;
|
|
19
|
-
expiryDate: Date;
|
|
20
|
-
}[];
|
|
21
|
-
lastUpdated?: Date;
|
|
22
|
-
customAttributes?: T;
|
|
23
|
-
}
|
|
24
|
-
export interface LoyaltyReward<T = Record<string, any>> {
|
|
25
|
-
id: string;
|
|
26
|
-
name: string;
|
|
27
|
-
description?: string;
|
|
28
|
-
pointsCost: number;
|
|
29
|
-
status: "redeemed" | "notRedeemed";
|
|
30
|
-
type: "discount" | "coupon" | "freeProduct" | "custom";
|
|
31
|
-
value?: number | string;
|
|
32
|
-
expiresAt?: Date;
|
|
33
|
-
isAvailable: boolean;
|
|
34
|
-
metadata?: Record<string, any>;
|
|
35
|
-
customAttributes?: T;
|
|
36
|
-
}
|
|
37
|
-
export interface LoyaltyActivity<T = Record<string, any>> {
|
|
38
|
-
id: string;
|
|
39
|
-
type: string;
|
|
40
|
-
points: number;
|
|
41
|
-
customerId: string;
|
|
42
|
-
status: "pending" | "completed" | "cancelled";
|
|
43
|
-
metadata?: Record<string, any>;
|
|
44
|
-
createdAt: Date;
|
|
45
|
-
customAttributes?: T;
|
|
46
|
-
title?: string;
|
|
47
|
-
details?: string;
|
|
48
|
-
reward_text?: string;
|
|
49
|
-
cta_text?: string;
|
|
50
|
-
icon?: string;
|
|
51
|
-
url?: string;
|
|
52
|
-
}
|
|
53
|
-
export interface LoyaltyTierRequirement {
|
|
54
|
-
type: "orders" | "points" | "referrals" | "amountSpent";
|
|
55
|
-
threshold: number;
|
|
56
|
-
progress: number;
|
|
57
|
-
}
|
|
58
|
-
export interface LoyaltyTier<T = Record<string, any>> {
|
|
59
|
-
id: string;
|
|
60
|
-
name: string;
|
|
61
|
-
level: number;
|
|
62
|
-
requirements: LoyaltyTierRequirement[];
|
|
63
|
-
benefits?: string[];
|
|
64
|
-
isActive: boolean;
|
|
65
|
-
metadata?: Record<string, any>;
|
|
66
|
-
customAttributes?: T;
|
|
67
|
-
}
|
|
68
|
-
export interface LoyaltyReferral<T = Record<string, any>> {
|
|
69
|
-
id: string;
|
|
70
|
-
referrerId: string;
|
|
71
|
-
referredEmail?: string;
|
|
72
|
-
status: "pending" | "completed" | "expired";
|
|
73
|
-
reward?: {
|
|
74
|
-
referrer: number | string;
|
|
75
|
-
referred: number | string;
|
|
76
|
-
};
|
|
77
|
-
createdAt: Date;
|
|
78
|
-
completedAt?: Date;
|
|
79
|
-
customAttributes?: T;
|
|
80
|
-
}
|
|
81
|
-
export default class LoyaltyAdapter {
|
|
82
|
-
adapter: string;
|
|
83
|
-
customer: LoyaltyCustomer | null;
|
|
84
|
-
constructor();
|
|
85
|
-
createCustomer(): Promise<LoyaltyCustomer>;
|
|
86
|
-
getCustomer(): Promise<LoyaltyCustomer | null>;
|
|
87
|
-
setCustomer(customer: LoyaltyCustomer): void;
|
|
88
|
-
updateCustomer(): Promise<LoyaltyCustomer | null>;
|
|
89
|
-
getPointsBalance(): Promise<LoyaltyPoints | null>;
|
|
90
|
-
addPoints(): Promise<LoyaltyPoints | null>;
|
|
91
|
-
getRewards(): Promise<LoyaltyReward[]>;
|
|
92
|
-
redeemReward(): Promise<LoyaltyReward[] | null>;
|
|
93
|
-
getAvailableActivities(): Promise<LoyaltyActivity[]>;
|
|
94
|
-
recordActivity(): Promise<LoyaltyActivity[] | null>;
|
|
95
|
-
getActivityHistory(): Promise<LoyaltyActivity[] | null>;
|
|
96
|
-
getCustomerTier(): Promise<LoyaltyTier | null>;
|
|
97
|
-
getTiers(): Promise<LoyaltyTier[]>;
|
|
98
|
-
createReferral(): Promise<LoyaltyReferral[] | null>;
|
|
99
|
-
getReferrals(): Promise<LoyaltyReferral[] | null>;
|
|
100
|
-
}
|
|
101
|
-
//# sourceMappingURL=LoyaltyAdapter.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"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,CAAC,eAAe,EAAE,GAAG,IAAI,CAAC;IAUnD,kBAAkB,IAAI,OAAO,CAAC,eAAe,EAAE,GAAG,IAAI,CAAC;IAUvD,eAAe,IAAI,OAAO,CAAC,WAAW,GAAG,IAAI,CAAC;IAU9C,QAAQ,IAAI,OAAO,CAAC,WAAW,EAAE,CAAC;IAMlC,cAAc,IAAI,OAAO,CAAC,eAAe,EAAE,GAAG,IAAI,CAAC;IAUnD,YAAY,IAAI,OAAO,CAAC,eAAe,EAAE,GAAG,IAAI,CAAC;CAOxD"}
|
|
@@ -1,119 +0,0 @@
|
|
|
1
|
-
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
2
|
-
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
3
|
-
return new (P || (P = Promise))(function (resolve, reject) {
|
|
4
|
-
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
5
|
-
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
6
|
-
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
7
|
-
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
8
|
-
});
|
|
9
|
-
};
|
|
10
|
-
export default class LoyaltyAdapter {
|
|
11
|
-
constructor() {
|
|
12
|
-
this.adapter = "unset";
|
|
13
|
-
this.customer = null;
|
|
14
|
-
// instantiate loyalty interface, noop
|
|
15
|
-
console.log(`Instantiating loyalty interface:`);
|
|
16
|
-
}
|
|
17
|
-
createCustomer() {
|
|
18
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
19
|
-
// create a customer
|
|
20
|
-
console.log(`createCustomer implementation not provided for ${this.adapter}`);
|
|
21
|
-
throw new Error(`createCustomer implementation not provided for ${this.adapter}`);
|
|
22
|
-
});
|
|
23
|
-
}
|
|
24
|
-
getCustomer() {
|
|
25
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
26
|
-
// get a single customer by key
|
|
27
|
-
console.log(`getCustomer implementation not provided for ${this.adapter}`);
|
|
28
|
-
throw new Error(`getCustomer implementation not provided for ${this.adapter}`);
|
|
29
|
-
});
|
|
30
|
-
}
|
|
31
|
-
setCustomer(customer) {
|
|
32
|
-
// set a customer
|
|
33
|
-
this.customer = customer;
|
|
34
|
-
}
|
|
35
|
-
updateCustomer() {
|
|
36
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
37
|
-
// update a customer
|
|
38
|
-
console.log(`updateCustomer implementation not provided for ${this.adapter}`);
|
|
39
|
-
throw new Error(`updateCustomer implementation not provided for ${this.adapter}`);
|
|
40
|
-
});
|
|
41
|
-
}
|
|
42
|
-
getPointsBalance() {
|
|
43
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
44
|
-
// get points
|
|
45
|
-
console.log(`getPointsBalance implementation not provided for ${this.adapter}`);
|
|
46
|
-
throw new Error(`getPointsBalance implementation not provided for ${this.adapter}`);
|
|
47
|
-
});
|
|
48
|
-
}
|
|
49
|
-
addPoints() {
|
|
50
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
51
|
-
// add points
|
|
52
|
-
console.log(`addPoints implementation not provided for ${this.adapter}`);
|
|
53
|
-
throw new Error(`addPoints implementation not provided for ${this.adapter}`);
|
|
54
|
-
});
|
|
55
|
-
}
|
|
56
|
-
getRewards() {
|
|
57
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
58
|
-
// get rewards
|
|
59
|
-
console.log(`getRewards implementation not provided for ${this.adapter}`);
|
|
60
|
-
throw new Error(`getRewards implementation not provided for ${this.adapter}`);
|
|
61
|
-
});
|
|
62
|
-
}
|
|
63
|
-
redeemReward() {
|
|
64
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
65
|
-
// redeem a reward
|
|
66
|
-
console.log(`redeemReward implementation not provided for ${this.adapter}`);
|
|
67
|
-
throw new Error(`redeemReward implementation not provided for ${this.adapter}`);
|
|
68
|
-
});
|
|
69
|
-
}
|
|
70
|
-
getAvailableActivities() {
|
|
71
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
72
|
-
// get available activities
|
|
73
|
-
console.log(`getAvailableActivities implementation not provided for ${this.adapter}`);
|
|
74
|
-
throw new Error(`getAvailableActivities implementation not provided for ${this.adapter}`);
|
|
75
|
-
});
|
|
76
|
-
}
|
|
77
|
-
recordActivity() {
|
|
78
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
79
|
-
// record activity
|
|
80
|
-
console.log(`recordActivity implementation not provided for ${this.adapter}`);
|
|
81
|
-
throw new Error(`recordActivity implementation not provided for ${this.adapter}`);
|
|
82
|
-
});
|
|
83
|
-
}
|
|
84
|
-
getActivityHistory() {
|
|
85
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
86
|
-
// record activity
|
|
87
|
-
console.log(`getActivityHistory implementation not provided for ${this.adapter}`);
|
|
88
|
-
throw new Error(`getActivityHistory implementation not provided for ${this.adapter}`);
|
|
89
|
-
});
|
|
90
|
-
}
|
|
91
|
-
getCustomerTier() {
|
|
92
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
93
|
-
// get customer tier
|
|
94
|
-
console.log(`getCustomerTier implementation not provided for ${this.adapter}`);
|
|
95
|
-
throw new Error(`getCustomerTier implementation not provided for ${this.adapter}`);
|
|
96
|
-
});
|
|
97
|
-
}
|
|
98
|
-
getTiers() {
|
|
99
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
100
|
-
// get tiers
|
|
101
|
-
console.log(`getTiers implementation not provided for ${this.adapter}`);
|
|
102
|
-
throw new Error(`getTiers implementation not provided for ${this.adapter}`);
|
|
103
|
-
});
|
|
104
|
-
}
|
|
105
|
-
createReferral() {
|
|
106
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
107
|
-
// create a referral
|
|
108
|
-
console.log(`createReferral implementation not provided for ${this.adapter}`);
|
|
109
|
-
throw new Error(`createReferral implementation not provided for ${this.adapter}`);
|
|
110
|
-
});
|
|
111
|
-
}
|
|
112
|
-
getReferrals() {
|
|
113
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
114
|
-
// get referrals
|
|
115
|
-
console.log(`getReferrals implementation not provided for ${this.adapter}`);
|
|
116
|
-
throw new Error(`getReferrals implementation not provided for ${this.adapter}`);
|
|
117
|
-
});
|
|
118
|
-
}
|
|
119
|
-
}
|
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
import LoyaltyAdapter, { LoyaltyCustomer, LoyaltyPoints, LoyaltyReward, LoyaltyActivity, LoyaltyTier, LoyaltyReferral } from "./LoyaltyAdapter";
|
|
2
|
-
export default class YotpoLoyalty extends LoyaltyAdapter {
|
|
3
|
-
adapter: string;
|
|
4
|
-
constructor();
|
|
5
|
-
createCustomer(): Promise<LoyaltyCustomer>;
|
|
6
|
-
getCustomer(): Promise<LoyaltyCustomer>;
|
|
7
|
-
updateCustomer(): Promise<LoyaltyCustomer | null>;
|
|
8
|
-
getPointsBalance(): Promise<LoyaltyPoints | null>;
|
|
9
|
-
addPoints(): Promise<LoyaltyPoints | null>;
|
|
10
|
-
getRewards(): Promise<LoyaltyReward[]>;
|
|
11
|
-
redeemReward(): Promise<LoyaltyReward[] | null>;
|
|
12
|
-
getAvailableActivities(): Promise<LoyaltyActivity[]>;
|
|
13
|
-
recordActivity(): Promise<LoyaltyActivity[] | null>;
|
|
14
|
-
getActivityHistory(): Promise<LoyaltyActivity[] | null>;
|
|
15
|
-
getCustomerTier(): Promise<LoyaltyTier | null>;
|
|
16
|
-
getTiers(): Promise<LoyaltyTier[]>;
|
|
17
|
-
createReferral(): Promise<LoyaltyReferral[] | null>;
|
|
18
|
-
getReferrals(): Promise<LoyaltyReferral[] | null>;
|
|
19
|
-
}
|
|
20
|
-
//# sourceMappingURL=YotpoLoyalty.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"YotpoLoyalty.d.ts","sourceRoot":"","sources":["../../../../components/libs/loyalty/YotpoLoyalty.tsx"],"names":[],"mappings":"AAAA,OAAO,cAAc,EAAE,EACrB,eAAe,EACf,aAAa,EACb,aAAa,EACb,eAAe,EACf,WAAW,EACX,eAAe,EAChB,MAAM,kBAAkB,CAAA;AAEzB,MAAM,CAAC,OAAO,OAAO,YAAa,SAAQ,cAAc;IACtD,OAAO,EAAE,MAAM,CAAU;;IAOnB,cAAc,IAAI,OAAO,CAAC,eAAe,CAAC;IAa1C,WAAW,IAAI,OAAO,CAAC,eAAe,CAAC;IAQvC,cAAc,IAAI,OAAO,CAAC,eAAe,GAAG,IAAI,CAAC;IAajD,gBAAgB,IAAI,OAAO,CAAC,aAAa,GAAG,IAAI,CAAC;IAoBjD,SAAS,IAAI,OAAO,CAAC,aAAa,GAAG,IAAI,CAAC;IAa1C,UAAU,IAAI,OAAO,CAAC,aAAa,EAAE,CAAC;IAiEtC,YAAY,IAAI,OAAO,CAAC,aAAa,EAAE,GAAG,IAAI,CAAC;IAsE/C,sBAAsB,IAAI,OAAO,CAAC,eAAe,EAAE,CAAC;IAkFpD,cAAc,IAAI,OAAO,CAAC,eAAe,EAAE,GAAG,IAAI,CAAC;IAyBnD,kBAAkB,IAAI,OAAO,CAAC,eAAe,EAAE,GAAG,IAAI,CAAC;IAqCvD,eAAe,IAAI,OAAO,CAAC,WAAW,GAAG,IAAI,CAAC;IA2B9C,QAAQ,IAAI,OAAO,CAAC,WAAW,EAAE,CAAC;IAsDlC,cAAc,IAAI,OAAO,CAAC,eAAe,EAAE,GAAG,IAAI,CAAC;IAiCnD,YAAY,IAAI,OAAO,CAAC,eAAe,EAAE,GAAG,IAAI,CAAC;CAqBxD"}
|
|
@@ -1,527 +0,0 @@
|
|
|
1
|
-
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
2
|
-
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
3
|
-
return new (P || (P = Promise))(function (resolve, reject) {
|
|
4
|
-
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
5
|
-
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
6
|
-
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
7
|
-
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
8
|
-
});
|
|
9
|
-
};
|
|
10
|
-
import LoyaltyAdapter from "./LoyaltyAdapter";
|
|
11
|
-
export default class YotpoLoyalty extends LoyaltyAdapter {
|
|
12
|
-
constructor() {
|
|
13
|
-
super();
|
|
14
|
-
this.adapter = "yotpo";
|
|
15
|
-
console.log("Instantiating yotpo loyalty interface");
|
|
16
|
-
}
|
|
17
|
-
createCustomer() {
|
|
18
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
19
|
-
const customer = {
|
|
20
|
-
id: "yotpo-customer-1",
|
|
21
|
-
email: "customer@example.com",
|
|
22
|
-
firstName: "John",
|
|
23
|
-
lastName: "Doe",
|
|
24
|
-
createdAt: new Date(),
|
|
25
|
-
updatedAt: new Date(),
|
|
26
|
-
};
|
|
27
|
-
this.setCustomer(customer);
|
|
28
|
-
return customer;
|
|
29
|
-
});
|
|
30
|
-
}
|
|
31
|
-
getCustomer() {
|
|
32
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
33
|
-
if (!this.customer) {
|
|
34
|
-
return this.createCustomer();
|
|
35
|
-
}
|
|
36
|
-
else {
|
|
37
|
-
return this.customer;
|
|
38
|
-
}
|
|
39
|
-
});
|
|
40
|
-
}
|
|
41
|
-
updateCustomer() {
|
|
42
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
43
|
-
if (!this.customer) {
|
|
44
|
-
console.error("No customer found");
|
|
45
|
-
return null;
|
|
46
|
-
}
|
|
47
|
-
else {
|
|
48
|
-
this.customer.email = "updated@example.com";
|
|
49
|
-
this.customer.firstName = "John";
|
|
50
|
-
this.customer.lastName = "Updated";
|
|
51
|
-
this.customer.updatedAt = new Date();
|
|
52
|
-
return this.customer;
|
|
53
|
-
}
|
|
54
|
-
});
|
|
55
|
-
}
|
|
56
|
-
getPointsBalance() {
|
|
57
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
58
|
-
if (!this.customer) {
|
|
59
|
-
console.error("No customer found");
|
|
60
|
-
return null;
|
|
61
|
-
}
|
|
62
|
-
else {
|
|
63
|
-
return {
|
|
64
|
-
balance: 500,
|
|
65
|
-
lifetimePoints: 1000,
|
|
66
|
-
pendingPoints: 50,
|
|
67
|
-
expiringPoints: [
|
|
68
|
-
{
|
|
69
|
-
amount: 100,
|
|
70
|
-
expiryDate: new Date(Date.now() + 30 * 24 * 60 * 60 * 1000), // 30 days from now
|
|
71
|
-
},
|
|
72
|
-
],
|
|
73
|
-
lastUpdated: new Date(),
|
|
74
|
-
};
|
|
75
|
-
}
|
|
76
|
-
});
|
|
77
|
-
}
|
|
78
|
-
addPoints() {
|
|
79
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
80
|
-
if (!this.customer) {
|
|
81
|
-
console.error("No customer found");
|
|
82
|
-
return null;
|
|
83
|
-
}
|
|
84
|
-
else {
|
|
85
|
-
return {
|
|
86
|
-
balance: 600,
|
|
87
|
-
lifetimePoints: 1100,
|
|
88
|
-
lastUpdated: new Date(),
|
|
89
|
-
};
|
|
90
|
-
}
|
|
91
|
-
});
|
|
92
|
-
}
|
|
93
|
-
getRewards() {
|
|
94
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
95
|
-
return [
|
|
96
|
-
{
|
|
97
|
-
id: "reward-1",
|
|
98
|
-
name: "$5 Off",
|
|
99
|
-
description: "Get $5 off your next purchase",
|
|
100
|
-
pointsCost: 500,
|
|
101
|
-
type: "discount",
|
|
102
|
-
value: "code-5-off",
|
|
103
|
-
isAvailable: true,
|
|
104
|
-
status: "redeemed",
|
|
105
|
-
},
|
|
106
|
-
{
|
|
107
|
-
id: "reward-2",
|
|
108
|
-
name: "15% Off Order",
|
|
109
|
-
description: "Save 15% on your entire order",
|
|
110
|
-
pointsCost: 1000,
|
|
111
|
-
type: "discount",
|
|
112
|
-
value: "code-15-off",
|
|
113
|
-
isAvailable: true,
|
|
114
|
-
status: "notRedeemed",
|
|
115
|
-
},
|
|
116
|
-
{
|
|
117
|
-
id: "reward-3",
|
|
118
|
-
name: "Free Shipping",
|
|
119
|
-
description: "Get free shipping on your next order",
|
|
120
|
-
pointsCost: 300,
|
|
121
|
-
type: "discount",
|
|
122
|
-
value: "code-free-shipping",
|
|
123
|
-
isAvailable: true,
|
|
124
|
-
status: "notRedeemed",
|
|
125
|
-
},
|
|
126
|
-
{
|
|
127
|
-
id: "reward-4",
|
|
128
|
-
name: "Free Product",
|
|
129
|
-
description: "Get a free mystery gift with your next purchase",
|
|
130
|
-
pointsCost: 750,
|
|
131
|
-
type: "freeProduct",
|
|
132
|
-
value: "mystery-gift-001",
|
|
133
|
-
isAvailable: true,
|
|
134
|
-
status: "redeemed",
|
|
135
|
-
},
|
|
136
|
-
{
|
|
137
|
-
id: "reward-5",
|
|
138
|
-
name: "Early Access",
|
|
139
|
-
description: "Get 24-hour early access to our next sale",
|
|
140
|
-
pointsCost: 1500,
|
|
141
|
-
type: "custom",
|
|
142
|
-
value: "code-early-access",
|
|
143
|
-
isAvailable: true,
|
|
144
|
-
status: "redeemed",
|
|
145
|
-
},
|
|
146
|
-
{
|
|
147
|
-
id: "reward-6",
|
|
148
|
-
name: "Birthday Double Points",
|
|
149
|
-
description: "Earn 2x points during your birthday month",
|
|
150
|
-
pointsCost: 2000,
|
|
151
|
-
type: "custom",
|
|
152
|
-
value: "code-birthday-double-points",
|
|
153
|
-
isAvailable: false,
|
|
154
|
-
status: "redeemed",
|
|
155
|
-
},
|
|
156
|
-
];
|
|
157
|
-
});
|
|
158
|
-
}
|
|
159
|
-
redeemReward() {
|
|
160
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
161
|
-
if (!this.customer) {
|
|
162
|
-
console.error("No customer found");
|
|
163
|
-
return null;
|
|
164
|
-
}
|
|
165
|
-
else {
|
|
166
|
-
return [
|
|
167
|
-
{
|
|
168
|
-
id: "reward-1",
|
|
169
|
-
name: "$5 Off",
|
|
170
|
-
description: "Get $5 off your next purchase",
|
|
171
|
-
pointsCost: 500,
|
|
172
|
-
type: "discount",
|
|
173
|
-
value: "code-5-off",
|
|
174
|
-
isAvailable: false,
|
|
175
|
-
status: "redeemed",
|
|
176
|
-
},
|
|
177
|
-
{
|
|
178
|
-
id: "reward-2",
|
|
179
|
-
name: "15% Off Order",
|
|
180
|
-
description: "Save 15% on your entire order",
|
|
181
|
-
pointsCost: 1000,
|
|
182
|
-
type: "discount",
|
|
183
|
-
value: "code-15-off",
|
|
184
|
-
isAvailable: true,
|
|
185
|
-
status: "notRedeemed",
|
|
186
|
-
},
|
|
187
|
-
{
|
|
188
|
-
id: "reward-3",
|
|
189
|
-
name: "Free Shipping",
|
|
190
|
-
description: "Get free shipping on your next order",
|
|
191
|
-
pointsCost: 300,
|
|
192
|
-
type: "discount",
|
|
193
|
-
value: "code-free-shipping",
|
|
194
|
-
isAvailable: true,
|
|
195
|
-
status: "notRedeemed",
|
|
196
|
-
},
|
|
197
|
-
{
|
|
198
|
-
id: "reward-4",
|
|
199
|
-
name: "Free Product",
|
|
200
|
-
description: "Get a free mystery gift with your next purchase",
|
|
201
|
-
pointsCost: 750,
|
|
202
|
-
type: "freeProduct",
|
|
203
|
-
value: "mystery-gift-001",
|
|
204
|
-
isAvailable: true,
|
|
205
|
-
status: "redeemed",
|
|
206
|
-
},
|
|
207
|
-
{
|
|
208
|
-
id: "reward-5",
|
|
209
|
-
name: "Early Access",
|
|
210
|
-
description: "Get 24-hour early access to our next sale",
|
|
211
|
-
pointsCost: 1500,
|
|
212
|
-
type: "custom",
|
|
213
|
-
value: "code-early-access",
|
|
214
|
-
isAvailable: true,
|
|
215
|
-
status: "redeemed",
|
|
216
|
-
},
|
|
217
|
-
{
|
|
218
|
-
id: "reward-6",
|
|
219
|
-
name: "Birthday Double Points",
|
|
220
|
-
description: "Earn 2x points during your birthday month",
|
|
221
|
-
pointsCost: 2000,
|
|
222
|
-
type: "custom",
|
|
223
|
-
value: "code-birthday-double-points",
|
|
224
|
-
isAvailable: false,
|
|
225
|
-
status: "redeemed",
|
|
226
|
-
},
|
|
227
|
-
];
|
|
228
|
-
}
|
|
229
|
-
});
|
|
230
|
-
}
|
|
231
|
-
getAvailableActivities() {
|
|
232
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
233
|
-
if (!this.customer) {
|
|
234
|
-
console.error("No customer found");
|
|
235
|
-
return [];
|
|
236
|
-
}
|
|
237
|
-
else {
|
|
238
|
-
return [
|
|
239
|
-
{
|
|
240
|
-
id: "act_123456",
|
|
241
|
-
type: "download_app",
|
|
242
|
-
points: 100,
|
|
243
|
-
customerId: "yotpo-customer-1",
|
|
244
|
-
status: "completed",
|
|
245
|
-
title: "Download App",
|
|
246
|
-
details: "Lorem ipsum dolor sit amet.",
|
|
247
|
-
reward_text: "100 Points",
|
|
248
|
-
cta_text: "Download",
|
|
249
|
-
icon: "https://picsum.photos/200",
|
|
250
|
-
url: "https://www.apple.com/app-store/",
|
|
251
|
-
metadata: {
|
|
252
|
-
platform: "ios",
|
|
253
|
-
appVersion: "1.0.0",
|
|
254
|
-
},
|
|
255
|
-
createdAt: new Date("2024-03-15T10:30:00Z"),
|
|
256
|
-
},
|
|
257
|
-
{
|
|
258
|
-
id: "act_234567",
|
|
259
|
-
type: "enable_push_notifications",
|
|
260
|
-
points: 100,
|
|
261
|
-
customerId: "yotpo-customer-1",
|
|
262
|
-
status: "pending",
|
|
263
|
-
title: "Enable Push Notifications",
|
|
264
|
-
details: "Lorem ipsum dolor sit amet.",
|
|
265
|
-
reward_text: "100 Points",
|
|
266
|
-
cta_text: "Enable",
|
|
267
|
-
icon: "https://assets.tapcart.com/default-icon-options/bell-exclamation.svg",
|
|
268
|
-
url: "https://www.apple.com/app-store/",
|
|
269
|
-
metadata: {
|
|
270
|
-
deviceType: "mobile",
|
|
271
|
-
permissionRequested: true,
|
|
272
|
-
},
|
|
273
|
-
createdAt: new Date("2024-03-15T10:31:00Z"),
|
|
274
|
-
},
|
|
275
|
-
{
|
|
276
|
-
id: "act_345678",
|
|
277
|
-
type: "create_account",
|
|
278
|
-
points: 100,
|
|
279
|
-
customerId: "yotpo-customer-1",
|
|
280
|
-
status: "completed",
|
|
281
|
-
title: "Create Account",
|
|
282
|
-
details: "Lorem ipsum dolor sit amet.",
|
|
283
|
-
reward_text: "100 Points",
|
|
284
|
-
cta_text: "Create",
|
|
285
|
-
icon: "https://assets.tapcart.com/default-icon-options/user.svg",
|
|
286
|
-
url: "https://www.yotpo.com",
|
|
287
|
-
metadata: {
|
|
288
|
-
registrationType: "email",
|
|
289
|
-
isVerified: true,
|
|
290
|
-
},
|
|
291
|
-
createdAt: new Date("2024-03-15T10:29:00Z"),
|
|
292
|
-
},
|
|
293
|
-
{
|
|
294
|
-
id: "act_456789",
|
|
295
|
-
type: "follow_tiktok",
|
|
296
|
-
points: 100,
|
|
297
|
-
customerId: "yotpo-customer-1",
|
|
298
|
-
status: "pending",
|
|
299
|
-
title: "Follow Tiktok",
|
|
300
|
-
details: "Lorem ipsum dolor sit amet.",
|
|
301
|
-
reward_text: "100 Points",
|
|
302
|
-
cta_text: "Follow",
|
|
303
|
-
icon: "https://assets.tapcart.com/default-icon-options/heart.svg",
|
|
304
|
-
url: "https://www.tiktok.com",
|
|
305
|
-
metadata: {
|
|
306
|
-
platform: "tiktok",
|
|
307
|
-
socialAction: "follow",
|
|
308
|
-
},
|
|
309
|
-
createdAt: new Date("2024-03-15T10:32:00Z"),
|
|
310
|
-
},
|
|
311
|
-
];
|
|
312
|
-
}
|
|
313
|
-
});
|
|
314
|
-
}
|
|
315
|
-
recordActivity() {
|
|
316
|
-
var _a;
|
|
317
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
318
|
-
if (!this.customer) {
|
|
319
|
-
console.error("No customer found");
|
|
320
|
-
return null;
|
|
321
|
-
}
|
|
322
|
-
return [
|
|
323
|
-
{
|
|
324
|
-
id: "activity-1",
|
|
325
|
-
type: "purchase",
|
|
326
|
-
points: 100,
|
|
327
|
-
customerId: this.customer.id,
|
|
328
|
-
status: "completed",
|
|
329
|
-
createdAt: new Date(),
|
|
330
|
-
},
|
|
331
|
-
{
|
|
332
|
-
id: "activity-2",
|
|
333
|
-
type: "purchase",
|
|
334
|
-
points: 100,
|
|
335
|
-
customerId: (_a = this.customer) === null || _a === void 0 ? void 0 : _a.id,
|
|
336
|
-
status: "completed",
|
|
337
|
-
createdAt: new Date(),
|
|
338
|
-
},
|
|
339
|
-
];
|
|
340
|
-
});
|
|
341
|
-
}
|
|
342
|
-
getActivityHistory() {
|
|
343
|
-
var _a, _b, _c;
|
|
344
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
345
|
-
if (!this.customer) {
|
|
346
|
-
console.error("No customer found");
|
|
347
|
-
return null;
|
|
348
|
-
}
|
|
349
|
-
else {
|
|
350
|
-
return [
|
|
351
|
-
{
|
|
352
|
-
id: "activity-3",
|
|
353
|
-
title: "Made a purchase",
|
|
354
|
-
type: "purchase",
|
|
355
|
-
points: 100,
|
|
356
|
-
customerId: (_a = this.customer) === null || _a === void 0 ? void 0 : _a.id,
|
|
357
|
-
status: "completed",
|
|
358
|
-
createdAt: new Date(),
|
|
359
|
-
},
|
|
360
|
-
{
|
|
361
|
-
id: "activity-1",
|
|
362
|
-
title: "Free shipping",
|
|
363
|
-
type: "redeem",
|
|
364
|
-
points: -1500,
|
|
365
|
-
customerId: (_b = this.customer) === null || _b === void 0 ? void 0 : _b.id,
|
|
366
|
-
status: "completed",
|
|
367
|
-
createdAt: new Date(),
|
|
368
|
-
},
|
|
369
|
-
{
|
|
370
|
-
id: "activity-2",
|
|
371
|
-
title: "Free product",
|
|
372
|
-
type: "redeem",
|
|
373
|
-
points: -1500,
|
|
374
|
-
customerId: (_c = this.customer) === null || _c === void 0 ? void 0 : _c.id,
|
|
375
|
-
status: "pending",
|
|
376
|
-
createdAt: new Date(),
|
|
377
|
-
},
|
|
378
|
-
];
|
|
379
|
-
}
|
|
380
|
-
});
|
|
381
|
-
}
|
|
382
|
-
getCustomerTier() {
|
|
383
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
384
|
-
if (!this.customer) {
|
|
385
|
-
console.error("No customer found");
|
|
386
|
-
return null;
|
|
387
|
-
}
|
|
388
|
-
else {
|
|
389
|
-
return {
|
|
390
|
-
id: "tier-1",
|
|
391
|
-
name: "Bronze",
|
|
392
|
-
level: 1,
|
|
393
|
-
requirements: [
|
|
394
|
-
{
|
|
395
|
-
type: "points",
|
|
396
|
-
threshold: 0,
|
|
397
|
-
progress: 200,
|
|
398
|
-
},
|
|
399
|
-
{
|
|
400
|
-
type: "orders",
|
|
401
|
-
threshold: 1,
|
|
402
|
-
progress: 3,
|
|
403
|
-
},
|
|
404
|
-
],
|
|
405
|
-
benefits: ["Free Shipping", "Priority Support"],
|
|
406
|
-
isActive: true,
|
|
407
|
-
};
|
|
408
|
-
}
|
|
409
|
-
});
|
|
410
|
-
}
|
|
411
|
-
getTiers() {
|
|
412
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
413
|
-
return [
|
|
414
|
-
{
|
|
415
|
-
id: "tier-1",
|
|
416
|
-
name: "Bronze",
|
|
417
|
-
level: 1,
|
|
418
|
-
requirements: [
|
|
419
|
-
{
|
|
420
|
-
type: "points",
|
|
421
|
-
threshold: 1000,
|
|
422
|
-
progress: 200,
|
|
423
|
-
},
|
|
424
|
-
],
|
|
425
|
-
isActive: true,
|
|
426
|
-
},
|
|
427
|
-
{
|
|
428
|
-
id: "tier-2",
|
|
429
|
-
name: "Silver",
|
|
430
|
-
level: 2,
|
|
431
|
-
requirements: [
|
|
432
|
-
{
|
|
433
|
-
type: "orders",
|
|
434
|
-
threshold: 10,
|
|
435
|
-
progress: 3,
|
|
436
|
-
},
|
|
437
|
-
{
|
|
438
|
-
type: "referrals",
|
|
439
|
-
threshold: 5,
|
|
440
|
-
progress: 2,
|
|
441
|
-
},
|
|
442
|
-
{
|
|
443
|
-
type: "amountSpent",
|
|
444
|
-
threshold: 100,
|
|
445
|
-
progress: 50,
|
|
446
|
-
},
|
|
447
|
-
],
|
|
448
|
-
isActive: false,
|
|
449
|
-
},
|
|
450
|
-
{
|
|
451
|
-
id: "tier-3",
|
|
452
|
-
name: "Gold",
|
|
453
|
-
level: 3,
|
|
454
|
-
requirements: [
|
|
455
|
-
{
|
|
456
|
-
type: "points",
|
|
457
|
-
threshold: 5000,
|
|
458
|
-
progress: 2000,
|
|
459
|
-
},
|
|
460
|
-
],
|
|
461
|
-
isActive: false,
|
|
462
|
-
},
|
|
463
|
-
];
|
|
464
|
-
});
|
|
465
|
-
}
|
|
466
|
-
createReferral() {
|
|
467
|
-
var _a, _b;
|
|
468
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
469
|
-
if (!this.customer) {
|
|
470
|
-
console.error("No customer found");
|
|
471
|
-
return null;
|
|
472
|
-
}
|
|
473
|
-
else {
|
|
474
|
-
return [
|
|
475
|
-
{
|
|
476
|
-
id: "referral-1",
|
|
477
|
-
referrerId: (_a = this.customer) === null || _a === void 0 ? void 0 : _a.id,
|
|
478
|
-
referredEmail: "friend@example.com",
|
|
479
|
-
status: "completed",
|
|
480
|
-
reward: {
|
|
481
|
-
referrer: 100,
|
|
482
|
-
referred: 50,
|
|
483
|
-
},
|
|
484
|
-
createdAt: new Date(),
|
|
485
|
-
completedAt: new Date(),
|
|
486
|
-
},
|
|
487
|
-
{
|
|
488
|
-
id: "referral-2",
|
|
489
|
-
referrerId: (_b = this.customer) === null || _b === void 0 ? void 0 : _b.id,
|
|
490
|
-
referredEmail: "friend@example.com",
|
|
491
|
-
status: "completed",
|
|
492
|
-
reward: {
|
|
493
|
-
referrer: 100,
|
|
494
|
-
referred: 50,
|
|
495
|
-
},
|
|
496
|
-
createdAt: new Date(),
|
|
497
|
-
},
|
|
498
|
-
];
|
|
499
|
-
}
|
|
500
|
-
});
|
|
501
|
-
}
|
|
502
|
-
getReferrals() {
|
|
503
|
-
var _a;
|
|
504
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
505
|
-
if (!this.customer) {
|
|
506
|
-
console.error("No customer found");
|
|
507
|
-
return null;
|
|
508
|
-
}
|
|
509
|
-
else {
|
|
510
|
-
return [
|
|
511
|
-
{
|
|
512
|
-
id: "referral-1",
|
|
513
|
-
referrerId: (_a = this.customer) === null || _a === void 0 ? void 0 : _a.id,
|
|
514
|
-
referredEmail: "friend@example.com",
|
|
515
|
-
status: "completed",
|
|
516
|
-
reward: {
|
|
517
|
-
referrer: 100,
|
|
518
|
-
referred: 50,
|
|
519
|
-
},
|
|
520
|
-
createdAt: new Date(),
|
|
521
|
-
completedAt: new Date(),
|
|
522
|
-
},
|
|
523
|
-
];
|
|
524
|
-
}
|
|
525
|
-
});
|
|
526
|
-
}
|
|
527
|
-
}
|