diff --git a/src/app/(pages)/students/archive/page.tsx b/src/app/(pages)/students/archive/page.tsx new file mode 100644 index 0000000..24bde9f --- /dev/null +++ b/src/app/(pages)/students/archive/page.tsx @@ -0,0 +1,43 @@ +import Image from 'next/image'; +import bluePeople from '../_assets/blue_people.svg'; +import Section, { TeamDataType } from '../_components/Section'; +import { v4 as uuidv4 } from 'uuid'; +import { getPastStudents } from '@/lib/notion/students'; + +export default async function Page() { + const students = await getPastStudents(); + + let teamNamesSet = new Set(); + for (const student of students) { + teamNamesSet.add(student.team); + } + + const teamNamesArray = Array.from(teamNamesSet); + const teams: TeamDataType[] = []; + for (const teamName of teamNamesArray) { + const teamMembers = students.filter(student => student.team == teamName); + teams.push({ teamName, teamMembers }); + } + return ( + <> +
+

+ + {'< Return to current team'} + +

+
+
+

+ Our Past Blueprinters +

+ Image of blue figures +
+
+ {teams.map(team => ( +
+ ))} +
+ + ); +} diff --git a/src/app/(pages)/students/layout.tsx b/src/app/(pages)/students/layout.tsx new file mode 100644 index 0000000..e90bbdb --- /dev/null +++ b/src/app/(pages)/students/layout.tsx @@ -0,0 +1,15 @@ +import React from 'react'; + +export default function StudentLayout({ + children, +}: Readonly<{ + children: React.ReactNode; +}>) { + return ( +
+
+
{children}
+
+
+ ); +} diff --git a/src/app/(pages)/students/page.tsx b/src/app/(pages)/students/page.tsx index 77cea84..2a750c6 100644 --- a/src/app/(pages)/students/page.tsx +++ b/src/app/(pages)/students/page.tsx @@ -1,5 +1,5 @@ import Section, { TeamDataType } from './_components/Section'; -import { getStudents } from '@/lib/notion/students'; +import { getCurrentStudents } from '@/lib/notion/students'; import { v4 as uuidv4 } from 'uuid'; import bluePeople from './_assets/blue_people.svg'; import Image from 'next/image'; @@ -7,7 +7,7 @@ import Image from 'next/image'; export const revalidate = Number(process.env.REVALIDATION_INTERVAL) || 3600; export default async function Students() { - const students = await getStudents(); + const students = await getCurrentStudents(); let teamNamesSet = new Set(); for (const student of students) { @@ -22,22 +22,23 @@ export default async function Students() { } return ( -
-
-
-
-

- Meet our Team -

- Image of blue figures -
-
- {teams.map(team => ( -
- ))} -
-
+ <> +
+

+ Meet our Team +

+ Image of blue figures
-
+
+ {teams.map(team => ( +
+ ))} +
+

+ + Check out our archive of past Blueprinters! + +

+ ); } diff --git a/src/lib/notion/students.ts b/src/lib/notion/students.ts index 3ecea3d..68df07e 100644 --- a/src/lib/notion/students.ts +++ b/src/lib/notion/students.ts @@ -53,3 +53,109 @@ export const getStudents = cache(async () => { return studentsArray; }); + +export const getCurrentStudents = cache(async () => { + const res = await notion.databases.query({ + database_id: STUDENTS_DATABASE_ID, + filter: { + and: [ + { + property: 'Visibility', + checkbox: { + equals: true, + }, + }, + { + property: 'Status', + status: { + equals: 'Current', + }, + }, + ], + }, + sorts: [ + { + property: 'Team', + direction: 'ascending', + }, + { + property: 'Roles', + direction: 'ascending', + }, + ], + }); + + const studentsArray: StudentDataType[] = []; + + for (const student of res.results as PageObjectResponse[]) { + if (student.properties.Visibility.type !== 'checkbox') continue; + if (!student.properties.Visibility.checkbox) { + continue; + } + + if (student.properties.Name.type !== 'title') continue; + if (student.properties.Team.type !== 'select') continue; + if (student.properties.Roles.type !== 'select') continue; + if (student.properties.Link.type !== 'url') continue; + if (student.properties.Image.type !== 'files') continue; + + if (student.properties.Image.files[0] && !('file' in student.properties.Image.files[0])) continue; + + const name = student.properties.Name.title[0]?.plain_text || 'Name'; + const team = student.properties.Team.select?.name || 'Executive'; + const role = student.properties.Roles.select?.name || 'Role'; + const imageUrl = student.properties['Image'].files[0]?.file.url || '/default.png'; + const personalUrl = student.properties.Link.url !== null ? student.properties.Link.url : 'No URL'; + studentsArray.push({ name, team, role, imageUrl, personalUrl }); + } + + return studentsArray; +}); + +export const getPastStudents = cache(async () => { + const res = await notion.databases.query({ + database_id: STUDENTS_DATABASE_ID, + filter: { + property: 'Status', + status: { + equals: 'Past', + }, + }, + sorts: [ + { + property: 'Team', + direction: 'ascending', + }, + { + property: 'Roles', + direction: 'ascending', + }, + ], + }); + + const studentsArray: StudentDataType[] = []; + + for (const student of res.results as PageObjectResponse[]) { + if (student.properties.Visibility.type !== 'checkbox') continue; + // if (!student.properties.Visibility.checkbox) { + // continue; + // } + + if (student.properties.Name.type !== 'title') continue; + if (student.properties.Team.type !== 'select') continue; + if (student.properties.Roles.type !== 'select') continue; + if (student.properties.Link.type !== 'url') continue; + if (student.properties.Image.type !== 'files') continue; + + if (student.properties.Image.files[0] && !('file' in student.properties.Image.files[0])) continue; + + const name = student.properties.Name.title[0]?.plain_text || 'Name'; + const team = student.properties.Team.select?.name || 'Executive'; + const role = student.properties.Roles.select?.name || 'Role'; + const imageUrl = student.properties['Image'].files[0]?.file.url || '/default.png'; + const personalUrl = student.properties.Link.url !== null ? student.properties.Link.url : 'No URL'; + studentsArray.push({ name, team, role, imageUrl, personalUrl }); + } + + return studentsArray; +});