diff --git a/package.json b/package.json index 3aea0924035de2970f033402aed9ad894989a686..733a2faa283a5fa6add4020b27069f24cf057235 100644 --- a/package.json +++ b/package.json @@ -31,7 +31,7 @@ "reactstrap": "^8.9.0" }, "scripts": { - "start": "cross-env REACT_APP_BASE_URL=http://localhost:8000 parcel public/index.html", + "start": "cross-env REACT_APP_BASE_URL=$(grep REACT_APP_BASE_URL .env_var | cut -d '=' -f2) parcel public/index.html", "build": "cross-env REACT_APP_BASE_URL=$(grep REACT_APP_BASE_URL .env_var | cut -d '=' -f2) parcel build public/index.html", "test": "jest", "test:coverage": "jest --coverage", diff --git a/src/page/produk/FormProduk.jsx b/src/page/produk/FormProduk.jsx index 3cd7da282556e1f8bb2e67e9804e7c112a8df89e..a7c3d64ed56da508f2be427215bb7216afd3f562 100644 --- a/src/page/produk/FormProduk.jsx +++ b/src/page/produk/FormProduk.jsx @@ -13,7 +13,7 @@ import { import { css } from "@emotion/core"; const FormProduk = ({ onSubmit, initialData = null, error }) => { - const [isPreorder, setIsPreorder] = useState(true); + const [isPreorder, setIsPreorder] = useState(""); const { register, handleSubmit, errors, watch } = useForm({ defaultValues: initialData !== null @@ -59,12 +59,11 @@ const FormProduk = ({ onSubmit, initialData = null, error }) => { if (data.image.length !== 0) formData.append("image", data["image"][0]); } else formData.append(key, data[key]); - - isPreorder ? formData.delete("stock") : formData.delete("preorder_duration") + isPreorder === "true" ? formData.set("stock" , null) : formData.set("preorder_duration", null) } onSubmit(formData); - }, []); + }, [isPreorder]); return (