Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
43 changes: 43 additions & 0 deletions src/app/(pages)/students/archive/page.tsx
Original file line number Diff line number Diff line change
@@ -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<string>();
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 (
<>
<div>
<h2 className="m-8 text-2xl font-bold text-blueprint-500">
<a href="/students/" className="underline">
{'< Return to current team'}
</a>
</h2>
</div>
<div className="m-4 ml-0 flex flex-row gap-5 md:m-8 md:justify-start">
<h1 className="mb-4 pt-6 text-4xl font-bold md:mb-8 md:text-5xl">
Our Past <span className="text-blueprint-500">Blueprinters</span>
</h1>
<Image src={bluePeople} width={188.5} alt="Image of blue figures" className="hidden md:block" />
</div>
<div className="flex flex-col space-y-12 text-center md:space-y-24">
{teams.map(team => (
<Section team={team} key={uuidv4()} />
))}
</div>
</>
);
}
15 changes: 15 additions & 0 deletions src/app/(pages)/students/layout.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
import React from 'react';

export default function StudentLayout({
children,
}: Readonly<{
children: React.ReactNode;
}>) {
return (
<div className="min-h-screen overflow-x-hidden bg-blueprint-50">
<div className="content container relative flex flex-col space-y-24 pb-24">
<div className="flex flex-col">{children}</div>
</div>
</div>
);
}
37 changes: 19 additions & 18 deletions src/app/(pages)/students/page.tsx
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
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';

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<string>();
for (const student of students) {
Expand All @@ -22,22 +22,23 @@ export default async function Students() {
}

return (
<div className="min-h-screen overflow-x-hidden bg-blueprint-50">
<div className="content container relative flex flex-col space-y-24 pb-24">
<div className="flex flex-col space-y-2">
<div className="m-4 ml-0 flex flex-row gap-5 md:m-8 md:justify-start">
<h1 className="mb-4 pt-6 text-4xl font-bold md:mb-8 md:text-5xl">
Meet our <span className="text-blueprint-500">Team</span>
</h1>
<Image src={bluePeople} width={188.5} alt="Image of blue figures" className="hidden md:block" />
</div>
<div className="flex flex-col space-y-12 text-center md:space-y-24">
{teams.map(team => (
<Section team={team} key={uuidv4()} />
))}
</div>
</div>
<>
<div className="m-4 ml-0 flex flex-row gap-5 md:m-8 md:justify-start">
<h1 className="mb-4 pt-6 text-4xl font-bold md:mb-8 md:text-5xl">
Meet our <span className="text-blueprint-500">Team</span>
</h1>
<Image src={bluePeople} width={188.5} alt="Image of blue figures" className="hidden md:block" />
</div>
</div>
<div className="flex flex-col space-y-12 text-center md:space-y-24">
{teams.map(team => (
<Section team={team} key={uuidv4()} />
))}
</div>
<h2 className="m-8 text-center text-2xl font-bold text-blueprint-500">
<a href="/students/archive" className="underline">
Check out our archive of past Blueprinters!
</a>
</h2>
</>
);
}
106 changes: 106 additions & 0 deletions src/lib/notion/students.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;
});