diff --git a/src/actions/userActions.ts b/src/actions/userActions.ts index d504a20..188c284 100644 --- a/src/actions/userActions.ts +++ b/src/actions/userActions.ts @@ -14,6 +14,11 @@ export const getUserByEmail = async (email:string) => { return data; }; +export const getUserByUUID = async (uuid:string) => { + const data = await db.select().from(users).where(eq(users.uuid, uuid)); + return data; +}; + export const addUser = async ( first_name: string, last_name: string, username: string, email: string, password_hash : string) => { await db.insert(users).values({ first_name : first_name, last_name: last_name, username: email, email: email, password_hash : password_hash diff --git a/src/app/userProfile/[uuid].tsx b/src/app/userProfile/[uuid].tsx index 5100318..30fd6f2 100644 --- a/src/app/userProfile/[uuid].tsx +++ b/src/app/userProfile/[uuid].tsx @@ -1,27 +1,26 @@ +import { getUserByUUID } from "@src/actions/userActions"; import { NextPage } from "next"; import { Herr_Von_Muellerhoff } from "next/font/google"; import { useRouter } from "next/router"; import { useEffect, useState } from "react"; - +import {db} from "@db/index"; export default function UserProfilePage() { const router = useRouter(); const { uuid } = router.query; +const [user, setUser] = useState<{ uuid: string | null; id: string; username: string; email: string; emailVerifiedOn: Date | null; password_hash: string; first_name: string | null; last_name: string | null; full_name: string | null; buildPrivacySetting: string | null; }[] | null>(null); - - useEffect(() => { - if (uuid) { - // Fetch product data based on the id - fetch(`/api/products/${id}`) - .then((response) => response.json()) - - .catch((error) => console.error("Error fetching product data:", error)); - } - }, [uuid]); - - if (!product) { - return
Loading...
; +useEffect(() => { + if (uuid) { + getUserByUUID(uuid as string) + .then((user) => setUser(user)) + .catch((error) => console.error("Error fetching user data:", error)); } +}, [uuid]); + +if (!user) { + return
Loading...
; +} return (
@@ -29,13 +28,13 @@ export default function UserProfilePage() { {/* Product Info */}
-

{product.name}

+

{user[0].first_name}

{/* Vendor Pricing Table */}

Available From

- + {/*
@@ -58,44 +57,16 @@ export default function UserProfilePage() { ))} -
Vendor
+ */}
- {/* Product Description */} -
-

Product Description

-

- {product.description} -

-
+ {/* Product Specifications */} -
-

Specifications

-
-
- Manufacturer: {product.specifications.manufacturer} -
-
- Model: {product.specifications.model} -
-
- Weight: {product.specifications.weight} -
-
- Dimensions: {product.specifications.dimensions} -
-
- Material: {product.specifications.material} -
-
- Warranty: {product.specifications.warranty} -
-
-
+ ); }