function EditProduct({ data, handleClose }) {

  
  const [product, updateItemInProduct] = useState(data);

  const handleChange = (event) => {
    let localProductItem = {...product, ...{[event.target.name] : event.target.value}}
    updateItemInProduct(localProductItem);
  };
  
  const saveProduct = (product) => {
    try {
      async function saveProduct(){
        let response = await makeRequest({
          method: "POST",
          url: "/v1/addOrUpdateProduct",
          data : product
        });
        if(response.data.code === 200){
          ToastsStore.success("Product Edited Successfully!")
        } else {
          ToastsStore.warning(response.data.message)
        }

      }
      saveProduct();
    } catch (error) {
      ToastsStore.error(error.message)
    }
  };


  return (
    <div className="popup-box">
      <div className="box">
        <span className="close-icon" onClick={handleClose}>
          x
        </span>

        <div className="column">
          <Typography component="h1" variant="h5">
            Edit Product Details
          </Typography>
          <form noValidate>
            <TextField
              variant="outlined"
              margin="normal"
              required
              fullWidth
              id="productName"
              label="Product Name"
              name="productName"
              autoComplete="Product Name"
              value = {product.productName}
              autoFocus
              onChange={handleChange}
            />
            <div className='row '>
            <SizingDropdown onChangeValue={handleChange} defaultValue = {product.sizeId}></SizingDropdown>
            <CategoryDropdown onChangeValue={handleChange} defaultValue = {product.categoryId}></CategoryDropdown>

            </div>
            <TextField
              variant="outlined"
              margin="normal"
              required
              fullWidth
              id="price"
              label="Price"
              name="price"
              autoComplete="Price"
              value = {product.price}
              autoFocus
              onChange={handleChange}
            />
            <TextField
              variant="outlined"
              margin="normal"
              required
              fullWidth
              id="stock"
              label="Stock"
              name="stock"
              autoComplete="Stock"
              value = {product.stock}
              onChange={handleChange}
              autoFocus
            />
            <TextField
              variant="outlined"
              margin="normal"
              required
              fullWidth
              id="description"
              label="Description"
              name="description"
              autoComplete="Description"
              value = {product.description}
              onChange={handleChange}
              autoFocus
            />
            <Button
              type="submit"
              fullWidth
              variant="contained"
              color="primary"
              onClick={() => saveProduct(product)}
            >
              Update
            </Button>
          </form>
        </div>
      </div>
    </div>
  );
}
/**
 * Created by Piyush on Sat Nov 21 2020 15:42:46 GMT+0530 (India Standard Time)
 * popup for product
 * Updated by Piyush on Sat Nov 21 2020 15:42:46 GMT+0530 (India Standard Time)
 * popup for product
 */
Created by Piyush on Sat Nov 21 2020 15:42:46 GMT+0530 (India Standard Time)
popup for product
Updated by Piyush on Sat Nov 21 2020 15:42:46 GMT+0530 (India Standard Time)
popup for product
Created by Piyush on Sat Nov 21 2020 15 : 42 : 46 GMT + 0530 ( India Standard Time ) popup for product Updated by Piyush on Sat Nov 21 2020 15 : 42 : 46 GMT + 0530 ( India Standard Time ) popup for product
function EditProduct({ data, handleClose }) {
  const [product, updateItemInProduct] = useState(data);
  const handleChange = (event) => {
    let localProductItem = {...product, ...{[event.target.name] : event.target.value}}
    updateItemInProduct(localProductItem);
  };
  const saveProduct = (product) => {
    try {
      async function saveProduct(){
        let response = await makeRequest({
          method: "POST",
          url: "/v1/addOrUpdateProduct",
          data : product
        });
        if(response.data.code === 200){
          ToastsStore.success("Product Edited Successfully!")
        } else {
          ToastsStore.warning(response.data.message)
        }
      }
      saveProduct();
    } catch (error) {
      ToastsStore.error(error.message)
    }
  };
  return (
    <div className="popup-box">
      <div className="box">
        <span className="close-icon" onClick={handleClose}>
          x
        </span>
        <div className="column">
          <Typography component="h1" variant="h5">
            Edit Product Details
          </Typography>
          <form noValidate>
            <TextField
              variant="outlined"
              margin="normal"
              required
              fullWidth
              id="productName"
              label="Product Name"
              name="productName"
              autoComplete="Product Name"
              value = {product.productName}
              autoFocus
              onChange={handleChange}
            />
            <div className='row '>
            <SizingDropdown onChangeValue={handleChange} defaultValue = {product.sizeId}></SizingDropdown>
            <CategoryDropdown onChangeValue={handleChange} defaultValue = {product.categoryId}></CategoryDropdown>
            </div>
            <TextField
              variant="outlined"
              margin="normal"
              required
              fullWidth
              id="price"
              label="Price"
              name="price"
              autoComplete="Price"
              value = {product.price}
              autoFocus
              onChange={handleChange}
            />
            <TextField
              variant="outlined"
              margin="normal"
              required
              fullWidth
              id="stock"
              label="Stock"
              name="stock"
              autoComplete="Stock"
              value = {product.stock}
              onChange={handleChange}
              autoFocus
            />
            <TextField
              variant="outlined"
              margin="normal"
              required
              fullWidth
              id="description"
              label="Description"
              name="description"
              autoComplete="Description"
              value = {product.description}
              onChange={handleChange}
              autoFocus
            />
            <Button
              type="submit"
              fullWidth
              variant="contained"
              color="primary"
              onClick={() => saveProduct(product)}
            >
              Update
            </Button>
          </form>
        </div>
      </div>
    </div>
  );
}
function EditProduct ( { data , handleClose } ) { const [ product , updateItemInProduct ] = useState ( data ) ; const handleChange = ( event ) => { let localProductItem = { ... product , ... { [ event . target . name ] : event . target . value } } updateItemInProduct ( localProductItem ) ; } ; const saveProduct = ( product ) => { try { async function saveProduct ( ) { let response = await makeRequest ( { method : "POST" , url : "/v1/addOrUpdateProduct" , data : product } ) ; if ( response . data . code === 200 ) { ToastsStore . success ( "Product Edited Successfully!" ) } else { ToastsStore . warning ( response . data . message ) } } saveProduct ( ) ; } catch ( error ) { ToastsStore . error ( error . message ) } } ; return ( < div className = "popup-box" > < div className = "box" > < span className = "close-icon" onClick = { handleClose } > 
          x
         < / span > < div className = "column" > < Typography component = "h1" variant = "h5" > 
            Edit Product Details
           < / Typography > < form noValidate > < TextField variant = "outlined" margin = "normal" required fullWidth id = "productName" label = "Product Name" name = "productName" autoComplete = "Product Name" value = { product . productName } autoFocus onChange = { handleChange } / > < div className = 'row ' > < SizingDropdown onChangeValue = { handleChange } defaultValue = { product . sizeId } > < / SizingDropdown > < CategoryDropdown onChangeValue = { handleChange } defaultValue = { product . categoryId } > < / CategoryDropdown > < / div > < TextField variant = "outlined" margin = "normal" required fullWidth id = "price" label = "Price" name = "price" autoComplete = "Price" value = { product . price } autoFocus onChange = { handleChange } / > < TextField variant = "outlined" margin = "normal" required fullWidth id = "stock" label = "Stock" name = "stock" autoComplete = "Stock" value = { product . stock } onChange = { handleChange } autoFocus / > < TextField variant = "outlined" margin = "normal" required fullWidth id = "description" label = "Description" name = "description" autoComplete = "Description" value = { product . description } onChange = { handleChange } autoFocus / > < Button type = "submit" fullWidth variant = "contained" color = "primary" onClick = { ( ) => saveProduct ( product ) } > 
              Update
             < / Button > < / form > < / div > < / div > < / div > ) ; }
Created by Piyush on Sat Nov 21 2020 15:42:46 GMT+0530 (India Standard Time)
 popup for product
 Updated by Piyush on Sat Nov 21 2020 15:42:46 GMT+0530 (India Standard Time)
 popup for product
Created by Piyush on Sat Nov 21 2020 15 : 42 : 46 GMT + 0530 ( India Standard Time ) popup for product Updated by Piyush on Sat Nov 21 2020 15 : 42 : 46 GMT + 0530 ( India Standard Time ) popup for product