diff --git a/backend/__pycache__/models.cpython-312.pyc b/backend/__pycache__/models.cpython-312.pyc index b6daf16..0614e14 100644 Binary files a/backend/__pycache__/models.cpython-312.pyc and b/backend/__pycache__/models.cpython-312.pyc differ diff --git a/backend/instance/mydatabase.db b/backend/instance/mydatabase.db index 328ee2f..faf786f 100644 Binary files a/backend/instance/mydatabase.db and b/backend/instance/mydatabase.db differ diff --git a/backend/main.py b/backend/main.py index 2563685..87409d9 100644 --- a/backend/main.py +++ b/backend/main.py @@ -121,11 +121,16 @@ def mail(): # Handle Serving Public Images -@app.route('/serve-image/', methods=['GET']) +@app.route('/uploads/', methods=['GET']) def serve_image(filename): return send_from_directory(app.config['UPLOAD_DIRECTORY'], filename) +# Get all files +@app.route("/images", methods=["GET"]) +def get_files(): + files = os.listdir(app.config['UPLOAD_DIRECTORY']) + return jsonify({"files": files}) # New Orders @app.route("/new-order", methods=["POST"]) diff --git a/backend/models.py b/backend/models.py index f31bf39..3295173 100644 --- a/backend/models.py +++ b/backend/models.py @@ -37,7 +37,29 @@ class Orders(db.Model): "order":self.order, } +class Products(db.Model): + __tablename__ = "products" + id = db.Column(db.String(32), primary_key=True, unique=True, default=get_uuid) + name = db.Column(db.String(345), default='New Shirt') + image = db.Column(db.String(34), nullable=False) + description = db.Column(db.String(345), default='Basic T-Shirt') + price = db.Column(db.Integer, default=25) + category = db.Column(db.String(345), default='New Shirt') + sale = db.Column(db.Boolean, default=False) + sale_price = db.Column(db.Integer, default=18) + def to_json(self): + return { + "id": self.id, + "name": self.name, + "image": self.image, + "description": self.description, + "price": self.price, + "category": self.category, + "sale": self.sale, + "sale_price": self.sale_price, + } + # class Category(db.Model): # __tablename__ = "categories" # id = db.Column(db.String(32), primary_key=True, unique=True, default=get_uuid) diff --git a/backend/uploads/Mockup 18.jpg b/backend/uploads/Mockup_18.jpg similarity index 100% rename from backend/uploads/Mockup 18.jpg rename to backend/uploads/Mockup_18.jpg diff --git a/frontend/next.config.mjs b/frontend/next.config.mjs index b965390..4efd672 100644 --- a/frontend/next.config.mjs +++ b/frontend/next.config.mjs @@ -27,6 +27,12 @@ const nextConfig = { port: "1337", pathname: "/**", }, + { + protocol: "http", + hostname: "localhost", + port: "5080", + pathname: "/**", + }, { protocol: "https", hostname: "api.kevosattire.com", diff --git a/frontend/src/app/products/page.tsx b/frontend/src/app/products/page.tsx index a45c6ed..1ffff8c 100644 --- a/frontend/src/app/products/page.tsx +++ b/frontend/src/app/products/page.tsx @@ -20,7 +20,18 @@ const Products = () => { Authorization: "Bearer " + process.env.NEXT_PUBLIC_API_TOKEN } }); + // const response = await fetch(process.env.NEXT_PUBLIC_Flask_URL +"/images", { + // method: "GET", + // }); const data = await response.json(); + + // console.log(data); + + // Flask + // console.log(data.files); + // setData(data.files); + + // Strapi console.log(data.data); // console.log(data.data[0].image.url); setData(data.data); diff --git a/frontend/src/components/ProductPage/ProductPage.css b/frontend/src/components/ProductPage/ProductPage.css index 2ca16c5..8513781 100644 --- a/frontend/src/components/ProductPage/ProductPage.css +++ b/frontend/src/components/ProductPage/ProductPage.css @@ -26,7 +26,7 @@ .main-image{ width: 100%; max-height: 800px; - cursor: pointer; + /* cursor: pointer; */ position: relative; } } diff --git a/frontend/src/components/ProductPage/ProductPage.tsx b/frontend/src/components/ProductPage/ProductPage.tsx index d0c8aa4..fa4e59a 100644 --- a/frontend/src/components/ProductPage/ProductPage.tsx +++ b/frontend/src/components/ProductPage/ProductPage.tsx @@ -14,13 +14,20 @@ const ProductPage = ({ productId }: any) => { // console.log(productId); const [selectedImage, setSelectedImage] = useState(0); const [quantity, setQuantity] = useState(1); + const [isSelected, setIsSelected] = useState(false); + const [imageClass, setImageClass] = useState('cursor-zoom-in'); - const images = [ - "https://ih1.redbubble.net/image.2997405810.0746/ssrco,slim_fit_t_shirt,womens,101010:01c5ca27c6,front,square_product,600x600.jpg", - "https://ih1.redbubble.net/image.2997405810.0746/ssrco,slim_fit_t_shirt,flatlay,101010:01c5ca27c6,front,wide_portrait,750x1000-bg,f8f8f8.jpg", - ]; + + // Set product variables const [data, setData] = useState([]); const [product, setProduct] = useState(''); + const [name, setName] = useState(''); + const [desc, setDesc] = useState(''); + const [price, setPrice] = useState(0); + const [sale, setSale] = useState(false); + const [salePrice, setSalePrice] = useState(0); + const [category, setCategory] = useState(''); + useEffect(() => { const fetchData = async () => { @@ -33,16 +40,30 @@ const ProductPage = ({ productId }: any) => { const res = await request.json(); // console.log(res.data); console.log(res.data[1].image.url); + setData(res.data); + // Set product variables setProduct(res.data[parseInt(productId)]?.image?.url); + setName(res.data[parseInt(productId)]?.title); + setDesc(res.data[parseInt(productId)]?.desc); + setPrice(res.data[parseInt(productId)]?.price); + setSale(res.data[parseInt(productId)]?.sale); + setSalePrice(res.data[parseInt(productId)]?.sale_price); + setCategory(res.data[parseInt(productId)]?.category); }; fetchData(); }, [productId]); + const handleSelectedImage = () => { + setIsSelected(!isSelected); + setImageClass(isSelected ? 'cursor-zoom-out scale-125' : 'cursor-zoom-in'); + }; + + return (
-
+ {/*
{ style={{ objectFit: "cover" }} onClick={(e) => setSelectedImage(0)} /> - {/* Shirt Mockup setSelectedImage(0)} - /> */} +
- {/* Shirt Mockup setSelectedImage(1)} - /> */} +
-
+
*/}
-
+
Profile picture
-

Title

- $199 +

{name}

+ ${price}

- Lorem ipsum dolor sit amet consectetur adipisicing elit. Modi, culpa - temporibus. Blanditiis, perferendis tempore praesentium voluptatibus - et, consectetur similique natus facilis reiciendis eum pariatur rem - vitae est aliquid, debitis corporis. + {desc}

{/* If quantity is at 1 then it stays at 1, otherwise it will subtract by 1 */} diff --git a/frontend/src/components/ui/MenuCard/MenuCard.tsx b/frontend/src/components/ui/MenuCard/MenuCard.tsx index 0aff0cd..3884071 100644 --- a/frontend/src/components/ui/MenuCard/MenuCard.tsx +++ b/frontend/src/components/ui/MenuCard/MenuCard.tsx @@ -34,6 +34,18 @@ const MenuCard = ({ Menu }: any) => { >
+ {/* Flask */} + {/* product photo router.push(`/products/${menu_item.id}`)} + /> */} + {/* Strapi */}