Skip to content

Commit

Permalink
cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
BillysByTe committed Dec 13, 2024
1 parent fc99590 commit ed95d8d
Show file tree
Hide file tree
Showing 34 changed files with 349 additions and 12,960 deletions.
66 changes: 41 additions & 25 deletions app/(pages)/Donations/page.tsx
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
"use client";
import React, { useState, useEffect } from "react";
import type { Donation } from "@/prisma";
import { Table, TableBody, TableCell, TableContainer, TableHead, TableRow } from "@mui/material";
import { Box, Table, TableBody, TableCell, TableContainer, TableHead, TableRow } from "@mui/material";
import Link from "next/link";
import { useRouter } from "next/navigation";
import Loading from "@/app/loading";

/*
place holder list
Expand Down Expand Up @@ -51,6 +53,9 @@ export const TableHeader = () => {

export default function DonationsList() {
const [data, setData] = useState<Donation[]>([]);
const [isLoading, setIsLoading] = useState<boolean>(true);

const router = useRouter();

const fetchDonationsData = async () => {
try {
Expand All @@ -60,39 +65,50 @@ export default function DonationsList() {
const result = await response.json();

setData(result.data);

setIsLoading(false);
} catch (error) {
console.error("Error fetching:", error);
router.push("/not-found");
}
};
useEffect(() => {
fetchDonationsData();
}, []);

return (
<TableContainer>
<Table stickyHeader sx={styles.table} aria-labelledby="tableTitle">
<TableHeader />
<TableBody>
{data.map((donation) => {
return (
<TableRow hover key={donation.id}>
<TableCell sx={styles.tableCell}>
<Link className="text-blue-500" href={`/Donations/Detail/${donation.id}`}>
{donation.type}
</Link>
</TableCell>
<TableCell sx={styles.tableCell} align="right">
${donation.amount}
</TableCell>
<TableCell sx={styles.tableCell}>{donation.type !== "In-Kind" ? "" : donation.item}</TableCell>
<TableCell sx={styles.tableCell}>{donation.type !== "In-Kind" ? donation.paymentMethod : ""}</TableCell>
<TableCell sx={styles.tableCell}>{new Date(donation.date).toLocaleDateString()}</TableCell>
</TableRow>
);
})}
</TableBody>
</Table>
</TableContainer>
<Box>
{isLoading ? (
<Loading />
) : (
<TableContainer>
<Table stickyHeader sx={styles.table} aria-labelledby="tableTitle">
<TableHeader />
<TableBody>
{data.map((donation) => {
return (
<TableRow hover key={donation.id}>
<TableCell sx={styles.tableCell}>
<Link className="text-blue-500" href={`/Donations/Detail/${donation.id}`}>
{donation.type}
</Link>
</TableCell>
<TableCell sx={styles.tableCell} align="right">
${donation.amount}
</TableCell>
<TableCell sx={styles.tableCell}>{donation.type !== "In-Kind" ? "" : donation.item}</TableCell>
<TableCell sx={styles.tableCell}>
{donation.type !== "In-Kind" ? donation.paymentMethod : ""}
</TableCell>
<TableCell sx={styles.tableCell}>{new Date(donation.date).toLocaleDateString()}</TableCell>
</TableRow>
);
})}
</TableBody>
</Table>
</TableContainer>
)}
</Box>
);
}

Expand Down
59 changes: 36 additions & 23 deletions app/(pages)/Donors/page.tsx
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
"use client";
import React, { useState, useEffect } from "react";
import type { Donation } from "@/prisma";
import { Table, TableBody, TableCell, TableContainer, TableHead, TableRow } from "@mui/material";
import { Box, Table, TableBody, TableCell, TableContainer, TableHead, TableRow } from "@mui/material";
import Link from "next/link";
import { Donor } from "@prisma/client";
import { useRouter } from "next/navigation";
import Loading from "@/app/loading";

/*
place holder list
Expand Down Expand Up @@ -42,44 +43,56 @@ export const TableHeader = () => {

export default function DonorsList() {
const [data, setData] = useState<Donor[]>([]);
const [isLoading, setIsLoading] = useState<boolean>(true);

const router = useRouter();

const fetchDonorData = async () => {
try {
const response = await fetch("/api/donors", {
method: "GET",
});
const result = await response.json();
console.log(result.data);

setData(result.data);

setIsLoading(false);
} catch (error) {
console.error("Error fetching:", error);
router.push("/not-found");
}
};
useEffect(() => {
fetchDonorData();
}, []);

return (
<TableContainer>
<Table stickyHeader sx={styles.table} aria-labelledby="tableTitle">
<TableHeader />
<TableBody>
{data.map((donor) => {
return (
<TableRow hover key={donor.id}>
<TableCell sx={styles.tableCell}>
<Link className="text-blue-500" href={`/Donors/Detail/${donor.id}`}>
{donor.type}
</Link>
</TableCell>
<TableCell sx={styles.tableCell}>{donor.communicationPreference}</TableCell>
<TableCell sx={styles.tableCell}>{donor.status}</TableCell>
</TableRow>
);
})}
</TableBody>
</Table>
</TableContainer>
<Box>
{isLoading ? (
<Loading />
) : (
<TableContainer>
<Table stickyHeader sx={styles.table} aria-labelledby="tableTitle">
<TableHeader />
<TableBody>
{data.map((donor) => {
return (
<TableRow hover key={donor.id}>
<TableCell sx={styles.tableCell}>
<Link className="text-blue-500" href={`/Donors/Detail/${donor.id}`}>
{donor.type}
</Link>
</TableCell>
<TableCell sx={styles.tableCell}>{donor.communicationPreference}</TableCell>
<TableCell sx={styles.tableCell}>{donor.status}</TableCell>
</TableRow>
);
})}
</TableBody>
</Table>
</TableContainer>
)}
</Box>
);
}

Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ import React, { useState } from "react";
import { format } from "date-fns";
import Link from "next/link";
import { useRouter } from "next/navigation";
import { Router } from "express";

interface Event {
ID: number;
Expand Down Expand Up @@ -49,9 +48,7 @@ export const AdminRegTable: React.FC<TableProps> = ({ data }) => {

const Breadcrumb = () => (
<div className="mb-5 text-sm text-gray-600 flex items-center space-x-2">
<span className="hover:text-blue-500 cursor-pointer transition-colors duration-200">
Home
</span>
<span className="hover:text-blue-500 cursor-pointer transition-colors duration-200">Home</span>
<span className="text-gray-400">/</span>
<span className="font-semibold text-gray-700">Registration</span>
</div>
Expand Down Expand Up @@ -83,32 +80,19 @@ export const AdminRegTable: React.FC<TableProps> = ({ data }) => {
<th className="border border-gray-300 p-2 bg-gray-100">Name</th>
<th className="border border-gray-300 p-2 bg-gray-100">Date</th>
<th className="border border-gray-300 p-2 bg-gray-100">Time</th>
<th className="border border-gray-300 p-2 bg-gray-100">
Description
</th>
<th className="border border-gray-300 p-2 bg-gray-100">
LocationID
</th>
<th className="border border-gray-300 p-2 bg-gray-100">
Volunteers
</th>
<th className="border border-gray-300 p-2 bg-gray-100">Description</th>
<th className="border border-gray-300 p-2 bg-gray-100">LocationID</th>
<th className="border border-gray-300 p-2 bg-gray-100">Volunteers</th>
<th className="border border-gray-300 p-2 bg-gray-100"></th>
</tr>
</thead>
<tbody>
{events.map((event, index) => (
<tr
key={index}
className={index % 2 === 0 ? "bg-gray-50" : "bg-white"}
>
<tr key={index} className={index % 2 === 0 ? "bg-gray-50" : "bg-white"}>
<td className="py-2 px-4 border-b">{event.ID}</td>
<td className="py-2 px-4 border-b">{event.Name}</td>
<td className="py-2 px-4 border-b">
{format(event.Date, "yyyy-MM-dd")}
</td>
<td className="py-2 px-4 border-b">
{format(event.Time, "HH:mm:ss")}
</td>
<td className="py-2 px-4 border-b">{format(event.Date, "yyyy-MM-dd")}</td>
<td className="py-2 px-4 border-b">{format(event.Time, "HH:mm:ss")}</td>
<td className="py-2 px-4 border-b">{event.Description}</td>
<td className="py-2 px-4 border-b">{event.LocationID}</td>
<td className="py-2 px-4 border-b">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ import React, { useState } from "react";
import Link from "next/link";
import { useRouter } from "next/navigation";
import { format } from "date-fns";
import { Router } from "express";

interface Event {
ID: number;
Expand Down Expand Up @@ -40,9 +39,7 @@ export const VolRegTable: React.FC<TableProps> = ({ data }) => {

const Breadcrumb = () => (
<div className="mb-5 text-sm text-gray-600 flex items-center space-x-2">
<span className="hover:text-blue-500 cursor-pointer transition-colors duration-200">
Home
</span>
<span className="hover:text-blue-500 cursor-pointer transition-colors duration-200">Home</span>
<span className="text-gray-400">/</span>
<span className="font-semibold text-gray-700">Registration</span>
</div>
Expand All @@ -68,32 +65,19 @@ export const VolRegTable: React.FC<TableProps> = ({ data }) => {
<th className="border border-gray-300 p-2 bg-gray-100">Name</th>
<th className="border border-gray-300 p-2 bg-gray-100">Date</th>
<th className="border border-gray-300 p-2 bg-gray-100">Time</th>
<th className="border border-gray-300 p-2 bg-gray-100">
Description
</th>
<th className="border border-gray-300 p-2 bg-gray-100">
LocationID
</th>
<th className="border border-gray-300 p-2 bg-gray-100">
Volunteers
</th>
<th className="border border-gray-300 p-2 bg-gray-100">Description</th>
<th className="border border-gray-300 p-2 bg-gray-100">LocationID</th>
<th className="border border-gray-300 p-2 bg-gray-100">Volunteers</th>
<th className="border border-gray-300 p-2 bg-gray-100"></th>
</tr>
</thead>
<tbody>
{events.map((event, index) => (
<tr
key={index}
className={index % 2 === 0 ? "bg-gray-50" : "bg-white"}
>
<tr key={index} className={index % 2 === 0 ? "bg-gray-50" : "bg-white"}>
<td className="py-2 px-4 border-b">{event.ID}</td>
<td className="py-2 px-4 border-b">{event.Name}</td>
<td className="py-2 px-4 border-b">
{format(event.Date, "yyyy-MM-dd")}
</td>
<td className="py-2 px-4 border-b">
{format(event.Time, "HH:mm:ss")}
</td>
<td className="py-2 px-4 border-b">{format(event.Date, "yyyy-MM-dd")}</td>
<td className="py-2 px-4 border-b">{format(event.Time, "HH:mm:ss")}</td>
<td className="py-2 px-4 border-b">{event.Description}</td>
<td className="py-2 px-4 border-b">{event.LocationID}</td>
<td className="py-2 px-4 border-b">
Expand Down
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
@@ -1,11 +1,7 @@
import React from "react";
import { SecondarySideBar } from "../components/SecondarySideBar";
import { SecondarySideBar } from "@/app/components/SecondarySideBar";

export default function VolunteerLayout({
children,
}: {
children: React.ReactNode;
}) {
export default function VolunteerLayout({ children }: { children: React.ReactNode }) {
return (
<div className="flex">
<SecondarySideBar
Expand Down
5 changes: 1 addition & 4 deletions app/Volunteers/page.tsx → app/(pages)/Volunteers/page.tsx
Original file line number Diff line number Diff line change
@@ -1,8 +1,5 @@
"use client";
import React, { useState, useEffect } from "react";
import { SecondarySideBar } from "../components/SecondarySideBar";

export default function GrantsPage() {
export default function VolunteersPage() {
const Header = () => (
<div className="flex justify-between items-center mb-5">
<h1 className="text-2xl font-bold text-gray-800">Volunteers</h1>
Expand Down
1 change: 1 addition & 0 deletions app/components/MainSidebar.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ const MainSidebarItems: ListItem[] = [
{ name: "Constituents", reference: "/Constituents" },
{ name: "Donations", reference: "/Donations" },
{ name: "Grants", reference: "/Grants" },
{ name: "Volunteers", reference: "/Volunteers" },
];

export default function MainSidebar() {
Expand Down
20 changes: 10 additions & 10 deletions app/layout.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,21 +7,21 @@ export const metadata = {
description: "Next.js application",
};

export default function RootLayout({
children,
}: {
children: React.ReactNode;
}) {
export default function RootLayout({ children }: { children: React.ReactNode }) {
return (
<html lang="en">
<body className="flex">
<MainSidebar />
<div className="flex flex-col flex-grow">
<body className="flex flex-col items-center">
<div className="w-full">
<TopNavigationBar />
<main className="flex-grow">{children}</main>
</div>

<div className="flex w-full">
<MainSidebar />
<div className="flex flex-col flex-grow">
<main className="flex-grow">{children}</main>
</div>
</div>
</body>
</html>
);
}

Loading

0 comments on commit ed95d8d

Please sign in to comment.