diff --git a/.eslintrc.js b/.eslintrc.js index 9030412..056c53d 100644 --- a/.eslintrc.js +++ b/.eslintrc.js @@ -66,6 +66,7 @@ module.exports = { ], }, ], + "@next/next/no-img-element": "off", //#endregion //*======== Import Sort =========== }, globals: { diff --git a/public/images/category_img/category_academic.webp b/public/images/category_img/category_academic.webp new file mode 100644 index 0000000..885deab Binary files /dev/null and b/public/images/category_img/category_academic.webp differ diff --git a/public/images/category_img/category_beauty.webp b/public/images/category_img/category_beauty.webp new file mode 100644 index 0000000..2bc35d6 Binary files /dev/null and b/public/images/category_img/category_beauty.webp differ diff --git a/public/images/category_img/category_clothes.webp b/public/images/category_img/category_clothes.webp new file mode 100644 index 0000000..a375f79 Binary files /dev/null and b/public/images/category_img/category_clothes.webp differ diff --git a/public/images/category_img/category_dorm.webp b/public/images/category_img/category_dorm.webp new file mode 100644 index 0000000..011864b Binary files /dev/null and b/public/images/category_img/category_dorm.webp differ diff --git a/public/images/category_img/category_electronics.webp b/public/images/category_img/category_electronics.webp new file mode 100644 index 0000000..32727df Binary files /dev/null and b/public/images/category_img/category_electronics.webp differ diff --git a/public/images/category_img/category_entertainment.webp b/public/images/category_img/category_entertainment.webp new file mode 100644 index 0000000..e5645b7 Binary files /dev/null and b/public/images/category_img/category_entertainment.webp differ diff --git a/public/images/category_img/category_other.webp b/public/images/category_img/category_other.webp new file mode 100644 index 0000000..da49503 Binary files /dev/null and b/public/images/category_img/category_other.webp differ diff --git a/src/components/categorycard/CategoryCard.jsx b/src/components/categorycard/CategoryCard.jsx index 10213ce..8ac4b9d 100644 --- a/src/components/categorycard/CategoryCard.jsx +++ b/src/components/categorycard/CategoryCard.jsx @@ -1,17 +1,21 @@ -import Image from "next/image"; +import Link from "next/link"; -const CategoryCard = ({ title, image, category }) => { +const CategoryCard = ({ imgSrc, title, href }) => { return ( -
- {/* {title} */} -
-
{category}
+ +
+
+ {title} +
+

+ {title} +

-
+ ); }; diff --git a/src/components/input/index.jsx b/src/components/input/index.jsx index f64c09b..2934f7f 100644 --- a/src/components/input/index.jsx +++ b/src/components/input/index.jsx @@ -1,4 +1,7 @@ import clsx from "clsx"; + +import { cn } from "@/lib/utils"; + const Input = ({ name, type, @@ -8,6 +11,7 @@ const Input = ({ requiredMessage, validation, errors, + className = "", }) => { return ( <> @@ -24,12 +28,13 @@ const Input = ({ })} placeholder={placeholder} type={type} - className={clsx( + className={cn( "p-2 block w-full border rounded-md focus:outline-none focus:ring-2 focus:ring-green", { "border-red": errors[name], "border-slate-300": !errors[name], }, + className, )} /> {errors[name] && ( diff --git a/src/constants/index.js b/src/constants/index.js index 0628bef..177101e 100644 --- a/src/constants/index.js +++ b/src/constants/index.js @@ -4,7 +4,7 @@ export const marketingCardData1 = [ { icon: ( Icon 1 -
+
{children}
diff --git a/src/lib/firebase/firestoreFunctions.js b/src/lib/firebase/firestoreFunctions.js index 97f0c5f..8f05bd8 100644 --- a/src/lib/firebase/firestoreFunctions.js +++ b/src/lib/firebase/firestoreFunctions.js @@ -5,6 +5,8 @@ import { doc, getDoc, getDocs, + limit, + orderBy, query, updateDoc, where, @@ -95,3 +97,16 @@ export const getItemByCategory = async (category) => { export const deleteDocData = async (collection, docId) => { return await deleteDoc(doc(db, collection, docId)); }; + +// GET ALL +export const getAllItems = async () => { + const q = query(collection(db, "items"), orderBy("createdAt"), limit(15)); + const querySnapshot = await getDocs(q); + const items = []; + querySnapshot.forEach((doc) => { + let data = doc.data(); + data.id = doc.id; + items.push(data); + }); + return items; +}; diff --git a/src/pages/listed-items/index.jsx b/src/pages/listed-items/index.jsx deleted file mode 100644 index f1954a1..0000000 --- a/src/pages/listed-items/index.jsx +++ /dev/null @@ -1,65 +0,0 @@ -import Link from "next/link"; - -import CategoryCard from "@/components/categorycard/CategoryCard"; -import Footer from "@/components/footer/Footer"; -import ItemCard from "@/components/itemcard/ItemCard"; -import Navbar from "@/components/navbar/Navbar"; - -//hey you need to run the server of the fake api (json-server --watch --port 4000 ./_data/db.json) in order for this page to work, -// also fontawesome won't work for some reason and the advanced search still needs to be reviewed in order to be merged. if u click on the click me it will take u to another page yay. -// I made a couple of tweaks to the itemcard and category so it could look descent. - -export default function Information({ id, items }) { - return ( -
- -

Click Me

- -
- {items.map((item) => ( -
- -
- ))} -
-
- {items.map((thing) => ( -
- - -
- ))} -
-
- ); -} - -export async function getStaticProps() { - try { - const response = await fetch("http://localhost:4000/items"); - const items = await response.json(); - - if (!items) { - console.error("Items not found."); - return { - notFound: true, - }; - } - return { - props: { items }, - }; - } catch (error) { - console.error("Error fetching items:", error); - return { - notFound: true, - }; - } -} diff --git a/src/pages/products/index.jsx b/src/pages/products/index.jsx new file mode 100644 index 0000000..a84b04d --- /dev/null +++ b/src/pages/products/index.jsx @@ -0,0 +1,83 @@ +import { useForm } from "react-hook-form"; + +import { getAllItems } from "@/lib/firebase/firestoreFunctions"; + +import Button from "@/components/button/Button"; +import CategoryCard from "@/components/categorycard/CategoryCard"; +import Input from "@/components/input"; +import ItemCard from "@/components/itemcard/ItemCard"; + +import { categories } from "@/constants"; + +export default function ProductsPage({ items }) { + const { + register, + handleSubmit, + formState: { errors, isSubmitting }, + } = useForm(); + return ( +
+
+

+ Browse by category:{" "} +

+
+ {categories.map((category) => { + return ; + })} +
+
+
+ + + + +
+
+ {items.map((item) => ( + + ))} +
+
+ ); +} + +export async function getServerSideProps() { + let items = await getAllItems(); + items = JSON.parse(JSON.stringify(items)); + return { + props: { + items, + }, + }; +}