Skip to content

Commit

Permalink
cashout
Browse files Browse the repository at this point in the history
  • Loading branch information
rarepepi committed Nov 30, 2023
1 parent d05f634 commit 22fa9d1
Show file tree
Hide file tree
Showing 5 changed files with 125 additions and 0 deletions.
9 changes: 9 additions & 0 deletions example/src/components/header.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,10 @@ const Header = () => {
title: 'Connect',
href: '/connect',
},
{
title: 'Cashout',
href: '/cashout',
},
];

const location = useLocation();
Expand Down Expand Up @@ -79,6 +83,11 @@ const Header = () => {
Connect
</Link>
</NavbarItem>
<NavbarItem isActive={location.pathname === '/cashout'}>
<Link className="text-gray-400 hover:text-gray-200" to="/cashout">
Cashout
</Link>
</NavbarItem>
</NavbarContent>
<NavbarContent justify="end">
<NavbarItem>
Expand Down
9 changes: 9 additions & 0 deletions example/src/main.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import Layout from './components/layout';
import Kyc from './routes/kyc';
import Payout from './routes/payout';
import { NextUIProvider } from '@nextui-org/react';
import Cashout from './routes/cashout';

const router = createHashRouter([
{
Expand All @@ -37,6 +38,14 @@ const router = createHashRouter([
</Layout>
),
},
{
path: '/cashout',
element: (
<Layout>
<Cashout />
</Layout>
),
},
{
path: '/kyc',
element: (
Expand Down
51 changes: 51 additions & 0 deletions example/src/routes/cashout.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
import { useState } from 'react';
import { NoRampCashout } from '../../../src';
import ThemeSwitcher from '../components/ui/theme-switcher/theme-switcher';

const Cashout = () => {
const [theme, setTheme] = useState<'light' | 'dark'>('dark');

const handleThemeChange = (checked: boolean) => {
setTheme(checked ? 'dark' : 'light');
};

return (
<div className="container flex mx-auto my-0 ">
<div className="flex flex-col items-center w-full ">
<div className="flex items-center justify-between w-full max-w-4xl">
<p className="my-4 text-2xl font-bold">Cashout Widget</p>

<div className="">
<ThemeSwitcher onChange={handleThemeChange} />
</div>
</div>

<div className="w-full max-w-4xl overflow-auto ">
<NoRampCashout token={''} />
</div>

<div className="flex flex-col justify-start w-full max-w-4xl mt-12">
<h3 className="mb-2 text-lg font-bold">Usage</h3>
<p className="mb-4">
Sign up on{' '}
<a
href="https://app.noramp.io"
className="text-blue-500 hover:underline"
>
app.noramp.io
</a>{' '}
, create a Marketplace App and register sellers in order to get the
token.
</p>
<pre className="p-2 mb-4 text-white bg-gray-800 rounded">
{`import { NoRampCashout } from 'norampkit';
<NoRampCashout/>`}
</pre>
</div>
</div>
</div>
);
};

export default Cashout;
55 changes: 55 additions & 0 deletions src/components/noramp-cashout/cashout.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
import React from 'react';
import NoRampLogo from '../NoRampLogo';

type NoRampCashoutProps = {
token: string;
testnet?: boolean;
theme?: 'light' | 'dark' | null;
height?: string;
width?: string;
};

export const NoRampCashout = ({
height = '440',
width = '440',
}: NoRampCashoutProps) => {
let src = `https://noramp-beam.vercel.app/`;
// let src = `http://localhost:3000`;

const [openWidget, setOpenWidget] = React.useState(false);

// const isPreview = token === 'preview';

// if (isPreview) {
// src += '&preview=true';
// }

if (openWidget) {
return (
<div className="w-full h-full">
<iframe
src={src}
title="NoRamp Cashout"
width={width}
height={height}
frameBorder="0"
allowFullScreen
/>
</div>
);
}

return (
<button
className={`button`}
type="button"
onClick={() => setOpenWidget(true)}
// disabled={openWidget}
>
<span className="icon">
<NoRampLogo />
</span>
{<span>Cashout with NoRamp</span>}
</button>
);
};
1 change: 1 addition & 0 deletions src/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,4 @@ export { NoRampOneClick } from './components/noramp-one-click/one-click';
export { NoRampPayout } from './components/noramp-payout/payout';
export { NoRampKyc } from './components/noramp-kyc/kyc';
export { NoRampConnect } from './components/noramp-connect/connect';
export { NoRampCashout } from './components/noramp-cashout/cashout';

0 comments on commit 22fa9d1

Please sign in to comment.