diff --git a/app/add-product-page/page.tsx b/app/add-product-page/page.tsx index 327d5ccc..772addf6 100644 --- a/app/add-product-page/page.tsx +++ b/app/add-product-page/page.tsx @@ -11,17 +11,14 @@ import { ProductSizePantsInseamList, } from "./product-prop-list"; const AddProduct = () => { - const defaultType: string = ProductTypeList.Shoes; - const [productType, setProductType] = useState(defaultType); - const defaultGender: string = ProductGenderList.MALE - const [productGender, setProductGender] = useState(defaultGender); - const [productSizeShoe, setProductSizeShoe] = useState(ProductSizeShoeList[0]); - const defaultSize: string = ProductSizesList.L; - const [productSizes, setProductSizes] = useState(defaultSize); - const [productSizePantsWaist, setProductSizePantsWaist] = useState(ProductSizePantsWaistList[0]); - const [productSizePantsInseam, setProductSizePantsInseam] = useState(ProductSizePantsInseamList[0]); - const [productDescription, setProductDescription] = useState(""); - const [productImage, setProductImage] = useState(""); + const [productType, setProductType] = useState(''); + const [productGender, setProductGender] = useState(''); + const [productSizeShoe, setProductSizeShoe] = useState(''); + const [productSizes, setProductSizes] = useState(''); + const [productSizePantsWaist, setProductSizePantsWaist] = useState(''); + const [productSizePantsInseam, setProductSizePantsInseam] = useState(''); + const [productDescription, setProductDescription] = useState(''); + const [productImage, setProductImage] = useState(''); const handleProductTypeSelect = (e: { target: { value: React.SetStateAction }; @@ -35,9 +32,10 @@ const AddProduct = () => { setProductGender(e.target.value); }; - const handleProductSizeShoeSelect = (event: any) => { - const newValue = parseInt(event.target.value.toString(), 10); - setProductSizeShoe(newValue); + const handleProductSizeShoeSelect = (e: { + target: { value: React.SetStateAction }; + }) => { + setProductSizeShoe(e.target.value); }; const handleProductSizeSelect = (e: { @@ -46,14 +44,16 @@ const AddProduct = () => { setProductSizes(e.target.value); }; - const handleProductSizePantsWaistSelect = (event: any) => { - const newValue = parseInt(event.target.value.toString(), 10); - setProductSizePantsWaist(newValue); + const handleProductSizePantsWaistSelect = (e: { + target: { value: React.SetStateAction }; + }) => { + setProductSizePantsWaist(e.target.value); }; - const handleProductSizePantsInseamSelect = (event: any) => { - const newValue = parseInt(event.target.value.toString(), 10); - setProductSizePantsInseam(newValue); + const handleProductSizePantsInseamSelect = (e: { + target: { value: React.SetStateAction }; + }) => { + setProductSizePantsInseam(e.target.value); }; const handleDescriptionChange = (e: { @@ -101,12 +101,14 @@ const AddProduct = () => { } }; + const notSizeApplicable = ['', 'Pants', 'Shoes'] + return (
Add a Product - + {/* Product Type Field */} @@ -124,103 +126,141 @@ const AddProduct = () => { {/* Product Gender Field */} - - Product Gender - - + { + productType == '' ? null : ( + + Product Gender + + + ) + } {/* Product Size Shoe Field */} - - Shoe Size - - + { + productType != 'Shoes' ? null : ( + + Shoe Size + + + ) + } {/* Product Size Field */} - - Product Size - - + { + notSizeApplicable.includes(productType) ? null : ( + + Product Size + + + ) + } {/* Product Size Pants Waist Field */} - - Waist Size - - + { + productType != 'Pants' ? null : ( + + Waist Size + + + ) + } {/* Product Size Pants Inseam Field */} - - Inseam Length - - + { + productType != 'Pants' ? null : ( + + Inseam Length + + + ) + } {/* Product Description Field */} - - - + { + productType == '' ? null : ( + + + + ) + } {/* Product Upload Image Field */} - - - + { + productType == '' ? null : ( + + + + ) + } {/* Submit Button */} - + { + productType == '' ? null : ( + + ) + } +
);