Skip to content

Commit

Permalink
wrapped pages in auth component
Browse files Browse the repository at this point in the history
  • Loading branch information
Stephen-Gordon committed Mar 21, 2024
1 parent 0f1b92d commit d1d08b1
Show file tree
Hide file tree
Showing 9 changed files with 244 additions and 268 deletions.
5 changes: 4 additions & 1 deletion src/app/@auth/layout.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
import SheetLayout from '@/app/components/Layouts/SheetLayout';
import { Metadata } from 'next';
import * as React from 'react';
import AuthPage from '../components/AuthPage/AuthPage';

export default function ComponentsLayout({
children,
Expand All @@ -10,7 +11,9 @@ export default function ComponentsLayout({
}) {
return (
<>
<SheetLayout>{children}</SheetLayout>
<AuthPage>
<SheetLayout>{children}</SheetLayout>
</AuthPage>
</>
);
}
46 changes: 6 additions & 40 deletions src/app/components/AuthPage/AuthPage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,56 +4,22 @@ import { useEffect } from "react"
// privy
import { usePrivySmartAccount } from "@zerodev/privy";

// hooks
import useUserAgent from '@/app/hooks/useUserAgent';


export default function AuthPage ({children} : {children: React.ReactNode}) {

const router = useRouter();


const { authenticated, login, zeroDevReady, user } = usePrivySmartAccount();
const { userAgent, isMobile, isStandalone, isIOS } = useUserAgent();
const { authenticated } = usePrivySmartAccount();

useEffect(() => {

if (!authenticated) {
router.push('/login');
}

/* if (window) {
console.log("window is here")
if (window.matchMedia('(display-mode: standalone)').matches) {
console.log('standalone')
if (authenticated && zeroDevReady) {
// route home
console.log('authenticated');
router.push('/home');
} else {
router.push('/login');
}
} else {
console.log('not standalone')
router.push('/');
}
} */



if (authenticated && zeroDevReady) {
// route home
console.log('authenticated');
router.push('/home');
} else {
router.push('/login');
}






}, [authenticated, zeroDevReady]);
}, [authenticated]);
return (
<> {children}</>
<>{children}</>
)
}
151 changes: 77 additions & 74 deletions src/app/home/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ import useGetAddress from '../hooks/useGetAddress';
import { motion, useScroll, useTransform } from 'framer-motion';

import useGetTokenBalance from '../hooks/useGetTokenBalance';
import AuthPage from '../components/AuthPage/AuthPage';

export default function Page() {
// privy
Expand Down Expand Up @@ -70,83 +71,84 @@ export default function Page() {
const usdcBalance = useGetTokenBalance(address as string)
console.log('usdcBalance', usdcBalance);
return (
<div id='render' className='min-h-[150vh]'>
<div className='absolute right-4 top-4'>
<Link
/* onClick={() => {
<AuthPage>
<div id='render' className='min-h-[150vh]'>
<div className='absolute right-4 top-4'>
<Link
/* onClick={() => {
dispatch(setSheet(true));
}} */ href={{
pathname: '/menu',
query: { isNavOpen: true },
}}
>
<Menu onClick={() => router.push(`/menu?isNavOpen=true`)} />
</Link>
</div>
<div className='blurios'>
<div className='absolute -z-50 '>
<BackgroundGradientAnimation />
pathname: '/menu',
query: { isNavOpen: true },
}}
>
<Menu onClick={() => router.push(`/menu?isNavOpen=true`)} />
</Link>
</div>
<motion.div
style={{ y, scale, opacity }}
className='items-center p-2 pt-40 text-center text-5xl mix-blend-exclusion'
>
{/* <Balance /> */}
{/* {address} */}
</motion.div>

<motion.div
style={{ y, scale, opacity }}
className='mt-10 grid grid-cols-2 gap-2 p-2'
>
<div>
<Link
onClick={() => {
dispatch(setSheet(true));
}}
href={{
pathname: '/search',
}}
>
<Button className='text-xl' size={'lg'} variant={'default'}>
<div className='flex grid-cols-3 content-center items-center'>
<div className='text-xl'>
<div>Send</div>
</div>
<div className='px-2'></div>
<div>
<Send size={20} />
</div>
</div>
</Button>
</Link>
<div className='blurios'>
<div className='absolute -z-50 '>
<BackgroundGradientAnimation />
</div>

<div>
<Link
onClick={() => {
dispatch(setSheet(true));
}}
href={{
pathname: '/receive',
}}
>
<Button className='text-xl' size={'lg'} variant={'default'}>
<div className='flex grid-cols-3 content-center items-center'>
<div className='text-xl'>
<div>Receive</div>
<motion.div
style={{ y, scale, opacity }}
className='items-center p-2 pt-40 text-center text-5xl mix-blend-exclusion'
>
{/* <Balance /> */}
{/* {address} */}
</motion.div>

<motion.div
style={{ y, scale, opacity }}
className='mt-10 grid grid-cols-2 gap-2 p-2'
>
<div>
<Link
onClick={() => {
dispatch(setSheet(true));
}}
href={{
pathname: '/search',
}}
>
<Button className='text-xl' size={'lg'} variant={'default'}>
<div className='flex grid-cols-3 content-center items-center'>
<div className='text-xl'>
<div>Send</div>
</div>
<div className='px-2'></div>
<div>
<Send size={20} />
</div>
</div>
<div className='px-2'></div>
<div>
<QrCode size={22} />
</Button>
</Link>
</div>

<div>
<Link
onClick={() => {
dispatch(setSheet(true));
}}
href={{
pathname: '/receive',
}}
>
<Button className='text-xl' size={'lg'} variant={'default'}>
<div className='flex grid-cols-3 content-center items-center'>
<div className='text-xl'>
<div>Receive</div>
</div>
<div className='px-2'></div>
<div>
<QrCode size={22} />
</div>
</div>
</div>
</Button>
</Link>
</div>
</motion.div>
<div className='bg-accent/90 relative mt-4 w-full rounded-t-3xl bg-opacity-10 bg-clip-padding p-4 backdrop-blur-sm backdrop-filter'>
{/* <Tab.Group>
</Button>
</Link>
</div>
</motion.div>
<div className='bg-accent/90 relative mt-4 w-full rounded-t-3xl bg-opacity-10 bg-clip-padding p-4 backdrop-blur-sm backdrop-filter'>
{/* <Tab.Group>
<Tab.List>
<div className='mb-4 flex justify-between'>
<Tab>
Expand All @@ -165,15 +167,16 @@ export default function Page() {
</Tab.Panels>
</Tab.Group> */}

{/* <div className='mb-4 flex justify-between'>
{/* <div className='mb-4 flex justify-between'>
<div className='text-lg'>Activity</div>
</div> */}

<Activity />
<Activity />
</div>
</div>
</div>
</div>
</AuthPage>
);
}
7 changes: 7 additions & 0 deletions src/app/menu/page.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,11 @@
import { useRouter } from "next/navigation";
import { useEffect } from "react";

export default function Page() {
const router = useRouter();
useEffect(() => {
router.push('/home')
}, [])
return (
<>
<h1> backup Menu</h1>
Expand Down
19 changes: 11 additions & 8 deletions src/app/payee/page.tsx
Original file line number Diff line number Diff line change
@@ -1,11 +1,14 @@
'use client'
import { useRouter } from 'next/router';
// Next
import { useSearchParams } from 'next/navigation';
import { useRouter } from 'next/navigation';
import { useEffect } from 'react';

export default function Page() {
const searchParams = useSearchParams();
let address = searchParams.get('address');

return <p>Payee: {address}</p>;
const router = useRouter();
useEffect(() => {
router.push('/home');
}, []);
return (
<>
<h1> backup payee</h1>
</>
);
}
29 changes: 5 additions & 24 deletions src/app/send/page.tsx
Original file line number Diff line number Diff line change
@@ -1,33 +1,14 @@
'use client';

import BackButton from '@/app/components/Navigation/BackButton/BackButton';
// components
import SendUsdc from '@/app/components/SendUsdc/SendUsdc';
import { useRouter } from 'next/navigation';
import { useEffect } from 'react';

export default function Page() {
const router = useRouter();
useEffect(() => {
router.push('/home');
}, []);
return (
<>
<div className='grid'>

<div className='flex p-4'>
<div
onClick={() => {
router.push('/home');
}}
>
<BackButton />
</div>
<div className='my-4'>
<p className='my-4 text-center text-xl text-gray-300'>Send</p>
</div>
</div>
</div>

<div className='mt-10'>
<SendUsdc />
</div>
<h1> backup Send</h1>
</>
);
}
9 changes: 7 additions & 2 deletions src/app/transaction/page.tsx
Original file line number Diff line number Diff line change
@@ -1,9 +1,14 @@
'use client';
import { useRouter } from 'next/navigation';
import { useEffect } from 'react';

export default function Page() {
const router = useRouter();
useEffect(() => {
router.push('/home');
}, []);
return (
<>
<h1>Backup Tx Page</h1>
<h1> backup tx page</h1>
</>
);
}
Loading

0 comments on commit d1d08b1

Please sign in to comment.