@crossmint/client-sdk-react-ui 0.2.7-alpha.6 → 0.2.7-alpha.8
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/LICENSE +201 -201
- package/README.md +43 -43
- package/lib/index.cjs +1 -1
- package/lib/index.d.ts +12 -9
- package/lib/index.js +1 -1
- package/package.json +3 -3
- package/src/CrossmintNFTCollectionView.tsx +30 -30
- package/src/CrossmintNFTDetail.tsx +26 -26
- package/src/CrossmintPayButton.tsx +139 -139
- package/src/CrossmintPaymentElement.tsx +36 -0
- package/src/CrossmintStatusButton.tsx +85 -85
- package/src/index.ts +7 -4
- package/src/styles/index.ts +50 -50
- package/src/types.ts +12 -12
- package/src/useEnvironment.ts +10 -10
- package/src/version.ts +1 -1
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@crossmint/client-sdk-react-ui",
|
|
3
|
-
"version": "0.2.7-alpha.
|
|
3
|
+
"version": "0.2.7-alpha.8",
|
|
4
4
|
"author": "Paella Labs Inc",
|
|
5
5
|
"license": "Apache-2.0",
|
|
6
6
|
"repository": "https://github.com/CrossMint/crossmint-client-sdk",
|
|
@@ -32,7 +32,7 @@
|
|
|
32
32
|
"test": "jest"
|
|
33
33
|
},
|
|
34
34
|
"dependencies": {
|
|
35
|
-
"@crossmint/client-sdk-base": "^0.2.7-alpha.
|
|
35
|
+
"@crossmint/client-sdk-base": "^0.2.7-alpha.8",
|
|
36
36
|
"react-jss": "10.9.2",
|
|
37
37
|
"uuid": "^8.3.2"
|
|
38
38
|
},
|
|
@@ -49,5 +49,5 @@
|
|
|
49
49
|
"ts-jest": "^27.1.3",
|
|
50
50
|
"ts-node-dev": "^1.1.8"
|
|
51
51
|
},
|
|
52
|
-
"gitHead": "
|
|
52
|
+
"gitHead": "cf4ae623cab8214f56a098f4ff74ae3eb5c7a305"
|
|
53
53
|
}
|
|
@@ -1,30 +1,30 @@
|
|
|
1
|
-
import * as React from "react";
|
|
2
|
-
|
|
3
|
-
import {
|
|
4
|
-
NFTCollectionViewProps,
|
|
5
|
-
assertValidNFTCollectionViewProps,
|
|
6
|
-
getNFTCollectionViewSrc,
|
|
7
|
-
} from "@crossmint/client-sdk-base";
|
|
8
|
-
|
|
9
|
-
import { LIB_VERSION } from "./version";
|
|
10
|
-
|
|
11
|
-
export function CrossmintNFTCollectionView(props: NFTCollectionViewProps) {
|
|
12
|
-
assertValidNFTCollectionViewProps(props);
|
|
13
|
-
|
|
14
|
-
const src = getNFTCollectionViewSrc(props, LIB_VERSION);
|
|
15
|
-
|
|
16
|
-
return (
|
|
17
|
-
<iframe
|
|
18
|
-
src={src}
|
|
19
|
-
width="100%"
|
|
20
|
-
height="100%"
|
|
21
|
-
style={{
|
|
22
|
-
flexGrow: "1",
|
|
23
|
-
border: "none",
|
|
24
|
-
margin: "0",
|
|
25
|
-
padding: "0",
|
|
26
|
-
}}
|
|
27
|
-
role="nft-collection-view"
|
|
28
|
-
/>
|
|
29
|
-
);
|
|
30
|
-
}
|
|
1
|
+
import * as React from "react";
|
|
2
|
+
|
|
3
|
+
import {
|
|
4
|
+
NFTCollectionViewProps,
|
|
5
|
+
assertValidNFTCollectionViewProps,
|
|
6
|
+
getNFTCollectionViewSrc,
|
|
7
|
+
} from "@crossmint/client-sdk-base";
|
|
8
|
+
|
|
9
|
+
import { LIB_VERSION } from "./version";
|
|
10
|
+
|
|
11
|
+
export function CrossmintNFTCollectionView(props: NFTCollectionViewProps) {
|
|
12
|
+
assertValidNFTCollectionViewProps(props);
|
|
13
|
+
|
|
14
|
+
const src = getNFTCollectionViewSrc(props, LIB_VERSION);
|
|
15
|
+
|
|
16
|
+
return (
|
|
17
|
+
<iframe
|
|
18
|
+
src={src}
|
|
19
|
+
width="100%"
|
|
20
|
+
height="100%"
|
|
21
|
+
style={{
|
|
22
|
+
flexGrow: "1",
|
|
23
|
+
border: "none",
|
|
24
|
+
margin: "0",
|
|
25
|
+
padding: "0",
|
|
26
|
+
}}
|
|
27
|
+
role="nft-collection-view"
|
|
28
|
+
/>
|
|
29
|
+
);
|
|
30
|
+
}
|
|
@@ -1,26 +1,26 @@
|
|
|
1
|
-
import * as React from "react";
|
|
2
|
-
|
|
3
|
-
import { NFTDetailProps, assertValidValidateNFTDetailProps, getNFTDetailSrc } from "@crossmint/client-sdk-base";
|
|
4
|
-
|
|
5
|
-
import { LIB_VERSION } from "./version";
|
|
6
|
-
|
|
7
|
-
export function CrossmintNFTDetail(props: NFTDetailProps) {
|
|
8
|
-
assertValidValidateNFTDetailProps(props);
|
|
9
|
-
|
|
10
|
-
const src = getNFTDetailSrc(props, LIB_VERSION);
|
|
11
|
-
|
|
12
|
-
return (
|
|
13
|
-
<iframe
|
|
14
|
-
src={src}
|
|
15
|
-
width="100%"
|
|
16
|
-
height="100%"
|
|
17
|
-
style={{
|
|
18
|
-
flexGrow: "1",
|
|
19
|
-
border: "none",
|
|
20
|
-
margin: "0",
|
|
21
|
-
padding: "0",
|
|
22
|
-
}}
|
|
23
|
-
role="nft-details"
|
|
24
|
-
/>
|
|
25
|
-
);
|
|
26
|
-
}
|
|
1
|
+
import * as React from "react";
|
|
2
|
+
|
|
3
|
+
import { NFTDetailProps, assertValidValidateNFTDetailProps, getNFTDetailSrc } from "@crossmint/client-sdk-base";
|
|
4
|
+
|
|
5
|
+
import { LIB_VERSION } from "./version";
|
|
6
|
+
|
|
7
|
+
export function CrossmintNFTDetail(props: NFTDetailProps) {
|
|
8
|
+
assertValidValidateNFTDetailProps(props);
|
|
9
|
+
|
|
10
|
+
const src = getNFTDetailSrc(props, LIB_VERSION);
|
|
11
|
+
|
|
12
|
+
return (
|
|
13
|
+
<iframe
|
|
14
|
+
src={src}
|
|
15
|
+
width="100%"
|
|
16
|
+
height="100%"
|
|
17
|
+
style={{
|
|
18
|
+
flexGrow: "1",
|
|
19
|
+
border: "none",
|
|
20
|
+
margin: "0",
|
|
21
|
+
padding: "0",
|
|
22
|
+
}}
|
|
23
|
+
role="nft-details"
|
|
24
|
+
/>
|
|
25
|
+
);
|
|
26
|
+
}
|
|
@@ -1,139 +1,139 @@
|
|
|
1
|
-
import React, { FC, MouseEvent, useEffect, useMemo } from "react";
|
|
2
|
-
import { useState } from "react";
|
|
3
|
-
|
|
4
|
-
import {
|
|
5
|
-
clientNames,
|
|
6
|
-
crossmintModalService,
|
|
7
|
-
crossmintPayButtonService,
|
|
8
|
-
crossmintStatusService,
|
|
9
|
-
mintingContractTypes,
|
|
10
|
-
onboardingRequestStatusResponse,
|
|
11
|
-
} from "@crossmint/client-sdk-base";
|
|
12
|
-
|
|
13
|
-
import { formatProps, useStyles } from "./styles";
|
|
14
|
-
import { CrossmintPayButtonReactProps } from "./types";
|
|
15
|
-
import useEnvironment from "./useEnvironment";
|
|
16
|
-
import { LIB_VERSION } from "./version";
|
|
17
|
-
|
|
18
|
-
const defaultMintConfig: any = {
|
|
19
|
-
type: mintingContractTypes.CANDY_MACHINE,
|
|
20
|
-
};
|
|
21
|
-
|
|
22
|
-
export function CrossmintPayButton({
|
|
23
|
-
className,
|
|
24
|
-
disabled,
|
|
25
|
-
onClick,
|
|
26
|
-
style,
|
|
27
|
-
tabIndex,
|
|
28
|
-
theme = "dark",
|
|
29
|
-
mintTo,
|
|
30
|
-
emailTo,
|
|
31
|
-
listingId,
|
|
32
|
-
clientId,
|
|
33
|
-
auctionId,
|
|
34
|
-
hideMintOnInactiveClient = false,
|
|
35
|
-
showOverlay = true,
|
|
36
|
-
mintConfig = defaultMintConfig,
|
|
37
|
-
whPassThroughArgs,
|
|
38
|
-
environment,
|
|
39
|
-
paymentMethod,
|
|
40
|
-
preferredSigninMethod,
|
|
41
|
-
dismissOverlayOnClick,
|
|
42
|
-
prepay,
|
|
43
|
-
locale = "en-US",
|
|
44
|
-
currency = "USD",
|
|
45
|
-
successCallbackURL = "",
|
|
46
|
-
failureCallbackURL = "",
|
|
47
|
-
...props
|
|
48
|
-
}: CrossmintPayButtonReactProps) {
|
|
49
|
-
const [connecting, setConnecting] = useState(false);
|
|
50
|
-
const [status, setStatus] = useState(onboardingRequestStatusResponse.WAITING_SUBMISSION);
|
|
51
|
-
const { isServerSideRendering } = useEnvironment();
|
|
52
|
-
|
|
53
|
-
const { fetchClientIntegration } = crossmintStatusService({
|
|
54
|
-
libVersion: LIB_VERSION,
|
|
55
|
-
clientId,
|
|
56
|
-
environment,
|
|
57
|
-
auctionId,
|
|
58
|
-
mintConfig,
|
|
59
|
-
setStatus,
|
|
60
|
-
clientName: clientNames.reactUi,
|
|
61
|
-
});
|
|
62
|
-
|
|
63
|
-
const { connect } = crossmintModalService({
|
|
64
|
-
clientId,
|
|
65
|
-
showOverlay,
|
|
66
|
-
dismissOverlayOnClick,
|
|
67
|
-
setConnecting,
|
|
68
|
-
libVersion: LIB_VERSION,
|
|
69
|
-
environment,
|
|
70
|
-
clientName: clientNames.reactUi,
|
|
71
|
-
locale,
|
|
72
|
-
currency,
|
|
73
|
-
successCallbackURL,
|
|
74
|
-
failureCallbackURL,
|
|
75
|
-
});
|
|
76
|
-
|
|
77
|
-
const { getButtonText, shouldHideButton, handleClick } = crossmintPayButtonService({
|
|
78
|
-
onClick,
|
|
79
|
-
connecting,
|
|
80
|
-
paymentMethod,
|
|
81
|
-
locale,
|
|
82
|
-
});
|
|
83
|
-
|
|
84
|
-
useEffect(() => {
|
|
85
|
-
if (hideMintOnInactiveClient) {
|
|
86
|
-
fetchClientIntegration();
|
|
87
|
-
}
|
|
88
|
-
}, [status]);
|
|
89
|
-
|
|
90
|
-
const _handleClick = (event: MouseEvent<HTMLButtonElement>) =>
|
|
91
|
-
handleClick(event, () => {
|
|
92
|
-
connect(
|
|
93
|
-
mintConfig,
|
|
94
|
-
mintTo,
|
|
95
|
-
emailTo,
|
|
96
|
-
listingId,
|
|
97
|
-
whPassThroughArgs,
|
|
98
|
-
paymentMethod,
|
|
99
|
-
preferredSigninMethod,
|
|
100
|
-
prepay
|
|
101
|
-
);
|
|
102
|
-
});
|
|
103
|
-
|
|
104
|
-
const classes = useStyles(formatProps(theme));
|
|
105
|
-
|
|
106
|
-
const content = useMemo(() => {
|
|
107
|
-
return (
|
|
108
|
-
<span className={classes.crossmintParagraph} role="button-paragraph">
|
|
109
|
-
{getButtonText(connecting)}
|
|
110
|
-
</span>
|
|
111
|
-
);
|
|
112
|
-
}, [connecting]);
|
|
113
|
-
|
|
114
|
-
if (shouldHideButton({ hideMintOnInactiveClient, status })) {
|
|
115
|
-
return null;
|
|
116
|
-
}
|
|
117
|
-
|
|
118
|
-
return (
|
|
119
|
-
<>
|
|
120
|
-
{!isServerSideRendering && (
|
|
121
|
-
<button
|
|
122
|
-
className={`${classes.crossmintButton} ${className || ""}`}
|
|
123
|
-
disabled={disabled}
|
|
124
|
-
onClick={_handleClick}
|
|
125
|
-
style={{ ...style }}
|
|
126
|
-
tabIndex={tabIndex}
|
|
127
|
-
{...props}
|
|
128
|
-
>
|
|
129
|
-
<img
|
|
130
|
-
className={classes.crossmintImg}
|
|
131
|
-
src="https://www.crossmint.io/assets/crossmint/logo.svg"
|
|
132
|
-
alt="Crossmint logo"
|
|
133
|
-
/>
|
|
134
|
-
{content}
|
|
135
|
-
</button>
|
|
136
|
-
)}
|
|
137
|
-
</>
|
|
138
|
-
);
|
|
139
|
-
}
|
|
1
|
+
import React, { FC, MouseEvent, useEffect, useMemo } from "react";
|
|
2
|
+
import { useState } from "react";
|
|
3
|
+
|
|
4
|
+
import {
|
|
5
|
+
clientNames,
|
|
6
|
+
crossmintModalService,
|
|
7
|
+
crossmintPayButtonService,
|
|
8
|
+
crossmintStatusService,
|
|
9
|
+
mintingContractTypes,
|
|
10
|
+
onboardingRequestStatusResponse,
|
|
11
|
+
} from "@crossmint/client-sdk-base";
|
|
12
|
+
|
|
13
|
+
import { formatProps, useStyles } from "./styles";
|
|
14
|
+
import { CrossmintPayButtonReactProps } from "./types";
|
|
15
|
+
import useEnvironment from "./useEnvironment";
|
|
16
|
+
import { LIB_VERSION } from "./version";
|
|
17
|
+
|
|
18
|
+
const defaultMintConfig: any = {
|
|
19
|
+
type: mintingContractTypes.CANDY_MACHINE,
|
|
20
|
+
};
|
|
21
|
+
|
|
22
|
+
export function CrossmintPayButton({
|
|
23
|
+
className,
|
|
24
|
+
disabled,
|
|
25
|
+
onClick,
|
|
26
|
+
style,
|
|
27
|
+
tabIndex,
|
|
28
|
+
theme = "dark",
|
|
29
|
+
mintTo,
|
|
30
|
+
emailTo,
|
|
31
|
+
listingId,
|
|
32
|
+
clientId,
|
|
33
|
+
auctionId,
|
|
34
|
+
hideMintOnInactiveClient = false,
|
|
35
|
+
showOverlay = true,
|
|
36
|
+
mintConfig = defaultMintConfig,
|
|
37
|
+
whPassThroughArgs,
|
|
38
|
+
environment,
|
|
39
|
+
paymentMethod,
|
|
40
|
+
preferredSigninMethod,
|
|
41
|
+
dismissOverlayOnClick,
|
|
42
|
+
prepay,
|
|
43
|
+
locale = "en-US",
|
|
44
|
+
currency = "USD",
|
|
45
|
+
successCallbackURL = "",
|
|
46
|
+
failureCallbackURL = "",
|
|
47
|
+
...props
|
|
48
|
+
}: CrossmintPayButtonReactProps) {
|
|
49
|
+
const [connecting, setConnecting] = useState(false);
|
|
50
|
+
const [status, setStatus] = useState(onboardingRequestStatusResponse.WAITING_SUBMISSION);
|
|
51
|
+
const { isServerSideRendering } = useEnvironment();
|
|
52
|
+
|
|
53
|
+
const { fetchClientIntegration } = crossmintStatusService({
|
|
54
|
+
libVersion: LIB_VERSION,
|
|
55
|
+
clientId,
|
|
56
|
+
environment,
|
|
57
|
+
auctionId,
|
|
58
|
+
mintConfig,
|
|
59
|
+
setStatus,
|
|
60
|
+
clientName: clientNames.reactUi,
|
|
61
|
+
});
|
|
62
|
+
|
|
63
|
+
const { connect } = crossmintModalService({
|
|
64
|
+
clientId,
|
|
65
|
+
showOverlay,
|
|
66
|
+
dismissOverlayOnClick,
|
|
67
|
+
setConnecting,
|
|
68
|
+
libVersion: LIB_VERSION,
|
|
69
|
+
environment,
|
|
70
|
+
clientName: clientNames.reactUi,
|
|
71
|
+
locale,
|
|
72
|
+
currency,
|
|
73
|
+
successCallbackURL,
|
|
74
|
+
failureCallbackURL,
|
|
75
|
+
});
|
|
76
|
+
|
|
77
|
+
const { getButtonText, shouldHideButton, handleClick } = crossmintPayButtonService({
|
|
78
|
+
onClick,
|
|
79
|
+
connecting,
|
|
80
|
+
paymentMethod,
|
|
81
|
+
locale,
|
|
82
|
+
});
|
|
83
|
+
|
|
84
|
+
useEffect(() => {
|
|
85
|
+
if (hideMintOnInactiveClient) {
|
|
86
|
+
fetchClientIntegration();
|
|
87
|
+
}
|
|
88
|
+
}, [status]);
|
|
89
|
+
|
|
90
|
+
const _handleClick = (event: MouseEvent<HTMLButtonElement>) =>
|
|
91
|
+
handleClick(event, () => {
|
|
92
|
+
connect(
|
|
93
|
+
mintConfig,
|
|
94
|
+
mintTo,
|
|
95
|
+
emailTo,
|
|
96
|
+
listingId,
|
|
97
|
+
whPassThroughArgs,
|
|
98
|
+
paymentMethod,
|
|
99
|
+
preferredSigninMethod,
|
|
100
|
+
prepay
|
|
101
|
+
);
|
|
102
|
+
});
|
|
103
|
+
|
|
104
|
+
const classes = useStyles(formatProps(theme));
|
|
105
|
+
|
|
106
|
+
const content = useMemo(() => {
|
|
107
|
+
return (
|
|
108
|
+
<span className={classes.crossmintParagraph} role="button-paragraph">
|
|
109
|
+
{getButtonText(connecting)}
|
|
110
|
+
</span>
|
|
111
|
+
);
|
|
112
|
+
}, [connecting]);
|
|
113
|
+
|
|
114
|
+
if (shouldHideButton({ hideMintOnInactiveClient, status })) {
|
|
115
|
+
return null;
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
return (
|
|
119
|
+
<>
|
|
120
|
+
{!isServerSideRendering && (
|
|
121
|
+
<button
|
|
122
|
+
className={`${classes.crossmintButton} ${className || ""}`}
|
|
123
|
+
disabled={disabled}
|
|
124
|
+
onClick={_handleClick}
|
|
125
|
+
style={{ ...style }}
|
|
126
|
+
tabIndex={tabIndex}
|
|
127
|
+
{...props}
|
|
128
|
+
>
|
|
129
|
+
<img
|
|
130
|
+
className={classes.crossmintImg}
|
|
131
|
+
src="https://www.crossmint.io/assets/crossmint/logo.svg"
|
|
132
|
+
alt="Crossmint logo"
|
|
133
|
+
/>
|
|
134
|
+
{content}
|
|
135
|
+
</button>
|
|
136
|
+
)}
|
|
137
|
+
</>
|
|
138
|
+
);
|
|
139
|
+
}
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import React, { useEffect } from "react";
|
|
2
|
+
|
|
3
|
+
import { crossmintPaymentService } from "@crossmint/client-sdk-base";
|
|
4
|
+
import type { CrossmintCheckoutEvent, PaymentElement } from "@crossmint/client-sdk-base";
|
|
5
|
+
|
|
6
|
+
export function CrossmintPaymentElement(props: PaymentElement) {
|
|
7
|
+
const { getIframeUrl, listenToEvents, emitQueryParams } = crossmintPaymentService(props);
|
|
8
|
+
|
|
9
|
+
useEffect(() => {
|
|
10
|
+
listenToEvents((event: MessageEvent<CrossmintCheckoutEvent>) => props.onEvent?.(event.data));
|
|
11
|
+
}, [listenToEvents, props.onEvent]);
|
|
12
|
+
|
|
13
|
+
useEffect(() => {
|
|
14
|
+
emitQueryParams({
|
|
15
|
+
recipient: props.recipient,
|
|
16
|
+
mintConfig: props.mintConfig,
|
|
17
|
+
locale: props.locale,
|
|
18
|
+
});
|
|
19
|
+
}, [emitQueryParams, props.recipient, props.mintConfig, props.locale]);
|
|
20
|
+
|
|
21
|
+
const iframeUrl = getIframeUrl();
|
|
22
|
+
|
|
23
|
+
return (
|
|
24
|
+
<iframe
|
|
25
|
+
src={iframeUrl}
|
|
26
|
+
id="iframe-crossmint-payment-element"
|
|
27
|
+
style={{
|
|
28
|
+
width: "100%",
|
|
29
|
+
border: "none",
|
|
30
|
+
margin: "0",
|
|
31
|
+
padding: "0",
|
|
32
|
+
height: "96px",
|
|
33
|
+
}}
|
|
34
|
+
></iframe>
|
|
35
|
+
);
|
|
36
|
+
}
|
|
@@ -1,85 +1,85 @@
|
|
|
1
|
-
import React, { FC, MouseEventHandler, useEffect, useMemo, useState } from "react";
|
|
2
|
-
|
|
3
|
-
import {
|
|
4
|
-
baseUrls,
|
|
5
|
-
clientNames,
|
|
6
|
-
crossmintStatusButtonService,
|
|
7
|
-
crossmintStatusService,
|
|
8
|
-
onboardingRequestStatusResponse,
|
|
9
|
-
} from "@crossmint/client-sdk-base";
|
|
10
|
-
|
|
11
|
-
import { formatProps, useStyles } from "./styles";
|
|
12
|
-
import { CrossmintStatusButtonReactProps } from "./types";
|
|
13
|
-
import useEnvironment from "./useEnvironment";
|
|
14
|
-
import { LIB_VERSION } from "./version";
|
|
15
|
-
|
|
16
|
-
export function CrossmintStatusButton({
|
|
17
|
-
className,
|
|
18
|
-
disabled,
|
|
19
|
-
onClick,
|
|
20
|
-
style,
|
|
21
|
-
tabIndex,
|
|
22
|
-
theme = "dark",
|
|
23
|
-
clientId,
|
|
24
|
-
auctionId,
|
|
25
|
-
platformId,
|
|
26
|
-
mintConfig,
|
|
27
|
-
environment,
|
|
28
|
-
locale = "en-US",
|
|
29
|
-
...props
|
|
30
|
-
}: CrossmintStatusButtonReactProps) {
|
|
31
|
-
const [status, setStatus] = useState(onboardingRequestStatusResponse.WAITING_SUBMISSION);
|
|
32
|
-
const { isServerSideRendering } = useEnvironment();
|
|
33
|
-
|
|
34
|
-
const { goToOnboarding, fetchClientIntegration } = crossmintStatusService({
|
|
35
|
-
libVersion: LIB_VERSION,
|
|
36
|
-
clientId,
|
|
37
|
-
environment,
|
|
38
|
-
platformId,
|
|
39
|
-
auctionId,
|
|
40
|
-
mintConfig,
|
|
41
|
-
setStatus,
|
|
42
|
-
clientName: clientNames.reactUi,
|
|
43
|
-
});
|
|
44
|
-
const { getButtonText, isButtonDisabled, handleClick } = crossmintStatusButtonService({ onClick, locale });
|
|
45
|
-
|
|
46
|
-
const _handleClick: MouseEventHandler<HTMLButtonElement> = (e) => handleClick(e, status, goToOnboarding);
|
|
47
|
-
|
|
48
|
-
useEffect(() => {
|
|
49
|
-
fetchClientIntegration();
|
|
50
|
-
|
|
51
|
-
const interval = setInterval(() => {
|
|
52
|
-
fetchClientIntegration();
|
|
53
|
-
}, 60 * 1000);
|
|
54
|
-
|
|
55
|
-
return () => clearInterval(interval);
|
|
56
|
-
}, []);
|
|
57
|
-
|
|
58
|
-
const classes = useStyles(formatProps(theme));
|
|
59
|
-
|
|
60
|
-
const content = useMemo(() => {
|
|
61
|
-
return <span className={classes.crossmintParagraph}>{getButtonText(status)}</span>;
|
|
62
|
-
}, [status]);
|
|
63
|
-
|
|
64
|
-
return (
|
|
65
|
-
<>
|
|
66
|
-
{!isServerSideRendering && (
|
|
67
|
-
<button
|
|
68
|
-
className={`${classes.crossmintButton} ${className || ""}`}
|
|
69
|
-
disabled={isButtonDisabled(status)}
|
|
70
|
-
onClick={_handleClick}
|
|
71
|
-
style={{ ...style }}
|
|
72
|
-
tabIndex={tabIndex}
|
|
73
|
-
{...props}
|
|
74
|
-
>
|
|
75
|
-
<img
|
|
76
|
-
className={classes.crossmintImg}
|
|
77
|
-
src={`${baseUrls.prod}/assets/crossmint/logo.svg`}
|
|
78
|
-
alt="Crossmint logo"
|
|
79
|
-
/>
|
|
80
|
-
{content}
|
|
81
|
-
</button>
|
|
82
|
-
)}
|
|
83
|
-
</>
|
|
84
|
-
);
|
|
85
|
-
}
|
|
1
|
+
import React, { FC, MouseEventHandler, useEffect, useMemo, useState } from "react";
|
|
2
|
+
|
|
3
|
+
import {
|
|
4
|
+
baseUrls,
|
|
5
|
+
clientNames,
|
|
6
|
+
crossmintStatusButtonService,
|
|
7
|
+
crossmintStatusService,
|
|
8
|
+
onboardingRequestStatusResponse,
|
|
9
|
+
} from "@crossmint/client-sdk-base";
|
|
10
|
+
|
|
11
|
+
import { formatProps, useStyles } from "./styles";
|
|
12
|
+
import { CrossmintStatusButtonReactProps } from "./types";
|
|
13
|
+
import useEnvironment from "./useEnvironment";
|
|
14
|
+
import { LIB_VERSION } from "./version";
|
|
15
|
+
|
|
16
|
+
export function CrossmintStatusButton({
|
|
17
|
+
className,
|
|
18
|
+
disabled,
|
|
19
|
+
onClick,
|
|
20
|
+
style,
|
|
21
|
+
tabIndex,
|
|
22
|
+
theme = "dark",
|
|
23
|
+
clientId,
|
|
24
|
+
auctionId,
|
|
25
|
+
platformId,
|
|
26
|
+
mintConfig,
|
|
27
|
+
environment,
|
|
28
|
+
locale = "en-US",
|
|
29
|
+
...props
|
|
30
|
+
}: CrossmintStatusButtonReactProps) {
|
|
31
|
+
const [status, setStatus] = useState(onboardingRequestStatusResponse.WAITING_SUBMISSION);
|
|
32
|
+
const { isServerSideRendering } = useEnvironment();
|
|
33
|
+
|
|
34
|
+
const { goToOnboarding, fetchClientIntegration } = crossmintStatusService({
|
|
35
|
+
libVersion: LIB_VERSION,
|
|
36
|
+
clientId,
|
|
37
|
+
environment,
|
|
38
|
+
platformId,
|
|
39
|
+
auctionId,
|
|
40
|
+
mintConfig,
|
|
41
|
+
setStatus,
|
|
42
|
+
clientName: clientNames.reactUi,
|
|
43
|
+
});
|
|
44
|
+
const { getButtonText, isButtonDisabled, handleClick } = crossmintStatusButtonService({ onClick, locale });
|
|
45
|
+
|
|
46
|
+
const _handleClick: MouseEventHandler<HTMLButtonElement> = (e) => handleClick(e, status, goToOnboarding);
|
|
47
|
+
|
|
48
|
+
useEffect(() => {
|
|
49
|
+
fetchClientIntegration();
|
|
50
|
+
|
|
51
|
+
const interval = setInterval(() => {
|
|
52
|
+
fetchClientIntegration();
|
|
53
|
+
}, 60 * 1000);
|
|
54
|
+
|
|
55
|
+
return () => clearInterval(interval);
|
|
56
|
+
}, []);
|
|
57
|
+
|
|
58
|
+
const classes = useStyles(formatProps(theme));
|
|
59
|
+
|
|
60
|
+
const content = useMemo(() => {
|
|
61
|
+
return <span className={classes.crossmintParagraph}>{getButtonText(status)}</span>;
|
|
62
|
+
}, [status]);
|
|
63
|
+
|
|
64
|
+
return (
|
|
65
|
+
<>
|
|
66
|
+
{!isServerSideRendering && (
|
|
67
|
+
<button
|
|
68
|
+
className={`${classes.crossmintButton} ${className || ""}`}
|
|
69
|
+
disabled={isButtonDisabled(status)}
|
|
70
|
+
onClick={_handleClick}
|
|
71
|
+
style={{ ...style }}
|
|
72
|
+
tabIndex={tabIndex}
|
|
73
|
+
{...props}
|
|
74
|
+
>
|
|
75
|
+
<img
|
|
76
|
+
className={classes.crossmintImg}
|
|
77
|
+
src={`${baseUrls.prod}/assets/crossmint/logo.svg`}
|
|
78
|
+
alt="Crossmint logo"
|
|
79
|
+
/>
|
|
80
|
+
{content}
|
|
81
|
+
</button>
|
|
82
|
+
)}
|
|
83
|
+
</>
|
|
84
|
+
);
|
|
85
|
+
}
|
package/src/index.ts
CHANGED
|
@@ -1,4 +1,7 @@
|
|
|
1
|
-
export * from "./CrossmintPayButton";
|
|
2
|
-
export * from "./CrossmintStatusButton";
|
|
3
|
-
export * from "./CrossmintNFTCollectionView";
|
|
4
|
-
export * from "./CrossmintNFTDetail";
|
|
1
|
+
export * from "./CrossmintPayButton";
|
|
2
|
+
export * from "./CrossmintStatusButton";
|
|
3
|
+
export * from "./CrossmintNFTCollectionView";
|
|
4
|
+
export * from "./CrossmintNFTDetail";
|
|
5
|
+
export * from "./CrossmintPaymentElement";
|
|
6
|
+
export { CheckoutEvents, useCrossmintEvents } from "@crossmint/client-sdk-base";
|
|
7
|
+
export type { CrossmintCheckoutEvent, CheckoutEventMap } from "@crossmint/client-sdk-base";
|