Spaces:
Sleeping
Sleeping
setup income and expense statement
Browse files- app/(auth)/login/page.tsx +69 -0
- app/(auth)/login/styles.css +26 -0
- app/(home)/layout.tsx +5 -2
- app/(home)/reports/page.tsx +2 -2
- app/components/Topbar/index.tsx +30 -0
- app/components/Topbar/styles.css +14 -0
- app/lib/endpoints/index.ts +2 -2
- middleware.ts +1 -1
- public/logo.jpg +0 -0
app/(auth)/login/page.tsx
ADDED
|
@@ -0,0 +1,69 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
'use client';
|
| 2 |
+
import React from 'react';
|
| 3 |
+
import { Form, Input, Button, Checkbox, Typography, Layout, FormProps } from 'antd';
|
| 4 |
+
import './styles.css';
|
| 5 |
+
import { useRouter } from 'next/navigation';
|
| 6 |
+
|
| 7 |
+
const { Title } = Typography;
|
| 8 |
+
const { Content } = Layout;
|
| 9 |
+
|
| 10 |
+
type FieldType = {
|
| 11 |
+
username?: string;
|
| 12 |
+
password?: string;
|
| 13 |
+
remember?: string;
|
| 14 |
+
};
|
| 15 |
+
|
| 16 |
+
const LoginPage = () => {
|
| 17 |
+
const router = useRouter();
|
| 18 |
+
const onFinish: FormProps<FieldType>['onFinish'] = (values) => {
|
| 19 |
+
console.log('Success:', values);
|
| 20 |
+
router.push('/dashboard');
|
| 21 |
+
};
|
| 22 |
+
|
| 23 |
+
const onFinishFailed: FormProps<FieldType>['onFinishFailed'] = (errorInfo) => {
|
| 24 |
+
console.log('Failed:', errorInfo);
|
| 25 |
+
};
|
| 26 |
+
|
| 27 |
+
return (
|
| 28 |
+
<Layout className="layout">
|
| 29 |
+
<Content className="content">
|
| 30 |
+
<div className="login-container">
|
| 31 |
+
<Title level={2}>Login</Title>
|
| 32 |
+
<Form
|
| 33 |
+
name="basic"
|
| 34 |
+
initialValues={{ remember: true }}
|
| 35 |
+
onFinish={onFinish}
|
| 36 |
+
onFinishFailed={onFinishFailed}
|
| 37 |
+
autoComplete="off"
|
| 38 |
+
>
|
| 39 |
+
<Form.Item
|
| 40 |
+
name="username"
|
| 41 |
+
rules={[{ required: true, message: 'Please input your username!' }]}
|
| 42 |
+
>
|
| 43 |
+
<Input placeholder="Username" />
|
| 44 |
+
</Form.Item>
|
| 45 |
+
|
| 46 |
+
<Form.Item
|
| 47 |
+
name="password"
|
| 48 |
+
rules={[{ required: true, message: 'Please input your password!' }]}
|
| 49 |
+
>
|
| 50 |
+
<Input.Password placeholder="Password" />
|
| 51 |
+
</Form.Item>
|
| 52 |
+
|
| 53 |
+
<Form.Item name="remember" valuePropName="checked">
|
| 54 |
+
<Checkbox>Remember me</Checkbox>
|
| 55 |
+
</Form.Item>
|
| 56 |
+
|
| 57 |
+
<Form.Item>
|
| 58 |
+
<Button type="primary" htmlType="submit" block>
|
| 59 |
+
Log in
|
| 60 |
+
</Button>
|
| 61 |
+
</Form.Item>
|
| 62 |
+
</Form>
|
| 63 |
+
</div>
|
| 64 |
+
</Content>
|
| 65 |
+
</Layout>
|
| 66 |
+
);
|
| 67 |
+
};
|
| 68 |
+
|
| 69 |
+
export default LoginPage;
|
app/(auth)/login/styles.css
ADDED
|
@@ -0,0 +1,26 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
.layout {
|
| 2 |
+
min-height: 100vh;
|
| 3 |
+
display: flex;
|
| 4 |
+
justify-content: center;
|
| 5 |
+
align-items: center;
|
| 6 |
+
background-color: #f0f2f5; /* Optional: Change the background color as needed */
|
| 7 |
+
}
|
| 8 |
+
|
| 9 |
+
.content {
|
| 10 |
+
width: 100%;
|
| 11 |
+
max-height: 450px;
|
| 12 |
+
max-width: 400px;
|
| 13 |
+
padding: 24px;
|
| 14 |
+
background: white;
|
| 15 |
+
box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
|
| 16 |
+
border-radius: 8px; /* Optional: Add border radius for rounded corners */
|
| 17 |
+
}
|
| 18 |
+
|
| 19 |
+
.login-container {
|
| 20 |
+
width: 100%;
|
| 21 |
+
text-align: center;
|
| 22 |
+
}
|
| 23 |
+
|
| 24 |
+
.login-container .ant-typography {
|
| 25 |
+
margin-bottom: 24px;
|
| 26 |
+
}
|
app/(home)/layout.tsx
CHANGED
|
@@ -9,6 +9,7 @@ import {
|
|
| 9 |
} from '@ant-design/icons';
|
| 10 |
import { Button, Layout, Menu, theme } from 'antd';
|
| 11 |
import { useRouter } from "next/navigation";
|
|
|
|
| 12 |
const { Header, Sider, Content } = Layout;
|
| 13 |
|
| 14 |
const Dashboard = ({
|
|
@@ -25,12 +26,13 @@ const Dashboard = ({
|
|
| 25 |
router.push(route);
|
| 26 |
}
|
| 27 |
return (
|
| 28 |
-
<
|
|
|
|
|
|
|
| 29 |
<Layout>
|
| 30 |
<Sider trigger={null} collapsible collapsed={collapsed}>
|
| 31 |
<div className="demo-logo-vertical" />
|
| 32 |
<Menu
|
| 33 |
-
style={{ marginTop: '8rem' }}
|
| 34 |
theme="dark"
|
| 35 |
mode="inline"
|
| 36 |
defaultSelectedKeys={['1']}
|
|
@@ -89,6 +91,7 @@ const Dashboard = ({
|
|
| 89 |
</Layout>
|
| 90 |
</Layout>
|
| 91 |
</main >
|
|
|
|
| 92 |
);
|
| 93 |
}
|
| 94 |
|
|
|
|
| 9 |
} from '@ant-design/icons';
|
| 10 |
import { Button, Layout, Menu, theme } from 'antd';
|
| 11 |
import { useRouter } from "next/navigation";
|
| 12 |
+
import TopBar from "../components/Topbar";
|
| 13 |
const { Header, Sider, Content } = Layout;
|
| 14 |
|
| 15 |
const Dashboard = ({
|
|
|
|
| 26 |
router.push(route);
|
| 27 |
}
|
| 28 |
return (
|
| 29 |
+
<>
|
| 30 |
+
<TopBar />
|
| 31 |
+
<main className="flex min-h-screen flex-col">
|
| 32 |
<Layout>
|
| 33 |
<Sider trigger={null} collapsible collapsed={collapsed}>
|
| 34 |
<div className="demo-logo-vertical" />
|
| 35 |
<Menu
|
|
|
|
| 36 |
theme="dark"
|
| 37 |
mode="inline"
|
| 38 |
defaultSelectedKeys={['1']}
|
|
|
|
| 91 |
</Layout>
|
| 92 |
</Layout>
|
| 93 |
</main >
|
| 94 |
+
</>
|
| 95 |
);
|
| 96 |
}
|
| 97 |
|
app/(home)/reports/page.tsx
CHANGED
|
@@ -5,7 +5,6 @@ import { List } from "antd";
|
|
| 5 |
import React, { useEffect, useState } from "react";
|
| 6 |
import { useRouter, useSearchParams } from "next/navigation";
|
| 7 |
import IncomeStatement from "@/app/components/IncomeStatement";
|
| 8 |
-
import { DoubleLeftOutlined } from '@ant-design/icons';
|
| 9 |
|
| 10 |
const Reports = () => {
|
| 11 |
const searchParams = useSearchParams()
|
|
@@ -15,7 +14,8 @@ const Reports = () => {
|
|
| 15 |
|
| 16 |
useEffect(() => {
|
| 17 |
(async () => {
|
| 18 |
-
const data = await fetch(incomeStatements)
|
|
|
|
| 19 |
const statements = await data.json();
|
| 20 |
setStatements(statements);
|
| 21 |
})();
|
|
|
|
| 5 |
import React, { useEffect, useState } from "react";
|
| 6 |
import { useRouter, useSearchParams } from "next/navigation";
|
| 7 |
import IncomeStatement from "@/app/components/IncomeStatement";
|
|
|
|
| 8 |
|
| 9 |
const Reports = () => {
|
| 10 |
const searchParams = useSearchParams()
|
|
|
|
| 14 |
|
| 15 |
useEffect(() => {
|
| 16 |
(async () => {
|
| 17 |
+
const data = await fetch(incomeStatements);
|
| 18 |
+
console.log('data', data);
|
| 19 |
const statements = await data.json();
|
| 20 |
setStatements(statements);
|
| 21 |
})();
|
app/components/Topbar/index.tsx
ADDED
|
@@ -0,0 +1,30 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import React from 'react';
|
| 2 |
+
import { Layout, Menu, Avatar } from 'antd';
|
| 3 |
+
import { SettingOutlined } from '@ant-design/icons';
|
| 4 |
+
import './styles.css'; // Create a CSS file for any custom styling
|
| 5 |
+
import Link from 'next/link';
|
| 6 |
+
|
| 7 |
+
const { Header } = Layout;
|
| 8 |
+
|
| 9 |
+
const TopBar = () => {
|
| 10 |
+
|
| 11 |
+
return (
|
| 12 |
+
<Layout>
|
| 13 |
+
<Header className="header">
|
| 14 |
+
<div className="logo">
|
| 15 |
+
<Link href={'/dashboard'}>
|
| 16 |
+
<img src="/llama.png" alt="Company Logo" />
|
| 17 |
+
</Link>
|
| 18 |
+
</div>
|
| 19 |
+
<Menu theme="dark" mode="horizontal" style={{ flex: 1 }}>
|
| 20 |
+
{/* You can add menu items here if needed */}
|
| 21 |
+
</Menu>
|
| 22 |
+
<div className="settings">
|
| 23 |
+
<Avatar icon={<SettingOutlined />} />
|
| 24 |
+
</div>
|
| 25 |
+
</Header>
|
| 26 |
+
</Layout>
|
| 27 |
+
);
|
| 28 |
+
};
|
| 29 |
+
|
| 30 |
+
export default TopBar;
|
app/components/Topbar/styles.css
ADDED
|
@@ -0,0 +1,14 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
.header {
|
| 2 |
+
display: flex;
|
| 3 |
+
align-items: center;
|
| 4 |
+
padding: 0 24px;
|
| 5 |
+
background-color: #3b5998; /* Change this to your desired top bar color */
|
| 6 |
+
}
|
| 7 |
+
|
| 8 |
+
.logo img {
|
| 9 |
+
height: 32px;
|
| 10 |
+
}
|
| 11 |
+
|
| 12 |
+
.settings {
|
| 13 |
+
margin-left: auto;
|
| 14 |
+
}
|
app/lib/endpoints/index.ts
CHANGED
|
@@ -3,5 +3,5 @@ const url = `${baseUrl}/api/v1`
|
|
| 3 |
|
| 4 |
export const transactionsEndpoint = `${url}/transactions/1`;
|
| 5 |
export const fielUploadEndpoint = `${url}/file_upload`;
|
| 6 |
-
export const incomeStatements = `${url}/income_statement/1`;
|
| 7 |
-
export const statementEndpoint = `${url}/statement`;
|
|
|
|
| 3 |
|
| 4 |
export const transactionsEndpoint = `${url}/transactions/1`;
|
| 5 |
export const fielUploadEndpoint = `${url}/file_upload`;
|
| 6 |
+
export const incomeStatements = `${url}/income_statement/user/1`;
|
| 7 |
+
export const statementEndpoint = `${url}/statement/report/1`;
|
middleware.ts
CHANGED
|
@@ -4,7 +4,7 @@ import type { NextRequest } from 'next/server'
|
|
| 4 |
// This function can be marked `async` if using `await` inside
|
| 5 |
export function middleware(request: NextRequest) {
|
| 6 |
if (request.nextUrl.pathname === '/') {
|
| 7 |
-
return NextResponse.redirect(new URL('/
|
| 8 |
}
|
| 9 |
return NextResponse.next();
|
| 10 |
}
|
|
|
|
| 4 |
// This function can be marked `async` if using `await` inside
|
| 5 |
export function middleware(request: NextRequest) {
|
| 6 |
if (request.nextUrl.pathname === '/') {
|
| 7 |
+
return NextResponse.redirect(new URL('/login', request.url))
|
| 8 |
}
|
| 9 |
return NextResponse.next();
|
| 10 |
}
|
public/logo.jpg
ADDED
|