Skip to content

Commit

Permalink
fixed shared layout
Browse files Browse the repository at this point in the history
  • Loading branch information
Stephen-Gordon committed Feb 18, 2024
1 parent db58a15 commit b588893
Show file tree
Hide file tree
Showing 4 changed files with 145 additions and 155 deletions.
122 changes: 0 additions & 122 deletions src/app/@transactionmodal/(.)tx/page.tsx

This file was deleted.

61 changes: 30 additions & 31 deletions src/app/components/RecentTransaction/RecentTransaction.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -19,42 +19,41 @@ export default function RecentTransaction({ transaction }: any) {
const address = useGetAddress();
const dispatch = useDispatch();
return (
<Link
onClick={() => dispatch(setSheet(true))}
href={{ pathname: '/tx', query: { hash: transaction.hash } }}
>
<motion.div
layoutId={transaction.hash}
className='hover:bg-button-hover mb-4 flex content-center justify-between rounded-lg p-2 text-base transition-all duration-300'
<motion.div layoutId={transaction.hash}>
<Link
onClick={() => dispatch(setSheet(true))}
href={{ pathname: '/tx', query: { hash: transaction.hash } }}
>
<div className='flex items-center'>
<div className='relative grid items-center justify-center'>
<div className='h-12 w-12 rounded-full bg-gradient-to-r from-cyan-500 to-blue-500 '>
{/* Circle */}
</div>
<div className='absolute left-6 top-5'>
<div className='bg-purple flex h-7 w-7 content-center items-center justify-center rounded-full '>
{transaction.from == address ? (
<ArrowLeft className='h-6 w-6' />
) : (
<ArrowRight className='h-6 w-6' />
)}
<motion.div className='hover:bg-button-hover mb-4 flex content-center justify-between rounded-lg p-2 text-base transition-all duration-300'>
<div className='flex items-center'>
<div className='relative grid items-center justify-center'>
<div className='h-12 w-12 rounded-full bg-gradient-to-r from-cyan-500 to-blue-500 '>
{/* Circle */}
</div>
<div className='absolute left-6 top-5'>
<div className='bg-purple flex h-7 w-7 content-center items-center justify-center rounded-full '>
{transaction.from == address ? (
<ArrowLeft className='h-6 w-6' />
) : (
<ArrowRight className='h-6 w-6' />
)}
</div>
</div>
</div>
<motion.div layoutId={`${transaction.hash}+title`} className='ml-2'>
{transaction.from == address ? 'From' : ''}{' '}
{truncateEthAddress(transaction.from)}
</motion.div>
</div>
<motion.div layoutId={`${transaction.hash}+title`} className='ml-2'>
{transaction.from == address ? 'From' : ''}{' '}
{truncateEthAddress(transaction.from)}
</motion.div>
</div>
<div className='flex text-white'>
{transaction.from == address ? '+$' : '-$'}
<div className='flex text-white'>
{transaction.from == address ? '+$' : '-$'}

{transaction.value}
</div>
{transaction.value}
</div>

{/* {transaction.blockNum} */}
</motion.div>
</Link>
{/* {transaction.blockNum} */}
</motion.div>
</Link>
</motion.div>
);
}
2 changes: 1 addition & 1 deletion src/app/layout.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -281,7 +281,7 @@ export default function RootLayout({
<QueryClientProvider client={queryClient}>
<LayoutGroup>
<div>{auth}</div>
<div>{transactionmodal}</div>
{/* <div>{transactionmodal}</div> */}
{/* <div
style={{
backgroundImage: `url(${bgimage.src})`,
Expand Down
115 changes: 114 additions & 1 deletion src/app/tx/page.tsx
Original file line number Diff line number Diff line change
@@ -1,3 +1,116 @@
'use client';
import { AnimatePresence, motion } from 'framer-motion';
import { useEffect, useState } from 'react';
// redux
import { useDispatch, useSelector } from 'react-redux';
import { setSheet } from '@/GlobalRedux/Features/sheet/sheetSlice';
// truncate-eth-address
import truncateEthAddress from 'truncate-eth-address';

// next
import { useRouter, useSearchParams } from 'next/navigation';
import Link from 'next/link';

// icons
import { Send, QrCode } from 'lucide-react';

export default function Page() {
return <div className='bg-button-hover'>backup tx page</div>;
console.log('Tx Modal Page');
const isOpen = useSelector((state) => state.sheet.value);
const dispatch = useDispatch();

const [transaction, setTransaction] = useState<any>({});

const [isLoading, setIsLoading] = useState<boolean>(true);
const searchParams = useSearchParams();

let hash = searchParams.get('hash');

const txState = useSelector((state: any) => state.transactions.value);

const address = useSelector((state: any) => state.address.value);

useEffect(() => {
console.log('txState', txState);
const filteredTransaction = txState.filter((tx: any) => tx.hash == hash);

setTransaction(filteredTransaction[0]);
console.log('filteredTransaction', filteredTransaction);
setIsLoading(false);
}, [txState]);

return (
<>
{!isLoading && (
<motion.div
key={hash}
layoutId={hash}
initial={{ opacity: 1 }}
animate={{
opacity: 1,
transition: { duration: 0.5, ease: [0.76, 0, 0.24, 1] },
}}
exit={{ opacity: 0 }}
style={{
width: '100vw',
height: '100vh',
backgroundColor: '#2f323d',
}}
>
<div className='grid p-4'>
<div className='my-4'>
<div className='flex text-xl font-bold text-white'>
{transaction.from == address ? '+$' : '-$'}

{transaction.value}
</div>
<div className='text-blue-400'>
{transaction.from == address ? 'From' : 'To'}{' '}
{truncateEthAddress(transaction.from)}
</div>
<div className='mt-10 grid grid-cols-2 gap-4 text-white'>
<div>
<Link
href={{
pathname: '/send',
query: { address: transaction.to },
}}
>
<button className='bg-dark border-button-border hover:bg-button-hover flex w-full content-center items-center justify-between rounded border px-4 py-2 text-lg text-white transition-all duration-300'>
<div className='text-white'>Send</div>{' '}
<Send size={20} color='#cbd5e1' />
</button>
</Link>
</div>
<div>
<Link
href={{
pathname: '/receive',
}}
>
<button className='bg-dark border-button-border hover:bg-button-hover flex w-full content-center items-center justify-between rounded border px-4 py-2 text-lg text-white transition-all duration-300'>
<div className='text-white'>Receive</div>{' '}
<QrCode size={20} color='#cbd5e1' />
</button>
</Link>
</div>
</div>
<div className='bg-paper-one mt-4 rounded-xl p-4 text-slate-300'>
<div className='mb-4 flex justify-between'>
<p>Status</p>
<p>Completed</p>
</div>
<div className='flex justify-between'>
<p>Tx Hash</p>
<p className='text-blue-400'>
{truncateEthAddress(transaction.hash)}
</p>
</div>
</div>
</div>
</div>
</motion.div>
)}
</>
);
}

0 comments on commit b588893

Please sign in to comment.