fix: fix the layout of fund transfer
This commit is contained in:
@@ -1,71 +1,74 @@
|
|||||||
"use client";
|
"use client";
|
||||||
import { Button, Group } from '@mantine/core';
|
import { Divider, Stack, Text } from '@mantine/core';
|
||||||
import { IconHome } from '@tabler/icons-react';
|
import { usePathname } from 'next/navigation';
|
||||||
import Link from 'next/link';
|
import Link from 'next/link';
|
||||||
import React from 'react';
|
import React, { useEffect, useState } from 'react';
|
||||||
|
import { useRouter } from "next/navigation";
|
||||||
|
|
||||||
export default function Layout({ children }: { children: React.ReactNode }) {
|
export default function Layout({ children }: { children: React.ReactNode }) {
|
||||||
|
const [authorized, SetAuthorized] = useState<boolean | null>(null);
|
||||||
|
const router = useRouter();
|
||||||
|
const pathname = usePathname();
|
||||||
|
|
||||||
|
const links = [
|
||||||
|
{ label: " Quick Pay", href: "/funds_transfer" },
|
||||||
|
{ label: "Send to Beneficiary", href: "/accounts/account_statement" },
|
||||||
|
{ label: "Transfer within the bank", href: "/accounts/account_statement" },
|
||||||
|
{ label: "Add Beneficary", href: "/accounts/account_statement" },
|
||||||
|
{ label: "View Beneficary ", href: "/accounts/account_statement" },
|
||||||
|
];
|
||||||
|
useEffect(() => {
|
||||||
|
const token = localStorage.getItem("access_token");
|
||||||
|
if (!token) {
|
||||||
|
SetAuthorized(false);
|
||||||
|
router.push("/login");
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
SetAuthorized(true);
|
||||||
|
}
|
||||||
|
}, []);
|
||||||
|
|
||||||
|
if (authorized) {
|
||||||
return (
|
return (
|
||||||
<div style={{ display: "flex" }}>
|
<div style={{ display: "flex", height: '100%' }}>
|
||||||
<div
|
<div
|
||||||
style={{
|
style={{
|
||||||
// width: "250px",
|
width: "16%",
|
||||||
backgroundColor: '#c5e4f9',
|
backgroundColor: '#c5e4f9',
|
||||||
padding: "20px",
|
|
||||||
display: "flex",
|
|
||||||
flexDirection: "column",
|
|
||||||
justifyContent: "flex-start",
|
|
||||||
gap: "20px",
|
|
||||||
borderRight: "1px solid #ccc",
|
borderRight: "1px solid #ccc",
|
||||||
}}
|
}}
|
||||||
>
|
>
|
||||||
<h2 style={{ fontSize: "20px", marginBottom: "10px" }}>Menu</h2>
|
<Stack style={{ background: '#228be6', height: '10%', alignItems: 'center' }}>
|
||||||
|
<Text fw={700} fs="italic" c='white' style={{ textAlign: 'center', marginTop: '10px' }}>
|
||||||
|
Send Money
|
||||||
|
</Text>
|
||||||
|
</Stack>
|
||||||
|
|
||||||
<Link href="/" passHref>
|
<Stack gap="sm" justify="flex-start" style={{ padding: '1rem' }}>
|
||||||
<Button
|
{links.map(link => {
|
||||||
component="a"
|
const isActive = pathname === link.href;
|
||||||
leftSection={<IconHome size={16} />}
|
return (
|
||||||
variant="light"
|
<Text
|
||||||
color="blue"
|
key={link.href}
|
||||||
fullWidth
|
component={Link}
|
||||||
|
href={link.href}
|
||||||
|
c={isActive ? 'darkblue' : 'blue'}
|
||||||
|
style={{
|
||||||
|
textDecoration: isActive ? 'underline' : 'none',
|
||||||
|
fontWeight: isActive ? 600 : 400,
|
||||||
|
}}
|
||||||
>
|
>
|
||||||
Quick Pay
|
{link.label}
|
||||||
</Button>
|
</Text>
|
||||||
</Link>
|
);
|
||||||
|
})}
|
||||||
<Link href="/" passHref>
|
</Stack>
|
||||||
<Button
|
|
||||||
component="a"
|
|
||||||
leftSection={<IconHome size={16} />}
|
|
||||||
variant="light"
|
|
||||||
color="blue"
|
|
||||||
fullWidth
|
|
||||||
>
|
|
||||||
Send to Beneficiary
|
|
||||||
</Button>
|
|
||||||
</Link>
|
|
||||||
|
|
||||||
<Link href="/" passHref>
|
|
||||||
<Button
|
|
||||||
component="a"
|
|
||||||
leftSection={<IconHome size={16} />}
|
|
||||||
variant="light"
|
|
||||||
color="blue"
|
|
||||||
fullWidth
|
|
||||||
>
|
|
||||||
Transfer within the bank
|
|
||||||
</Button>
|
|
||||||
</Link>
|
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
{/* Main content */}
|
<div style={{ flex: 1, padding: '1rem' }}>
|
||||||
<div style={{
|
|
||||||
// width: '80%',
|
|
||||||
// padding: '20px',
|
|
||||||
// border:'1px solid red'
|
|
||||||
}}>
|
|
||||||
{children}
|
{children}
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
Reference in New Issue
Block a user