Skip to content

Commit

Permalink
Checkpoint
Browse files Browse the repository at this point in the history
  • Loading branch information
cammoore committed Oct 5, 2024
1 parent 250a613 commit e1abd65
Show file tree
Hide file tree
Showing 39 changed files with 1,037 additions and 451 deletions.
4 changes: 1 addition & 3 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,3 +1 @@
[![ci-nextjs-application-template](https://github.com/ics-software-engineering/nextjs-application-template/actions/workflows/ci.yml/badge.svg)](https://github.com/ics-software-engineering/nextjs-application-template/actions/workflows/ci.yml)

For details, please see http://ics-software-engineering.github.io/nextjs-application-template/.
# bowfolios-nextjs
21 changes: 0 additions & 21 deletions src/app/add/page.tsx

This file was deleted.

27 changes: 27 additions & 0 deletions src/app/addProject/page.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
/* eslint-disable import/extensions */
import { Container } from 'react-bootstrap';
import { getServerSession } from 'next-auth';
import { prisma } from '@/lib/prisma';
import AddProjectForm from '@/components/AddProjectForm';
import { loggedInProtectedPage } from '@/lib/page-protection';
import { authOptions } from '../api/auth/[...nextauth]/route';

const AddProjectPage = async () => {
const session = await getServerSession(authOptions);
loggedInProtectedPage(
session as {
user: { email: string; id: string; randomKey: string };
} | null
);
const interests = await prisma.interest.findMany();
const participants = await prisma.user.findMany();

return (
<Container>
<h1 className="text-center">Add Project</h1>
<AddProjectForm interests={interests} participants={participants} />
</Container>
);
};

export default AddProjectPage;
68 changes: 0 additions & 68 deletions src/app/admin/page.tsx

This file was deleted.

33 changes: 0 additions & 33 deletions src/app/edit/[id]/page.tsx

This file was deleted.

33 changes: 33 additions & 0 deletions src/app/filter/page.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
/* eslint-disable import/extensions */
import { getServerSession } from 'next-auth';
import { Container } from 'react-bootstrap';
import { prisma } from '@/lib/prisma';
import FilterProfileForm from '@/components/FilterProfileForm';
import { loggedInProtectedPage } from '@/lib/page-protection';
import { authOptions } from '../api/auth/[...nextauth]/route';

const FilterPage = async () => {
const session = await getServerSession(authOptions);
loggedInProtectedPage(
session as {
user: { email: string; id: string; randomKey: string };
} | null
);
const allInterests = await prisma.interest.findMany();
const allProfiles = await prisma.profile.findMany();
const allProfileInterests = await prisma.profileInterest.findMany();
const allProjects = await prisma.project.findMany();
const allProfileProjects = await prisma.profileProject.findMany();
return (
<Container>
<FilterProfileForm
interests={allInterests}
profiles={allProfiles}
profileInterests={allProfileInterests}
profileProjects={allProfileProjects}
projects={allProjects}
/>
</Container>
);
};
export default FilterPage;
18 changes: 18 additions & 0 deletions src/app/home/HomePage.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
'use client';

import React from 'react';
import { Container, Col } from 'react-bootstrap';
import { PageIDs } from '../../utilities/ids';
import pageStyle from '../../utilities/pageStyle';

const HomePage = () => (
<Container id={PageIDs.homePage} className="justify-content-center" style={pageStyle}>
<Col>
<Col className="justify-content-center text-center">
<h2>Your Profile</h2>
</Col>
</Col>
</Container>
);

export default HomePage;
51 changes: 51 additions & 0 deletions src/app/home/page.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
/* eslint-disable import/extensions */
import React from 'react';
import { getServerSession } from 'next-auth';
import { prisma } from '@/lib/prisma';
import { loggedInProtectedPage } from '@/lib/page-protection';
import { authOptions } from '../api/auth/[...nextauth]/route';
import HomePage from './HomePage';

const HomePageHelper = async () => {
const session = await getServerSession(authOptions);
// console.log(session);
loggedInProtectedPage(
session as {
user: { email: string; id: string; randomKey: string };
} | null
);
const email = (session && session.user && session.user.email) || '';
const profile = await prisma.profile.findUnique({
where: { email },
});
const interests = await prisma.interest.findMany();
// const allInterestNames = interests.map((interest) => interest.name);
const projects = await prisma.project.findMany();
// const allProjectNames = projects.map((project) => project.name);
const profileInterests = await prisma.profileInterest.findMany({
where: { profileId: profile!.id },
});
const profileInterestNames = profileInterests.map((profileInterest) => {
const i = interests.find((interest) => interest.id === profileInterest.interestId);
return i ? i.name : '';
});
console.log(profileInterestNames);
const profileProjects = await prisma.profileProject.findMany({
where: { profileId: profile!.id },
});
const profileProjectNames = profileProjects.map((profileProject) => {
const p = projects.find((project) => project.id === profileProject.projectId);
return p ? p.name : '';
});
console.log(
// interests,
// projects,
// profileInterests,
// profileProjects,
profileInterestNames,
profileProjectNames
);
return <HomePage />;
};

export default HomePageHelper;
35 changes: 35 additions & 0 deletions src/app/interests/InterestCard.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
'use client';

import { Card } from 'react-bootstrap';
// eslint-disable-next-line import/extensions
import TooltipImage from '@/components/TooltipImage';
import { InterestCardData } from './InterestCardData';

const InterestCard = ({ interest }: { interest: InterestCardData }) => (
<Card>
<Card.Body>
<Card.Title style={{ marginTop: '0px' }}>{interest.name}</Card.Title>
{interest.profilePictures.map((p) => (
<TooltipImage
className="mx-1"
key={`profile-${p!.name}`}
src={p?.picture ? p.picture : ''}
name={p!.name}
width={50}
roundedCircle
/>
))}
{interest.projectPictures.map((p) => (
<TooltipImage
className={undefined}
key={`project-${p!.name}`}
src={p?.picture ? p.picture : ''}
name={p!.name}
width={50}
roundedCircle
/>
))}
</Card.Body>
</Card>
);
export default InterestCard;
10 changes: 10 additions & 0 deletions src/app/interests/InterestCardData.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
export type PictureInfo = {
name: string;
picture: string | null;
};

export type InterestCardData = {
name: string;
profilePictures: (PictureInfo | null)[];
projectPictures: (PictureInfo | null)[];
};
34 changes: 34 additions & 0 deletions src/app/interests/InterestCardHelper.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
import { Interest } from '@prisma/client';
// eslint-disable-next-line import/extensions
import { prisma } from '@/lib/prisma';
import InterestCard from './InterestCard';

const InterestCardHelper = async ({ interest }: { interest: Interest }) => {
const profileInterests = await prisma.profileInterest.findMany({
where: { interestId: interest.id },
});
// console.log('profileInterests: ', profileInterests);
const profiles = await prisma.profile.findMany({
where: { id: { in: profileInterests.map((profileInterest) => profileInterest.profileId) } },
});
// console.log('profiles: ', profiles);
const profileImages = profiles.map((profile) => ({ name: profile.email, picture: profile.picture }));
// console.log('profileImages: ', profileImages);
const projectInterests = await prisma.projectInterest.findMany({
where: { interestId: interest.id },
});
const projects = await prisma.project.findMany({
where: { id: { in: projectInterests.map((projectInterest) => projectInterest.projectId) } },
});
// console.log('projects: ', projects);
const projectImages = projects.map((project) => ({ name: project.name, picture: project.picture }));
// console.log('projectImages: ', projectImages);
const interestData = {
name: interest.name,
profilePictures: profileImages,
projectPictures: projectImages,
};
return <InterestCard interest={interestData} />;
};

export default InterestCardHelper;
20 changes: 20 additions & 0 deletions src/app/interests/page.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
import { prisma } from '@/lib/prisma';
import { Container, Row } from 'react-bootstrap';
import { PageIDs } from '@/utilities/ids';
import { pageStyle } from '@/utilities/pageStyle';
import InterestCardHelper from './InterestCardHelper';

const InterestsPage = async () => {
const interests = await prisma.interest.findMany();
interests.sort((a, b) => a.name.localeCompare(b.name));
console.log(interests);
return (
<Container id={PageIDs.interestsPage} style={pageStyle}>
<Row xs={1} md={2} lg={4} className="g-2">
{interests.map((interest) => (<InterestCardHelper key={interest.id} interest={interest} />))}
</Row>
</Container>
);
};

export default InterestsPage;
2 changes: 1 addition & 1 deletion src/app/layout.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import Providers from './providers';
const inter = Inter({ subsets: ['latin'] });

export const metadata: Metadata = {
title: 'Next.js Application Template',
title: 'Bowfolios',
description: 'Generated by ics-software-engineering.github.io',
};

Expand Down
12 changes: 12 additions & 0 deletions src/app/lib/ProfileCardData.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
import { Project } from '@prisma/client';

export type ProfileCardData = {
email: string;
bio: string | null;
firstName: string | null;
lastName: string | null;
picture: string | null;
title: string | null;
projects: Project[];
interests: string[];
};
10 changes: 10 additions & 0 deletions src/app/lib/ProjectCardData.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
import { Profile } from '@prisma/client';

export type ProjectCardData = {
name: string;
homepage: string | null;
picture: string | null;
description: string | null;
interests: string[];
participants: Profile[];
};
Loading

0 comments on commit e1abd65

Please sign in to comment.