Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
20 commits
Select commit Hold shift + click to select a range
d8699c5
feat: add product variants and update cart functionality to support s…
Jeffcar1993 Aug 20, 2025
d86c6c9
Improve variant handling for sizes M and L in both frontend and backend
Aug 20, 2025
e80ed14
refactor: add functions to add variants for category polos
Jeffcar1993 Aug 22, 2025
88f5c16
Merge pull request #253 from codeableorg/branch-grupo2
Kellyarias02 Aug 22, 2025
2c65377
Refactor: Add functions to stickers category and add information to c…
Jeffcar1993 Aug 26, 2025
8cf348c
Merge pull request #258 from codeableorg/branch-Jeff2
Kellyarias02 Aug 26, 2025
55c360b
Merge branch 'avance-Jeff' into avance-Kelly'
Aug 26, 2025
58ee447
Fix type errors and price display in cart/checkout
Aug 26, 2025
0defd8e
Merge pull request #259 from codeableorg/avance-Kelly
Jeffcar1993 Aug 26, 2025
fc592f4
Refactor: To add information about as availability variables on grid …
Jeffcar1993 Aug 27, 2025
885eba2
Merge pull request #260 from codeableorg/branch-Jeff3
Kellyarias02 Aug 27, 2025
b09d189
Refactor: to add interactivity hover category stickers and to improve…
Aug 28, 2025
f80a5e8
Merge pull request #261 from codeableorg/branch-Kelly3
Jeffcar1993 Aug 28, 2025
4dec2c4
Refactor: To add functions about as filters for stickers category
Jeffcar1993 Aug 28, 2025
2af8106
Merge pull request #264 from codeableorg/branch-Jeff4
Kellyarias02 Aug 28, 2025
59d6a55
Fix: Display the dynamic prices on the sticker category
Aug 29, 2025
1910dab
Merge pull request #265 from codeableorg/branch-Kelly4
Jeffcar1993 Aug 29, 2025
c4e4e93
Refactor: to add test about as variants of polos and stickers
Aug 30, 2025
0d4aeea
Merge pull request #268 from codeableorg/branch-Kelly4
Kellyarias02 Aug 30, 2025
e4938aa
Fix: errors with esLint but we have one error on cart service
Jeffcar1993 Aug 30, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .react-router/types/+register.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,4 +29,5 @@ type Params = {
"/account/orders": {};
"/not-found": {};
"/verify-email": {};
"/chat": {};
};
18 changes: 18 additions & 0 deletions api/gemini-chat.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
import express from "express";
import { GoogleGenAI } from "@google/genai";

const router = express.Router();
const ai = new GoogleGenAI({ apiKey: process.env.GOOGLE_API_KEY || "" });

router.post("/", async (req, res) => {
const { message } = req.body;
try {
const chat = ai.chats.create({ model: "gemini-2.5-flash", history: [] });
const response = await chat.sendMessage({ message });
res.json({ text: response.text });
} catch (err) {
res.status(500).json({ error: "Error al contactar a Gemini" });
}
});

export default router;
12 changes: 12 additions & 0 deletions api/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
import express from "express";
import cors from "cors";
import geminiChatRouter from "./gemini-chat.js";

const app = express();
app.use(express.json());
app.use("/api/gemini-chat", geminiChatRouter);
app.use(cors());

app.listen(3001, () => {
console.log("API server listening on http://localhost:3001");
});
24 changes: 24 additions & 0 deletions prisma/initial_data.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,30 @@ export const categories = [
},
];

export const productVariant = [
// Ejemplo para un producto Polo
{ productTitle: "Polo React", sizes: ["small", "medium", "large"] },
{ productTitle: "Polo JavaScript", sizes: ["small", "medium", "large"] },
{ productTitle: "Polo Node.js", sizes: ["small", "medium", "large"] },
{ productTitle: "Polo TypeScript", sizes: ["small", "medium", "large"] },
{ productTitle: "Polo Backend Developer", sizes: ["small", "medium", "large"] },
{ productTitle: "Polo Frontend Developer", sizes: ["small", "medium", "large"] },
{ productTitle: "Polo Full-Stack Developer", sizes: ["small", "medium", "large"] },
{ productTitle: "Polo It's A Feature", sizes: ["small", "medium", "large"] },
{ productTitle: "Polo It Works On My Machine", sizes: ["small", "medium", "large"] },
];

export const stickersVariant = [
{ productTitle: "Sticker JavaScript", measure: ["3*3", "5*5", "10*10"] },
{ productTitle: "Sticker React", measure: ["3*3", "5*5", "10*10"] },
{ productTitle: "Sticker Git", measure: ["3*3", "5*5", "10*10"] },
{ productTitle: "Sticker Docker", measure: ["3*3", "5*5", "10*10"] },
{ productTitle: "Sticker Linux", measure: ["3*3", "5*5", "10*10"] },
{ productTitle: "Sticker VS Code", measure: ["3*3", "5*5", "10*10"] },
{ productTitle: "Sticker GitHub", measure: ["3*3", "5*5", "10*10"] },
{ productTitle: "Sticker HTML", measure: ["3*3", "5*5", "10*10"] },
];

export const products = [
{
title: "Polo React",
Expand Down
15 changes: 0 additions & 15 deletions prisma/migrations/20250621010244_create_user_table/migration.sql

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,8 +1,24 @@
-- CreateEnum
CREATE TYPE "CategorySlug" AS ENUM ('polos', 'tazas', 'stickers');

-- CreateTable
CREATE TABLE "users" (
"id" SERIAL NOT NULL,
"email" TEXT NOT NULL,
"name" TEXT,
"password" TEXT,
"is_guest" BOOLEAN NOT NULL DEFAULT true,
"created_at" TIMESTAMP(0) NOT NULL DEFAULT CURRENT_TIMESTAMP,
"updated_at" TIMESTAMP(0) NOT NULL DEFAULT CURRENT_TIMESTAMP,

CONSTRAINT "users_pkey" PRIMARY KEY ("id")
);

-- CreateTable
CREATE TABLE "categories" (
"id" SERIAL NOT NULL,
"title" TEXT NOT NULL,
"slug" TEXT NOT NULL,
"slug" "CategorySlug" NOT NULL,
"img_src" TEXT,
"alt" TEXT,
"description" TEXT,
Expand All @@ -29,6 +45,25 @@ CREATE TABLE "products" (
CONSTRAINT "products_pkey" PRIMARY KEY ("id")
);

-- CreateTable
CREATE TABLE "ProductVariant" (
"id" SERIAL NOT NULL,
"productId" INTEGER NOT NULL,
"size" TEXT NOT NULL,

CONSTRAINT "ProductVariant_pkey" PRIMARY KEY ("id")
);

-- CreateTable
CREATE TABLE "stickersVariant" (
"id" SERIAL NOT NULL,
"productId" INTEGER NOT NULL,
"measure" TEXT NOT NULL,
"price" DECIMAL(10,2) NOT NULL,

CONSTRAINT "stickersVariant_pkey" PRIMARY KEY ("id")
);

-- CreateTable
CREATE TABLE "carts" (
"id" SERIAL NOT NULL,
Expand All @@ -43,8 +78,11 @@ CREATE TABLE "carts" (
-- CreateTable
CREATE TABLE "cart_items" (
"id" SERIAL NOT NULL,
"cart_id" INTEGER NOT NULL,
"product_id" INTEGER NOT NULL,
"cartId" INTEGER NOT NULL,
"productId" INTEGER NOT NULL,
"productVariantId" INTEGER,
"stickersVariantId" INTEGER,
"price" DECIMAL(10,2) NOT NULL,
"quantity" INTEGER NOT NULL,
"created_at" TIMESTAMP(0) NOT NULL DEFAULT CURRENT_TIMESTAMP,
"updated_at" TIMESTAMP(0) NOT NULL DEFAULT CURRENT_TIMESTAMP,
Expand All @@ -58,6 +96,7 @@ CREATE TABLE "orders" (
"user_id" INTEGER NOT NULL,
"total_amount" DECIMAL(10,2) NOT NULL,
"email" TEXT NOT NULL,
"payment_id" TEXT,
"first_name" TEXT NOT NULL,
"last_name" TEXT NOT NULL,
"company" TEXT,
Expand Down Expand Up @@ -88,26 +127,41 @@ CREATE TABLE "order_items" (
CONSTRAINT "order_items_pkey" PRIMARY KEY ("id")
);

-- CreateIndex
CREATE UNIQUE INDEX "users_email_key" ON "users"("email");

-- CreateIndex
CREATE UNIQUE INDEX "categories_slug_key" ON "categories"("slug");

-- CreateIndex
CREATE UNIQUE INDEX "carts_session_cart_id_key" ON "carts"("session_cart_id");

-- CreateIndex
CREATE UNIQUE INDEX "cart_items_cart_id_product_id_key" ON "cart_items"("cart_id", "product_id");
CREATE UNIQUE INDEX "cart_items_cartId_productId_productVariantId_stickersVarian_key" ON "cart_items"("cartId", "productId", "productVariantId", "stickersVariantId");

-- AddForeignKey
ALTER TABLE "products" ADD CONSTRAINT "products_category_id_fkey" FOREIGN KEY ("category_id") REFERENCES "categories"("id") ON DELETE SET NULL ON UPDATE CASCADE;

-- AddForeignKey
ALTER TABLE "ProductVariant" ADD CONSTRAINT "ProductVariant_productId_fkey" FOREIGN KEY ("productId") REFERENCES "products"("id") ON DELETE RESTRICT ON UPDATE CASCADE;

-- AddForeignKey
ALTER TABLE "stickersVariant" ADD CONSTRAINT "stickersVariant_productId_fkey" FOREIGN KEY ("productId") REFERENCES "products"("id") ON DELETE RESTRICT ON UPDATE CASCADE;

-- AddForeignKey
ALTER TABLE "carts" ADD CONSTRAINT "carts_user_id_fkey" FOREIGN KEY ("user_id") REFERENCES "users"("id") ON DELETE CASCADE ON UPDATE CASCADE;

-- AddForeignKey
ALTER TABLE "cart_items" ADD CONSTRAINT "cart_items_cart_id_fkey" FOREIGN KEY ("cart_id") REFERENCES "carts"("id") ON DELETE CASCADE ON UPDATE CASCADE;
ALTER TABLE "cart_items" ADD CONSTRAINT "cart_items_cartId_fkey" FOREIGN KEY ("cartId") REFERENCES "carts"("id") ON DELETE CASCADE ON UPDATE CASCADE;

-- AddForeignKey
ALTER TABLE "cart_items" ADD CONSTRAINT "cart_items_productId_fkey" FOREIGN KEY ("productId") REFERENCES "products"("id") ON DELETE CASCADE ON UPDATE CASCADE;

-- AddForeignKey
ALTER TABLE "cart_items" ADD CONSTRAINT "cart_items_productVariantId_fkey" FOREIGN KEY ("productVariantId") REFERENCES "ProductVariant"("id") ON DELETE SET NULL ON UPDATE CASCADE;

-- AddForeignKey
ALTER TABLE "cart_items" ADD CONSTRAINT "cart_items_product_id_fkey" FOREIGN KEY ("product_id") REFERENCES "products"("id") ON DELETE CASCADE ON UPDATE CASCADE;
ALTER TABLE "cart_items" ADD CONSTRAINT "cart_items_stickersVariantId_fkey" FOREIGN KEY ("stickersVariantId") REFERENCES "stickersVariant"("id") ON DELETE SET NULL ON UPDATE CASCADE;

-- AddForeignKey
ALTER TABLE "orders" ADD CONSTRAINT "orders_user_id_fkey" FOREIGN KEY ("user_id") REFERENCES "users"("id") ON DELETE CASCADE ON UPDATE CASCADE;
Expand Down
58 changes: 42 additions & 16 deletions prisma/schema.prisma
Original file line number Diff line number Diff line change
Expand Up @@ -51,17 +51,19 @@ model Category {
}

model Product {
id Int @id @default(autoincrement())
id Int @id @default(autoincrement())
title String
imgSrc String @map("img_src")
imgSrc String @map("img_src")
alt String?
price Decimal @db.Decimal(10, 2)
price Decimal @db.Decimal(10, 2)
description String?
categoryId Int? @map("category_id")
isOnSale Boolean @default(false) @map("is_on_sale")
categoryId Int? @map("category_id")
isOnSale Boolean @default(false) @map("is_on_sale")
features String[]
createdAt DateTime @default(now()) @map("created_at") @db.Timestamp(0)
updatedAt DateTime @default(now()) @map("updated_at") @db.Timestamp(0)
createdAt DateTime @default(now()) @map("created_at") @db.Timestamp(0)
updatedAt DateTime @default(now()) @map("updated_at") @db.Timestamp(0)
variants ProductVariant[]
stickersVariants stickersVariant[]

category Category? @relation(fields: [categoryId], references: [id], onDelete: SetNull)
cartItems CartItem[]
Expand All @@ -70,6 +72,25 @@ model Product {
@@map("products")
}

model ProductVariant {
id Int @id @default(autoincrement())
product Product @relation(fields: [productId], references: [id])
productId Int
size String // 'small', 'medium', 'large'

cartItems CartItem[] @relation("CartItemToProductVariant")
}

model stickersVariant {
id Int @id @default(autoincrement())
product Product @relation(fields: [productId], references: [id])
productId Int
measure String // '3*3', '5*5', '10*10'
price Decimal @db.Decimal(10, 2)

cartItems CartItem[] @relation("CartItemTostickersVariant")
}

model Cart {
id Int @id @default(autoincrement())
sessionCartId String @unique @default(dbgenerated("gen_random_uuid()")) @map("session_cart_id") @db.Uuid
Expand All @@ -84,17 +105,22 @@ model Cart {
}

model CartItem {
id Int @id @default(autoincrement())
cartId Int @map("cart_id")
productId Int @map("product_id")
quantity Int
createdAt DateTime @default(now()) @map("created_at") @db.Timestamp(0)
updatedAt DateTime @default(now()) @map("updated_at") @db.Timestamp(0)
id Int @id @default(autoincrement())
cartId Int
productId Int
productVariantId Int?
stickersVariantId Int?
price Decimal @db.Decimal(10, 2)
quantity Int
createdAt DateTime @default(now()) @map("created_at") @db.Timestamp(0)
updatedAt DateTime @default(now()) @map("updated_at") @db.Timestamp(0)

cart Cart @relation(fields: [cartId], references: [id], onDelete: Cascade)
product Product @relation(fields: [productId], references: [id], onDelete: Cascade)
cart Cart @relation(fields: [cartId], references: [id], onDelete: Cascade)
product Product @relation(fields: [productId], references: [id], onDelete: Cascade)
productVariant ProductVariant? @relation("CartItemToProductVariant", fields: [productVariantId], references: [id])
stickersVariant stickersVariant? @relation("CartItemTostickersVariant", fields: [stickersVariantId], references: [id])

@@unique([cartId, productId], name: "unique_cart_item")
@@unique([cartId, productId, productVariantId, stickersVariantId], name: "unique_cart_item")
@@map("cart_items")
}

Expand Down
Loading
Loading