@anker-in/campaign-ui 0.2.10-beta.20 → 0.2.10-beta.22
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/chat/action.d.ts +25 -0
- package/dist/components/chat/button.d.ts +3 -0
- package/dist/components/chat/chatContext.d.ts +101 -0
- package/dist/components/chat/index.d.ts +71 -0
- package/dist/components/chat/markdown.d.ts +5 -0
- package/dist/components/chat/messages.d.ts +3 -0
- package/dist/components/chat/props.d.ts +43 -0
- package/dist/components/chat/response.d.ts +4 -0
- package/dist/components/chat/suggestions.d.ts +3 -0
- package/dist/components/chat/utils.d.ts +3 -0
- package/dist/components/credits/context/const.d.ts +81 -0
- package/dist/components/credits/context/hooks/useActivities.d.ts +12 -0
- package/dist/components/credits/context/hooks/useAddressValidate.d.ts +34 -0
- package/dist/components/credits/context/hooks/useAlpcFetch.d.ts +23 -0
- package/dist/components/credits/context/hooks/useClickOutside.d.ts +3 -0
- package/dist/components/credits/context/hooks/useCopy.d.ts +5 -0
- package/dist/components/credits/context/hooks/useCountries.d.ts +8 -0
- package/dist/components/credits/context/hooks/useFirstPurchaseFinished.d.ts +1 -0
- package/dist/components/credits/context/hooks/useMyRewards.d.ts +14 -0
- package/dist/components/credits/context/hooks/useReceiptUploaded.d.ts +2 -0
- package/dist/components/credits/context/hooks/useRedeemAndBuy.d.ts +9 -0
- package/dist/components/credits/context/hooks/useRedeemCoupon.d.ts +17 -0
- package/dist/components/credits/context/hooks/useRedeemProduct.d.ts +16 -0
- package/dist/components/credits/context/hooks/useRedeemableList.d.ts +7 -0
- package/dist/components/credits/context/hooks/useSendEmailValidation.d.ts +1 -0
- package/dist/components/credits/context/hooks/useSubscribed.d.ts +1 -0
- package/dist/components/credits/context/hooks/useSubscriptions.d.ts +5 -0
- package/dist/components/credits/context/hooks/useUploadReceipt.d.ts +14 -0
- package/dist/components/credits/context/provider.d.ts +49 -0
- package/dist/components/credits/context/response.d.ts +63 -0
- package/dist/components/credits/context/utils.d.ts +25 -0
- package/dist/components/credits/creditsBanner/index.d.ts +23 -0
- package/dist/components/credits/creditsBenefits/benefitItem.d.ts +19 -0
- package/dist/components/credits/creditsBenefits/iconInfo.d.ts +2 -0
- package/dist/components/credits/creditsBenefits/index.d.ts +12 -0
- package/dist/components/credits/creditsCash/RedeemableItem.d.ts +15 -0
- package/dist/components/credits/creditsCash/index.d.ts +13 -0
- package/dist/components/credits/creditsCash/type.d.ts +47 -0
- package/dist/components/credits/creditsFaq/faqItem/FaqItem.d.ts +13 -0
- package/dist/components/credits/creditsFaq/index.d.ts +16 -0
- package/dist/components/credits/creditsInfoCard/index.d.ts +20 -0
- package/dist/components/credits/creditsRedeemList/AddressForm/CountrySelect.d.ts +14 -0
- package/dist/components/credits/creditsRedeemList/AddressForm/FormItem.d.ts +6 -0
- package/dist/components/credits/creditsRedeemList/AddressForm/Input.d.ts +13 -0
- package/dist/components/credits/creditsRedeemList/AddressForm/StateSelect.d.ts +15 -0
- package/dist/components/credits/creditsRedeemList/AddressForm/index.d.ts +2 -0
- package/dist/components/credits/creditsRedeemList/AddressForm/type.d.ts +26 -0
- package/dist/components/credits/creditsRedeemList/RedeemCouponModal.d.ts +9 -0
- package/dist/components/credits/creditsRedeemList/RedeemProductModal/Address.d.ts +20 -0
- package/dist/components/credits/creditsRedeemList/RedeemProductModal/Error.d.ts +8 -0
- package/dist/components/credits/creditsRedeemList/RedeemProductModal/Init.d.ts +11 -0
- package/dist/components/credits/creditsRedeemList/RedeemProductModal/ProductInfo.d.ts +8 -0
- package/dist/components/credits/creditsRedeemList/RedeemProductModal/Success.d.ts +13 -0
- package/dist/components/credits/creditsRedeemList/RedeemProductModal/index.d.ts +11 -0
- package/dist/components/credits/creditsRedeemList/RedeemableItem.d.ts +9 -0
- package/dist/components/credits/creditsRedeemList/index.d.ts +13 -0
- package/dist/components/credits/creditsRedeemList/type.d.ts +77 -0
- package/dist/components/credits/creditsWaysToGetCredits/index.d.ts +2 -0
- package/dist/components/credits/creditsWaysToGetCredits/type.d.ts +60 -0
- package/dist/components/credits/creditsWaysToGetCredits/useActions.d.ts +96 -0
- package/dist/components/credits/index.d.ts +10 -0
- package/dist/components/credits/modal/MyRewardsModal.d.ts +32 -0
- package/dist/components/credits/modal/activitiesModal.d.ts +32 -0
- package/dist/components/credits/modal/creditsUploadReceiptModal.d.ts +24 -0
- package/dist/components/credits/modal/loadingDots.d.ts +6 -0
- package/dist/components/credits/modal/modalContainer.d.ts +15 -0
- package/dist/components/credits/modal/rulesModal.d.ts +7 -0
- package/dist/components/credits/modal/tip.d.ts +5 -0
- package/dist/components/credits/type.d.ts +55 -0
- package/dist/components/index.d.ts +3 -0
- package/dist/debug-env.d.ts +7 -0
- package/dist/helpers/fetchResponse.d.ts +14 -0
- package/dist/helpers/fetcher.d.ts +2 -0
- package/dist/helpers/index.d.ts +2 -0
- package/dist/helpers/track.d.ts +19 -0
- package/dist/helpers/utils.d.ts +3 -0
- package/dist/index.d.mts +3 -3
- package/dist/index.d.ts +2 -494
- package/dist/index.js +1318 -4377
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +1294 -4330
- package/dist/index.mjs.map +1 -1
- package/dist/stories/chat.stories.d.ts +7 -0
- package/package.json +14 -9
- package/src/components/credits/context/hooks/useActivities.ts +1 -1
- package/src/components/credits/context/hooks/useAddressValidate.ts +1 -1
- package/src/components/credits/context/hooks/useAlpcFetch.ts +1 -1
- package/src/components/credits/context/hooks/useCountries.ts +1 -1
- package/src/components/credits/context/hooks/useMyRewards.ts +1 -1
- package/src/components/credits/context/hooks/useRedeemAndBuy.ts +2 -2
- package/src/components/credits/context/hooks/useRedeemCoupon.ts +1 -1
- package/src/components/credits/context/hooks/useRedeemProduct.ts +1 -1
- package/src/components/credits/context/hooks/useRedeemableList.ts +1 -1
- package/src/components/credits/context/hooks/useSendEmailValidation.ts +1 -1
- package/src/components/credits/context/hooks/useSubscribed.ts +1 -1
- package/src/components/credits/context/hooks/useSubscriptions.ts +1 -1
- package/src/components/credits/creditsCash/index.tsx +2 -2
- package/src/components/credits/creditsCash/type.ts +1 -1
- package/src/components/credits/creditsRedeemList/AddressForm/index.tsx +1 -1
- package/src/components/credits/creditsRedeemList/RedeemCouponModal.tsx +1 -1
- package/src/components/credits/creditsRedeemList/RedeemProductModal/Address.tsx +1 -1
- package/src/components/credits/creditsRedeemList/RedeemProductModal/ProductInfo.tsx +1 -1
- package/src/components/credits/creditsRedeemList/RedeemProductModal/index.tsx +1 -1
- package/src/components/credits/creditsRedeemList/index.tsx +1 -1
- package/src/components/credits/creditsWaysToGetCredits/useActions.ts +1 -1
- package/src/components/credits/type.ts +1 -1
- package/src/index.ts +1 -1
- package/src/styles/global.css +15 -0
- package/style.css +1 -0
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
interface Message {
|
|
3
|
+
content: string;
|
|
4
|
+
role: string;
|
|
5
|
+
name?: string;
|
|
6
|
+
scope?: any;
|
|
7
|
+
arguments?: any;
|
|
8
|
+
}
|
|
9
|
+
export interface ActionProps {
|
|
10
|
+
start?: string;
|
|
11
|
+
history: Message[];
|
|
12
|
+
addtocartHandler?: (_args: any) => Promise<any>;
|
|
13
|
+
commonRender?: string | ((_props: any) => React.ReactElement);
|
|
14
|
+
pointsExchangeCouponRender?: string | ((_props: any) => React.ReactElement);
|
|
15
|
+
gotocheckoutRender?: string | ((_props: any) => React.ReactElement);
|
|
16
|
+
gotocartRender?: string | ((_props: any) => React.ReactElement);
|
|
17
|
+
addtocartRender?: string | ((_props: any) => React.ReactElement);
|
|
18
|
+
signupRender?: string | ((_props: any) => React.ReactElement);
|
|
19
|
+
shulexRender?: string | ((_props: any) => React.ReactElement);
|
|
20
|
+
productRender?: string | ((_props: any) => React.ReactElement);
|
|
21
|
+
productRenderTipMessage?: string;
|
|
22
|
+
children?: React.ReactNode;
|
|
23
|
+
}
|
|
24
|
+
export declare const CopilotAction: ({ start, history, addtocartHandler, commonRender, pointsExchangeCouponRender, gotocheckoutRender, gotocartRender, addtocartRender, productRender, signupRender, shulexRender, children, }: ActionProps) => import("react/jsx-runtime").JSX.Element;
|
|
25
|
+
export {};
|
|
@@ -0,0 +1,101 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
/**
|
|
3
|
+
* Icons for CopilotChat component.
|
|
4
|
+
*/
|
|
5
|
+
export interface CopilotChatIcons {
|
|
6
|
+
/**
|
|
7
|
+
* The icon to use for the open chat button.
|
|
8
|
+
* @default <OpenIcon />
|
|
9
|
+
*/
|
|
10
|
+
openIcon?: React.ReactNode;
|
|
11
|
+
/**
|
|
12
|
+
* The icon to use for the close chat button.
|
|
13
|
+
* @default <CloseIcon />
|
|
14
|
+
*/
|
|
15
|
+
closeIcon?: React.ReactNode;
|
|
16
|
+
/**
|
|
17
|
+
* The icon to use for the close chat button in the header.
|
|
18
|
+
* @default <HeaderCloseIcon />
|
|
19
|
+
*/
|
|
20
|
+
headerCloseIcon?: React.ReactNode;
|
|
21
|
+
/**
|
|
22
|
+
* The icon to use for the send button.
|
|
23
|
+
* @default <SendIcon />
|
|
24
|
+
*/
|
|
25
|
+
sendIcon?: React.ReactNode;
|
|
26
|
+
/**
|
|
27
|
+
* The icon to use for the activity indicator.
|
|
28
|
+
* @default <ActivityIcon />
|
|
29
|
+
*/
|
|
30
|
+
activityIcon?: React.ReactNode;
|
|
31
|
+
/**
|
|
32
|
+
* The icon to use for the spinner.
|
|
33
|
+
* @default <SpinnerIcon />
|
|
34
|
+
*/
|
|
35
|
+
spinnerIcon?: React.ReactNode;
|
|
36
|
+
/**
|
|
37
|
+
* The icon to use for the stop button.
|
|
38
|
+
* @default <StopIcon />
|
|
39
|
+
*/
|
|
40
|
+
stopIcon?: React.ReactNode;
|
|
41
|
+
/**
|
|
42
|
+
* The icon to use for the regenerate button.
|
|
43
|
+
* @default <RegenerateIcon />
|
|
44
|
+
*/
|
|
45
|
+
regenerateIcon?: React.ReactNode;
|
|
46
|
+
/**
|
|
47
|
+
* The icons to use for push to talk.
|
|
48
|
+
* @default <PushToTalkIcon />
|
|
49
|
+
*/
|
|
50
|
+
pushToTalkIcon?: React.ReactNode;
|
|
51
|
+
}
|
|
52
|
+
/**
|
|
53
|
+
* Labels for CopilotChat component.
|
|
54
|
+
*/
|
|
55
|
+
export interface CopilotChatLabels {
|
|
56
|
+
/**
|
|
57
|
+
* The initial message(s) to display in the chat window.
|
|
58
|
+
*/
|
|
59
|
+
initial?: string | string[];
|
|
60
|
+
/**
|
|
61
|
+
* The title to display in the header.
|
|
62
|
+
* @default "CopilotKit"
|
|
63
|
+
*/
|
|
64
|
+
title?: string;
|
|
65
|
+
/**
|
|
66
|
+
* The placeholder to display in the input.
|
|
67
|
+
* @default "Type a message..."
|
|
68
|
+
*/
|
|
69
|
+
placeholder?: string;
|
|
70
|
+
/**
|
|
71
|
+
* The message to display when an error occurs.
|
|
72
|
+
* @default "❌ An error occurred. Please try again."
|
|
73
|
+
*/
|
|
74
|
+
error?: string;
|
|
75
|
+
/**
|
|
76
|
+
* The label to display on the stop button.
|
|
77
|
+
* @default "Stop generating"
|
|
78
|
+
*/
|
|
79
|
+
stopGenerating?: string;
|
|
80
|
+
/**
|
|
81
|
+
* The label to display on the regenerate button.
|
|
82
|
+
* @default "Regenerate response"
|
|
83
|
+
*/
|
|
84
|
+
regenerateResponse?: string;
|
|
85
|
+
}
|
|
86
|
+
interface ChatContext {
|
|
87
|
+
labels: Required<CopilotChatLabels>;
|
|
88
|
+
icons: Required<CopilotChatIcons>;
|
|
89
|
+
open: boolean;
|
|
90
|
+
setOpen: (_open: boolean) => void;
|
|
91
|
+
}
|
|
92
|
+
export declare const ChatContext: React.Context<ChatContext | undefined>;
|
|
93
|
+
export declare function useChatContext(): ChatContext;
|
|
94
|
+
export interface ChatContextProps {
|
|
95
|
+
labels?: CopilotChatLabels;
|
|
96
|
+
icons?: CopilotChatIcons;
|
|
97
|
+
children?: React.ReactNode;
|
|
98
|
+
open: boolean;
|
|
99
|
+
setOpen: (_open: boolean) => void;
|
|
100
|
+
}
|
|
101
|
+
export {};
|
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
export interface ChatProps {
|
|
3
|
+
title: string;
|
|
4
|
+
runtimeUrl: string;
|
|
5
|
+
shopifyDomain: string;
|
|
6
|
+
/** GA 的 client id
|
|
7
|
+
*/
|
|
8
|
+
userId: string;
|
|
9
|
+
/** 是否登陆用户 0 or 1
|
|
10
|
+
*/
|
|
11
|
+
account?: string;
|
|
12
|
+
/** 用户浏览器语言
|
|
13
|
+
*/
|
|
14
|
+
locale?: string;
|
|
15
|
+
/** 开场白
|
|
16
|
+
*/
|
|
17
|
+
prologue?: string;
|
|
18
|
+
/** ?a=1&b=2
|
|
19
|
+
*/
|
|
20
|
+
query?: string;
|
|
21
|
+
/** 'follow' or 'unfollow' | true or false
|
|
22
|
+
* follow: ResponseButton 会跟随在 messages 的后边
|
|
23
|
+
* unfollow: ResponseButton 在聊天框底部
|
|
24
|
+
*/
|
|
25
|
+
showResponseButton?: string | boolean;
|
|
26
|
+
/** messages 的回调事件
|
|
27
|
+
* 每次生成/接受新的messages,会将 整个 messages list 传递给外部
|
|
28
|
+
*/
|
|
29
|
+
messagesCallback?: (_messages: any) => void;
|
|
30
|
+
/** 通用 action 的触发事件
|
|
31
|
+
*/
|
|
32
|
+
commonRender?: string | ((_props: any) => React.ReactElement);
|
|
33
|
+
/** shulex的 action 的触发事件
|
|
34
|
+
*/
|
|
35
|
+
shulexRender?: string | ((_props: any) => React.ReactElement);
|
|
36
|
+
/** 通用 积分 换 Coupon 的触发事件
|
|
37
|
+
*/
|
|
38
|
+
pointsExchangeCouponRender?: string | ((_props: any) => React.ReactElement);
|
|
39
|
+
/** 跳转 checkout action 卡片,接受参数: {"status":"complete","args":[{"sku":["A3936031"],"handle":"space-a40-a3936031"}],"result":""}
|
|
40
|
+
* 后端接口文档:https://anker-in.feishu.cn/wiki/DOYJwE9oxipWmYk072ncnJNznBb
|
|
41
|
+
*/
|
|
42
|
+
gotocheckoutRender?: string | ((_props: any) => React.ReactElement);
|
|
43
|
+
/** 打开购物车 action 卡片,接受参数: {"status":"complete","args":[{"sku":["A3936031"],"handle":"space-a40-a3936031"}],"result":""}
|
|
44
|
+
* 后端接口文档:https://anker-in.feishu.cn/wiki/DOYJwE9oxipWmYk072ncnJNznBb
|
|
45
|
+
*/
|
|
46
|
+
gotocartRender?: string | ((_props: any) => React.ReactElement);
|
|
47
|
+
/** 打开购物车 action 的触发事件
|
|
48
|
+
*/
|
|
49
|
+
addtocartHandler?: (_args: any) => Promise<any>;
|
|
50
|
+
/** 加购卡片,接受参数: {"status":"complete","args":[{"sku":["A3936031"],"handle":"space-a40-a3936031"}],"result":""}
|
|
51
|
+
* 后端接口文档:https://anker-in.feishu.cn/wiki/DOYJwE9oxipWmYk072ncnJNznBb
|
|
52
|
+
*/
|
|
53
|
+
addtocartRender?: string | ((_props: any) => React.ReactElement);
|
|
54
|
+
/** 订阅卡片,接受参数: {"status":"complete","args":[{"sku":["A3936031"],"handle":"space-a40-a3936031"}],"result":""}
|
|
55
|
+
* 后端接口文档:https://anker-in.feishu.cn/wiki/DOYJwE9oxipWmYk072ncnJNznBb
|
|
56
|
+
*/
|
|
57
|
+
signupRender?: string | ((_props: any) => React.ReactElement);
|
|
58
|
+
/** 产品卡片,接受参数: {"status":"complete","args":[{"sku":["A3936031"],"handle":"space-a40-a3936031"}],"result":""}
|
|
59
|
+
* 后端接口文档:https://anker-in.feishu.cn/wiki/DOYJwE9oxipWmYk072ncnJNznBb
|
|
60
|
+
*/
|
|
61
|
+
productRender?: string | ((_props: any) => React.ReactElement);
|
|
62
|
+
/** CopilotPopup 自定义参数,参考:https://docs.copilotkit.ai/reference/components/CopilotPopup */
|
|
63
|
+
popup?: any;
|
|
64
|
+
/** 文案,{"productRenderTipMessage": "","popupTip": "Hi ! Welcome to soundcore Innovations live chat!", "popupTipTimeout": [3000, 6000]} */
|
|
65
|
+
lang?: any;
|
|
66
|
+
/** 参考此文档:https://docs.copilotkit.ai/concepts/customize-look-and-feel */
|
|
67
|
+
style?: any;
|
|
68
|
+
className?: string;
|
|
69
|
+
}
|
|
70
|
+
declare const Chat: (props: ChatProps) => import("react/jsx-runtime").JSX.Element;
|
|
71
|
+
export default Chat;
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { Message } from '@copilotkit/runtime-client-gql';
|
|
3
|
+
export interface ButtonProps {
|
|
4
|
+
open: boolean;
|
|
5
|
+
setOpen: () => void;
|
|
6
|
+
}
|
|
7
|
+
export interface WindowProps {
|
|
8
|
+
open: boolean;
|
|
9
|
+
setOpen: (open: boolean) => void;
|
|
10
|
+
clickOutsideToClose: boolean;
|
|
11
|
+
hitEscapeToClose: boolean;
|
|
12
|
+
shortcut: string;
|
|
13
|
+
children?: React.ReactNode;
|
|
14
|
+
}
|
|
15
|
+
export interface HeaderProps {
|
|
16
|
+
open: boolean;
|
|
17
|
+
setOpen: (open: boolean) => void;
|
|
18
|
+
}
|
|
19
|
+
export interface ChatSuggestions {
|
|
20
|
+
currentSuggestions: SuggestionsProps[];
|
|
21
|
+
}
|
|
22
|
+
export interface SuggestionsProps {
|
|
23
|
+
title: string;
|
|
24
|
+
message: string;
|
|
25
|
+
partial?: boolean;
|
|
26
|
+
className?: string;
|
|
27
|
+
}
|
|
28
|
+
export interface MessagesProps {
|
|
29
|
+
messages: Message[];
|
|
30
|
+
inProgress: boolean;
|
|
31
|
+
ResponseButton?: React.ReactElement;
|
|
32
|
+
children?: React.ReactNode;
|
|
33
|
+
messagesCallback?: (messages: any) => void;
|
|
34
|
+
}
|
|
35
|
+
export interface InputProps {
|
|
36
|
+
inProgress: boolean;
|
|
37
|
+
onSend: (text: string) => Promise<Message>;
|
|
38
|
+
isVisible?: boolean;
|
|
39
|
+
}
|
|
40
|
+
export interface ResponseButtonProps {
|
|
41
|
+
onClick: () => void;
|
|
42
|
+
inProgress: boolean;
|
|
43
|
+
}
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
import { useCopilotChat, useCopilotAction, useCopilotReadable } from '@copilotkit/react-core';
|
|
2
|
+
import { Role, ActionExecutionMessage, TextMessage } from '@copilotkit/runtime-client-gql';
|
|
3
|
+
export { useCopilotChat, useCopilotAction, useCopilotReadable, Role, ActionExecutionMessage, TextMessage };
|
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
export declare enum CreditType {
|
|
2
|
+
All = 0,
|
|
3
|
+
Earned = 1,
|
|
4
|
+
Deducted = 2,
|
|
5
|
+
Expired = 3
|
|
6
|
+
}
|
|
7
|
+
export declare enum ConsumeType {
|
|
8
|
+
Coupon = "coupon",
|
|
9
|
+
GiftCard = "giftCard",
|
|
10
|
+
GoGift = "goGift",
|
|
11
|
+
Product = "product"
|
|
12
|
+
}
|
|
13
|
+
export declare enum AlpcConsumeType {
|
|
14
|
+
Coupon = 1,
|
|
15
|
+
Product = 2
|
|
16
|
+
}
|
|
17
|
+
export declare enum TaskType {
|
|
18
|
+
Program = 1,
|
|
19
|
+
Operation = 2,
|
|
20
|
+
Redeem = 3
|
|
21
|
+
}
|
|
22
|
+
export declare enum DTC_TASK_TYPE {
|
|
23
|
+
FirstPurchase = "firstPurchase",
|
|
24
|
+
UploadReceipt = "uploadReceipt",
|
|
25
|
+
Shopping = "shopping"
|
|
26
|
+
}
|
|
27
|
+
export declare enum TaskSubType {
|
|
28
|
+
Activation = 1,// 激活事件
|
|
29
|
+
UpdateName = 2,// 完善姓名
|
|
30
|
+
UpdatePhone = 3,// 更新手机号
|
|
31
|
+
UpdateBirthday = 4,// 更新生日
|
|
32
|
+
Subscription = 5,// 订阅
|
|
33
|
+
UpadteAppName = 7,// 完善APP姓名
|
|
34
|
+
Refund = 3000,// 购物送积分任务退款
|
|
35
|
+
ProductUnApproved = 5000
|
|
36
|
+
}
|
|
37
|
+
export declare enum CouponType {
|
|
38
|
+
FixedMount = "fixed_amount",
|
|
39
|
+
Percent = "percent"
|
|
40
|
+
}
|
|
41
|
+
export declare enum RewardType {
|
|
42
|
+
Received = 0,
|
|
43
|
+
Pending = 1,
|
|
44
|
+
ApproveSuccess = 2,
|
|
45
|
+
ApproveFail = 3,
|
|
46
|
+
Unfulfilled = 4,
|
|
47
|
+
Fulfilled = 5,
|
|
48
|
+
Failed = 6
|
|
49
|
+
}
|
|
50
|
+
export declare enum AlpcErrorCode {
|
|
51
|
+
CodeLpcRedeemFailed = 180001,
|
|
52
|
+
CodeLpcUserNotFound = 180002,
|
|
53
|
+
CodeLpcCreditRuleNotFound = 180003,
|
|
54
|
+
CodeLpcUnknownError = 180004,
|
|
55
|
+
CodeLpcNotEnoughCredits = 180005,
|
|
56
|
+
CodeLpcUserMigrate = 180006,
|
|
57
|
+
CodeLpcRuleInventoryNotEnough = 180007,
|
|
58
|
+
CodeLpcShopifyCouponRuleRedeemLimit = 180009,
|
|
59
|
+
CodeCrossSiteError = 180011
|
|
60
|
+
}
|
|
61
|
+
export declare const ALPC_COUNTRY_MAP: Map<string, string>;
|
|
62
|
+
export declare enum ApprovalStatus {
|
|
63
|
+
Pending = 0,
|
|
64
|
+
Success = 1,
|
|
65
|
+
Failed = 2,
|
|
66
|
+
DoubleConfirm = 3
|
|
67
|
+
}
|
|
68
|
+
export declare const PRICE_SYMBOL: {
|
|
69
|
+
us: string;
|
|
70
|
+
uk: string;
|
|
71
|
+
ca: string;
|
|
72
|
+
eu: string;
|
|
73
|
+
pl: string;
|
|
74
|
+
fr: string;
|
|
75
|
+
de: string;
|
|
76
|
+
vn: string;
|
|
77
|
+
cl: string;
|
|
78
|
+
sg: string;
|
|
79
|
+
ae: string;
|
|
80
|
+
es: string;
|
|
81
|
+
};
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import type { CreditLogResponse } from '../response';
|
|
2
|
+
declare function useActivities({ page, pageSize, options }: {
|
|
3
|
+
page: number;
|
|
4
|
+
pageSize: number;
|
|
5
|
+
options?: any;
|
|
6
|
+
}): {
|
|
7
|
+
activities: CreditLogResponse[];
|
|
8
|
+
isLoading: boolean;
|
|
9
|
+
total: number;
|
|
10
|
+
canNext: boolean;
|
|
11
|
+
};
|
|
12
|
+
export default useActivities;
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
export interface Rule {
|
|
2
|
+
key: string;
|
|
3
|
+
error: string;
|
|
4
|
+
rule?: string;
|
|
5
|
+
params?: Record<string, any>;
|
|
6
|
+
required?: boolean;
|
|
7
|
+
validator?: (value: string, key: string, address: Record<string, any>) => boolean | string;
|
|
8
|
+
}
|
|
9
|
+
export type FormData = {
|
|
10
|
+
key: string;
|
|
11
|
+
label: string;
|
|
12
|
+
tips: string;
|
|
13
|
+
required: boolean;
|
|
14
|
+
placeholder: string;
|
|
15
|
+
type?: string;
|
|
16
|
+
}[];
|
|
17
|
+
export declare const useAddressValidate: ({ address, validatorInfo, formData, errorLabel, }: {
|
|
18
|
+
address: Record<string, any>;
|
|
19
|
+
validatorInfo: any;
|
|
20
|
+
formData: any;
|
|
21
|
+
errorLabel: {
|
|
22
|
+
require: string;
|
|
23
|
+
email: string;
|
|
24
|
+
};
|
|
25
|
+
}) => {
|
|
26
|
+
validate: ({ force, ignoreKeys }: {
|
|
27
|
+
force?: boolean;
|
|
28
|
+
ignoreKeys?: string[];
|
|
29
|
+
}) => boolean;
|
|
30
|
+
errors: {
|
|
31
|
+
key: string;
|
|
32
|
+
message: string;
|
|
33
|
+
}[];
|
|
34
|
+
};
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { type SWRConfiguration } from 'swr';
|
|
2
|
+
interface UseAlpcFetchOptionsSwrOptions<TData, Error> extends SWRConfiguration<TData, Error> {
|
|
3
|
+
enable?: boolean;
|
|
4
|
+
}
|
|
5
|
+
interface FetchOptions extends RequestInit {
|
|
6
|
+
queryKey: [string, Record<string, any>];
|
|
7
|
+
data?: Record<string, any>;
|
|
8
|
+
}
|
|
9
|
+
interface MutationOptions extends RequestInit {
|
|
10
|
+
url: string;
|
|
11
|
+
initData: Record<string, any>;
|
|
12
|
+
}
|
|
13
|
+
export interface UseMutationConfig<TData> {
|
|
14
|
+
onSuccess?: (response: TData) => any;
|
|
15
|
+
onError?: (error: Error) => any;
|
|
16
|
+
}
|
|
17
|
+
export declare const useAlpcFetch: <TData>(options: FetchOptions, swrOptions?: UseAlpcFetchOptionsSwrOptions<TData, Error>) => import("swr").SWRResponse<TData, any, SWRConfiguration<TData, any, import("swr").BareFetcher<TData>> | undefined>;
|
|
18
|
+
export declare const useAlpcMutation: <TData, TBody>(options: MutationOptions, mutationOptions?: UseMutationConfig<TData>) => {
|
|
19
|
+
isMutating: boolean;
|
|
20
|
+
trigger: (fetchData: TBody, opts?: UseMutationConfig<TData>) => Promise<TData | undefined>;
|
|
21
|
+
data: TData | undefined;
|
|
22
|
+
};
|
|
23
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const useFirstPurchaseFinished: () => boolean;
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { AlpcConsumeType } from '../const';
|
|
2
|
+
import type { RedeemLogResponse } from '../response';
|
|
3
|
+
declare function useMyRewards({ page, pageSize, consumeType, }: {
|
|
4
|
+
page: number;
|
|
5
|
+
pageSize: number;
|
|
6
|
+
consumeType?: AlpcConsumeType;
|
|
7
|
+
}): {
|
|
8
|
+
myRewards: RedeemLogResponse[];
|
|
9
|
+
isLoading: boolean;
|
|
10
|
+
total: number;
|
|
11
|
+
getMyRewards: () => Promise<void>;
|
|
12
|
+
canNext: boolean;
|
|
13
|
+
};
|
|
14
|
+
export default useMyRewards;
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { SWRMutationConfiguration } from 'swr/mutation';
|
|
2
|
+
import type { ProductVariant } from '@anker-in/lib';
|
|
3
|
+
export declare const useRedeemAndBuy: (_: any, swrOptions?: SWRMutationConfiguration<undefined, Error, string, any> & {
|
|
4
|
+
throwOnError?: boolean;
|
|
5
|
+
}) => import("swr/mutation").SWRMutationResponse<undefined, Error, "redeemAndBuy", {
|
|
6
|
+
productVariant: ProductVariant;
|
|
7
|
+
quantity?: number;
|
|
8
|
+
redeemId: number;
|
|
9
|
+
}>;
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { type UseMutationConfig } from './useAlpcFetch';
|
|
2
|
+
type RedeemCouponResponse = {
|
|
3
|
+
code: number;
|
|
4
|
+
data: {
|
|
5
|
+
success: boolean;
|
|
6
|
+
coupon_code: string;
|
|
7
|
+
};
|
|
8
|
+
};
|
|
9
|
+
export declare const useRedeemCoupon: (mutationOptions?: UseMutationConfig<RedeemCouponResponse>) => {
|
|
10
|
+
isMutating: boolean;
|
|
11
|
+
trigger: (fetchData: {
|
|
12
|
+
user_id?: string;
|
|
13
|
+
rule_id: number;
|
|
14
|
+
}, opts?: UseMutationConfig<RedeemCouponResponse>) => Promise<RedeemCouponResponse | undefined>;
|
|
15
|
+
data: RedeemCouponResponse | undefined;
|
|
16
|
+
};
|
|
17
|
+
export {};
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { type UseMutationConfig } from './useAlpcFetch';
|
|
2
|
+
type RedeemProductResponse = {
|
|
3
|
+
code: number;
|
|
4
|
+
data: {
|
|
5
|
+
success: boolean;
|
|
6
|
+
};
|
|
7
|
+
};
|
|
8
|
+
export declare const useRedeemProduct: (mutationOptions?: UseMutationConfig<RedeemProductResponse>) => {
|
|
9
|
+
isMutating: boolean;
|
|
10
|
+
trigger: (fetchData: {
|
|
11
|
+
rule_id: number;
|
|
12
|
+
address: string;
|
|
13
|
+
}, opts?: UseMutationConfig<RedeemProductResponse>) => Promise<RedeemProductResponse | undefined>;
|
|
14
|
+
data: RedeemProductResponse | undefined;
|
|
15
|
+
};
|
|
16
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function useSendEmailValidation(): import("swr/mutation").SWRMutationResponse<any, any, "send-email-validation", never>;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const useSubscribed: () => boolean;
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
export declare const uploadReceipt: (_: any, { arg: { orderName } }: {
|
|
2
|
+
arg: {
|
|
3
|
+
orderName: string;
|
|
4
|
+
};
|
|
5
|
+
}) => Promise<{
|
|
6
|
+
ok: boolean;
|
|
7
|
+
code: number;
|
|
8
|
+
}>;
|
|
9
|
+
export declare const useUploadReceipt: () => import("swr/mutation").SWRMutationResponse<{
|
|
10
|
+
ok: boolean;
|
|
11
|
+
code: number;
|
|
12
|
+
}, any, "/api/multipass/mktsrv/v1/credit/upload_third_party_order", {
|
|
13
|
+
orderName: string;
|
|
14
|
+
}>;
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import type { DTC_TASK_TYPE } from './const';
|
|
3
|
+
import type { CreditInfoResponse } from './response';
|
|
4
|
+
export declare const CreditsContext: React.Context<{
|
|
5
|
+
profile: any;
|
|
6
|
+
isLoadingProfile: boolean;
|
|
7
|
+
removeProfile: () => void;
|
|
8
|
+
taskIdToTypeMapping: Record<string, DTC_TASK_TYPE>;
|
|
9
|
+
openSignInPopup: () => void;
|
|
10
|
+
openSignUpPopup: () => void;
|
|
11
|
+
creditInfo?: CreditInfoResponse;
|
|
12
|
+
customer?: any;
|
|
13
|
+
customerLoading: boolean;
|
|
14
|
+
fetchCreditInfo: (user_id: string) => void;
|
|
15
|
+
gtm: {
|
|
16
|
+
pageGroup: string;
|
|
17
|
+
};
|
|
18
|
+
}>;
|
|
19
|
+
export declare function CreditsProvider({ children, profile, removeProfile, isLoadingProfile, openSignInPopup, openSignUpPopup, taskIdToTypeMapping, creditInfo, customer, customerLoading, fetchCreditInfo, gtm, }: {
|
|
20
|
+
children: React.ReactNode;
|
|
21
|
+
profile: any;
|
|
22
|
+
removeProfile: () => void;
|
|
23
|
+
isLoadingProfile: boolean;
|
|
24
|
+
openSignInPopup: () => void;
|
|
25
|
+
openSignUpPopup: () => void;
|
|
26
|
+
taskIdToTypeMapping: Record<string, DTC_TASK_TYPE>;
|
|
27
|
+
creditInfo?: CreditInfoResponse;
|
|
28
|
+
customer: any;
|
|
29
|
+
fetchCreditInfo: (user_id: string) => void;
|
|
30
|
+
customerLoading: boolean;
|
|
31
|
+
gtm: {
|
|
32
|
+
pageGroup: string;
|
|
33
|
+
};
|
|
34
|
+
}): import("react/jsx-runtime").JSX.Element;
|
|
35
|
+
export declare function useCreditsContext(): {
|
|
36
|
+
profile: any;
|
|
37
|
+
isLoadingProfile: boolean;
|
|
38
|
+
removeProfile: () => void;
|
|
39
|
+
taskIdToTypeMapping: Record<string, DTC_TASK_TYPE>;
|
|
40
|
+
openSignInPopup: () => void;
|
|
41
|
+
openSignUpPopup: () => void;
|
|
42
|
+
creditInfo?: CreditInfoResponse;
|
|
43
|
+
customer?: any;
|
|
44
|
+
customerLoading: boolean;
|
|
45
|
+
fetchCreditInfo: (user_id: string) => void;
|
|
46
|
+
gtm: {
|
|
47
|
+
pageGroup: string;
|
|
48
|
+
};
|
|
49
|
+
};
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
import { ApprovalStatus, AlpcConsumeType, CreditType, TaskSubType, TaskType } from './const';
|
|
2
|
+
interface BaseResponse {
|
|
3
|
+
brand: string;
|
|
4
|
+
}
|
|
5
|
+
export interface Task extends BaseResponse {
|
|
6
|
+
goods_sku?: string;
|
|
7
|
+
task_type: TaskType;
|
|
8
|
+
task_sub_type: TaskSubType;
|
|
9
|
+
task_rule_id: number;
|
|
10
|
+
task_name: string;
|
|
11
|
+
task_note: string;
|
|
12
|
+
app_name: string;
|
|
13
|
+
}
|
|
14
|
+
export interface CreditLogResponse extends Task {
|
|
15
|
+
credit: number;
|
|
16
|
+
task_name: string;
|
|
17
|
+
create_time: number;
|
|
18
|
+
credit_type: CreditType;
|
|
19
|
+
pending_time: number;
|
|
20
|
+
status: number;
|
|
21
|
+
expired_time?: number;
|
|
22
|
+
}
|
|
23
|
+
export interface ConsumeCreditRuleResponse extends BaseResponse {
|
|
24
|
+
id: number;
|
|
25
|
+
name: string;
|
|
26
|
+
note: string;
|
|
27
|
+
consume_credits: number;
|
|
28
|
+
consume_type: AlpcConsumeType;
|
|
29
|
+
coupon_rule: string;
|
|
30
|
+
remaining_inventory: number;
|
|
31
|
+
is_limited: number;
|
|
32
|
+
sku_handle: string;
|
|
33
|
+
goods_sku: string;
|
|
34
|
+
goods_url: string;
|
|
35
|
+
extra?: string;
|
|
36
|
+
}
|
|
37
|
+
export interface RedeemLogResponse extends BaseResponse {
|
|
38
|
+
goods_title: string;
|
|
39
|
+
coupon_code: string;
|
|
40
|
+
order_number: string;
|
|
41
|
+
create_time: number;
|
|
42
|
+
consume_credits: number;
|
|
43
|
+
fulfillment_status: string;
|
|
44
|
+
approval_status: ApprovalStatus;
|
|
45
|
+
rule_id: number;
|
|
46
|
+
code_status: number;
|
|
47
|
+
}
|
|
48
|
+
export interface CreditTaskResponse extends Task {
|
|
49
|
+
status: number;
|
|
50
|
+
is_enable: number;
|
|
51
|
+
id: number;
|
|
52
|
+
weight: number;
|
|
53
|
+
reward_type: number;
|
|
54
|
+
}
|
|
55
|
+
export interface CreditInfoResponse extends BaseResponse {
|
|
56
|
+
total_credit: number;
|
|
57
|
+
available_credit: number;
|
|
58
|
+
pending_credit: number;
|
|
59
|
+
expired_credit: number;
|
|
60
|
+
cancel_credit: number;
|
|
61
|
+
consumed_credit: number;
|
|
62
|
+
}
|
|
63
|
+
export {};
|