Added schedule page
This commit is contained in:
@@ -4,6 +4,7 @@ import SignUpPage from "./pages/SignUpPage";
|
|||||||
import SignInPage from "./pages/SignInPage";
|
import SignInPage from "./pages/SignInPage";
|
||||||
import SpringboardPage from "./pages/SpringboardPage";
|
import SpringboardPage from "./pages/SpringboardPage";
|
||||||
import ManageUserAccountPage from "./pages/ManageUserAccountPage";
|
import ManageUserAccountPage from "./pages/ManageUserAccountPage";
|
||||||
|
import SchedulePage from "./pages/SchedulePage";
|
||||||
|
|
||||||
function App() {
|
function App() {
|
||||||
return (
|
return (
|
||||||
@@ -16,6 +17,7 @@ function App() {
|
|||||||
element={<ManageUserAccountPage />}
|
element={<ManageUserAccountPage />}
|
||||||
path="/manage-account/:accessToken"
|
path="/manage-account/:accessToken"
|
||||||
/>
|
/>
|
||||||
|
<Route element={<SchedulePage/>} path="/schedule"/>
|
||||||
</Routes>
|
</Routes>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,14 +1,18 @@
|
|||||||
import { Button } from "@nextui-org/react";
|
import { Button } from "@nextui-org/react";
|
||||||
|
import { useNavigate } from "react-router-dom";
|
||||||
|
|
||||||
export default function SpringboardButton({
|
export default function SpringboardButton({
|
||||||
title,
|
title,
|
||||||
subtitle,
|
subtitle,
|
||||||
|
linkToPage,
|
||||||
}: {
|
}: {
|
||||||
title: string;
|
title: string;
|
||||||
subtitle: string;
|
subtitle: string;
|
||||||
|
linkToPage: string;
|
||||||
}) {
|
}) {
|
||||||
|
const navigate = useNavigate();
|
||||||
return (
|
return (
|
||||||
<Button className="border-4 border-red-500 bg-neutral-700 hover:bg-red-500 text-white">
|
<Button onPress={() => {navigate(linkToPage)}} className="border-4 border-red-500 bg-neutral-700 hover:bg-red-500 text-white">
|
||||||
<div className="flex flex-col justify-between w-full h-full py-4 px-2 text-left *:text-wrap mr-16">
|
<div className="flex flex-col justify-between w-full h-full py-4 px-2 text-left *:text-wrap mr-16">
|
||||||
<p className="text-2xl font-semibold">{title}</p>
|
<p className="text-2xl font-semibold">{title}</p>
|
||||||
<p>{subtitle}</p>
|
<p>{subtitle}</p>
|
||||||
|
|||||||
109
client/src/pages/SchedulePage.tsx
Normal file
109
client/src/pages/SchedulePage.tsx
Normal file
@@ -0,0 +1,109 @@
|
|||||||
|
import { Card, CardBody, Table, TableBody, TableCell, TableColumn, TableHeader, TableRow } from '@nextui-org/react';
|
||||||
|
import DefaultLayout from "../layouts/default";
|
||||||
|
import { useEffect, useState } from 'react';
|
||||||
|
import axios from 'axios';
|
||||||
|
import config from '../config';
|
||||||
|
|
||||||
|
|
||||||
|
interface Schedule {
|
||||||
|
id: number;
|
||||||
|
dateTime: string;
|
||||||
|
location: string;
|
||||||
|
postalCode: string;
|
||||||
|
status: string;
|
||||||
|
}
|
||||||
|
|
||||||
|
export default function SchedulePage() {
|
||||||
|
|
||||||
|
const [scheduleList, setScheduleList] = useState<Schedule[]>([]);
|
||||||
|
|
||||||
|
useEffect(() => {
|
||||||
|
axios.get(config.serverAddress + '/schedule')
|
||||||
|
.then((res) => {
|
||||||
|
const schedules = res.data.map((schedule: Schedule) => ({
|
||||||
|
...schedule,
|
||||||
|
dateTime: new Date(schedule.dateTime), // Convert to Date object
|
||||||
|
}));
|
||||||
|
setScheduleList(schedules);
|
||||||
|
})
|
||||||
|
.catch((err) => {
|
||||||
|
console.error('Error fetching schedules:', err);
|
||||||
|
});
|
||||||
|
}, []);
|
||||||
|
|
||||||
|
return (
|
||||||
|
<DefaultLayout>
|
||||||
|
<section className="flex flex-col items-center justify-center gap-4 py-8 md:py-10">
|
||||||
|
<h1>Karang Guni Schedule</h1>
|
||||||
|
<div className="flex flex-col gap-8">
|
||||||
|
<Table>
|
||||||
|
<TableHeader>
|
||||||
|
<TableColumn>Date</TableColumn>
|
||||||
|
<TableColumn>Time</TableColumn>
|
||||||
|
<TableColumn>Location</TableColumn>
|
||||||
|
<TableColumn>Postal Code</TableColumn>
|
||||||
|
<TableColumn>Status</TableColumn>
|
||||||
|
</TableHeader>
|
||||||
|
<TableBody>
|
||||||
|
{scheduleList.map((schedule) => (
|
||||||
|
<TableRow key={schedule.id}>
|
||||||
|
<TableCell>{((schedule.dateTime as unknown) as Date).toLocaleDateString()}</TableCell>
|
||||||
|
<TableCell>{((schedule.dateTime as unknown) as Date).toLocaleTimeString([], { hour: '2-digit', minute: '2-digit' })}</TableCell>
|
||||||
|
<TableCell>{schedule.location}</TableCell>
|
||||||
|
<TableCell>{schedule.postalCode}</TableCell>
|
||||||
|
<TableCell>{schedule.status}</TableCell>
|
||||||
|
</TableRow>
|
||||||
|
))}
|
||||||
|
</TableBody>
|
||||||
|
</Table>
|
||||||
|
<div>
|
||||||
|
<div>
|
||||||
|
<div className="flex flex-row gap-20 ">
|
||||||
|
<div>
|
||||||
|
<Card>
|
||||||
|
<CardBody>
|
||||||
|
<p className="text-lg">Paper</p>
|
||||||
|
<p className="text-xl">$0.05 to 0.20/KG</p>
|
||||||
|
<ul>
|
||||||
|
<li>Cardboard ($0.20/kg)</li>
|
||||||
|
<li>Newspaper and B&W ($0.11/kg)</li>
|
||||||
|
<li>Mix paper ($0.05/kg)</li>
|
||||||
|
</ul>
|
||||||
|
</CardBody>
|
||||||
|
</Card>
|
||||||
|
</div>
|
||||||
|
<div>
|
||||||
|
<Card>
|
||||||
|
<CardBody>
|
||||||
|
<p className="text-lg">Paper</p>
|
||||||
|
<p className="text-xl">$0.05 to 0.20/KG</p>
|
||||||
|
<ul>
|
||||||
|
<li>Cardboard ($0.20/kg)</li>
|
||||||
|
<li>Newspaper and B&W ($0.11/kg)</li>
|
||||||
|
<li>Mix paper ($0.05/kg)</li>
|
||||||
|
</ul>
|
||||||
|
</CardBody>
|
||||||
|
</Card>
|
||||||
|
</div>
|
||||||
|
<div>
|
||||||
|
<Card>
|
||||||
|
<CardBody>
|
||||||
|
<p className="text-lg">Paper</p>
|
||||||
|
<p className="text-xl">$0.05 to 0.20/KG</p>
|
||||||
|
<ul>
|
||||||
|
<li>Cardboard ($0.20/kg)</li>
|
||||||
|
<li>Newspaper and B&W ($0.11/kg)</li>
|
||||||
|
<li>Mix paper ($0.05/kg)</li>
|
||||||
|
</ul>
|
||||||
|
</CardBody>
|
||||||
|
</Card>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
</section>
|
||||||
|
</DefaultLayout>
|
||||||
|
);
|
||||||
|
}
|
||||||
@@ -76,18 +76,26 @@ export default function SpringboardPage() {
|
|||||||
<SpringboardButton
|
<SpringboardButton
|
||||||
title="Community Forums"
|
title="Community Forums"
|
||||||
subtitle="Be involved in discussions among your neighbourhood"
|
subtitle="Be involved in discussions among your neighbourhood"
|
||||||
|
linkToPage=""
|
||||||
|
|
||||||
></SpringboardButton>
|
></SpringboardButton>
|
||||||
<SpringboardButton
|
<SpringboardButton
|
||||||
title="Events"
|
title="Events"
|
||||||
subtitle="Participate in exciting upcoming events around Singapore"
|
subtitle="Participate in exciting upcoming events around Singapore"
|
||||||
|
linkToPage=""
|
||||||
|
|
||||||
></SpringboardButton>
|
></SpringboardButton>
|
||||||
<SpringboardButton
|
<SpringboardButton
|
||||||
title="Home Bill Contest"
|
title="Home Bill Contest"
|
||||||
subtitle="Save resources, win vouchers!"
|
subtitle="Save resources, win vouchers!"
|
||||||
|
linkToPage=""
|
||||||
|
|
||||||
></SpringboardButton>
|
></SpringboardButton>
|
||||||
<SpringboardButton
|
<SpringboardButton
|
||||||
title="Karang Guni Scheduling"
|
title="Karang Guni Scheduling"
|
||||||
subtitle="Arrange doorstep sales for your old gears with Karang Guni"
|
subtitle="Arrange doorstep sales for your old gears with Karang Guni"
|
||||||
|
linkToPage="/schedule"
|
||||||
|
|
||||||
></SpringboardButton>
|
></SpringboardButton>
|
||||||
</div>
|
</div>
|
||||||
<div className="w-full h-[600px] bg-red-500"></div>
|
<div className="w-full h-[600px] bg-red-500"></div>
|
||||||
|
|||||||
24
server/models/Schedule.js
Normal file
24
server/models/Schedule.js
Normal file
@@ -0,0 +1,24 @@
|
|||||||
|
module.exports = (sequelize, DataTypes) => {
|
||||||
|
const Schedule = sequelize.define("Schedule", {
|
||||||
|
dateTime: {
|
||||||
|
type: DataTypes.DATE,
|
||||||
|
allowNull: false
|
||||||
|
},
|
||||||
|
location: {
|
||||||
|
type: DataTypes.TEXT,
|
||||||
|
allowNull: false
|
||||||
|
},
|
||||||
|
postalCode: {
|
||||||
|
type: DataTypes.INTEGER(6),
|
||||||
|
allowNull: false
|
||||||
|
},
|
||||||
|
status: {
|
||||||
|
type: DataTypes.TEXT,
|
||||||
|
allowNull: false
|
||||||
|
},
|
||||||
|
},
|
||||||
|
{
|
||||||
|
tableName: 'schedule'
|
||||||
|
});
|
||||||
|
return Schedule;
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user