@crossmint/client-sdk-react-ui 0.1.3 → 0.1.4-alpha.0
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/lib/index.cjs +1 -0
- package/lib/index.d.ts +17 -0
- package/lib/index.js +1 -0
- package/package.json +9 -9
- package/src/CrossmintPayButton.tsx +47 -26
- package/src/CrossmintStatusButton.tsx +29 -43
- package/src/types.ts +5 -55
- package/src/version.ts +1 -1
- package/lib/cjs/CrossmintPayButton.d.ts +0 -3
- package/lib/cjs/CrossmintPayButton.js +0 -91
- package/lib/cjs/CrossmintPayButton.js.map +0 -1
- package/lib/cjs/CrossmintStatusButton.d.ts +0 -3
- package/lib/cjs/CrossmintStatusButton.js +0 -90
- package/lib/cjs/CrossmintStatusButton.js.map +0 -1
- package/lib/cjs/hooks/useCrossmintModal.d.ts +0 -12
- package/lib/cjs/hooks/useCrossmintModal.js +0 -90
- package/lib/cjs/hooks/useCrossmintModal.js.map +0 -1
- package/lib/cjs/hooks/useCrossmintStatus.d.ts +0 -19
- package/lib/cjs/hooks/useCrossmintStatus.js +0 -75
- package/lib/cjs/hooks/useCrossmintStatus.js.map +0 -1
- package/lib/cjs/index.d.ts +0 -2
- package/lib/cjs/index.js +0 -19
- package/lib/cjs/index.js.map +0 -1
- package/lib/cjs/package.json +0 -3
- package/lib/cjs/styles/index.d.ts +0 -9
- package/lib/cjs/styles/index.js +0 -45
- package/lib/cjs/styles/index.js.map +0 -1
- package/lib/cjs/types.d.ts +0 -52
- package/lib/cjs/types.js +0 -24
- package/lib/cjs/types.js.map +0 -1
- package/lib/cjs/utils.d.ts +0 -1
- package/lib/cjs/utils.js +0 -5
- package/lib/cjs/utils.js.map +0 -1
- package/lib/cjs/version.d.ts +0 -1
- package/lib/cjs/version.js +0 -5
- package/lib/cjs/version.js.map +0 -1
- package/lib/esm/CrossmintPayButton.d.ts +0 -3
- package/lib/esm/CrossmintPayButton.js +0 -49
- package/lib/esm/CrossmintPayButton.js.map +0 -1
- package/lib/esm/CrossmintStatusButton.d.ts +0 -3
- package/lib/esm/CrossmintStatusButton.js +0 -51
- package/lib/esm/CrossmintStatusButton.js.map +0 -1
- package/lib/esm/hooks/useCrossmintModal.d.ts +0 -12
- package/lib/esm/hooks/useCrossmintModal.js +0 -87
- package/lib/esm/hooks/useCrossmintModal.js.map +0 -1
- package/lib/esm/hooks/useCrossmintStatus.d.ts +0 -19
- package/lib/esm/hooks/useCrossmintStatus.js +0 -60
- package/lib/esm/hooks/useCrossmintStatus.js.map +0 -1
- package/lib/esm/index.d.ts +0 -2
- package/lib/esm/index.js +0 -3
- package/lib/esm/index.js.map +0 -1
- package/lib/esm/package.json +0 -3
- package/lib/esm/styles/index.d.ts +0 -9
- package/lib/esm/styles/index.js +0 -41
- package/lib/esm/styles/index.js.map +0 -1
- package/lib/esm/types.d.ts +0 -52
- package/lib/esm/types.js +0 -21
- package/lib/esm/types.js.map +0 -1
- package/lib/esm/utils.d.ts +0 -1
- package/lib/esm/utils.js +0 -2
- package/lib/esm/utils.js.map +0 -1
- package/lib/esm/version.d.ts +0 -1
- package/lib/esm/version.js +0 -2
- package/lib/esm/version.js.map +0 -1
- package/src/hooks/useCrossmintModal.ts +0 -142
- package/src/hooks/useCrossmintStatus.ts +0 -85
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
export declare enum OnboardingRequestStatusResponse {
|
|
2
|
-
WAITING_SUBMISSION = "waiting-submission",
|
|
3
|
-
PENDING = "pending",
|
|
4
|
-
REJECTED = "rejected",
|
|
5
|
-
ACCEPTED = "accepted",
|
|
6
|
-
INVALID = "invalid"
|
|
7
|
-
}
|
|
8
|
-
export interface CrossMintStatusContextState {
|
|
9
|
-
status: OnboardingRequestStatusResponse;
|
|
10
|
-
clientId: string;
|
|
11
|
-
auctionId?: string;
|
|
12
|
-
hideMintOnInactiveClient: boolean;
|
|
13
|
-
}
|
|
14
|
-
interface IProps {
|
|
15
|
-
clientId: string;
|
|
16
|
-
development: boolean;
|
|
17
|
-
}
|
|
18
|
-
export default function useCrossMintStatus({ clientId, development }: IProps): OnboardingRequestStatusResponse;
|
|
19
|
-
export {};
|
|
@@ -1,60 +0,0 @@
|
|
|
1
|
-
import { useState, useEffect } from "react";
|
|
2
|
-
import { validate } from "uuid";
|
|
3
|
-
import { LIB_VERSION } from "../version";
|
|
4
|
-
import { clientNames, baseUrls, customHeaders } from "../types";
|
|
5
|
-
export var OnboardingRequestStatusResponse;
|
|
6
|
-
(function (OnboardingRequestStatusResponse) {
|
|
7
|
-
OnboardingRequestStatusResponse["WAITING_SUBMISSION"] = "waiting-submission";
|
|
8
|
-
OnboardingRequestStatusResponse["PENDING"] = "pending";
|
|
9
|
-
OnboardingRequestStatusResponse["REJECTED"] = "rejected";
|
|
10
|
-
OnboardingRequestStatusResponse["ACCEPTED"] = "accepted";
|
|
11
|
-
OnboardingRequestStatusResponse["INVALID"] = "invalid";
|
|
12
|
-
})(OnboardingRequestStatusResponse || (OnboardingRequestStatusResponse = {}));
|
|
13
|
-
const validateClientId = (clientId) => {
|
|
14
|
-
try {
|
|
15
|
-
const isValid = validate(clientId);
|
|
16
|
-
return !!isValid;
|
|
17
|
-
}
|
|
18
|
-
catch (e) {
|
|
19
|
-
console.error(e);
|
|
20
|
-
return false;
|
|
21
|
-
}
|
|
22
|
-
};
|
|
23
|
-
export default function useCrossMintStatus({ clientId, development }) {
|
|
24
|
-
const [status, setStatus] = useState(OnboardingRequestStatusResponse.WAITING_SUBMISSION);
|
|
25
|
-
async function fetchClientIntegration() {
|
|
26
|
-
if (!clientId || clientId === "" || clientId === "<YOUR_CLIENT_ID>") {
|
|
27
|
-
console.error("You must enter your own Crossmint client ID in <CrossmintPayButton clientId=XXX>");
|
|
28
|
-
return;
|
|
29
|
-
}
|
|
30
|
-
if (!validateClientId(clientId)) {
|
|
31
|
-
console.error("The clientId passed to is invalid. Make sure to pass the clientId obtained from the crossmint team, with format XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXX");
|
|
32
|
-
return;
|
|
33
|
-
}
|
|
34
|
-
const baseUrl = development ? baseUrls.dev : baseUrls.prod;
|
|
35
|
-
const res = await fetch(`${baseUrl}/api/crossmint/onboardingRequests/${clientId}/status`, {
|
|
36
|
-
headers: {
|
|
37
|
-
[customHeaders.clientVersion]: LIB_VERSION,
|
|
38
|
-
[customHeaders.clientName]: clientNames.reactUi,
|
|
39
|
-
},
|
|
40
|
-
});
|
|
41
|
-
if (res.status === 200) {
|
|
42
|
-
const resData = await res.json();
|
|
43
|
-
setStatus(resData.status);
|
|
44
|
-
}
|
|
45
|
-
else {
|
|
46
|
-
if (status !== OnboardingRequestStatusResponse.INVALID) {
|
|
47
|
-
setStatus(OnboardingRequestStatusResponse.INVALID);
|
|
48
|
-
}
|
|
49
|
-
}
|
|
50
|
-
}
|
|
51
|
-
useEffect(() => {
|
|
52
|
-
fetchClientIntegration();
|
|
53
|
-
const interval = setInterval(() => {
|
|
54
|
-
fetchClientIntegration();
|
|
55
|
-
}, 60 * 1000);
|
|
56
|
-
return () => clearInterval(interval);
|
|
57
|
-
}, []);
|
|
58
|
-
return status;
|
|
59
|
-
}
|
|
60
|
-
//# sourceMappingURL=useCrossmintStatus.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"useCrossmintStatus.js","sourceRoot":"","sources":["../../../src/hooks/useCrossmintStatus.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,SAAS,EAAE,MAAM,OAAO,CAAC;AAC5C,OAAO,EAAE,QAAQ,EAAE,MAAM,MAAM,CAAC;AAChC,OAAO,EAAE,WAAW,EAAE,MAAM,YAAY,CAAC;AACzC,OAAO,EAAE,WAAW,EAAE,QAAQ,EAAE,aAAa,EAAE,MAAM,UAAU,CAAC;AAEhE,MAAM,CAAN,IAAY,+BAMX;AAND,WAAY,+BAA+B;IACvC,4EAAyC,CAAA;IACzC,sDAAmB,CAAA;IACnB,wDAAqB,CAAA;IACrB,wDAAqB,C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,GAAkE,MAAM,GAAG,CAAC,IAAI,EAAE,CAAC;YAEhG,SAAS,CAAC,OAAO,CAAC,MAAM,CAAC,CAAC;SAC7B;aAAM;YACH,IAAI,MAAM,KAAK,+BAA+B,CAAC,OAAO,EAAE;gBACpD,SAAS,CAAC,+BAA+B,CAAC,OAAO,CAAC,CAAC;aACtD;SACJ;IACL,CAAC;IAED,SAAS,CAAC,GAAG,EAAE;QACX,sBAAsB,EAAE,CAAC;QAEzB,MAAM,QAAQ,GAAG,WAAW,CAAC,GAAG,EAAE;YAC9B,sBAAsB,EAAE,CAAC;QAC7B,CAAC,EAAE,EAAE,GAAG,IAAI,CAAC,CAAC;QAEd,OAAO,GAAG,EAAE,CAAC,aAAa,CAAC,QAAQ,CAAC,CAAC;IACzC,CAAC,EAAE,EAAE,CAAC,CAAC;IAEP,OAAO,MAAM,CAAC;AAClB,CAAC"}
|
package/lib/esm/index.d.ts
DELETED
package/lib/esm/index.js
DELETED
package/lib/esm/index.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,sBAAsB,CAAC;AACrC,cAAc,yBAAyB,CAAC"}
|
package/lib/esm/package.json
DELETED
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
interface CustomStylingProps {
|
|
2
|
-
buttonBgColor?: string;
|
|
3
|
-
paragraphColor?: string;
|
|
4
|
-
}
|
|
5
|
-
export declare const formatProps: (theme: string) => CustomStylingProps;
|
|
6
|
-
export declare const useStyles: (data?: (CustomStylingProps & {
|
|
7
|
-
theme?: Jss.Theme | undefined;
|
|
8
|
-
}) | undefined) => import("jss").Classes<"@global" | "crossmintButton" | "crossmintImg" | "crossmintParagraph">;
|
|
9
|
-
export {};
|
package/lib/esm/styles/index.js
DELETED
|
@@ -1,41 +0,0 @@
|
|
|
1
|
-
import { createUseStyles } from "react-jss";
|
|
2
|
-
const DARK_BG = "#1e1e1e";
|
|
3
|
-
const themeIsLight = (theme) => theme === "light";
|
|
4
|
-
export const formatProps = (theme) => ({
|
|
5
|
-
buttonBgColor: themeIsLight(theme) ? "white" : DARK_BG,
|
|
6
|
-
paragraphColor: themeIsLight(theme) ? "black" : "white",
|
|
7
|
-
});
|
|
8
|
-
export const useStyles = createUseStyles({
|
|
9
|
-
"@global": {
|
|
10
|
-
"@import": "url('https://fonts.googleapis.com/css2?family=Inter:wght@100;200;300;400;500;600;700;800;900&display=swap')",
|
|
11
|
-
},
|
|
12
|
-
crossmintButton: {
|
|
13
|
-
display: "flex",
|
|
14
|
-
"flex-direction": "row",
|
|
15
|
-
"align-items": "center",
|
|
16
|
-
padding: "0.875rem 0.875rem",
|
|
17
|
-
"font-weight": "900",
|
|
18
|
-
transition: "opacity ease-in-out 0.25s",
|
|
19
|
-
"border-radius": "0.5rem",
|
|
20
|
-
"font-family": `"Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Oxygen, Ubuntu, Cantarell, "Open Sans", "Helvetica Neue", sans-serif`,
|
|
21
|
-
outline: "none",
|
|
22
|
-
border: "none",
|
|
23
|
-
"box-shadow": "0px 8px 15px rgba(0, 0, 0, 0.1)",
|
|
24
|
-
"justify-content": "center",
|
|
25
|
-
background: ({ buttonBgColor }) => buttonBgColor,
|
|
26
|
-
"&:hover:enabled": {
|
|
27
|
-
opacity: "0.6",
|
|
28
|
-
cursor: "pointer",
|
|
29
|
-
},
|
|
30
|
-
},
|
|
31
|
-
crossmintImg: {
|
|
32
|
-
width: "21px",
|
|
33
|
-
height: "21px",
|
|
34
|
-
"margin-right": "0.875rem",
|
|
35
|
-
},
|
|
36
|
-
crossmintParagraph: {
|
|
37
|
-
color: ({ paragraphColor }) => paragraphColor,
|
|
38
|
-
margin: "0",
|
|
39
|
-
},
|
|
40
|
-
});
|
|
41
|
-
//# sourceMappingURL=index.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../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,GAAG;KACd;CACJ,CAAC,CAAC"}
|
package/lib/esm/types.d.ts
DELETED
|
@@ -1,52 +0,0 @@
|
|
|
1
|
-
import { CSSProperties, MouseEvent } from "react";
|
|
2
|
-
export declare enum clientNames {
|
|
3
|
-
reactUi = "client-sdk-react-ui"
|
|
4
|
-
}
|
|
5
|
-
export declare enum baseUrls {
|
|
6
|
-
prod = "https://www.crossmint.io",
|
|
7
|
-
dev = "http://localhost:3001"
|
|
8
|
-
}
|
|
9
|
-
export declare enum customHeaders {
|
|
10
|
-
clientVersion = "X-Client-Version",
|
|
11
|
-
clientName = "X-Client-Name"
|
|
12
|
-
}
|
|
13
|
-
declare type theme = "light" | "dark";
|
|
14
|
-
export declare enum mintingContractTypes {
|
|
15
|
-
CANDY_MACHINE = "candy-machine",
|
|
16
|
-
SOLANA_AUCTION = "solana-auction",
|
|
17
|
-
ERC_721 = "erc-721"
|
|
18
|
-
}
|
|
19
|
-
export interface PayButtonConfig {
|
|
20
|
-
type: string;
|
|
21
|
-
[propName: string]: any;
|
|
22
|
-
}
|
|
23
|
-
export interface StatusButtonConfig {
|
|
24
|
-
[propName: string]: any;
|
|
25
|
-
}
|
|
26
|
-
export interface BaseButtonProps {
|
|
27
|
-
className?: string;
|
|
28
|
-
disabled?: boolean;
|
|
29
|
-
onClick?: (e: MouseEvent<HTMLButtonElement>) => void;
|
|
30
|
-
style?: CSSProperties;
|
|
31
|
-
tabIndex?: number;
|
|
32
|
-
clientId: string;
|
|
33
|
-
auctionId?: string;
|
|
34
|
-
theme?: theme;
|
|
35
|
-
development?: boolean;
|
|
36
|
-
}
|
|
37
|
-
export interface CrossmintPayButtonProps extends BaseButtonProps {
|
|
38
|
-
collectionTitle?: string;
|
|
39
|
-
collectionDescription?: string;
|
|
40
|
-
collectionPhoto?: string;
|
|
41
|
-
mintTo?: string;
|
|
42
|
-
emailTo?: string;
|
|
43
|
-
listingId?: string;
|
|
44
|
-
showOverlay?: boolean;
|
|
45
|
-
hideMintOnInactiveClient?: boolean;
|
|
46
|
-
mintConfig?: PayButtonConfig;
|
|
47
|
-
}
|
|
48
|
-
export interface CrossmintStatusButtonProps extends BaseButtonProps {
|
|
49
|
-
platformId?: string;
|
|
50
|
-
mintConfig?: StatusButtonConfig;
|
|
51
|
-
}
|
|
52
|
-
export {};
|
package/lib/esm/types.js
DELETED
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
export var clientNames;
|
|
2
|
-
(function (clientNames) {
|
|
3
|
-
clientNames["reactUi"] = "client-sdk-react-ui";
|
|
4
|
-
})(clientNames || (clientNames = {}));
|
|
5
|
-
export var baseUrls;
|
|
6
|
-
(function (baseUrls) {
|
|
7
|
-
baseUrls["prod"] = "https://www.crossmint.io";
|
|
8
|
-
baseUrls["dev"] = "http://localhost:3001";
|
|
9
|
-
})(baseUrls || (baseUrls = {}));
|
|
10
|
-
export var customHeaders;
|
|
11
|
-
(function (customHeaders) {
|
|
12
|
-
customHeaders["clientVersion"] = "X-Client-Version";
|
|
13
|
-
customHeaders["clientName"] = "X-Client-Name";
|
|
14
|
-
})(customHeaders || (customHeaders = {}));
|
|
15
|
-
export var mintingContractTypes;
|
|
16
|
-
(function (mintingContractTypes) {
|
|
17
|
-
mintingContractTypes["CANDY_MACHINE"] = "candy-machine";
|
|
18
|
-
mintingContractTypes["SOLANA_AUCTION"] = "solana-auction";
|
|
19
|
-
mintingContractTypes["ERC_721"] = "erc-721";
|
|
20
|
-
})(mintingContractTypes || (mintingContractTypes = {}));
|
|
21
|
-
//# sourceMappingURL=types.js.map
|
package/lib/esm/types.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"types.js","sourceRoot":"","sources":["../../src/types.ts"],"names":[],"mappings":"AAEA,MAAM,CAAN,IAAY,WAEX;AAFD,WAAY,WAAW;IACnB,8CAA+B,CAAA;AACnC,CAAC,EAFW,WAAW,KAAX,WAAW,QAEtB;AAED,MAAM,CAAN,IAAY,QAGX;AAHD,WAAY,QAAQ;IAChB,6CAAiC,CAAA;IACjC,yCAA6B,CAAA;AACjC,CAAC,EAHW,QAAQ,KAAR,QAAQ,QAGnB;AAED,MAAM,CAAN,IAAY,aAGX;AAHD,WAAY,aAAa;IACrB,mDAAkC,CAAA;IAClC,6CAA4B,CAAA;AAChC,CAAC,EAHW,aAAa,KAAb,aAAa,QAGxB;AAID,MAAM,CAAN,IAAY,oBAIX;AAJD,WAAY,oBAAoB;IAC5B,uDAA+B,CAAA;IAC/B,yDAAiC,CAAA;IACjC,2CAAmB,CAAA;AACvB,CAAC,EAJW,oBAAoB,KAApB,oBAAoB,QAI/B"}
|
package/lib/esm/utils.d.ts
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export declare const isClientSide: boolean;
|
package/lib/esm/utils.js
DELETED
package/lib/esm/utils.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"utils.js","sourceRoot":"","sources":["../../src/utils.ts"],"names":[],"mappings":"AAAA,MAAM,CAAC,MAAM,YAAY,GAAG,OAAO,MAAM,KAAK,WAAW,CAAC"}
|
package/lib/esm/version.d.ts
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export declare const LIB_VERSION = "0.1.2";
|
package/lib/esm/version.js
DELETED
package/lib/esm/version.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"version.js","sourceRoot":"","sources":["../../src/version.ts"],"names":[],"mappings":"AAAA,MAAM,CAAC,MAAM,WAAW,GAAG,OAAO,CAAC"}
|
|
@@ -1,142 +0,0 @@
|
|
|
1
|
-
import { useState } from "react";
|
|
2
|
-
import { LIB_VERSION } from "../version";
|
|
3
|
-
import { baseUrls, clientNames, PayButtonConfig } from "../types";
|
|
4
|
-
|
|
5
|
-
function createPopupString() {
|
|
6
|
-
return `height=750,width=400,left=${window.innerWidth / 2 - 200},top=${
|
|
7
|
-
window.innerHeight / 2 - 375
|
|
8
|
-
},resizable=yes,scrollbars=yes,toolbar=yes,menubar=true,location=no,directories=no, status=yes`;
|
|
9
|
-
}
|
|
10
|
-
|
|
11
|
-
interface IProps {
|
|
12
|
-
development: boolean;
|
|
13
|
-
clientId: string;
|
|
14
|
-
showOverlay: boolean;
|
|
15
|
-
}
|
|
16
|
-
|
|
17
|
-
interface IReturn {
|
|
18
|
-
connecting: boolean;
|
|
19
|
-
connect: (
|
|
20
|
-
mintConfig: PayButtonConfig,
|
|
21
|
-
collectionTitle?: string,
|
|
22
|
-
collectionDescription?: string,
|
|
23
|
-
collectionPhoto?: string,
|
|
24
|
-
mintTo?: string,
|
|
25
|
-
emailTo?: string,
|
|
26
|
-
listingId?: string
|
|
27
|
-
) => void;
|
|
28
|
-
}
|
|
29
|
-
|
|
30
|
-
type MintQueryParams = {
|
|
31
|
-
clientId: string;
|
|
32
|
-
closeOnSuccess: string;
|
|
33
|
-
collectionTitle?: string;
|
|
34
|
-
collectionDescription?: string;
|
|
35
|
-
collectionPhoto?: string;
|
|
36
|
-
mintTo?: string;
|
|
37
|
-
emailTo?: string;
|
|
38
|
-
listingId?: string;
|
|
39
|
-
clientName: string;
|
|
40
|
-
clientVersion: string;
|
|
41
|
-
mintConfig: string;
|
|
42
|
-
};
|
|
43
|
-
|
|
44
|
-
const overlayId = "__crossmint-overlay__";
|
|
45
|
-
|
|
46
|
-
const addLoadingOverlay = (): void => {
|
|
47
|
-
const overlayEl = document.createElement("div");
|
|
48
|
-
overlayEl.setAttribute("id", overlayId);
|
|
49
|
-
const overlayStyles = {
|
|
50
|
-
width: "100vw",
|
|
51
|
-
height: "100vh",
|
|
52
|
-
"background-color": "rgba(0, 0, 0, 0.5)",
|
|
53
|
-
position: "fixed",
|
|
54
|
-
"z-index": "99999999",
|
|
55
|
-
top: "0",
|
|
56
|
-
left: "0",
|
|
57
|
-
};
|
|
58
|
-
Object.assign(overlayEl.style, overlayStyles);
|
|
59
|
-
document.body.appendChild(overlayEl);
|
|
60
|
-
};
|
|
61
|
-
|
|
62
|
-
const removeLoadingOverlay = (): void => {
|
|
63
|
-
const overlayEl = document.getElementById(overlayId);
|
|
64
|
-
if (overlayEl) overlayEl.remove();
|
|
65
|
-
};
|
|
66
|
-
|
|
67
|
-
export default function useCrossMintModal({ development, clientId, showOverlay }: IProps): IReturn {
|
|
68
|
-
const [connecting, setConnecting] = useState(false);
|
|
69
|
-
|
|
70
|
-
const createPopup = (
|
|
71
|
-
mintConfig: PayButtonConfig,
|
|
72
|
-
collectionTitle?: string,
|
|
73
|
-
collectionDescription?: string,
|
|
74
|
-
collectionPhoto?: string,
|
|
75
|
-
mintTo?: string,
|
|
76
|
-
emailTo?: string,
|
|
77
|
-
listingId?: string
|
|
78
|
-
) => {
|
|
79
|
-
const urlOrigin = development ? baseUrls.dev : baseUrls.prod;
|
|
80
|
-
const getMintQueryParams = (): string => {
|
|
81
|
-
const mintQueryParams: MintQueryParams = {
|
|
82
|
-
clientId: clientId,
|
|
83
|
-
closeOnSuccess: "false",
|
|
84
|
-
clientName: clientNames.reactUi,
|
|
85
|
-
clientVersion: LIB_VERSION,
|
|
86
|
-
mintConfig: JSON.stringify(mintConfig),
|
|
87
|
-
};
|
|
88
|
-
|
|
89
|
-
if (collectionTitle) mintQueryParams.collectionTitle = collectionTitle;
|
|
90
|
-
if (collectionDescription) mintQueryParams.collectionDescription = collectionDescription;
|
|
91
|
-
if (collectionPhoto) mintQueryParams.collectionPhoto = collectionPhoto;
|
|
92
|
-
if (mintTo) mintQueryParams.mintTo = mintTo;
|
|
93
|
-
if (emailTo) mintQueryParams.emailTo = emailTo;
|
|
94
|
-
if (listingId) mintQueryParams.listingId = listingId;
|
|
95
|
-
|
|
96
|
-
return new URLSearchParams(mintQueryParams).toString();
|
|
97
|
-
};
|
|
98
|
-
const callbackUrl = encodeURIComponent(`${urlOrigin}/checkout/mint?${getMintQueryParams()}`);
|
|
99
|
-
const url = `${urlOrigin}/signin?callbackUrl=${callbackUrl}`;
|
|
100
|
-
|
|
101
|
-
const pop = window.open(url, "popUpWindow", createPopupString());
|
|
102
|
-
if (pop) {
|
|
103
|
-
registerListeners(pop);
|
|
104
|
-
if (showOverlay) {
|
|
105
|
-
addLoadingOverlay();
|
|
106
|
-
}
|
|
107
|
-
} else {
|
|
108
|
-
setConnecting(false);
|
|
109
|
-
console.error("Failed to open popup window");
|
|
110
|
-
}
|
|
111
|
-
};
|
|
112
|
-
|
|
113
|
-
const connect = (
|
|
114
|
-
mintConfig: PayButtonConfig,
|
|
115
|
-
collectionTitle?: string,
|
|
116
|
-
collectionDescription?: string,
|
|
117
|
-
collectionPhoto?: string,
|
|
118
|
-
mintTo?: string,
|
|
119
|
-
emailTo?: string,
|
|
120
|
-
listingId?: string
|
|
121
|
-
) => {
|
|
122
|
-
if (connecting) return;
|
|
123
|
-
|
|
124
|
-
setConnecting(true);
|
|
125
|
-
|
|
126
|
-
createPopup(mintConfig, collectionTitle, collectionDescription, collectionPhoto, mintTo, emailTo, listingId);
|
|
127
|
-
};
|
|
128
|
-
|
|
129
|
-
function registerListeners(pop: Window) {
|
|
130
|
-
const timer = setInterval(function () {
|
|
131
|
-
if (pop.closed) {
|
|
132
|
-
clearInterval(timer);
|
|
133
|
-
setConnecting(false);
|
|
134
|
-
if (showOverlay) {
|
|
135
|
-
removeLoadingOverlay();
|
|
136
|
-
}
|
|
137
|
-
}
|
|
138
|
-
}, 500);
|
|
139
|
-
}
|
|
140
|
-
|
|
141
|
-
return { connecting, connect };
|
|
142
|
-
}
|
|
@@ -1,85 +0,0 @@
|
|
|
1
|
-
import { useState, useEffect } from "react";
|
|
2
|
-
import { validate } from "uuid";
|
|
3
|
-
import { LIB_VERSION } from "../version";
|
|
4
|
-
import { clientNames, baseUrls, customHeaders } from "../types";
|
|
5
|
-
|
|
6
|
-
export enum OnboardingRequestStatusResponse {
|
|
7
|
-
WAITING_SUBMISSION = "waiting-submission",
|
|
8
|
-
PENDING = "pending",
|
|
9
|
-
REJECTED = "rejected",
|
|
10
|
-
ACCEPTED = "accepted",
|
|
11
|
-
INVALID = "invalid",
|
|
12
|
-
}
|
|
13
|
-
|
|
14
|
-
export interface CrossMintStatusContextState {
|
|
15
|
-
status: OnboardingRequestStatusResponse;
|
|
16
|
-
clientId: string;
|
|
17
|
-
auctionId?: string;
|
|
18
|
-
hideMintOnInactiveClient: boolean;
|
|
19
|
-
}
|
|
20
|
-
|
|
21
|
-
interface IProps {
|
|
22
|
-
clientId: string;
|
|
23
|
-
development: boolean;
|
|
24
|
-
}
|
|
25
|
-
|
|
26
|
-
const validateClientId = (clientId: string): boolean => {
|
|
27
|
-
try {
|
|
28
|
-
const isValid = validate(clientId);
|
|
29
|
-
return !!isValid;
|
|
30
|
-
} catch (e) {
|
|
31
|
-
console.error(e);
|
|
32
|
-
return false;
|
|
33
|
-
}
|
|
34
|
-
};
|
|
35
|
-
|
|
36
|
-
export default function useCrossMintStatus({ clientId, development }: IProps) {
|
|
37
|
-
const [status, setStatus] = useState<OnboardingRequestStatusResponse>(
|
|
38
|
-
OnboardingRequestStatusResponse.WAITING_SUBMISSION
|
|
39
|
-
);
|
|
40
|
-
|
|
41
|
-
async function fetchClientIntegration() {
|
|
42
|
-
if (!clientId || clientId === "" || clientId === "<YOUR_CLIENT_ID>") {
|
|
43
|
-
console.error("You must enter your own Crossmint client ID in <CrossmintPayButton clientId=XXX>");
|
|
44
|
-
return;
|
|
45
|
-
}
|
|
46
|
-
|
|
47
|
-
if (!validateClientId(clientId)) {
|
|
48
|
-
console.error(
|
|
49
|
-
"The clientId passed to is invalid. Make sure to pass the clientId obtained from the crossmint team, with format XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXX"
|
|
50
|
-
);
|
|
51
|
-
return;
|
|
52
|
-
}
|
|
53
|
-
|
|
54
|
-
const baseUrl = development ? baseUrls.dev : baseUrls.prod;
|
|
55
|
-
|
|
56
|
-
const res = await fetch(`${baseUrl}/api/crossmint/onboardingRequests/${clientId}/status`, {
|
|
57
|
-
headers: {
|
|
58
|
-
[customHeaders.clientVersion]: LIB_VERSION,
|
|
59
|
-
[customHeaders.clientName]: clientNames.reactUi,
|
|
60
|
-
},
|
|
61
|
-
});
|
|
62
|
-
|
|
63
|
-
if (res.status === 200) {
|
|
64
|
-
const resData: { clientId: string; status: OnboardingRequestStatusResponse } = await res.json();
|
|
65
|
-
|
|
66
|
-
setStatus(resData.status);
|
|
67
|
-
} else {
|
|
68
|
-
if (status !== OnboardingRequestStatusResponse.INVALID) {
|
|
69
|
-
setStatus(OnboardingRequestStatusResponse.INVALID);
|
|
70
|
-
}
|
|
71
|
-
}
|
|
72
|
-
}
|
|
73
|
-
|
|
74
|
-
useEffect(() => {
|
|
75
|
-
fetchClientIntegration();
|
|
76
|
-
|
|
77
|
-
const interval = setInterval(() => {
|
|
78
|
-
fetchClientIntegration();
|
|
79
|
-
}, 60 * 1000);
|
|
80
|
-
|
|
81
|
-
return () => clearInterval(interval);
|
|
82
|
-
}, []);
|
|
83
|
-
|
|
84
|
-
return status;
|
|
85
|
-
}
|