@coin-voyage/paykit
Version:
Seamless crypto payments. Onboard users from any chain, any coin into your app with one click.
126 lines (125 loc) • 4.97 kB
JavaScript
import { jsx as _jsx } from "react/jsx-runtime";
import { getChainName } from "@coin-voyage/shared/common";
import About from "../components/Pages/About";
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 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 SwitchNetworks from "../components/Pages/SwitchNetworks";
import ConnectUsing from "../components/pay-modal/ConnectUsing";
import { ROUTES } from "../types/routes";
export const routeConfig = {
[ROUTES.SELECT_METHOD]: {
component: _jsx(SelectMethod, {}),
heading: (ctx) => ctx.locales.selectMethodScreen_heading,
showBackButton: false,
},
// Pay to address routes
[ROUTES.SELECT_PAY_TO_ADDRESS_CHAIN]: {
component: _jsx(SelectPayToAddressChain, {}),
heading: (ctx) => ctx.locales.selectPayToAddressChainScreen_heading,
onBack: (actions) => {
actions.setRoute(ROUTES.SELECT_METHOD);
},
},
[ROUTES.SELECT_PAY_TO_ADDRESS_TOKEN]: {
component: _jsx(SelectPayToAddressToken, {}),
heading: (ctx) => ctx.locales.selectPayToAddressTokenScreen_heading,
onBack: (actions) => {
actions.setPayToAddressChain(undefined);
actions.setRoute(ROUTES.SELECT_PAY_TO_ADDRESS_CHAIN);
},
},
[ROUTES.PAY_TO_ADDRESS]: {
component: _jsx(PayToAddress, {}),
heading: (ctx) => ctx.locales.payToAddressWaitingScreen_heading,
onBack: (actions) => {
actions.setPayToAddressCurrency(undefined);
actions.setRoute(ROUTES.SELECT_PAY_TO_ADDRESS_TOKEN);
},
},
// Pay with token routes
[ROUTES.SELECT_CHAIN]: {
component: _jsx(SelectChain, {}),
heading: (ctx) => ctx.locales.selectChainScreen_heading,
onBack: (actions) => {
actions.setRoute(ROUTES.SELECT_METHOD);
},
},
[ROUTES.SELECT_TOKEN]: {
component: _jsx(SelectToken, {}),
heading: (ctx) => ctx.locales.selectTokenScreen_heading,
onBack: (actions) => {
actions.setConnectorChainType(undefined);
actions.setRoute(ROUTES.SELECT_CHAIN);
},
},
[ROUTES.PAY_WITH_TOKEN]: {
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(ROUTES.SELECT_TOKEN);
},
},
[ROUTES.CONFIRMATION]: {
component: _jsx(Confirmation, {}),
heading: (ctx) => ctx.locales.confirmationScreen_heading,
showBackButton: false,
showInfoButton: false,
},
[ROUTES.ONBOARDING]: {
component: _jsx(Onboarding, {}),
heading: (ctx) => ctx.locales.onboardingScreen_heading,
onBack: ROUTES.SELECT_METHOD,
},
[ROUTES.ABOUT]: {
component: _jsx(About, {}),
heading: (ctx) => ctx.locales.aboutScreen_heading,
},
[ROUTES.CONNECTORS]: {
component: _jsx(Connectors, {}),
heading: (ctx) => ctx.locales.connectorsScreen_heading,
depth: 0,
onBack: (actions) => {
actions.setConnectorChainType(undefined);
actions.setRoute(ROUTES.SELECT_METHOD);
},
},
[ROUTES.MOBILECONNECTORS]: {
component: _jsx(MobileConnectors, {}),
heading: (ctx) => ctx.locales.connectorsScreen_heading,
},
[ROUTES.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: ROUTES.CONNECTORS,
},
[ROUTES.DOWNLOAD]: {
component: _jsx(DownloadApp, {}),
heading: (ctx) => ctx.locales.downloadAppScreen_heading,
depth: 2,
onBack: ROUTES.CONNECT,
},
[ROUTES.SWITCHNETWORKS]: {
component: _jsx(SwitchNetworks, {}),
heading: (ctx) => ctx.locales.switchNetworkScreen_heading,
},
};