Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

replaced static json files with database and prisma #128

Open
wants to merge 2 commits into
base: develop
Choose a base branch
from
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
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -33,3 +33,6 @@ yarn-error.log*

.vercel
*.lock
.env

prisma/migrations
10 changes: 10 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,3 +11,13 @@ yarn dev
```

Open [http://localhost:3000](http://localhost:3000) with your browser to see the result.



### Prisma

yarn prisma db seed
yarn prisma db push
yarn prisma db pull

yarn prisma studio
85 changes: 56 additions & 29 deletions app/e-lab/[id]/page.tsx
Original file line number Diff line number Diff line change
@@ -1,37 +1,50 @@
import {FontAwesomeIcon} from "@fortawesome/react-fontawesome";
import {faArrowLeft} from "@fortawesome/free-solid-svg-icons";
import {alumni, Person, team} from "@data/e-lab";
import Link from "next/link";
import NotFound from "next/dist/client/components/not-found-error";
import Section from "@components/ui/Section";
import Image from "next/image";
import {ProfilePage, WithContext} from "schema-dts";
import SocialMediaLinks from "@components/SocialMediaLinks";
import prisma from "../../../lib/db";

export function generateStaticParams() {
return team.map((person) => ({
export async function generateStaticParams() {
// get all persons from prisma which type is elab-team or elab-alumni
const team_or_alumni = await prisma.person.findMany();

return team_or_alumni.map((person) => ({
id: person.id,
})).concat(alumni.map((person) => ({id: person.id})));
}));
}

export function generateMetadata({params: {id}}: { params: { id: string } }) {
let person = team.find((person: Person) => id === person.id);
if(!person) {
person = alumni.find((person: Person) => id === person.id);
export async function generateMetadata({params: {id}}: { params: { id: string } }) {
const person = await prisma.person.findUnique({
where: {
id: id
}
})
if (!person) {
return {
title: "Person Not Found",
description: "This person does not exist.",
};
}
const name = person?.firstName + " " + person?.lastName;

const name = person.firstName + " " + person.lastName;

return {
title: name + " - AI E-LAB | TUM.ai",
description:
"Meet " + name + " from the AI Entrepreneurship Lab. Join us if you are up for a 3-month founding journey designed to ignite your innovative spirit and equip you with the relevant know-how to build your own AI startup in Munich.",
title: `${name} - AI E-LAB | TUM.ai`,
description: `Meet ${name} from the AI Entrepreneurship Lab. Join us if you are up for a 3-month founding journey designed to ignite your innovative spirit and equip you with the relevant know-how to build your own AI startup in Munich.`,
};
}

export default function Page({params: {id}}: { params: { id: string } }) {
let person = team.find((person: Person) => id === person.id);
if (!person) {
person = alumni.find((person: Person) => id === person.id);
}
export default async function Page({params: {id}}: { params: { id: string } }) {
const person = await prisma.person.findUnique({
where: {
id: id
}
})

if (!person) {
return <NotFound />;
}
Expand All @@ -45,12 +58,12 @@ export default function Page({params: {id}}: { params: { id: string } }) {
name: person.firstName + ' ' + person.lastName,
givenName: person.firstName,
familyName: person.lastName,
description: person.description,
description: person.description ?? '',
image: 'https://www.tum-ai.com' + person.imgSrc,
email: person.socialMedia.email,
email: person.email ?? '',
worksFor: {
'@type': 'EmployeeRole',
roleName: person.role,
roleName: person.role ?? '',
worksFor: {
'@type': 'Organization',
name: 'Venture Department',
Expand All @@ -67,11 +80,11 @@ export default function Page({params: {id}}: { params: { id: string } }) {
},
url: 'https://www.tum-ai.com/e-lab/' + person.id,
sameAs: [
person.socialMedia.linkedin,
person.socialMedia.x ? person.socialMedia.x : "",
person.socialMedia.instagram ? person.socialMedia.instagram : "",
person.socialMedia.youtube ? person.socialMedia.youtube : "",
person.socialMedia.website ? person.socialMedia.website : "",
person.linkedin ?? '',
person.x ?? '',
person.instagram ?? '',
person.youtube ?? '',
person.website ?? '',
],
},
}
Expand Down Expand Up @@ -122,7 +135,14 @@ export default function Page({params: {id}}: { params: { id: string } }) {
<h2 className="sr-only">Social Media Links</h2>
<div className="flex items-center">
<div className="space-x-4">
<SocialMediaLinks socialMedia={person.socialMedia} iconClassNames={"duration-500 hover:text-yellow-500"}/>
<SocialMediaLinks socialMedia={{
linkedin: person.linkedin,
x: person.x,
instagram: person.instagram,
youtube: person.youtube,
website: person.website,
email: person.email
}} iconClassNames={"duration-500 hover:text-yellow-500"}/>
</div>
</div>
</div>
Expand All @@ -140,11 +160,11 @@ export default function Page({params: {id}}: { params: { id: string } }) {
<div className="mt-10 lg:mt-0 lg:col-start-2 lg:row-span-2 lg:self-center">
<div className="aspect-w-1 aspect-h-1 rounded-lg overflow-hidden">
<Image
src={person?.imgSrc}
src={person?.imgSrc ?? ""}
width={0}
height={0}
sizes="100vw"
alt={person?.imgAlt}
alt={person?.imgAlt ?? ""}
className="w-full h-full object-center object-cover"
/>
</div>
Expand All @@ -164,7 +184,14 @@ export default function Page({params: {id}}: { params: { id: string } }) {
</p>
</div>
<div className="space-x-4 mt-2 md:mt-0">
<SocialMediaLinks socialMedia={person.socialMedia} iconClassNames={"text-black duration-500 hover:text-yellow-500"} />
<SocialMediaLinks socialMedia={{
linkedin: person.linkedin,
x: person.x,
instagram: person.instagram,
youtube: person.youtube,
website: person.website,
email: person.email
}} iconClassNames={"text-black duration-500 hover:text-yellow-500"} />
</div>
</div>
</div>
Expand Down
18 changes: 13 additions & 5 deletions app/e-lab/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,19 +7,18 @@ import Timeline from "@components/Timeline";
import Section from "@components/ui/Section";
import { Carousel, CarouselContent, CarouselItem, CarouselNext, CarouselPrevious } from "@components/ui/carousel";
import Card from "@components/ui/Card";
import { startups } from "data/e-lab-startups";
import {
faBook,
faCircleNodes,
faHandshakeSimple,
faHandsHoldingCircle,
} from "@fortawesome/free-solid-svg-icons";
import { faq, testimonials } from "data/e-lab";
import Link from "next/link";
import { Hero } from "./hero";
import type { Metadata } from "next";
import VentureTeam from "@components/VentureTeam";
import {Organization, WithContext} from "schema-dts";
import prisma from "../../lib/db";

export const metadata: Metadata = {
title: "TUM.ai - AI Entrepreneurship Lab",
Expand All @@ -41,7 +40,7 @@ export const metadata: Metadata = {
},
};

export default function Page() {
export default async function Page() {
const jsonLd: WithContext<Organization> = {
'@context': 'https://schema.org',
'@type': 'Organization',
Expand Down Expand Up @@ -96,6 +95,15 @@ export default function Page() {
},
}

const testimonials = await prisma.testimonial.findMany();
const faq = await prisma.fAQ.findMany();
const startups = await prisma.startup.findMany();
const venture_team = await prisma.person.findMany({
where: {
type: "elab-team"
}
});


return (
<>
Expand Down Expand Up @@ -192,7 +200,7 @@ export default function Page() {
className="h-full"
/>
</CarouselItem>
))}
))}
</CarouselContent>
<CarouselPrevious />
<CarouselNext />
Expand Down Expand Up @@ -424,7 +432,7 @@ export default function Page() {
</Link>
</Section>

<VentureTeam/>
<VentureTeam team={venture_team}/>


<Section className="bg-purple-950 text-white">
Expand Down
13 changes: 11 additions & 2 deletions app/e-lab/startuplist/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,24 @@ import type { Metadata } from "next";
import Section from "@ui/Section";
import Link from "next/link";
import StartupList from "@components/ELabStartupList";
import { startups } from "data/e-lab-startups";
import prisma from "../../../lib/db";

// Define the metadata for the page
export const metadata: Metadata = {
title: "E-Lab Startup Directory",
description: "Registry of all E-Lab based Startups.",
};

export default function Page() {
export default async function Page() {
const startups = await prisma.startup.findMany({
include: {
metrics: true,
founders: true,
jobs: true,
latestNews: true
},
});

return (
<>
{/* Hidden Title for Accessibility */}
Expand Down
19 changes: 12 additions & 7 deletions app/e-lab/startups/[id]/page.tsx
Original file line number Diff line number Diff line change
@@ -1,13 +1,18 @@
import { startups, Startup} from '@data/e-lab-startups';
import StartupDetails from '@components/StartupDetails';
import prisma from "../../../../lib/db";

export default function StartupPage({ params }: { params: { id: string } }) {
export default async function StartupPage({ params }: { params: { id: string } }) {

const startup: Startup | undefined = startups.find((startup: Startup) => {
if (startup && startup.id === params.id) {
return startup;
}
return undefined;
const startup = await prisma.startup.findUnique({
where: {
id: params.id
},
include: {
metrics: true,
founders: true,
jobs: true,
latestNews: true
},
});

if (!startup) {
Expand Down
16 changes: 14 additions & 2 deletions app/e-lab/team/page.tsx
Original file line number Diff line number Diff line change
@@ -1,17 +1,29 @@
import type {Metadata} from "next";
import Section from "@ui/Section";
import Link from "next/link";
import {alumni, faq, team} from "../../../data/e-lab";
import FAQ from "@components/FAQ";
import Person from "@components/Person";
import prisma from "../../../lib/db";

export const metadata: Metadata = {
title: "Team - AI E-LAB | TUM.ai",
description:
"Meet the Team behind the AI Entrepreneurship Lab. Join us if you are up for a 3-month founding journey designed to ignite your innovative spirit and equip you with the relevant know-how to build your own AI startup in Munich.",
};

export default function Page() {
export default async function Page() {
const team = await prisma.person.findMany({
where: {
type: "elab-team"
}
});
const alumni = await prisma.person.findMany({
where: {
type: "elab-alumni"
}
});
const faq = await prisma.fAQ.findMany();

return (
<>
<h1 className="hidden">Meet the Team behind the AI E-LAB | Venture Department Members</h1>
Expand Down
Loading