Skip to content

Conversation

@rachael-peng
Copy link
Contributor

Changes Being Made

Purpose of Change: dynamic page routing for all headsets in database

  • New feature
  • Revision of current feature
  • Fixing current feature
  • Other: _______________________

Here give examples of the changes you've made in this pull request. Include an itemized list if you can.

  • When click on headset name, user is sent to page with the information on that headset (id, name, description, etc.)

Screenshots (optional)

Screen Shot 2024-05-18 at 10 13 46 PM

@@ -0,0 +1,65 @@
import { db } from '@/app/server/db/index'
Copy link
Contributor

Choose a reason for hiding this comment

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

Client side sites should start with "use client".

@@ -0,0 +1,65 @@
import { db } from '@/app/server/db/index'
import { type Headset, headsets } from '@/app/server/db/schema/headsets'
import { eq, SQLWrapper } from 'drizzle-orm'
Copy link
Contributor

Choose a reason for hiding this comment

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

Database should not be accessed directly from Client. This should make use of existing backend server routes

Copy link
Contributor

@priyanshumahey priyanshumahey left a comment

Choose a reason for hiding this comment

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

Client and Server need to be decoupled. Current code has server functions (calls to the database) present directly within the client side view. If a prior backend route exists, please use that instead. Otherwise, create a new route specifically for querying up one headset specifically. For the page please use use client to declare it for client side usage.

For further reference, use: https://nextjs.org/docs/app/building-your-application/rendering/client-components. Tldr, splitting client and server improves performance, has better user experience and is more scalable.

import { type Headset, headsets } from '@/app/server/db/schema/headsets'
import { eq, SQLWrapper } from 'drizzle-orm'

/**
Copy link
Contributor

Choose a reason for hiding this comment

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

Server side function present in client

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