From 276546515d3e0ee6a13f7b6cf263836523725aa6 Mon Sep 17 00:00:00 2001 From: Hy Nguyen Date: Sat, 12 Oct 2024 03:08:48 -0500 Subject: [PATCH 1/5] set primary text color to spinner on product card --- app/routes/store/ProductCard.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/routes/store/ProductCard.tsx b/app/routes/store/ProductCard.tsx index f56f482..c8899e5 100644 --- a/app/routes/store/ProductCard.tsx +++ b/app/routes/store/ProductCard.tsx @@ -226,7 +226,7 @@ export default function ProductCard({ product }: Props) { const renderAddToCartText = function (isAddingToCart: boolean) { if (isAddingToCart) { return ( -
+
); From 940318a850d05f77a7774bfc670103e0e56e7830 Mon Sep 17 00:00:00 2001 From: Hy Nguyen Date: Sun, 13 Oct 2024 00:47:29 -0500 Subject: [PATCH 2/5] admin page style adjust --- app/routes/admin/ProductDetails.tsx | 4 ++-- app/routes/admin/index.tsx | 6 +++--- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/app/routes/admin/ProductDetails.tsx b/app/routes/admin/ProductDetails.tsx index c4dacc2..cf6d1f8 100644 --- a/app/routes/admin/ProductDetails.tsx +++ b/app/routes/admin/ProductDetails.tsx @@ -292,7 +292,7 @@ export default function ProductDetails({ mode, updateFormState }: Props) { }} />
-

{review.feedback}

+

{review.feedback}

); } From 8378356682c84aea3d43315f1fa03e6ac3bee77b Mon Sep 17 00:00:00 2001 From: Hy Nguyen Date: Tue, 15 Oct 2024 01:39:44 -0500 Subject: [PATCH 4/5] add price & discount inputs to /admin route --- app/routes/admin/ProductDetails.tsx | 24 ++++++++++++++++++++++++ app/routes/admin/index.tsx | 11 +++++++++++ 2 files changed, 35 insertions(+) diff --git a/app/routes/admin/ProductDetails.tsx b/app/routes/admin/ProductDetails.tsx index cf6d1f8..a0e4f32 100644 --- a/app/routes/admin/ProductDetails.tsx +++ b/app/routes/admin/ProductDetails.tsx @@ -109,6 +109,8 @@ export default function ProductDetails({ mode, updateFormState }: Props) { title: formData.get("title") as string, description: formData.get("description") as string, quantity: Number(formData.get("quantity")), + price: Number(formData.get("price")), + discount: Number(formData.get("discount")), }) .select() .single(); @@ -127,6 +129,8 @@ export default function ProductDetails({ mode, updateFormState }: Props) { title: formData.get("title") as string, description: formData.get("description") as string, quantity: Number(formData.get("quantity")), + price: Number(formData.get("price")), + discount: Number(formData.get("discount")), }) .eq("id", productID); @@ -261,6 +265,26 @@ export default function ProductDetails({ mode, updateFormState }: Props) { defaultValue={updateFormState.quantity} /> + + + +
{tags.map((tag, i) => (
diff --git a/app/routes/admin/index.tsx b/app/routes/admin/index.tsx index b2f3c4e..1cb1138 100644 --- a/app/routes/admin/index.tsx +++ b/app/routes/admin/index.tsx @@ -9,6 +9,9 @@ export type UpdateFormState = { title: string; description: string; quantity: string | number; + price: string | number; + discount: string | number; + tags: string[]; imgNames: string[]; }; @@ -36,6 +39,8 @@ export default function Admin() { title: "", description: "", quantity: "", + price: "", + discount: "", tags: [], imgNames: [], }); @@ -58,6 +63,8 @@ export default function Admin() { title, description, quantity, + price, + discount, tags:PRODUCTS_TAGS(tag_id(name)) `, ) @@ -68,6 +75,8 @@ export default function Admin() { title: string; description: string; quantity: number; + price: number; + discount: number; tags: { tag_id: { name: string } }[]; }[] >() @@ -94,6 +103,8 @@ export default function Admin() { title: data.title, description: data.description, quantity: data.quantity, + price: data.price, + discount: data.discount, tags: data.tags.map(({ tag_id }) => tag_id.name), imgNames: fetchedImagesData.map((imgData) => imgData.name), }); From 340165e7c077354a9030853d970422a03905c834 Mon Sep 17 00:00:00 2001 From: Hy Nguyen Date: Tue, 15 Oct 2024 01:54:37 -0500 Subject: [PATCH 5/5] review form: add spinner to submit button, add notifications --- .../reviews_section/ReviewForm.tsx | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/app/routes/product.$productID/reviews_section/ReviewForm.tsx b/app/routes/product.$productID/reviews_section/ReviewForm.tsx index b9e80f4..2fb8745 100644 --- a/app/routes/product.$productID/reviews_section/ReviewForm.tsx +++ b/app/routes/product.$productID/reviews_section/ReviewForm.tsx @@ -2,6 +2,7 @@ import { FormEvent, useEffect, useState } from "react"; import { ProductInfo, ReviewsFetchTriggerType } from "../Types"; import { Form, useOutletContext } from "@remix-run/react"; import { ContextProps } from "~/utils/types/ContextProps.type"; +import SpinnerSVG from "~/components/SpinnerSVG"; type Props = { productInfo: ProductInfo; @@ -50,6 +51,7 @@ export default function ReviewForm({ async function handleSubmit(event: FormEvent) { event.preventDefault(); if (rating < 1 || rating > 5) { + addNotification("Rating not set", "FAIL"); return console.error("Stars amount must be between 1 and 5."); } @@ -69,6 +71,7 @@ export default function ReviewForm({ if (countError) { console.error("Error upserting review", countError); + addNotification("Error upserting review", "FAIL"); return setIsSubmitting(false); } @@ -182,10 +185,18 @@ export default function ReviewForm({ {enableFormInput ? ( ) : null}