import { Outlet, Form, useActionData, useNavigation, useOutletContext } from '@remix-run/react'; import { twMerge } from 'tailwind-merge'; import { json, redirect } from '@remix-run/node'; import { Badge } from '../components/Badge'; import { SwapCodeBlock } from '../components/SwapCodeBlock'; import { AppsTable } from '../components/AppsTable'; import { GoToExplorer } from '../components/GoToExplorer'; import { Button, LinkButton } from '../components/Button'; import { useDemoApp } from '../hooks/useDemoApp'; import { getSignedInUser } from '../auth.server'; import { appsList, createApp } from '../data/zippo.server'; import * as Tooltip from '../components/Tooltip'; import type { ActionArgs } from '@remix-run/node'; import type { AppsOutletContext } from './_dashboard'; import { CopyButton } from '../components/CopyButton'; import { useRef } from 'react'; export async function action({ request }: ActionArgs) { const [user, headers] = await getSignedInUser(request); if (!user) { throw redirect('/login', { headers }); } const list = await appsList(user.teamId); if (list.result === 'ERROR') { throw list.error; } const demoApp = list.data.filter((app) => app.description === '__test_key')[0]; if (demoApp) { return json({ error: null, app: demoApp }, { headers }); } const result = await createApp({ appName: 'Demo App', description: '__test_key', teamId: user.teamId, }); if (result.result === 'ERROR') { return json({ error: 'Fail to create test key. Try again later.' }, { headers }); } return json({ error: null, app: result.data }, { headers }); } export default function Apps() { const { apps } = useOutletContext(); const demoApp = useDemoApp(apps); const actionData = useActionData(); const navigation = useNavigation(); const hasFormError = Boolean(actionData?.error); const tooltipTriggerRef = useRef(null); return (

Welcome to 0x

Beta

Build a live app

Create an app to get a live API key with access to multiple 0x products.

Create an app

Test API key

Make a sample request to any 0x product with the key below.

{demoApp ? ( <> {demoApp.apiKeys[0] ? ( {demoApp.apiKeys[0].apiKey} ) : ( Go to settings To enable products for test API key )} ) : (
{hasFormError && navigation.state === 'idle' && (
{actionData?.error}
)}
)}
); }