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

teacher profile unstyled #20

Merged
merged 12 commits into from
Oct 23, 2024
Merged

Conversation

135ze
Copy link
Collaborator

@135ze 135ze commented Jul 11, 2024

Notion ticket link

Implement Unstyled Teacher Profile Page

Implementation description

  • add profile.tsx page with user info, absences, sign out
  • update Dockerfile for prisma schema
  • add endpoint to fetch user info based on email from gauth (userid and num of absences)
  • add endpoint to fetch user absences given user id
  • update .env to replace localhost with db (??) so db:5432 instead

image

Steps to test

  1. run docker
  2. ensure db is seeded (see PR Seeding script #12 and David/gcal export #19 for details)
  3. log in with google on localhost:3000
  4. go to localhost:3000/profile and validate info is correct
  5. go to console to ensure the email logged is correct (code has a fake email from the seeded db)

What should reviewers focus on?

  • Dockerfile changes
  • whether profile.tsx has React best practices

Checklist

  • My PR name is descriptive and in imperative tense
  • My commit messages are descriptive and in imperative tense. My commits are atomic and trivial commits are squashed or fixup'd into non-trivial commits
  • I have run the appropriate linter(s)
  • I have requested a review from the PL, as well as other devs who have background knowledge on this PR or who will be building on top of this PR

@135ze 135ze self-assigned this Jul 11, 2024
@135ze 135ze force-pushed the evelina/teacher-profile-unstyled branch 2 times, most recently from f1f9ee0 to a254945 Compare July 11, 2024 20:31
@ChinemeremChigbo
Copy link
Member

Please address the failing build issue and warning:
image
https://github.com/uwblueprint/sistema/actions/runs/9898109170/job/27344151094?pr=20

For the failing build I know what needs to be fixed so feel free to contact me if you need some help with that!

@ChinemeremChigbo ChinemeremChigbo force-pushed the evelina/teacher-profile-unstyled branch from 00a4962 to 1b74398 Compare July 18, 2024 22:29
@135ze 135ze force-pushed the evelina/teacher-profile-unstyled branch from 4077550 to 1b74398 Compare July 18, 2024 23:36
@135ze 135ze marked this pull request as draft July 18, 2024 23:42
@135ze 135ze force-pushed the evelina/teacher-profile-unstyled branch from bec1d1f to fd3b9cb Compare July 25, 2024 23:09
Copy link

vercel bot commented Jul 25, 2024

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
sistema ✅ Ready (Inspect) Visit Preview 💬 Add feedback Oct 23, 2024 0:03am

Copy link
Member

@ChinemeremChigbo ChinemeremChigbo left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please fix the deployment and re-request a review

@135ze
Copy link
Collaborator Author

135ze commented Oct 9, 2024

Looks good to me :p. I would just make these small changes. But the PR looks great overall and works very well locally :)

Thanks! Updated to comments

@135ze 135ze requested a review from ludavidca October 9, 2024 00:37
if (encodedAbsences) {
getAbsences = Boolean(encodedAbsences);
}
// TODO: rename realEmail to email to be used in the findUnique later
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't like having these TODOs in the code. Please make a Notion Ticket for the remaining work 🥺🙏

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think Rahul volunteered to make that Notion ticket. Please coordinate with him to ensure that it is accurate.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.


try {
// TODO: remove block once emails are set up
// fake stuff begins
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Don't love these comments. I think you should just get rid of them lol.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Removed in latest

import { PrismaClient } from '@prisma/client';
import type { NextApiRequest, NextApiResponse } from 'next';

const prisma = new PrismaClient();
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We shouldn't be remaking the PrismaClient each time. We should use the singleton pattern as documented here: https://www.prisma.io/docs/orm/more/help-and-troubleshooting/help-articles/nextjs-prisma-client-dev-practices. I mentioned this in David's PR here: https://github.com/uwblueprint/sistema/pull/19/files#r1789262220, so please have centralized Prisma access like he does in his PR.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Built on top of his branch to share the same utils/prisma here:
bdf4ec0

} else {
email = useFake ? fakeEmailReq.email : realEmail;
}
// fake stuff ends
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Don't like this comment.

});

if (!user) {
res.status(400).json({ error: 'User not found' });
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

should this be a return?

Copy link
Collaborator Author

@135ze 135ze Oct 16, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No need - existing api code doesn't use return either:

res.status(200).json({ message: 'Email sent successfully' });

if (!user) {
res.status(400).json({ error: 'User not found' });
} else {
res.status(200).json(user);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

should this be a return?

res.status(200).json(user);
}
} catch {
res.status(500).json({ error: 'Internal server error' });
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

should this be a return?

});
let email;
if (!fakeEmailReq) {
res.status(400).json({ error: 'Database is empty' });
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

should there be a return instead?

src/pages/profile.tsx Outdated Show resolved Hide resolved
src/pages/profile.tsx Show resolved Hide resolved
@135ze 135ze changed the base branch from main to david/gcal-export October 19, 2024 22:04
Copy link
Member

@ChinemeremChigbo ChinemeremChigbo left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A few minor changes I would appreciate if you made. Otherwise LGTM.

src/pages/profile.tsx Outdated Show resolved Hide resolved
@135ze 135ze merged commit a81f4e1 into david/gcal-export Oct 23, 2024
2 checks passed
135ze added a commit that referenced this pull request Oct 23, 2024
135ze added a commit that referenced this pull request Oct 23, 2024
ludavidca added a commit that referenced this pull request Nov 20, 2024
* Add Prisma and create Prisma models

* Add MailingList table

* Add seeding script commmand

* Add seeding script

* Add seeding script command in package.json

* Fix code formatting with prettier

* Fix prettier issues

* First Commit

* Added preliminary files

* Fixed Querying Prisma issue via troubleshooting docker

* Implemented ICS hosting Feature

* Tidied up code, ran lint and prettier

* Created ICS Branch.

Squashing :)

* Added necessary files

* Remove uneeded changes

* Remove uneeded changes

* Remove uneeded changes

* Update schema.prisma

* Remove unused variables

* Move seed.config.ts back

* Added ics

* Fixed Docker issues

* Testing commit

* Testing commit

* Testing commit

* Testing commit

* Fixed map issues

* Fixed map issues

* Testing

* Testing

* fixed lock file

* Update src/pages/ics.tsx

Co-authored-by: Chinemerem <[email protected]>

* Commited some changes

* Update app/api/getAbsences/route.ts

Co-authored-by: Chinemerem <[email protected]>

* Update app/api/getAbsences/route.ts

Co-authored-by: Chinemerem <[email protected]>

* test

* Made changes based on CEO's instructions

* fixed merge issues

* Made Changes based on CEO's guidance

* teacher profile unstyled (#20)

* add unstyled teacher profile page with gauth info and x/10 absences

---------

Co-authored-by: Rahul Tandon <[email protected]>
Co-authored-by: David Lu <[email protected]>
Co-authored-by: Chinemerem <[email protected]>

* Revert "teacher profile unstyled (#20)" (#37)

This reverts commit a81f4e1. sorry

* Update utils/prisma.ts

Co-authored-by: Chinemerem <[email protected]>

* Update src/pages/ics.tsx

Co-authored-by: Chinemerem <[email protected]>

* Update app/api/getAbsences/route.ts

Co-authored-by: Chinemerem <[email protected]>

* Revert Original Files

* Fix ICS as per Chinemerem's request

* Yeehaw

* Update app/api/getAbsences/route.ts

Co-authored-by: Chinemerem <[email protected]>

* Update app/api/getAbsences/route.ts

Co-authored-by: Chinemerem <[email protected]>

* Update app/api/getAbsences/route.ts

Co-authored-by: Chinemerem <[email protected]>

---------

Co-authored-by: Kelly Pham <[email protected]>
Co-authored-by: Vihaan Jagiasi <[email protected]>
Co-authored-by: evelina <[email protected]>
Co-authored-by: Chinemerem <[email protected]>
Co-authored-by: evelina zheng <[email protected]>
Co-authored-by: Rahul Tandon <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants