diff --git a/client/package-lock.json b/client/package-lock.json index 5fe71be9..c3ed537d 100644 --- a/client/package-lock.json +++ b/client/package-lock.json @@ -32,6 +32,7 @@ "react-redux": "^8.0.5", "react-router-dom": "^6.8.1", "react-scripts": "^5.0.1", + "react-toastify": "^9.1.3", "redux": "^4.2.1", "redux-devtools-extension": "^2.13.9", "redux-thunk": "^2.4.2", @@ -15842,6 +15843,18 @@ "react": "^16.3.0 || ^17.0.0 || ^18.0.0" } }, + "node_modules/react-toastify": { + "version": "9.1.3", + "resolved": "https://registry.npmjs.org/react-toastify/-/react-toastify-9.1.3.tgz", + "integrity": "sha512-fPfb8ghtn/XMxw3LkxQBk3IyagNpF/LIKjOBflbexr2AWxAH1MJgvnESwEwBn9liLFXgTKWgBSdZpw9m4OTHTg==", + "dependencies": { + "clsx": "^1.1.1" + }, + "peerDependencies": { + "react": ">=16", + "react-dom": ">=16" + } + }, "node_modules/react-transition-group": { "version": "4.4.5", "resolved": "https://registry.npmjs.org/react-transition-group/-/react-transition-group-4.4.5.tgz", @@ -30133,6 +30146,14 @@ "integrity": "sha512-PVjOcvVOyIILrYoyGEpDN3vmYNLdy1CajSFNt4TDsVQC5KpTijDvWVoR+/7Rz2xT978D8/ZtFceXxzsPwZEDvw==", "requires": {} }, + "react-toastify": { + "version": "9.1.3", + "resolved": "https://registry.npmjs.org/react-toastify/-/react-toastify-9.1.3.tgz", + "integrity": "sha512-fPfb8ghtn/XMxw3LkxQBk3IyagNpF/LIKjOBflbexr2AWxAH1MJgvnESwEwBn9liLFXgTKWgBSdZpw9m4OTHTg==", + "requires": { + "clsx": "^1.1.1" + } + }, "react-transition-group": { "version": "4.4.5", "resolved": "https://registry.npmjs.org/react-transition-group/-/react-transition-group-4.4.5.tgz", diff --git a/client/package.json b/client/package.json index e4927688..eda71636 100644 --- a/client/package.json +++ b/client/package.json @@ -27,6 +27,7 @@ "react-redux": "^8.0.5", "react-router-dom": "^6.8.1", "react-scripts": "^5.0.1", + "react-toastify": "^9.1.3", "redux": "^4.2.1", "redux-devtools-extension": "^2.13.9", "redux-thunk": "^2.4.2", diff --git a/client/src/pages/CreateStore.js b/client/src/pages/CreateStore.js index 745bf416..6f346285 100644 --- a/client/src/pages/CreateStore.js +++ b/client/src/pages/CreateStore.js @@ -5,8 +5,11 @@ import BreadCrumb from "../components/BreadCrumb"; import Container from "../components/Container"; import CustomInput from "../components/CustomInput"; import { useAuth0 } from "@auth0/auth0-react"; +import Loader from "../components/Loader"; const CreateStore = () => { + //used to disable button when clicked once in createstore form + const [isButtonDisabled, setIsButtonDisabled] = useState(false); const [formData, setFormData] = useState({ name: "", category: "", @@ -42,6 +45,8 @@ const CreateStore = () => { return; } + setIsButtonDisabled(true); + console.log("Form submitted"); const formDataForBackend = new FormData(); @@ -55,11 +60,14 @@ const CreateStore = () => { const response = await axios.post("https://sheearns.onrender.com/createShop", formDataForBackend); + setIsButtonDisabled(false); console.log("Store created:", response.data); window.location.href = '/'; } catch (error) { + setIsButtonDisabled(false); + console.error("Error creating store:", error); } console.log("After Axios request"); @@ -67,6 +75,7 @@ const CreateStore = () => { return ( <> + {isButtonDisabled && } @@ -99,7 +108,7 @@ const CreateStore = () => { />
-