Skip to content

Conversation

lawrencelu5
Copy link

@lawrencelu5 lawrencelu5 commented Mar 5, 2025

This pull request includes several changes to allow pages to fetch data through server actions. The key changes involves refactoring numerous pages into separate async components that handles server-side logic, allowing the application to support dynamic server-side data.

Server Action Integration:

  • Each page now call server actions from an async component that follows a [Category]Data.tsx naming format; the component themselves are wrapped by CategoryPost.tsx, which renders a fallback component while fetching data to enhance user experience.
    • Each component uses an optional lang of type "en" | "tr", to indicate whether the page should render in EN or TR. Only hardcoded labels, such as Comments, will be affected by this parameter; the data fetched will not take lang into consideration.
    • The local JSON files have been commented out, but not removed, in the event that local data is required for testing pages.
    • The page renders potential errors gracefully with the new component ErrorHeader.tsx and error.tsx when they occur from network issues, invalid requests, or if no results were found.
      chrome_2025-03-05_05-43-42
      chrome_2025-03-05_05-46-25

Code Readability Improvements:

  • Pages are now grouped by their language categories (category)/(en) and (category)/(tr) for easier readability, with the help of NextJS's documentation on Route Groups. These changes will not affect URL pathing.
  • Grouped pages now include a separate layout for their language categories. This is introduced as a workaround regarding incorrect translation for the Back to Home link due to refactored components, when users are browsing in either EN or TR languages.
  • Some code has been extracted into reusable components that accept a text parameter of type String to maintain readability, while cleaning up repeated sections:

Minor Schema Fix:

  • club.model.ts: The memberSize property has been changed from number to string to correctly parse its expected type "low" | "mid" | "high"
  • [category].model.ts: The default exports have been tweaked to resolve an issue, where Mongoose throws out OverwriteModelError: Cannot overwrite 'Model' model once compiled. when a schema is already defined.

This closes issue #14

refactor!: move categories to en and tr folders

feat!: added in daisy ui plugin via tailwind.config.ts
initial commit testing for fetching mongodb data via server actions
…ble components

refactor!: reactor numerous static pages to their own components, including some UI

feat!: added server actions in the individual data components to fetch data from mongodb; wrapped components in a suspense when loading data
fix: adjusts memberSize in Club model to accept String instead of number
Copy link

vercel bot commented Mar 5, 2025

@lawrencelu5 is attempting to deploy a commit to the atasoya's projects Team on Vercel.

A member of the Team first needs to authorize it.

@atasoya
Copy link
Owner

atasoya commented Mar 5, 2025

Good work!
I am reviewing it :))

@atasoya atasoya self-requested a review March 5, 2025 19:55
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.

2 participants