{"ast":null,"code":"var _jsxFileName = \"C:\\\\Users\\\\noanr\\\\OneDrive\\\\Documents\\\\2eme an\\xE9e\\\\Projet Favor Complet\\\\client\\\\src\\\\components\\\\Log\\\\Inscription.js\",\n _s = $RefreshSig$();\nimport React, { useState } from 'react';\nimport axios from \"axios\";\nimport Connexion from \"./Connexion\";\nimport { jsxDEV as _jsxDEV } from \"react/jsx-dev-runtime\";\nconst Inscription = () => {\n _s();\n const [formSubmit, setFormSubmit] = useState(false);\n const [pseudo, setPseudo] = useState(\"\");\n const [email, setEmail] = useState(\"\");\n const [password, setPassword] = useState(\"\");\n const [controlPassword, setControlPassword] = useState(\"\");\n const handleRegister = async e => {\n e.preventDefault();\n const terms = document.getElementById(\"terms\");\n const pseudoError = document.querySelector(\".pseudo.error\");\n const emailError = document.querySelector(\".email.error\");\n const passwordError = document.querySelector(\".password.error\");\n const passwordConfirmError = document.querySelector(\".password-confirm.error\");\n const termsError = document.querySelector(\".terms.error\");\n passwordConfirmError.innerHTML = \"\";\n termsError.innerHTML = \"\";\n if (password !== controlPassword || !terms.checked) {\n if (password !== controlPassword) passwordConfirmError.innerHTML = \"Les mots de passe ne correspondent pas\";\n if (!terms.checked) termsError.innerHTML = \"Veuillez valider les conditions générales\";\n } else {\n await axios({\n method: \"post\",\n url: `${process.env.REACT_APP_API_URL}api/user/register`,\n data: {\n pseudo,\n email,\n password\n }\n }).then(res => {\n console.log(res);\n if (res.data.errors) {\n pseudoError.innerHTML = res.data.errors.pseudo;\n emailError.innerHTML = res.data.errors.email;\n passwordError.innerHTML = res.data.errors.password;\n } else {\n setFormSubmit(true);\n }\n }).catch(err => console.log(err));\n }\n };\n return /*#__PURE__*/_jsxDEV(\"div\", {\n className: \"formulaire\",\n children: /*#__PURE__*/_jsxDEV(\"form\", {\n className: \"cadre\",\n children: [/*#__PURE__*/_jsxDEV(\"h1\", {\n children: \"INSCRIPTION\"\n }, void 0, false, {\n fileName: _jsxFileName,\n lineNumber: 60,\n columnNumber: 17\n }, this), /*#__PURE__*/_jsxDEV(\"div\", {\n className: \"inputbox\",\n children: [/*#__PURE__*/_jsxDEV(\"input\", {\n type: \"text\",\n required: \"required\"\n }, void 0, false, {\n fileName: _jsxFileName,\n lineNumber: 62,\n columnNumber: 21\n }, this), /*#__PURE__*/_jsxDEV(\"span\", {\n children: \"pseudo\"\n }, void 0, false, {\n fileName: _jsxFileName,\n lineNumber: 63,\n columnNumber: 21\n }, this)]\n }, void 0, true, {\n fileName: _jsxFileName,\n lineNumber: 61,\n columnNumber: 17\n }, this), /*#__PURE__*/_jsxDEV(\"div\", {\n className: \"inputbox\",\n children: [/*#__PURE__*/_jsxDEV(\"input\", {\n type: \"email\",\n required: \"required\"\n }, void 0, false, {\n fileName: _jsxFileName,\n lineNumber: 67,\n columnNumber: 21\n }, this), /*#__PURE__*/_jsxDEV(\"span\", {\n children: \"email\"\n }, void 0, false, {\n fileName: _jsxFileName,\n lineNumber: 68,\n columnNumber: 21\n }, this)]\n }, void 0, true, {\n fileName: _jsxFileName,\n lineNumber: 66,\n columnNumber: 17\n }, this), /*#__PURE__*/_jsxDEV(\"div\", {\n className: \"inputbox\",\n children: [/*#__PURE__*/_jsxDEV(\"input\", {\n type: \"password\",\n required: \"required\"\n }, void 0, false, {\n fileName: _jsxFileName,\n lineNumber: 72,\n columnNumber: 21\n }, this), /*#__PURE__*/_jsxDEV(\"span\", {\n children: \"mot de passe\"\n }, void 0, false, {\n fileName: _jsxFileName,\n lineNumber: 73,\n columnNumber: 21\n }, this)]\n }, void 0, true, {\n fileName: _jsxFileName,\n lineNumber: 71,\n columnNumber: 17\n }, this), /*#__PURE__*/_jsxDEV(\"div\", {\n className: \"inputbox\",\n children: [/*#__PURE__*/_jsxDEV(\"input\", {\n type: \"password\",\n required: \"required\"\n }, void 0, false, {\n fileName: _jsxFileName,\n lineNumber: 77,\n columnNumber: 21\n }, this), /*#__PURE__*/_jsxDEV(\"span\", {\n children: \"comfirmation mot de passe\"\n }, void 0, false, {\n fileName: _jsxFileName,\n lineNumber: 78,\n columnNumber: 21\n }, this)]\n }, void 0, true, {\n fileName: _jsxFileName,\n lineNumber: 76,\n columnNumber: 17\n }, this), /*#__PURE__*/_jsxDEV(\"input\", {\n type: \"submit\",\n value: \"inscription\"\n }, void 0, false, {\n fileName: _jsxFileName,\n lineNumber: 81,\n columnNumber: 17\n }, this), /*#__PURE__*/_jsxDEV(\"div\", {\n children: /*#__PURE__*/_jsxDEV(\"a\", {\n href: \"connection.html\",\n children: \"deja un compte?\"\n }, void 0, false, {\n fileName: _jsxFileName,\n lineNumber: 83,\n columnNumber: 21\n }, this)\n }, void 0, false, {\n fileName: _jsxFileName,\n lineNumber: 82,\n columnNumber: 17\n }, this)]\n }, void 0, true, {\n fileName: _jsxFileName,\n lineNumber: 59,\n columnNumber: 13\n }, this)\n }, void 0, false, {\n fileName: _jsxFileName,\n lineNumber: 58,\n columnNumber: 9\n }, this);\n};\n_s(Inscription, \"zuBpTmdP4YRPQ6ZaQpYYGosTei8=\");\n_c = Inscription;\nexport default Inscription;\nvar _c;\n$RefreshReg$(_c, \"Inscription\");","map":{"version":3,"names":["React","useState","axios","Connexion","Inscription","formSubmit","setFormSubmit","pseudo","setPseudo","email","setEmail","password","setPassword","controlPassword","setControlPassword","handleRegister","e","preventDefault","terms","document","getElementById","pseudoError","querySelector","emailError","passwordError","passwordConfirmError","termsError","innerHTML","checked","method","url","process","env","REACT_APP_API_URL","data","then","res","console","log","errors","catch","err"],"sources":["C:/Users/noanr/OneDrive/Documents/2eme anée/Projet Favor Complet/client/src/components/Log/Inscription.js"],"sourcesContent":["import React, { useState } from 'react';\r\nimport axios from \"axios\";\r\nimport Connexion from \"./Connexion\";\r\n\r\nconst Inscription = () => {\r\n const [formSubmit, setFormSubmit] = useState(false);\r\n const [pseudo, setPseudo] = useState(\"\");\r\n const [email, setEmail] = useState(\"\");\r\n const [password, setPassword] = useState(\"\");\r\n const [controlPassword, setControlPassword] = useState(\"\");\r\n \r\n const handleRegister = async (e) => {\r\n e.preventDefault();\r\n const terms = document.getElementById(\"terms\");\r\n const pseudoError = document.querySelector(\".pseudo.error\");\r\n const emailError = document.querySelector(\".email.error\");\r\n const passwordError = document.querySelector(\".password.error\");\r\n const passwordConfirmError = document.querySelector(\r\n \".password-confirm.error\"\r\n );\r\n const termsError = document.querySelector(\".terms.error\");\r\n \r\n passwordConfirmError.innerHTML = \"\";\r\n termsError.innerHTML = \"\";\r\n \r\n if (password !== controlPassword || !terms.checked) {\r\n if (password !== controlPassword)\r\n passwordConfirmError.innerHTML =\r\n \"Les mots de passe ne correspondent pas\";\r\n \r\n if (!terms.checked)\r\n termsError.innerHTML = \"Veuillez valider les conditions générales\";\r\n } else {\r\n await axios({\r\n method: \"post\",\r\n url: `${process.env.REACT_APP_API_URL}api/user/register`,\r\n data: {\r\n pseudo,\r\n email,\r\n password,\r\n },\r\n })\r\n .then((res) => {\r\n console.log(res);\r\n if (res.data.errors) {\r\n pseudoError.innerHTML = res.data.errors.pseudo;\r\n emailError.innerHTML = res.data.errors.email;\r\n passwordError.innerHTML = res.data.errors.password;\r\n } else {\r\n setFormSubmit(true);\r\n }\r\n })\r\n .catch((err) => console.log(err));\r\n }\r\n };\r\n\r\n return (\r\n