-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #17 from ubc-biztech/stats-base-page
base page completed
- Loading branch information
Showing
4 changed files
with
76 additions
and
26 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
export async function fetchRegistrationData(eventId: string, year: string) { | ||
// TODO - fetch data registration data from backend. This is just returning a Mock, likely won't be the final data struct format | ||
|
||
let data = [] | ||
for (let i = 0; i < 200; i++) { | ||
data.push({ | ||
id: i.toString(), | ||
regStatus: "Checked-In", | ||
appStatus: "Accepted", | ||
firstName: "John", | ||
lastName: "Smith", | ||
email: "[email protected]", | ||
points: 0, | ||
studentNumber: "12345678", | ||
faculty: "Comm...", | ||
dynamicField1: "aa...", | ||
shouldNotDisplay: "THIS SHOULD NOT BE DISPLAYING." | ||
}) | ||
} | ||
|
||
return data | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -4,6 +4,7 @@ import { DataTable } from "@/components/RegistrationTable/data-table"; | |
import { useEffect, useState } from "react"; | ||
import { ColumnDef } from "@tanstack/react-table"; | ||
import { GetServerSideProps } from 'next' | ||
import { fetchRegistrationData } from '@/lib/dbUtils'; | ||
|
||
// Dynamic columns | ||
const dynamicColumns: ColumnDef<Attendee>[] = [ | ||
|
@@ -33,7 +34,7 @@ export default function AdminEvent({ initialData }: Props) { | |
const year = router.query.year as string; | ||
|
||
if (eventId && year) { | ||
fetchRegistationData(eventId, year).then(d => { | ||
fetchRegistrationData(eventId, year).then(d => { | ||
setData(d) | ||
setLoading(false) | ||
}) | ||
|
@@ -73,33 +74,10 @@ export const getServerSideProps: GetServerSideProps = async (context) => { | |
const { eventId, year } = context.params as { eventId: string, year: string }; | ||
|
||
try { | ||
const data = await fetchRegistationData(eventId, year); | ||
const data = await fetchRegistrationData(eventId, year); | ||
return { props: { initialData: data } }; | ||
} catch (error) { | ||
console.error("Failed to fetch initial data:", error); | ||
return { props: { initialData: null } }; | ||
} | ||
} | ||
|
||
async function fetchRegistationData(eventId: string, year: string) { | ||
// TODO - fetch data from backend. This is just returning a Mock, likely won't be the final data struct format | ||
|
||
let data = [] | ||
for (let i = 0; i < 200; i++) { | ||
data.push({ | ||
id: i.toString(), | ||
regStatus: "Checked-In", | ||
appStatus: "Accepted", | ||
firstName: "John", | ||
lastName: "Smith", | ||
email: "[email protected]", | ||
points: 0, | ||
studentNumber: "12345678", | ||
faculty: "Comm...", | ||
dynamicField1: "aa...", | ||
shouldNotDisplay: "THIS SHOULD NOT BE DISPLAYING." | ||
}) | ||
} | ||
|
||
return data | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
import { BasicInformation } from "@/types"; | ||
import { GetServerSideProps } from "next"; | ||
import { useRouter } from "next/router"; | ||
import { fetchRegistrationData } from "@/lib/dbUtils"; | ||
|
||
type Props = { | ||
initialData: BasicInformation[] | null | ||
} | ||
|
||
export default function Statistics( { initialData }: Props) { | ||
const router = useRouter() | ||
|
||
return ( | ||
<main className="bg-primary-color min-h-screen"> | ||
<div className="container mx-auto p-10 flex flex-col"> | ||
<span> | ||
<h2 className="text-white">Event Statistics</h2> | ||
<p className="text-baby-blue font-poppins">Statistics {">"} {router.query.eventId} {router.query.year}</p> | ||
{/* | ||
insert charts here | ||
*/} | ||
</span> | ||
</div> | ||
</main> | ||
); | ||
} | ||
|
||
|
||
|
||
export const getServerSideProps: GetServerSideProps = async (context) => { | ||
const { eventId, year } = context.params as { eventId: string, year: string }; | ||
|
||
try { | ||
const data = await fetchRegistrationData(eventId, year); | ||
return { props: { initialData: data } }; | ||
} catch (error) { | ||
console.error("Failed to fetch initial data:", error); | ||
return { props: { initialData: null } }; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
export type BasicInformation = { | ||
fname: string | ||
lname: string | ||
major: string | ||
gender: string | ||
year: string | ||
diet: string | ||
heardFrom: string | ||
faculty: string | ||
} |