Skip to content

Commit

Permalink
upgrade
Browse files Browse the repository at this point in the history
  • Loading branch information
Nathan-Roberts123 committed May 24, 2024
1 parent 98b7b49 commit 3ec9c5d
Show file tree
Hide file tree
Showing 35 changed files with 1,633 additions and 245 deletions.
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -36,3 +36,5 @@ yarn-error.log*
# typescript
*.tsbuildinfo
next-env.d.ts

public/uploads
11 changes: 10 additions & 1 deletion next.config.mjs
Original file line number Diff line number Diff line change
@@ -1,11 +1,20 @@
import { fileURLToPath } from "node:url";
import createJiti from "jiti";

const jiti = createJiti(fileURLToPath(import.meta.url));

// Import env here to validate during build. Using jiti we can import .ts files :)
jiti("./src/env.ts");

/** @type {import('next').NextConfig} */
const nextConfig = {};
const nextConfig = {
images: {
remotePatterns: [
{
hostname: "online-store-dev-bkt.s3.us-east-1.amazonaws.com",
},
],
},
};

export default nextConfig;
722 changes: 719 additions & 3 deletions package-lock.json

Large diffs are not rendered by default.

11 changes: 10 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,13 @@
},
"dependencies": {
"@auth/prisma-adapter": "^2.1.0",
"@aws-sdk/client-s3": "^3.577.0",
"@aws-sdk/client-ses": "^3.577.0",
"@aws-sdk/s3-request-presigner": "^3.582.0",
"@emotion/cache": "^11.11.0",
"@emotion/react": "^11.11.4",
"@emotion/styled": "^11.11.5",
"@hookform/resolvers": "^3.4.2",
"@mui/material": "^5.15.18",
"@mui/material-nextjs": "^5.15.11",
"@prisma/client": "^5.14.0",
Expand All @@ -30,21 +33,27 @@
"@trpc/next": "^11.0.0-rc.373",
"@trpc/react-query": "^11.0.0-rc.373",
"@trpc/server": "^11.0.0-rc.373",
"bcryptjs": "^2.4.3",
"clsx": "^2.1.1",
"next": "14.2.3",
"next-auth": "^4.24.7",
"postcss-import": "^16.1.0",
"react": "^18",
"react-dom": "^18",
"react-hook-form": "^7.51.5",
"react-icons": "^5.2.1",
"stripe": "^15.7.0",
"tailwind-merge": "^2.3.0",
"zod": "^3.23.8"
"uuid": "^9.0.1",
"zod": "^3.23.8",
"zod-form-data": "^2.0.2"
},
"devDependencies": {
"@types/bcryptjs": "^2.4.6",
"@types/node": "^20",
"@types/react": "^18",
"@types/react-dom": "^18",
"@types/uuid": "^9.0.8",
"eslint": "^8",
"eslint-config-next": "14.2.3",
"postcss": "^8",
Expand Down
38 changes: 38 additions & 0 deletions prisma/migrations/20240522220953_added_to_product/migration.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
/*
Warnings:
- You are about to drop the column `cartId` on the `Product` table. All the data in the column will be lost.
- Added the required column `quantity` to the `Product` table without a default value. This is not possible if the table is not empty.
- Added the required column `status` to the `Product` table without a default value. This is not possible if the table is not empty.
- Added the required column `suk` to the `Product` table without a default value. This is not possible if the table is not empty.
*/
-- CreateEnum
CREATE TYPE "Status" AS ENUM ('Active', 'InActive');

-- DropForeignKey
ALTER TABLE "Product" DROP CONSTRAINT "Product_cartId_fkey";

-- AlterTable
ALTER TABLE "Product" DROP COLUMN "cartId",
ADD COLUMN "quantity" INTEGER NOT NULL,
ADD COLUMN "status" "Status" NOT NULL,
ADD COLUMN "suk" TEXT NOT NULL;

-- CreateTable
CREATE TABLE "_CartToProduct" (
"A" TEXT NOT NULL,
"B" TEXT NOT NULL
);

-- CreateIndex
CREATE UNIQUE INDEX "_CartToProduct_AB_unique" ON "_CartToProduct"("A", "B");

-- CreateIndex
CREATE INDEX "_CartToProduct_B_index" ON "_CartToProduct"("B");

-- AddForeignKey
ALTER TABLE "_CartToProduct" ADD CONSTRAINT "_CartToProduct_A_fkey" FOREIGN KEY ("A") REFERENCES "Cart"("id") ON DELETE CASCADE ON UPDATE CASCADE;

-- AddForeignKey
ALTER TABLE "_CartToProduct" ADD CONSTRAINT "_CartToProduct_B_fkey" FOREIGN KEY ("B") REFERENCES "Product"("id") ON DELETE CASCADE ON UPDATE CASCADE;
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
-- AlterTable
ALTER TABLE "Product" ALTER COLUMN "price" SET DATA TYPE DOUBLE PRECISION;
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
-- AlterTable
ALTER TABLE "User" ADD COLUMN "password" TEXT;
22 changes: 15 additions & 7 deletions prisma/schema.prisma
Original file line number Diff line number Diff line change
Expand Up @@ -20,14 +20,15 @@ model User {
email String @unique
emailVerified DateTime?
image String?
password String?
accounts Account[]
sessions Session[]
// Optional for WebAuthn support
Authenticator Authenticator[]
createdAt DateTime @default(now())
updatedAt DateTime @updatedAt
Cart Cart?
Cart Cart[]
}

model Account {
Expand Down Expand Up @@ -85,13 +86,20 @@ model Authenticator {
@@id([userId, credentialID])
}

enum Status {
Active
InActive
}

model Product {
id String @id @default(cuid())
name String
price Int
image String
Cart Cart? @relation(fields: [cartId], references: [id])
cartId String?
id String @id @default(cuid())
name String
price Float
image String
status Status
suk String
quantity Int
Cart Cart[]
}

model Cart {
Expand Down
Binary file added public/sign-bg-image.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 2 additions & 0 deletions src/app/admin/layout.tsx
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
"use client";

import OrdersIcon from "@/components/icons/orders";
import ProductIcon from "@/components/icons/product";
import React from "react";
Expand Down
87 changes: 16 additions & 71 deletions src/app/admin/product/components/product-table.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,18 @@
import Image from "next/image";
"use client";
import { trpc } from "@/utils/trpc";
import TableBottom from "./table-bottom";

const ProductTable = () => {
const products = trpc.product.getProducts.useQuery();

if (!products.data) {
return <h2>Loading</h2>;
}

if (!products.data.length) {
return <h2>No Products</h2>;
}

return (
<table className="w-full text-base text-left text-gray-500">
<thead className="bg-white">
Expand Down Expand Up @@ -44,76 +56,9 @@ const ProductTable = () => {
</tr>
</thead>
<tbody>
<tr className="bg-white border-b border-gray6 last:border-0 text-start mx-9">
<td className="pr-8 py-5 whitespace-nowrap">
<a href="#" className="flex items-center space-x-5">
<Image
className="w-[60px] h-[60px] rounded-md"
width={60}
height={60}
src="assets/img/product/prodcut-1.jpg"
alt=""
/>
<span className="font-medium text-heading text-hover-primary transition">
Whitetails Women&apos;s Open Sky
</span>
</a>
</td>
<td className="px-3 py-3 font-normal text-[#55585B] text-end">
#479063DR
</td>
<td className="px-3 py-3 font-normal text-[#55585B] text-end">37</td>
<td className="px-3 py-3 font-normal text-[#55585B] text-end">
$171.00
</td>
<td className="px-3 py-3 text-end">
<span className="text-[11px] text-success px-3 py-1 rounded-md leading-none bg-success/10 font-medium text-end">
Active
</span>
</td>
<td className="px-9 py-3 text-end">
<div className="flex items-center justify-end space-x-2">
<button className="leading-10 text-tiny bg-success text-white rounded-md hover:bg-green-600 flex justify-center items-center w-10 h-10">
<svg
className="-translate-y-px"
height="12"
viewBox="0 0 492.49284 492"
width="12"
xmlns="http://www.w3.org/2000/svg"
>
<path
fill="currentColor"
d="m304.140625 82.472656-270.976563 270.996094c-1.363281 1.367188-2.347656 3.09375-2.816406 4.949219l-30.035156 120.554687c-.898438 3.628906.167969 7.488282 2.816406 10.136719 2.003906 2.003906 4.734375 3.113281 7.527344 3.113281.855469 0 1.730469-.105468 2.582031-.320312l120.554688-30.039063c1.878906-.46875 3.585937-1.449219 4.949219-2.8125l271-270.976562zm0 0"
/>
<path
fill="currentColor"
d="m476.875 45.523438-30.164062-30.164063c-20.160157-20.160156-55.296876-20.140625-75.433594 0l-36.949219 36.949219 105.597656 105.597656 36.949219-36.949219c10.070312-10.066406 15.617188-23.464843 15.617188-37.714843s-5.546876-27.648438-15.617188-37.71875zm0 0"
/>
</svg>
</button>

<button className="w-10 h-10 flex justify-center items-center leading-[33px] text-tiny bg-white border border-gray text-slate-600 rounded-md hover:bg-danger hover:border-danger hover:text-white">
<svg
className="-translate-y-px"
width="14"
height="14"
viewBox="0 0 20 22"
fill="none"
xmlns="http://www.w3.org/2000/svg"
>
<path
d="M19.0697 4.23C17.4597 4.07 15.8497 3.95 14.2297 3.86V3.85L14.0097 2.55C13.8597 1.63 13.6397 0.25 11.2997 0.25H8.67967C6.34967 0.25 6.12967 1.57 5.96967 2.54L5.75967 3.82C4.82967 3.88 3.89967 3.94 2.96967 4.03L0.929669 4.23C0.509669 4.27 0.209669 4.64 0.249669 5.05C0.289669 5.46 0.649669 5.76 1.06967 5.72L3.10967 5.52C8.34967 5 13.6297 5.2 18.9297 5.73C18.9597 5.73 18.9797 5.73 19.0097 5.73C19.3897 5.73 19.7197 5.44 19.7597 5.05C19.7897 4.64 19.4897 4.27 19.0697 4.23Z"
fill="currentColor"
/>
<path
d="M17.2297 7.14C16.9897 6.89 16.6597 6.75 16.3197 6.75H3.67975C3.33975 6.75 2.99975 6.89 2.76975 7.14C2.53975 7.39 2.40975 7.73 2.42975 8.08L3.04975 18.34C3.15975 19.86 3.29975 21.76 6.78975 21.76H13.2097C16.6997 21.76 16.8398 19.87 16.9497 18.34L17.5697 8.09C17.5897 7.73 17.4597 7.39 17.2297 7.14ZM11.6597 16.75H8.32975C7.91975 16.75 7.57975 16.41 7.57975 16C7.57975 15.59 7.91975 15.25 8.32975 15.25H11.6597C12.0697 15.25 12.4097 15.59 12.4097 16C12.4097 16.41 12.0697 16.75 11.6597 16.75ZM12.4997 12.75H7.49975C7.08975 12.75 6.74975 12.41 6.74975 12C6.74975 11.59 7.08975 11.25 7.49975 11.25H12.4997C12.9097 11.25 13.2497 11.59 13.2497 12C13.2497 12.41 12.9097 12.75 12.4997 12.75Z"
fill="currentColor"
/>
</svg>
</button>
</div>
</td>
</tr>
{products.data.map((product) => {
return <TableBottom key={product.id} product={product} />;
})}
</tbody>
</table>
);
Expand Down
87 changes: 87 additions & 0 deletions src/app/admin/product/components/table-bottom.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,87 @@
import React from "react";
import Image from "next/image";
import { TProduct } from "@/type";

interface TableBottomProps {
product: TProduct;
}

const TableBottom = (props: TableBottomProps) => {
const { product } = props;
return (
<tr className="bg-white border-b border-gray6 last:border-0 text-start mx-9">
<td className="pr-8 py-5 whitespace-nowrap">
<a href="#" className="flex items-center space-x-5">
<Image
className="w-[60px] h-[60px] rounded-md"
width={60}
height={60}
src={product.image}
alt=""
/>
<span className="font-medium text-heading text-hover-primary transition">
{product.name}
</span>
</a>
</td>
<td className="px-3 py-3 font-normal text-[#55585B] text-end">
{product.suk}
</td>
<td className="px-3 py-3 font-normal text-[#55585B] text-end">
{product.quantity}
</td>
<td className="px-3 py-3 font-normal text-[#55585B] text-end">
${product.price}
</td>
<td className="px-3 py-3 text-end">
<span className="text-[11px] text-success px-3 py-1 rounded-md leading-none bg-success/10 font-medium text-end">
{product.status}
</span>
</td>
<td className="px-9 py-3 text-end">
<div className="flex items-center justify-end space-x-2">
<button className="leading-10 text-tiny bg-success text-white rounded-md hover:bg-green-600 flex justify-center items-center w-10 h-10">
<svg
className="-translate-y-px"
height="12"
viewBox="0 0 492.49284 492"
width="12"
xmlns="http://www.w3.org/2000/svg"
>
<path
fill="currentColor"
d="m304.140625 82.472656-270.976563 270.996094c-1.363281 1.367188-2.347656 3.09375-2.816406 4.949219l-30.035156 120.554687c-.898438 3.628906.167969 7.488282 2.816406 10.136719 2.003906 2.003906 4.734375 3.113281 7.527344 3.113281.855469 0 1.730469-.105468 2.582031-.320312l120.554688-30.039063c1.878906-.46875 3.585937-1.449219 4.949219-2.8125l271-270.976562zm0 0"
/>
<path
fill="currentColor"
d="m476.875 45.523438-30.164062-30.164063c-20.160157-20.160156-55.296876-20.140625-75.433594 0l-36.949219 36.949219 105.597656 105.597656 36.949219-36.949219c10.070312-10.066406 15.617188-23.464843 15.617188-37.714843s-5.546876-27.648438-15.617188-37.71875zm0 0"
/>
</svg>
</button>

<button className="w-10 h-10 flex justify-center items-center leading-[33px] text-tiny bg-white border border-gray text-slate-600 rounded-md hover:bg-danger hover:border-danger hover:text-white">
<svg
className="-translate-y-px"
width="14"
height="14"
viewBox="0 0 20 22"
fill="none"
xmlns="http://www.w3.org/2000/svg"
>
<path
d="M19.0697 4.23C17.4597 4.07 15.8497 3.95 14.2297 3.86V3.85L14.0097 2.55C13.8597 1.63 13.6397 0.25 11.2997 0.25H8.67967C6.34967 0.25 6.12967 1.57 5.96967 2.54L5.75967 3.82C4.82967 3.88 3.89967 3.94 2.96967 4.03L0.929669 4.23C0.509669 4.27 0.209669 4.64 0.249669 5.05C0.289669 5.46 0.649669 5.76 1.06967 5.72L3.10967 5.52C8.34967 5 13.6297 5.2 18.9297 5.73C18.9597 5.73 18.9797 5.73 19.0097 5.73C19.3897 5.73 19.7197 5.44 19.7597 5.05C19.7897 4.64 19.4897 4.27 19.0697 4.23Z"
fill="currentColor"
/>
<path
d="M17.2297 7.14C16.9897 6.89 16.6597 6.75 16.3197 6.75H3.67975C3.33975 6.75 2.99975 6.89 2.76975 7.14C2.53975 7.39 2.40975 7.73 2.42975 8.08L3.04975 18.34C3.15975 19.86 3.29975 21.76 6.78975 21.76H13.2097C16.6997 21.76 16.8398 19.87 16.9497 18.34L17.5697 8.09C17.5897 7.73 17.4597 7.39 17.2297 7.14ZM11.6597 16.75H8.32975C7.91975 16.75 7.57975 16.41 7.57975 16C7.57975 15.59 7.91975 15.25 8.32975 15.25H11.6597C12.0697 15.25 12.4097 15.59 12.4097 16C12.4097 16.41 12.0697 16.75 11.6597 16.75ZM12.4997 12.75H7.49975C7.08975 12.75 6.74975 12.41 6.74975 12C6.74975 11.59 7.08975 11.25 7.49975 11.25H12.4997C12.9097 11.25 13.2497 11.59 13.2497 12C13.2497 12.41 12.9097 12.75 12.4997 12.75Z"
fill="currentColor"
/>
</svg>
</button>
</div>
</td>
</tr>
);
};

export default TableBottom;
File renamed without changes.
Loading

0 comments on commit 3ec9c5d

Please sign in to comment.