@coin-voyage/paykit
Version:
Seamless crypto payments. Onboard users from any chain, any coin into your app with one click.
136 lines (135 loc) • 5.26 kB
JavaScript
import { jsx as _jsx } from "react/jsx-runtime";
import { getChainName } from "@coin-voyage/shared/chain";
import About from "../components/Pages/About";
import CardPayment from "../components/Pages/CardPayment";
import Confirmation from "../components/Pages/Confirmation";
import Connectors from "../components/Pages/Connectors";
import DownloadApp from "../components/Pages/DownloadApp";
import MobileConnectors from "../components/Pages/MobileConnectors";
import Onboarding from "../components/Pages/Onboarding";
import PayToAddress from "../components/Pages/PayToAddress";
import PayWithToken from "../components/Pages/PayWithToken";
import PreparingPayment from "../components/Pages/PreparingPayment";
import SelectChain from "../components/Pages/SelectChain";
import SelectMethod from "../components/Pages/SelectMethod";
import SelectPayToAddressChain from "../components/Pages/SelectPayToAddressChain";
import SelectPayToAddressToken from "../components/Pages/SelectPayToAddressToken";
import SelectToken from "../components/Pages/SelectToken";
import ConnectUsing from "../components/pay-modal/ConnectUsing";
import { ROUTE } from "../types/routes";
export const routeConfig = {
[ROUTE.SELECT_METHOD]: {
component: _jsx(SelectMethod, {}),
heading: (ctx) => ctx.locales.selectMethodScreen_heading,
showBackButton: false,
},
[ROUTE.PREPARING_PAYMENT]: {
component: _jsx(PreparingPayment, {}),
heading: () => "Preparing payment",
showBackButton: false,
showInfoButton: false,
},
[ROUTE.CARD_PAYMENT]: {
component: _jsx(CardPayment, {}),
heading: () => "Pay with Card",
onBack: (actions) => {
actions.setRoute(ROUTE.SELECT_METHOD);
},
},
// Pay to address routes
[ROUTE.ADDRESS_CHAIN_SELECT]: {
component: _jsx(SelectPayToAddressChain, {}),
heading: (ctx) => ctx.locales.selectPayToAddressChainScreen_heading,
onBack: (actions) => {
actions.setRoute(ROUTE.SELECT_METHOD);
},
},
[ROUTE.ADDRESS_TOKEN_SELECT]: {
component: _jsx(SelectPayToAddressToken, {}),
heading: (ctx) => ctx.locales.selectPayToAddressTokenScreen_heading,
onBack: (actions) => {
actions.setPayToAddressChain(undefined);
actions.setRoute(ROUTE.ADDRESS_CHAIN_SELECT);
},
},
[ROUTE.PAY_TO_ADDRESS]: {
component: _jsx(PayToAddress, {}),
heading: (ctx) => ctx.locales.payToAddressWaitingScreen_heading,
onBack: (actions) => {
actions.setPayToAddressCurrency(undefined);
actions.setRoute(ROUTE.ADDRESS_TOKEN_SELECT);
},
},
// Pay with token routes
[ROUTE.WALLET_CHAIN_SELECT]: {
component: _jsx(SelectChain, {}),
heading: (ctx) => ctx.locales.selectChainScreen_heading,
onBack: (actions) => {
actions.setRoute(ROUTE.SELECT_METHOD);
},
},
[ROUTE.WALLET_TOKEN_SELECT]: {
component: _jsx(SelectToken, {}),
heading: (ctx) => ctx.locales.selectTokenScreen_heading,
onBack: (actions) => {
actions.setConnectorChainType(undefined);
actions.setRoute(ROUTE.WALLET_CHAIN_SELECT);
},
},
[ROUTE.WALLET_PAYMENT]: {
component: _jsx(PayWithToken, {}),
heading: (ctx) => ctx.selectedCurrencyOption
? `Pay with ${ctx.selectedCurrencyOption.ticker} on ${getChainName(ctx.selectedCurrencyOption.chain_id)}`
: undefined,
onBack: (actions) => {
actions.setSelectedCurrencyOption(undefined);
actions.setRoute(ROUTE.WALLET_TOKEN_SELECT);
},
},
[ROUTE.CONFIRMATION]: {
component: _jsx(Confirmation, {}),
heading: (ctx) => ctx.locales.confirmationScreen_heading,
showBackButton: false,
showInfoButton: false,
},
[ROUTE.ONBOARDING]: {
component: _jsx(Onboarding, {}),
heading: (ctx) => ctx.locales.onboardingScreen_heading,
onBack: ROUTE.SELECT_METHOD,
},
[ROUTE.ABOUT]: {
component: _jsx(About, {}),
heading: (ctx) => ctx.locales.aboutScreen_heading,
},
[ROUTE.CONNECTORS]: {
component: _jsx(Connectors, {}),
heading: (ctx) => ctx.locales.connectorsScreen_heading,
depth: 0,
onBack: (actions) => {
actions.setConnectorChainType(undefined);
actions.setRoute(ROUTE.SELECT_METHOD);
},
},
[ROUTE.MOBILECONNECTORS]: {
component: _jsx(MobileConnectors, {}),
heading: (ctx) => ctx.locales.connectorsScreen_heading,
},
[ROUTE.CONNECT]: {
component: _jsx(ConnectUsing, {}),
heading: (ctx) => {
if (ctx.shouldUseQrcode) {
return ctx.isWalletConnectConnector
? ctx.locales.scanScreen_heading
: ctx.locales.scanScreen_heading_withConnector;
}
return ctx.walletName;
},
onBack: ROUTE.CONNECTORS,
},
[ROUTE.DOWNLOAD]: {
component: _jsx(DownloadApp, {}),
heading: (ctx) => ctx.locales.downloadAppScreen_heading,
depth: 2,
onBack: ROUTE.CONNECT,
},
};