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

111 projects page see more #142

Open
wants to merge 21 commits into
base: main
Choose a base branch
from
Open

111 projects page see more #142

wants to merge 21 commits into from

Conversation

zozzzC
Copy link
Contributor

@zozzzC zozzzC commented Oct 9, 2024

Context

We want the projects page to have a limited number of projects showing at each time, with a button that allows the client to load additional projects.

Closes #111

What Changed?

  • Add fetchPaginationStrapi which specifically fetches Strapi project pages within a specified Date range and pagination number.
  • Add See More button to projects page.
  • Made Projects component a client component.

How To Review

  • Start from the Projects component since this has the most changes, mostly using useState and useEffect to fetch data.
  • Review fetchPaginationStrapi to see how it works. Note that this had to be a seperate component and also not in the strapi.ts file because I had to make this a server function, otherwise it didn't appear to work.

Notes

  • There are a few things that could be changed for better readability, for example:
    • Explictly type the return values in fetchPaginationStrapi
    • Change the naming for said return values
    • Allow Projects component to have first or last day be null/undefined, this just helps the queries to Strapi and makes it so that the range of first and last day dates arent just the arbitrary values I added in.
  • I have tried to fix these, however, they involve using a lot of Zod schemas which I am unfamiliar with. I can work on this if need be, but for now the code provided works to specification.

@zozzzC zozzzC marked this pull request as draft October 9, 2024 02:25
@h4yleysh4rpe
Copy link
Contributor

Will have a look at this PR this weekend!

@zozzzC
Copy link
Contributor Author

zozzzC commented Oct 11, 2024

Will have a look at this PR this weekend!

Don't worry, I actually set this as a draft because I actually need to fix some things before I can make the PR!

@zozzzC zozzzC marked this pull request as ready for review October 17, 2024 04:41
@zozzzC zozzzC requested a review from jessicazeng13 October 17, 2024 04:44
@Oculux314
Copy link
Contributor

Seen! Will review tonight

Copy link
Contributor

@Oculux314 Oculux314 left a comment

Choose a reason for hiding this comment

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

Recording.2024-10-20.022415.mp4

It's SO good 😍

I've got a few bugs to report before we merge, but I'm so excited.

  • fetchPaginationStrapi typesafety
    Yeah, ik you commented on this, I think it's quite important we have type safety/zod checking for this (see a bug later down). Since pagination is only used for this particular route, you're alg to make the pagination logic specific to the projects page (but if so, name it specifically and comment to explain that to avoid confusion)
  • First load
    At the moment, it takes a split-second for the client component to load the initial set of projects from useEffect. Might be better if this was passed down from a parent client component then used as the initial state in useState? Will have with no-projects message too I bet
  • .toLocaleDateString()
    I think this bug is being caused by our code/types thinking date is a Date type but actually it's a string.
    image
    image
    You may need to use Strapi to coerce the date type into a string, just like with the regular fetchStrapi.
    image
    This goes hand-in-hand with type safety, I'm happy to jump on a call if you'd like!
  • Message if no projects
    Just a heads up if we've got no projects in Strapi it looks like this
    image
    I kinda liked the 404 page but I think we have a better fix - conditionally render the projects component or a piece of "no projects" text. Probably easier to do after the first load stuff

Amd finally just transitioning from dev to production environments - might be good to up the page size from 2 to say 8? Oh and remove console.logs hehe

@@ -0,0 +1,7 @@
export function createDate(days: number, months: number, years: number) {
Copy link
Contributor

Choose a reason for hiding this comment

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

Maybe rename to createRelativeDate or smth, tripped me up for a sec!

Copy link
Contributor

@h4yleysh4rpe h4yleysh4rpe left a comment

Choose a reason for hiding this comment

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

Yo! This looks awesome! So impressive!!
I don't know nearly as much as Nate does about all of the zod stuff and strapi stuff and all of that, so from a repo architecture POV I don't have much to add. However, I did come across this problem -
image
which happened when I loaded a page, hit back, and then went back to the page (sorry tried to get a video but apparently it's too big). Should be fairly easy to replicate though I hope!
I agree with Nate about the load times and the lack of projects as well, but all good you already got his feedback on it.
Looks suuuuper awesome though I am SO impressed!! good stuff

@zozzzC
Copy link
Contributor Author

zozzzC commented Nov 8, 2024

Yo! This looks awesome! So impressive!! I don't know nearly as much as Nate does about all of the zod stuff and strapi stuff and all of that, so from a repo architecture POV I don't have much to add. However, I did come across this problem - image which happened when I loaded a page, hit back, and then went back to the page (sorry tried to get a video but apparently it's too big). Should be fairly easy to replicate though I hope! I agree with Nate about the load times and the lack of projects as well, but all good you already got his feedback on it. Looks suuuuper awesome though I am SO impressed!! good stuff

Hiya, sorry for the month-late reply! I did try to replicate this and I also got an error, but it was a context-related error and I'm not sure how/why this happened since the code I added doesn't have anything to do with context. I will try to replicate yours since the error you attatched would have something to do with the way I structured my code though!

@zozzzC
Copy link
Contributor Author

zozzzC commented Nov 8, 2024

Yo! This looks awesome! So impressive!! I don't know nearly as much as Nate does about all of the zod stuff and strapi stuff and all of that, so from a repo architecture POV I don't have much to add. However, I did come across this problem - image which happened when I loaded a page, hit back, and then went back to the page (sorry tried to get a video but apparently it's too big). Should be fairly easy to replicate though I hope! I agree with Nate about the load times and the lack of projects as well, but all good you already got his feedback on it. Looks suuuuper awesome though I am SO impressed!! good stuff

Nevermind, I think I was able to get that error after enough fiddling around. Thanks for spotting it! I will try to fix it up (as best I can, since I'm not sure what's causing it LOL)

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.

Project Page See More
3 participants