-
Notifications
You must be signed in to change notification settings - Fork 1
Rachael peng/neu 48 individual page for each headset #18
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
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -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' | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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 |
||
|
|
||
| /** | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Server side function present in client |
||
| * @param params.headsetName | ||
| * @returns {Promise<Headset[]>} | ||
| * @description Gets desired headset info from the database | ||
| */ | ||
| async function getHeadsetInfo( params: { headsetName: string } ): Promise<Headset[]> { | ||
| const headset: Headset[] = await db | ||
| .select() | ||
| .from(headsets) | ||
| .where(eq(headsets.name, params.headsetName)) | ||
| .execute() | ||
| return headset; | ||
| } | ||
|
|
||
| /** | ||
| * @description display the headset info | ||
| * @returns null | ||
| */ | ||
| export default async function HeadsetDetails( { params }: { | ||
| params: {headsetName: string} | ||
| } ) { | ||
| const headsetInfo = await getHeadsetInfo(params); | ||
|
|
||
| return ( | ||
| <> | ||
| <h1>Details about {params.headsetName} headset:</h1> | ||
| <table> | ||
| <thead> | ||
| <tr> | ||
| <th>ID</th> | ||
| <th>Name</th> | ||
| <th>Description</th> | ||
| <th>Price ($)</th> | ||
| <th>Channel Number</th> | ||
| <th>Channel List</th> | ||
| <th>Purpose</th> | ||
| <th>Portability</th> | ||
| <th>Company</th> | ||
| <th>Battery Life</th> | ||
| </tr> | ||
| </thead> | ||
| <tbody> | ||
| {headsetInfo.map(item => ( | ||
| <tr key={item.id}> | ||
| <td>{item.id}</td> | ||
| <td>{item.name}</td> | ||
| <td>{item.description}</td> | ||
| <td>{item.price}</td> | ||
| <td>{item.channelNumber}</td> | ||
| <td>{item.channelList}</td> | ||
| <td>{item.purpose}</td> | ||
| <td>{item.portability}</td> | ||
| <td>{item.company}</td> | ||
| <td>{item.batteryLife}</td> | ||
| </tr> | ||
| ))} | ||
| </tbody> | ||
| </table> | ||
| </> | ||
| ); | ||
| } | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -6,4 +6,4 @@ export default { | |
| dbCredentials: { | ||
| url: './main.db' | ||
| } | ||
| } satisfies Config | ||
| } satisfies Config | ||
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
There was a problem hiding this comment.
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".