mirror of
https://gitea.gofwd.group/dstrawsb/ballistic-builder.git
synced 2025-12-06 02:36:44 -05:00
fixes
This commit is contained in:
@@ -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
|
||||
|
||||
@@ -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(() => {
|
||||
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));
|
||||
getUserByUUID(uuid as string)
|
||||
.then((user) => setUser(user))
|
||||
.catch((error) => console.error("Error fetching user data:", error));
|
||||
}
|
||||
}, [uuid]);
|
||||
}, [uuid]);
|
||||
|
||||
if (!product) {
|
||||
if (!user) {
|
||||
return <div>Loading...</div>;
|
||||
}
|
||||
}
|
||||
|
||||
return (
|
||||
<div className="p-4 pt-16 mx-auto max-w-screen-lg">
|
||||
@@ -29,13 +28,13 @@ export default function UserProfilePage() {
|
||||
|
||||
{/* Product Info */}
|
||||
<div>
|
||||
<h1 className="text-3xl font-bold mb-4">{product.name}</h1>
|
||||
<h1 className="text-3xl font-bold mb-4">{user[0].first_name}</h1>
|
||||
|
||||
{/* Vendor Pricing Table */}
|
||||
<div className="bg-white rounded-lg shadow-md p-4 mb-6">
|
||||
<h2 className="text-xl font-semibold mb-4">Available From</h2>
|
||||
<div className="overflow-x-auto">
|
||||
<table className="min-w-full table-auto">
|
||||
{/* <table className="min-w-full table-auto">
|
||||
<thead>
|
||||
<tr className="bg-gray-50 border-b">
|
||||
<th className="px-4 py-2 text-left">Vendor</th>
|
||||
@@ -58,44 +57,16 @@ export default function UserProfilePage() {
|
||||
</tr>
|
||||
))}
|
||||
</tbody>
|
||||
</table>
|
||||
</table> */}
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
{/* Product Description */}
|
||||
<div className="bg-white rounded-lg shadow-md p-6 mb-8">
|
||||
<h2 className="text-xl font-semibold mb-4">Product Description</h2>
|
||||
<p className="text-gray-600">
|
||||
{product.description}
|
||||
</p>
|
||||
</div>
|
||||
|
||||
|
||||
{/* Product Specifications */}
|
||||
<div className="bg-white rounded-lg shadow-md p-6">
|
||||
<h2 className="text-xl font-semibold mb-4">Specifications</h2>
|
||||
<div className="grid grid-cols-1 md:grid-cols-2 gap-4">
|
||||
<div className="border-b py-2">
|
||||
<span className="font-medium">Manufacturer:</span> {product.specifications.manufacturer}
|
||||
</div>
|
||||
<div className="border-b py-2">
|
||||
<span className="font-medium">Model:</span> {product.specifications.model}
|
||||
</div>
|
||||
<div className="border-b py-2">
|
||||
<span className="font-medium">Weight:</span> {product.specifications.weight}
|
||||
</div>
|
||||
<div className="border-b py-2">
|
||||
<span className="font-medium">Dimensions:</span> {product.specifications.dimensions}
|
||||
</div>
|
||||
<div className="border-b py-2">
|
||||
<span className="font-medium">Material:</span> {product.specifications.material}
|
||||
</div>
|
||||
<div className="border-b py-2">
|
||||
<span className="font-medium">Warranty:</span> {product.specifications.warranty}
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user