@crossmint/client-sdk-react-ui 0.1.3 → 0.1.4-alpha.2
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 +10 -9
- package/src/CrossmintPayButton.tsx +62 -43
- 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
package/lib/index.cjs
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
var it=Object.create;var C=Object.defineProperty;var at=Object.getOwnPropertyDescriptor;var mt=Object.getOwnPropertyNames,P=Object.getOwnPropertySymbols,ut=Object.getPrototypeOf,V=Object.prototype.hasOwnProperty,q=Object.prototype.propertyIsEnumerable;var W=(t,o,s)=>o in t?C(t,o,{enumerable:!0,configurable:!0,writable:!0,value:s}):t[o]=s,l=(t,o)=>{for(var s in o||(o={}))V.call(o,s)&&W(t,s,o[s]);if(P)for(var s of P(o))q.call(o,s)&&W(t,s,o[s]);return t};var N=(t,o)=>{var s={};for(var e in t)V.call(t,e)&&o.indexOf(e)<0&&(s[e]=t[e]);if(t!=null&&P)for(var e of P(t))o.indexOf(e)<0&&q.call(t,e)&&(s[e]=t[e]);return s};var lt=(t,o)=>{for(var s in o)C(t,s,{get:o[s],enumerable:!0})},D=(t,o,s,e)=>{if(o&&typeof o=="object"||typeof o=="function")for(let i of mt(o))!V.call(t,i)&&i!==s&&C(t,i,{get:()=>o[i],enumerable:!(e=at(o,i))||e.enumerable});return t};var j=(t,o,s)=>(s=t!=null?it(ut(t)):{},D(o||!t||!t.__esModule?C(s,"default",{value:t,enumerable:!0}):s,t)),pt=t=>D(C({},"__esModule",{value:!0}),t);var St={};lt(St,{CrossmintPayButton:()=>ft,CrossmintStatusButton:()=>dt});module.exports=pt(St);var v=require("@crossmint/client-sdk-base"),n=j(require("react"),1);var Y=require("react-jss"),ct="#1e1e1e",K=t=>t==="light",w=t=>({buttonBgColor:K(t)?"white":ct,paragraphColor:K(t)?"black":"white"}),M=(0,Y.createUseStyles)({"@global":{"@import":"url('https://fonts.googleapis.com/css2?family=Inter:wght@100;200;300;400;500;600;700;800;900&display=swap')"},crossmintButton:{display:"flex","flex-direction":"row","align-items":"center",padding:"0.875rem 0.875rem","font-weight":"900",transition:"opacity ease-in-out 0.25s","border-radius":"0.5rem","font-family":'"Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Oxygen, Ubuntu, Cantarell, "Open Sans", "Helvetica Neue", sans-serif',outline:"none",border:"none","box-shadow":"0px 8px 15px rgba(0, 0, 0, 0.1)","justify-content":"center",background:({buttonBgColor:t})=>t,"&:hover:enabled":{opacity:"0.6",cursor:"pointer"}},crossmintImg:{width:"21px",height:"21px","margin-right":"0.875rem"},crossmintParagraph:{color:({paragraphColor:t})=>t,margin:"0"}});var E=typeof window<"u";var p=require("@crossmint/client-sdk-base"),F=require("react");var I="0.1.4-alpha.1";var gt={type:v.mintingContractTypes.CANDY_MACHINE},ft=R=>{var u=R,{className:t,disabled:o,onClick:s,style:e,tabIndex:i,theme:k="dark",collectionTitle:c,collectionDescription:g,collectionPhoto:f,mintTo:O,emailTo:T,listingId:_,clientId:H,auctionId:y,hideMintOnInactiveClient:a=!1,showOverlay:U=!0,mintConfig:B=gt,whPassThroughArgs:h,environment:x}=u,A=N(u,["className","disabled","onClick","style","tabIndex","theme","collectionTitle","collectionDescription","collectionPhoto","mintTo","emailTo","listingId","clientId","auctionId","hideMintOnInactiveClient","showOverlay","mintConfig","whPassThroughArgs","environment"]);let[d,S]=(0,F.useState)(!1),[$,z]=(0,F.useState)(p.onboardingRequestStatusResponse.WAITING_SUBMISSION),{fetchClientIntegration:J}=(0,p.crossmintStatusService)({libVersion:I,clientId:H,environment:x,auctionId:y,mintConfig:B,setStatus:z}),{connect:Q}=(0,p.crossmintModalService)({clientId:H,showOverlay:U,setConnecting:S,libVersion:I,environment:x}),{checkProps:X,getButtonText:Z,shouldHideButton:tt}=(0,v.crossmintPayButtonService)(),[st,ot,et]=X({collectionTitle:c,collectionPhoto:f,collectionDescription:g});c=st,g=ot,f=et,(0,n.useEffect)(()=>{a&&J()},[$]);let rt=G=>{s&&s(G),!d&&(G.defaultPrevented||Q(B,c,g,f,O,T,_,h))},L=M(w(k)),nt=(0,n.useMemo)(()=>n.default.createElement("p",{className:L.crossmintParagraph},Z(d)),[d]);return tt({hideMintOnInactiveClient:a,status:$})?null:n.default.createElement(n.default.Fragment,null,E&&n.default.createElement("button",l({className:`${L.crossmintButton} ${t||""}`,disabled:o,onClick:rt,style:l({},e),tabIndex:i},A),n.default.createElement("img",{className:L.crossmintImg,src:"https://www.crossmint.io/assets/crossmint/logo.png",alt:"Crossmint logo"}),nt))};var r=j(require("react"),1);var m=require("@crossmint/client-sdk-base");var dt=H=>{var y=H,{className:t,disabled:o,onClick:s,style:e,tabIndex:i,theme:k="dark",clientId:c,auctionId:g,platformId:f,mintConfig:O,environment:T}=y,_=N(y,["className","disabled","onClick","style","tabIndex","theme","clientId","auctionId","platformId","mintConfig","environment"]);let[a,U]=(0,r.useState)(m.onboardingRequestStatusResponse.WAITING_SUBMISSION),{goToOnboarding:B,fetchClientIntegration:h,getButtonText:x,isButtonDisabled:A}=(0,m.crossmintStatusService)({libVersion:I,clientId:c,environment:T,platformId:f,auctionId:g,mintConfig:O,setStatus:U}),R=(0,r.useCallback)(S=>{if(s&&s(S),a===m.onboardingRequestStatusResponse.WAITING_SUBMISSION){B();return}},[a]);(0,r.useEffect)(()=>{h();let S=setInterval(()=>{h()},60*1e3);return()=>clearInterval(S)},[]);let u=M(w(k)),d=(0,r.useMemo)(()=>r.default.createElement("p",{className:u.crossmintParagraph},x(a)),[a]);return r.default.createElement(r.default.Fragment,null,E&&r.default.createElement("button",l({className:`${u.crossmintButton} ${t||""}`,disabled:A(a),onClick:R,style:l({},e),tabIndex:i},_),r.default.createElement("img",{className:u.crossmintImg,src:`${m.baseUrls.prod}/assets/crossmint/logo.png`,alt:"Crossmint logo"}),d))};0&&(module.exports={CrossmintPayButton,CrossmintStatusButton});
|
package/lib/index.d.ts
ADDED
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { MouseEvent, CSSProperties, FC } from 'react';
|
|
2
|
+
import { CrossmintPayButtonProps, BaseButtonProps } from '@crossmint/client-sdk-base';
|
|
3
|
+
|
|
4
|
+
interface CrossmintPayButtonReactProps extends CrossmintPayButtonProps {
|
|
5
|
+
onClick?: (e: MouseEvent<HTMLButtonElement>) => void;
|
|
6
|
+
style?: CSSProperties;
|
|
7
|
+
}
|
|
8
|
+
interface CrossmintStatusButtonReactProps extends BaseButtonProps {
|
|
9
|
+
onClick?: (e: MouseEvent<HTMLButtonElement>) => void;
|
|
10
|
+
style?: CSSProperties;
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
declare const CrossmintPayButton: FC<CrossmintPayButtonReactProps>;
|
|
14
|
+
|
|
15
|
+
declare const CrossmintStatusButton: FC<CrossmintStatusButtonReactProps>;
|
|
16
|
+
|
|
17
|
+
export { CrossmintPayButton, CrossmintStatusButton };
|
package/lib/index.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
var st=Object.defineProperty;var B=Object.getOwnPropertySymbols;var F=Object.prototype.hasOwnProperty,R=Object.prototype.propertyIsEnumerable;var V=(t,o,s)=>o in t?st(t,o,{enumerable:!0,configurable:!0,writable:!0,value:s}):t[o]=s,i=(t,o)=>{for(var s in o||(o={}))F.call(o,s)&&V(t,s,o[s]);if(B)for(var s of B(o))R.call(o,s)&&V(t,s,o[s]);return t};var h=(t,o)=>{var s={};for(var e in t)F.call(t,e)&&o.indexOf(e)<0&&(s[e]=t[e]);if(t!=null&&B)for(var e of B(t))o.indexOf(e)<0&&R.call(t,e)&&(s[e]=t[e]);return s};import{mintingContractTypes as rt,crossmintPayButtonService as nt}from"@crossmint/client-sdk-base";import d,{useMemo as it,useEffect as at}from"react";import{createUseStyles as ot}from"react-jss";var et="#1e1e1e",$=t=>t==="light",x=t=>({buttonBgColor:$(t)?"white":et,paragraphColor:$(t)?"black":"white"}),P=ot({"@global":{"@import":"url('https://fonts.googleapis.com/css2?family=Inter:wght@100;200;300;400;500;600;700;800;900&display=swap')"},crossmintButton:{display:"flex","flex-direction":"row","align-items":"center",padding:"0.875rem 0.875rem","font-weight":"900",transition:"opacity ease-in-out 0.25s","border-radius":"0.5rem","font-family":'"Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Oxygen, Ubuntu, Cantarell, "Open Sans", "Helvetica Neue", sans-serif',outline:"none",border:"none","box-shadow":"0px 8px 15px rgba(0, 0, 0, 0.1)","justify-content":"center",background:({buttonBgColor:t})=>t,"&:hover:enabled":{opacity:"0.6",cursor:"pointer"}},crossmintImg:{width:"21px",height:"21px","margin-right":"0.875rem"},crossmintParagraph:{color:({paragraphColor:t})=>t,margin:"0"}});var N=typeof window<"u";import{crossmintModalService as mt,onboardingRequestStatusResponse as ut,crossmintStatusService as lt}from"@crossmint/client-sdk-base";import{useState as G}from"react";var f="0.1.4-alpha.1";var pt={type:rt.CANDY_MACHINE},Tt=U=>{var n=U,{className:t,disabled:o,onClick:s,style:e,tabIndex:w,theme:M="dark",collectionTitle:a,collectionDescription:m,collectionPhoto:u,mintTo:E,emailTo:v,listingId:k,clientId:O,auctionId:C,hideMintOnInactiveClient:r=!1,showOverlay:T=!0,mintConfig:b=pt,whPassThroughArgs:I,environment:y}=n,_=h(n,["className","disabled","onClick","style","tabIndex","theme","collectionTitle","collectionDescription","collectionPhoto","mintTo","emailTo","listingId","clientId","auctionId","hideMintOnInactiveClient","showOverlay","mintConfig","whPassThroughArgs","environment"]);let[l,p]=G(!1),[A,q]=G(ut.WAITING_SUBMISSION),{fetchClientIntegration:D}=lt({libVersion:f,clientId:O,environment:y,auctionId:C,mintConfig:b,setStatus:q}),{connect:j}=mt({clientId:O,showOverlay:T,setConnecting:p,libVersion:f,environment:y}),{checkProps:K,getButtonText:Y,shouldHideButton:z}=nt(),[J,Q,X]=K({collectionTitle:a,collectionPhoto:u,collectionDescription:m});a=J,m=Q,u=X,at(()=>{r&&D()},[A]);let Z=L=>{s&&s(L),!l&&(L.defaultPrevented||j(b,a,m,u,E,v,k,I))},H=P(x(M)),tt=it(()=>d.createElement("p",{className:H.crossmintParagraph},Y(l)),[l]);return z({hideMintOnInactiveClient:r,status:A})?null:d.createElement(d.Fragment,null,N&&d.createElement("button",i({className:`${H.crossmintButton} ${t||""}`,disabled:o,onClick:Z,style:i({},e),tabIndex:w},_),d.createElement("img",{className:H.crossmintImg,src:"https://www.crossmint.io/assets/crossmint/logo.png",alt:"Crossmint logo"}),tt))};import S,{useMemo as ct,useCallback as gt,useState as ft,useEffect as dt}from"react";import{baseUrls as St,onboardingRequestStatusResponse as W,crossmintStatusService as Ct}from"@crossmint/client-sdk-base";var $t=O=>{var C=O,{className:t,disabled:o,onClick:s,style:e,tabIndex:w,theme:M="dark",clientId:a,auctionId:m,platformId:u,mintConfig:E,environment:v}=C,k=h(C,["className","disabled","onClick","style","tabIndex","theme","clientId","auctionId","platformId","mintConfig","environment"]);let[r,T]=ft(W.WAITING_SUBMISSION),{goToOnboarding:b,fetchClientIntegration:I,getButtonText:y,isButtonDisabled:_}=Ct({libVersion:f,clientId:a,environment:v,platformId:u,auctionId:m,mintConfig:E,setStatus:T}),U=gt(p=>{if(s&&s(p),r===W.WAITING_SUBMISSION){b();return}},[r]);dt(()=>{I();let p=setInterval(()=>{I()},60*1e3);return()=>clearInterval(p)},[]);let n=P(x(M)),l=ct(()=>S.createElement("p",{className:n.crossmintParagraph},y(r)),[r]);return S.createElement(S.Fragment,null,N&&S.createElement("button",i({className:`${n.crossmintButton} ${t||""}`,disabled:_(r),onClick:U,style:i({},e),tabIndex:w},k),S.createElement("img",{className:n.crossmintImg,src:`${St.prod}/assets/crossmint/logo.png`,alt:"Crossmint logo"}),l))};export{Tt as CrossmintPayButton,$t as CrossmintStatusButton};
|
package/package.json
CHANGED
|
@@ -1,18 +1,18 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@crossmint/client-sdk-react-ui",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.4-alpha.2",
|
|
4
4
|
"author": "Paella Labs Inc",
|
|
5
5
|
"license": "Apache-2.0",
|
|
6
6
|
"repository": "https://github.com/CrossMint/crossmint-client-sdk",
|
|
7
7
|
"type": "module",
|
|
8
8
|
"sideEffects": false,
|
|
9
|
-
"main": "lib/
|
|
10
|
-
"module": "lib/
|
|
11
|
-
"types": "lib/
|
|
9
|
+
"main": "lib/index.cjs",
|
|
10
|
+
"module": "lib/index.js",
|
|
11
|
+
"types": "lib/index.d.ts",
|
|
12
12
|
"exports": {
|
|
13
13
|
".": {
|
|
14
|
-
"import": "./lib/
|
|
15
|
-
"require": "./lib/
|
|
14
|
+
"import": "./lib/index.js",
|
|
15
|
+
"require": "./lib/index.cjs"
|
|
16
16
|
}
|
|
17
17
|
},
|
|
18
18
|
"files": [
|
|
@@ -28,17 +28,18 @@
|
|
|
28
28
|
"version": "yarn run create-version-file && git add .",
|
|
29
29
|
"prebuild": "yarn run create-version-file",
|
|
30
30
|
"clean": "shx rm -rf lib/*",
|
|
31
|
-
"build": "yarn clean &&
|
|
32
|
-
"postbuild": "echo '{\"type\":\"commonjs\"}' | npx json > lib/cjs/package.json && echo '{\"type\":\"module\"}' | npx json > lib/esm/package.json",
|
|
31
|
+
"build": "yarn clean && tsup src/index.ts --format esm,cjs --outDir ./lib --minify --dts",
|
|
33
32
|
"test": "jest"
|
|
34
33
|
},
|
|
35
34
|
"dependencies": {
|
|
35
|
+
"@crossmint/client-sdk-base": "^0.1.0-alpha.2",
|
|
36
36
|
"react": "^17.0.2",
|
|
37
37
|
"react-dom": "^17.0.2",
|
|
38
38
|
"react-jss": "^10.9.0",
|
|
39
39
|
"uuid": "^8.3.2"
|
|
40
40
|
},
|
|
41
41
|
"devDependencies": {
|
|
42
|
+
"@crossmint/client-sdk-base": "^0.1.0-alpha.0",
|
|
42
43
|
"@testing-library/jest-dom": "^5.16.2",
|
|
43
44
|
"@testing-library/react": "^12.1.3",
|
|
44
45
|
"@types/jest": "^27.4.1",
|
|
@@ -49,5 +50,5 @@
|
|
|
49
50
|
"ts-jest": "^27.1.3",
|
|
50
51
|
"ts-node-dev": "^1.1.8"
|
|
51
52
|
},
|
|
52
|
-
"gitHead": "
|
|
53
|
+
"gitHead": "955d667647e7d0b5412a46cfb9ed9f252d87a066"
|
|
53
54
|
}
|
|
@@ -1,15 +1,21 @@
|
|
|
1
|
-
import
|
|
2
|
-
import
|
|
3
|
-
import useCrossmintModal from "./hooks/useCrossmintModal";
|
|
1
|
+
import { mintingContractTypes, crossmintPayButtonService } from "@crossmint/client-sdk-base";
|
|
2
|
+
import React, { FC, MouseEvent, useMemo, useEffect } from "react";
|
|
4
3
|
import { useStyles, formatProps } from "./styles";
|
|
5
4
|
import { isClientSide } from "./utils";
|
|
6
|
-
import {
|
|
5
|
+
import { CrossmintPayButtonReactProps } from "./types";
|
|
6
|
+
import {
|
|
7
|
+
crossmintModalService,
|
|
8
|
+
onboardingRequestStatusResponse,
|
|
9
|
+
crossmintStatusService,
|
|
10
|
+
} from "@crossmint/client-sdk-base";
|
|
11
|
+
import { useState } from "react";
|
|
12
|
+
import { LIB_VERSION } from "./version";
|
|
7
13
|
|
|
8
14
|
const defaultMintConfig: any = {
|
|
9
15
|
type: mintingContractTypes.CANDY_MACHINE,
|
|
10
16
|
};
|
|
11
17
|
|
|
12
|
-
export const CrossmintPayButton: FC<
|
|
18
|
+
export const CrossmintPayButton: FC<CrossmintPayButtonReactProps> = ({
|
|
13
19
|
className,
|
|
14
20
|
disabled,
|
|
15
21
|
onClick,
|
|
@@ -23,64 +29,77 @@ export const CrossmintPayButton: FC<CrossmintPayButtonProps> = ({
|
|
|
23
29
|
emailTo,
|
|
24
30
|
listingId,
|
|
25
31
|
clientId,
|
|
26
|
-
development = false,
|
|
27
32
|
auctionId,
|
|
28
33
|
hideMintOnInactiveClient = false,
|
|
29
34
|
showOverlay = true,
|
|
30
35
|
mintConfig = defaultMintConfig,
|
|
36
|
+
whPassThroughArgs,
|
|
37
|
+
environment,
|
|
31
38
|
...props
|
|
32
39
|
}) => {
|
|
33
|
-
const
|
|
34
|
-
const
|
|
40
|
+
const [connecting, setConnecting] = useState(false);
|
|
41
|
+
const [status, setStatus] = useState(onboardingRequestStatusResponse.WAITING_SUBMISSION);
|
|
42
|
+
|
|
43
|
+
const { fetchClientIntegration } = crossmintStatusService({
|
|
44
|
+
libVersion: LIB_VERSION,
|
|
45
|
+
clientId,
|
|
46
|
+
environment,
|
|
47
|
+
auctionId,
|
|
48
|
+
mintConfig,
|
|
49
|
+
setStatus,
|
|
50
|
+
});
|
|
51
|
+
|
|
52
|
+
const { connect } = crossmintModalService({
|
|
35
53
|
clientId,
|
|
36
|
-
development,
|
|
37
54
|
showOverlay,
|
|
55
|
+
setConnecting,
|
|
56
|
+
libVersion: LIB_VERSION,
|
|
57
|
+
environment,
|
|
38
58
|
});
|
|
39
59
|
|
|
40
|
-
|
|
41
|
-
console.warn("No collection title specified. Please add a collection title to your <CrossmintPayButton />");
|
|
42
|
-
collectionTitle = "";
|
|
43
|
-
}
|
|
60
|
+
const { checkProps, getButtonText, shouldHideButton } = crossmintPayButtonService();
|
|
44
61
|
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
62
|
+
const [newCollectionTitle, newCollectionDescription, newCollectionPhoto] = checkProps({
|
|
63
|
+
collectionTitle,
|
|
64
|
+
collectionPhoto,
|
|
65
|
+
collectionDescription,
|
|
66
|
+
});
|
|
67
|
+
collectionTitle = newCollectionTitle;
|
|
68
|
+
collectionDescription = newCollectionDescription;
|
|
69
|
+
collectionPhoto = newCollectionPhoto;
|
|
51
70
|
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
71
|
+
useEffect(() => {
|
|
72
|
+
if (hideMintOnInactiveClient) {
|
|
73
|
+
fetchClientIntegration();
|
|
74
|
+
}
|
|
75
|
+
}, [status]);
|
|
56
76
|
|
|
57
|
-
const handleClick:
|
|
58
|
-
(event)
|
|
59
|
-
if (onClick) onClick(event);
|
|
77
|
+
const handleClick = (event: MouseEvent<HTMLButtonElement>) => {
|
|
78
|
+
if (onClick) onClick(event);
|
|
60
79
|
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
80
|
+
if (connecting) return;
|
|
81
|
+
|
|
82
|
+
if (!event.defaultPrevented) {
|
|
83
|
+
connect(
|
|
84
|
+
mintConfig,
|
|
85
|
+
collectionTitle,
|
|
86
|
+
collectionDescription,
|
|
87
|
+
collectionPhoto,
|
|
88
|
+
mintTo,
|
|
89
|
+
emailTo,
|
|
90
|
+
listingId,
|
|
91
|
+
whPassThroughArgs
|
|
92
|
+
);
|
|
93
|
+
}
|
|
94
|
+
};
|
|
75
95
|
|
|
76
96
|
const classes = useStyles(formatProps(theme));
|
|
77
97
|
|
|
78
98
|
const content = useMemo(() => {
|
|
79
|
-
|
|
80
|
-
return <p className={classes.crossmintParagraph}>Buy with credit card</p>;
|
|
99
|
+
return <p className={classes.crossmintParagraph}>{getButtonText(connecting)}</p>;
|
|
81
100
|
}, [connecting]);
|
|
82
101
|
|
|
83
|
-
if (hideMintOnInactiveClient
|
|
102
|
+
if (shouldHideButton({ hideMintOnInactiveClient, status })) {
|
|
84
103
|
return null;
|
|
85
104
|
}
|
|
86
105
|
|
|
@@ -1,17 +1,11 @@
|
|
|
1
|
-
import React, { FC, MouseEventHandler, useMemo, useCallback } from "react";
|
|
2
|
-
import useCrossmintStatus, { OnboardingRequestStatusResponse } from "./hooks/useCrossmintStatus";
|
|
1
|
+
import React, { FC, MouseEventHandler, useMemo, useCallback, useState, useEffect } from "react";
|
|
3
2
|
import { useStyles, formatProps } from "./styles";
|
|
4
|
-
import {
|
|
3
|
+
import { CrossmintStatusButtonReactProps } from "./types";
|
|
5
4
|
import { isClientSide } from "./utils";
|
|
5
|
+
import { baseUrls, onboardingRequestStatusResponse, crossmintStatusService } from "@crossmint/client-sdk-base";
|
|
6
|
+
import { LIB_VERSION } from "./version";
|
|
6
7
|
|
|
7
|
-
|
|
8
|
-
clientId: string;
|
|
9
|
-
platformId?: string;
|
|
10
|
-
auctionId?: string;
|
|
11
|
-
mintConfig?: string;
|
|
12
|
-
};
|
|
13
|
-
|
|
14
|
-
export const CrossmintStatusButton: FC<CrossmintStatusButtonProps> = ({
|
|
8
|
+
export const CrossmintStatusButton: FC<CrossmintStatusButtonReactProps> = ({
|
|
15
9
|
className,
|
|
16
10
|
disabled,
|
|
17
11
|
onClick,
|
|
@@ -20,35 +14,28 @@ export const CrossmintStatusButton: FC<CrossmintStatusButtonProps> = ({
|
|
|
20
14
|
theme = "dark",
|
|
21
15
|
clientId,
|
|
22
16
|
auctionId,
|
|
23
|
-
development = false,
|
|
24
17
|
platformId,
|
|
25
18
|
mintConfig,
|
|
19
|
+
environment,
|
|
26
20
|
...props
|
|
27
21
|
}) => {
|
|
28
|
-
const status =
|
|
29
|
-
|
|
30
|
-
const formatOnboardingQueryParams = () => {
|
|
31
|
-
const onboardingQueryParams: OnboardingQueryParams = {
|
|
32
|
-
clientId: clientId,
|
|
33
|
-
};
|
|
34
|
-
|
|
35
|
-
if (platformId) onboardingQueryParams.platformId = platformId;
|
|
36
|
-
if (auctionId) onboardingQueryParams.auctionId = auctionId;
|
|
37
|
-
if (mintConfig) onboardingQueryParams.mintConfig = JSON.stringify(mintConfig);
|
|
22
|
+
const [status, setStatus] = useState(onboardingRequestStatusResponse.WAITING_SUBMISSION);
|
|
38
23
|
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
24
|
+
const { goToOnboarding, fetchClientIntegration, getButtonText, isButtonDisabled } = crossmintStatusService({
|
|
25
|
+
libVersion: LIB_VERSION,
|
|
26
|
+
clientId,
|
|
27
|
+
environment,
|
|
28
|
+
platformId,
|
|
29
|
+
auctionId,
|
|
30
|
+
mintConfig,
|
|
31
|
+
setStatus,
|
|
32
|
+
});
|
|
46
33
|
|
|
47
34
|
const handleClick: MouseEventHandler<HTMLButtonElement> = useCallback(
|
|
48
35
|
(event) => {
|
|
49
36
|
if (onClick) onClick(event);
|
|
50
37
|
|
|
51
|
-
if (status ===
|
|
38
|
+
if (status === onboardingRequestStatusResponse.WAITING_SUBMISSION) {
|
|
52
39
|
goToOnboarding();
|
|
53
40
|
return;
|
|
54
41
|
}
|
|
@@ -56,21 +43,20 @@ export const CrossmintStatusButton: FC<CrossmintStatusButtonProps> = ({
|
|
|
56
43
|
[status]
|
|
57
44
|
);
|
|
58
45
|
|
|
46
|
+
useEffect(() => {
|
|
47
|
+
fetchClientIntegration();
|
|
48
|
+
|
|
49
|
+
const interval = setInterval(() => {
|
|
50
|
+
fetchClientIntegration();
|
|
51
|
+
}, 60 * 1000);
|
|
52
|
+
|
|
53
|
+
return () => clearInterval(interval);
|
|
54
|
+
}, []);
|
|
55
|
+
|
|
59
56
|
const classes = useStyles(formatProps(theme));
|
|
60
57
|
|
|
61
58
|
const content = useMemo(() => {
|
|
62
|
-
|
|
63
|
-
case OnboardingRequestStatusResponse.INVALID:
|
|
64
|
-
return <p className={classes.crossmintParagraph}>Invalid clientId</p>;
|
|
65
|
-
case OnboardingRequestStatusResponse.WAITING_SUBMISSION:
|
|
66
|
-
return <p className={classes.crossmintParagraph}>Click here to setup CrossMint</p>;
|
|
67
|
-
case OnboardingRequestStatusResponse.PENDING:
|
|
68
|
-
return <p className={classes.crossmintParagraph}>Your application is under review</p>;
|
|
69
|
-
case OnboardingRequestStatusResponse.ACCEPTED:
|
|
70
|
-
return <p className={classes.crossmintParagraph}>You're good to go!</p>;
|
|
71
|
-
case OnboardingRequestStatusResponse.REJECTED:
|
|
72
|
-
return <p className={classes.crossmintParagraph}>Your application was rejected</p>;
|
|
73
|
-
}
|
|
59
|
+
return <p className={classes.crossmintParagraph}>{getButtonText(status)}</p>;
|
|
74
60
|
}, [status]);
|
|
75
61
|
|
|
76
62
|
return (
|
|
@@ -78,7 +64,7 @@ export const CrossmintStatusButton: FC<CrossmintStatusButtonProps> = ({
|
|
|
78
64
|
{isClientSide && (
|
|
79
65
|
<button
|
|
80
66
|
className={`${classes.crossmintButton} ${className || ""}`}
|
|
81
|
-
disabled={status
|
|
67
|
+
disabled={isButtonDisabled(status)}
|
|
82
68
|
onClick={handleClick}
|
|
83
69
|
style={{ ...style }}
|
|
84
70
|
tabIndex={tabIndex}
|
package/src/types.ts
CHANGED
|
@@ -1,62 +1,12 @@
|
|
|
1
1
|
import { CSSProperties, MouseEvent } from "react";
|
|
2
|
+
import { CrossmintPayButtonProps, BaseButtonProps } from "@crossmint/client-sdk-base";
|
|
2
3
|
|
|
3
|
-
export
|
|
4
|
-
reactUi = "client-sdk-react-ui",
|
|
5
|
-
}
|
|
6
|
-
|
|
7
|
-
export enum baseUrls {
|
|
8
|
-
prod = "https://www.crossmint.io",
|
|
9
|
-
dev = "http://localhost:3001",
|
|
10
|
-
}
|
|
11
|
-
|
|
12
|
-
export enum customHeaders {
|
|
13
|
-
clientVersion = "X-Client-Version",
|
|
14
|
-
clientName = "X-Client-Name",
|
|
15
|
-
}
|
|
16
|
-
|
|
17
|
-
type theme = "light" | "dark";
|
|
18
|
-
|
|
19
|
-
export enum mintingContractTypes {
|
|
20
|
-
CANDY_MACHINE = "candy-machine",
|
|
21
|
-
SOLANA_AUCTION = "solana-auction",
|
|
22
|
-
ERC_721 = "erc-721",
|
|
23
|
-
}
|
|
24
|
-
|
|
25
|
-
export interface PayButtonConfig {
|
|
26
|
-
type: string;
|
|
27
|
-
|
|
28
|
-
[propName: string]: any;
|
|
29
|
-
}
|
|
30
|
-
|
|
31
|
-
export interface StatusButtonConfig {
|
|
32
|
-
[propName: string]: any;
|
|
33
|
-
}
|
|
34
|
-
|
|
35
|
-
export interface BaseButtonProps {
|
|
36
|
-
className?: string;
|
|
37
|
-
disabled?: boolean;
|
|
4
|
+
export interface CrossmintPayButtonReactProps extends CrossmintPayButtonProps {
|
|
38
5
|
onClick?: (e: MouseEvent<HTMLButtonElement>) => void;
|
|
39
6
|
style?: CSSProperties;
|
|
40
|
-
tabIndex?: number;
|
|
41
|
-
clientId: string;
|
|
42
|
-
auctionId?: string;
|
|
43
|
-
theme?: theme;
|
|
44
|
-
development?: boolean;
|
|
45
7
|
}
|
|
46
8
|
|
|
47
|
-
export interface
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
collectionPhoto?: string;
|
|
51
|
-
mintTo?: string;
|
|
52
|
-
emailTo?: string;
|
|
53
|
-
listingId?: string;
|
|
54
|
-
showOverlay?: boolean;
|
|
55
|
-
hideMintOnInactiveClient?: boolean;
|
|
56
|
-
mintConfig?: PayButtonConfig;
|
|
57
|
-
}
|
|
58
|
-
|
|
59
|
-
export interface CrossmintStatusButtonProps extends BaseButtonProps {
|
|
60
|
-
platformId?: string;
|
|
61
|
-
mintConfig?: StatusButtonConfig;
|
|
9
|
+
export interface CrossmintStatusButtonReactProps extends BaseButtonProps {
|
|
10
|
+
onClick?: (e: MouseEvent<HTMLButtonElement>) => void;
|
|
11
|
+
style?: CSSProperties;
|
|
62
12
|
}
|
package/src/version.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export const LIB_VERSION = "0.1.
|
|
1
|
+
export const LIB_VERSION = "0.1.4-alpha.2";
|
|
@@ -1,91 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
-
if (k2 === undefined) k2 = k;
|
|
4
|
-
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
-
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
-
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
-
}
|
|
8
|
-
Object.defineProperty(o, k2, desc);
|
|
9
|
-
}) : (function(o, m, k, k2) {
|
|
10
|
-
if (k2 === undefined) k2 = k;
|
|
11
|
-
o[k2] = m[k];
|
|
12
|
-
}));
|
|
13
|
-
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
-
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
-
}) : function(o, v) {
|
|
16
|
-
o["default"] = v;
|
|
17
|
-
});
|
|
18
|
-
var __importStar = (this && this.__importStar) || function (mod) {
|
|
19
|
-
if (mod && mod.__esModule) return mod;
|
|
20
|
-
var result = {};
|
|
21
|
-
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
22
|
-
__setModuleDefault(result, mod);
|
|
23
|
-
return result;
|
|
24
|
-
};
|
|
25
|
-
var __rest = (this && this.__rest) || function (s, e) {
|
|
26
|
-
var t = {};
|
|
27
|
-
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
|
|
28
|
-
t[p] = s[p];
|
|
29
|
-
if (s != null && typeof Object.getOwnPropertySymbols === "function")
|
|
30
|
-
for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
|
|
31
|
-
if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
|
|
32
|
-
t[p[i]] = s[p[i]];
|
|
33
|
-
}
|
|
34
|
-
return t;
|
|
35
|
-
};
|
|
36
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
37
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
38
|
-
};
|
|
39
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
40
|
-
exports.CrossmintPayButton = void 0;
|
|
41
|
-
const react_1 = __importStar(require("react"));
|
|
42
|
-
const useCrossmintStatus_1 = __importStar(require("./hooks/useCrossmintStatus"));
|
|
43
|
-
const useCrossmintModal_1 = __importDefault(require("./hooks/useCrossmintModal"));
|
|
44
|
-
const styles_1 = require("./styles");
|
|
45
|
-
const utils_1 = require("./utils");
|
|
46
|
-
const types_1 = require("./types");
|
|
47
|
-
const defaultMintConfig = {
|
|
48
|
-
type: types_1.mintingContractTypes.CANDY_MACHINE,
|
|
49
|
-
};
|
|
50
|
-
const CrossmintPayButton = (_a) => {
|
|
51
|
-
var { className, disabled, onClick, style, tabIndex, theme = "dark", collectionTitle, collectionDescription, collectionPhoto, mintTo, emailTo, listingId, clientId, development = false, auctionId, hideMintOnInactiveClient = false, showOverlay = true, mintConfig = defaultMintConfig } = _a, props = __rest(_a, ["className", "disabled", "onClick", "style", "tabIndex", "theme", "collectionTitle", "collectionDescription", "collectionPhoto", "mintTo", "emailTo", "listingId", "clientId", "development", "auctionId", "hideMintOnInactiveClient", "showOverlay", "mintConfig"]);
|
|
52
|
-
const status = (0, useCrossmintStatus_1.default)({ clientId, development });
|
|
53
|
-
const { connecting, connect } = (0, useCrossmintModal_1.default)({
|
|
54
|
-
clientId,
|
|
55
|
-
development,
|
|
56
|
-
showOverlay,
|
|
57
|
-
});
|
|
58
|
-
if (collectionTitle === "<TITLE_FOR_YOUR_COLLECTION>") {
|
|
59
|
-
console.warn("No collection title specified. Please add a collection title to your <CrossmintPayButton />");
|
|
60
|
-
collectionTitle = "";
|
|
61
|
-
}
|
|
62
|
-
if (collectionDescription === "<DESCRIPTION_OF_YOUR_COLLECTION>") {
|
|
63
|
-
console.warn("No collection description specified. Please add a collection description to your <CrossmintPayButton />");
|
|
64
|
-
collectionDescription = "";
|
|
65
|
-
}
|
|
66
|
-
if (collectionPhoto === "<OPT_URL_TO_PHOTO_COVER>") {
|
|
67
|
-
console.warn("No collection photo specified. Please add a collection photo to your <CrossmintPayButton />");
|
|
68
|
-
collectionPhoto = "";
|
|
69
|
-
}
|
|
70
|
-
const handleClick = (0, react_1.useCallback)((event) => {
|
|
71
|
-
if (onClick)
|
|
72
|
-
onClick(event);
|
|
73
|
-
if (!event.defaultPrevented) {
|
|
74
|
-
connect(mintConfig, collectionTitle, collectionDescription, collectionPhoto, mintTo, emailTo, listingId);
|
|
75
|
-
}
|
|
76
|
-
}, [onClick]);
|
|
77
|
-
const classes = (0, styles_1.useStyles)((0, styles_1.formatProps)(theme));
|
|
78
|
-
const content = (0, react_1.useMemo)(() => {
|
|
79
|
-
if (connecting)
|
|
80
|
-
return react_1.default.createElement("p", { className: classes.crossmintParagraph }, "Connecting ...");
|
|
81
|
-
return react_1.default.createElement("p", { className: classes.crossmintParagraph }, "Buy with credit card");
|
|
82
|
-
}, [connecting]);
|
|
83
|
-
if (hideMintOnInactiveClient && status !== useCrossmintStatus_1.OnboardingRequestStatusResponse.ACCEPTED) {
|
|
84
|
-
return null;
|
|
85
|
-
}
|
|
86
|
-
return (react_1.default.createElement(react_1.default.Fragment, null, utils_1.isClientSide && (react_1.default.createElement("button", Object.assign({ className: `${classes.crossmintButton} ${className || ""}`, disabled: disabled, onClick: handleClick, style: Object.assign({}, style), tabIndex: tabIndex }, props),
|
|
87
|
-
react_1.default.createElement("img", { className: classes.crossmintImg, src: "https://www.crossmint.io/assets/crossmint/logo.png", alt: "Crossmint logo" }),
|
|
88
|
-
content))));
|
|
89
|
-
};
|
|
90
|
-
exports.CrossmintPayButton = CrossmintPayButton;
|
|
91
|
-
//# sourceMappingURL=CrossmintPayButton.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"CrossmintPayButton.js","sourceRoot":"","sources":["../../src/CrossmintPayButton.tsx"],"names":[],"mappings":"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"}
|
|
@@ -1,90 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
-
if (k2 === undefined) k2 = k;
|
|
4
|
-
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
-
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
-
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
-
}
|
|
8
|
-
Object.defineProperty(o, k2, desc);
|
|
9
|
-
}) : (function(o, m, k, k2) {
|
|
10
|
-
if (k2 === undefined) k2 = k;
|
|
11
|
-
o[k2] = m[k];
|
|
12
|
-
}));
|
|
13
|
-
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
-
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
-
}) : function(o, v) {
|
|
16
|
-
o["default"] = v;
|
|
17
|
-
});
|
|
18
|
-
var __importStar = (this && this.__importStar) || function (mod) {
|
|
19
|
-
if (mod && mod.__esModule) return mod;
|
|
20
|
-
var result = {};
|
|
21
|
-
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
22
|
-
__setModuleDefault(result, mod);
|
|
23
|
-
return result;
|
|
24
|
-
};
|
|
25
|
-
var __rest = (this && this.__rest) || function (s, e) {
|
|
26
|
-
var t = {};
|
|
27
|
-
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
|
|
28
|
-
t[p] = s[p];
|
|
29
|
-
if (s != null && typeof Object.getOwnPropertySymbols === "function")
|
|
30
|
-
for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
|
|
31
|
-
if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
|
|
32
|
-
t[p[i]] = s[p[i]];
|
|
33
|
-
}
|
|
34
|
-
return t;
|
|
35
|
-
};
|
|
36
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
37
|
-
exports.CrossmintStatusButton = void 0;
|
|
38
|
-
const react_1 = __importStar(require("react"));
|
|
39
|
-
const useCrossmintStatus_1 = __importStar(require("./hooks/useCrossmintStatus"));
|
|
40
|
-
const styles_1 = require("./styles");
|
|
41
|
-
const types_1 = require("./types");
|
|
42
|
-
const utils_1 = require("./utils");
|
|
43
|
-
const CrossmintStatusButton = (_a) => {
|
|
44
|
-
var { className, disabled, onClick, style, tabIndex, theme = "dark", clientId, auctionId, development = false, platformId, mintConfig } = _a, props = __rest(_a, ["className", "disabled", "onClick", "style", "tabIndex", "theme", "clientId", "auctionId", "development", "platformId", "mintConfig"]);
|
|
45
|
-
const status = (0, useCrossmintStatus_1.default)({ clientId, development });
|
|
46
|
-
const formatOnboardingQueryParams = () => {
|
|
47
|
-
const onboardingQueryParams = {
|
|
48
|
-
clientId: clientId,
|
|
49
|
-
};
|
|
50
|
-
if (platformId)
|
|
51
|
-
onboardingQueryParams.platformId = platformId;
|
|
52
|
-
if (auctionId)
|
|
53
|
-
onboardingQueryParams.auctionId = auctionId;
|
|
54
|
-
if (mintConfig)
|
|
55
|
-
onboardingQueryParams.mintConfig = JSON.stringify(mintConfig);
|
|
56
|
-
return new URLSearchParams(onboardingQueryParams).toString();
|
|
57
|
-
};
|
|
58
|
-
const goToOnboarding = () => {
|
|
59
|
-
const baseUrl = development ? types_1.baseUrls.dev : types_1.baseUrls.prod;
|
|
60
|
-
window.open(`${baseUrl}/developers/onboarding?${formatOnboardingQueryParams()}`, "_blank");
|
|
61
|
-
};
|
|
62
|
-
const handleClick = (0, react_1.useCallback)((event) => {
|
|
63
|
-
if (onClick)
|
|
64
|
-
onClick(event);
|
|
65
|
-
if (status === useCrossmintStatus_1.OnboardingRequestStatusResponse.WAITING_SUBMISSION) {
|
|
66
|
-
goToOnboarding();
|
|
67
|
-
return;
|
|
68
|
-
}
|
|
69
|
-
}, [status]);
|
|
70
|
-
const classes = (0, styles_1.useStyles)((0, styles_1.formatProps)(theme));
|
|
71
|
-
const content = (0, react_1.useMemo)(() => {
|
|
72
|
-
switch (status) {
|
|
73
|
-
case useCrossmintStatus_1.OnboardingRequestStatusResponse.INVALID:
|
|
74
|
-
return react_1.default.createElement("p", { className: classes.crossmintParagraph }, "Invalid clientId");
|
|
75
|
-
case useCrossmintStatus_1.OnboardingRequestStatusResponse.WAITING_SUBMISSION:
|
|
76
|
-
return react_1.default.createElement("p", { className: classes.crossmintParagraph }, "Click here to setup CrossMint");
|
|
77
|
-
case useCrossmintStatus_1.OnboardingRequestStatusResponse.PENDING:
|
|
78
|
-
return react_1.default.createElement("p", { className: classes.crossmintParagraph }, "Your application is under review");
|
|
79
|
-
case useCrossmintStatus_1.OnboardingRequestStatusResponse.ACCEPTED:
|
|
80
|
-
return react_1.default.createElement("p", { className: classes.crossmintParagraph }, "You're good to go!");
|
|
81
|
-
case useCrossmintStatus_1.OnboardingRequestStatusResponse.REJECTED:
|
|
82
|
-
return react_1.default.createElement("p", { className: classes.crossmintParagraph }, "Your application was rejected");
|
|
83
|
-
}
|
|
84
|
-
}, [status]);
|
|
85
|
-
return (react_1.default.createElement(react_1.default.Fragment, null, utils_1.isClientSide && (react_1.default.createElement("button", Object.assign({ className: `${classes.crossmintButton} ${className || ""}`, disabled: status !== useCrossmintStatus_1.OnboardingRequestStatusResponse.WAITING_SUBMISSION, onClick: handleClick, style: Object.assign({}, style), tabIndex: tabIndex }, props),
|
|
86
|
-
react_1.default.createElement("img", { className: classes.crossmintImg, src: `${types_1.baseUrls.prod}/assets/crossmint/logo.png`, alt: "Crossmint logo" }),
|
|
87
|
-
content))));
|
|
88
|
-
};
|
|
89
|
-
exports.CrossmintStatusButton = CrossmintStatusButton;
|
|
90
|
-
//# sourceMappingURL=CrossmintStatusButton.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"CrossmintStatusButton.js","sourceRoot":"","sources":["../../src/CrossmintStatusButton.tsx"],"names":[],"mappings":"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"}
|
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
import { PayButtonConfig } from "../types";
|
|
2
|
-
interface IProps {
|
|
3
|
-
development: boolean;
|
|
4
|
-
clientId: string;
|
|
5
|
-
showOverlay: boolean;
|
|
6
|
-
}
|
|
7
|
-
interface IReturn {
|
|
8
|
-
connecting: boolean;
|
|
9
|
-
connect: (mintConfig: PayButtonConfig, collectionTitle?: string, collectionDescription?: string, collectionPhoto?: string, mintTo?: string, emailTo?: string, listingId?: string) => void;
|
|
10
|
-
}
|
|
11
|
-
export default function useCrossMintModal({ development, clientId, showOverlay }: IProps): IReturn;
|
|
12
|
-
export {};
|