updated address section

This commit is contained in:
print-signs 2023-12-05 13:37:44 +05:30
parent 3a3bd79d2f
commit 3eb24add8b
2 changed files with 56 additions and 2 deletions

View File

@ -13,7 +13,7 @@
"license": "MIT",
"author": "The CoreUI Team (https://github.com/orgs/coreui/people)",
"scripts": {
"dev": "react-scripts start",
"dev": "SET NODE_OPTIONS=--openssl-legacy-provider && react-scripts start",
"build": "react-scripts build",
"build:n17": "react-scripts --openssl-legacy-provider build",
"changelog": "auto-changelog --starting-version 4.1.0 --commit-limit false --hide-credit",

View File

@ -18,6 +18,8 @@ function Address() {
const [website, setWebsite] = useState("");
const [contact, setContact] = useState("");
const [email, setEmail] = useState("");
const [latitude, setLatitude] = useState("");
const [longitude, setLongitude] = useState("");
useEffect(() => {
async function getConfiguration() {
@ -37,6 +39,8 @@ function Address() {
setWebsite(el.website);
setContact(el.contact);
setEmail(el.email);
setLatitude(el.latitude);
setLongitude(el.longitude);
});
});
}
@ -61,10 +65,30 @@ function Address() {
setContact(e.target.value);
} else if (e.target.name.toLowerCase() === "email") {
setEmail(e.target.value);
} else if (e.target.name.toLowerCase() === "latitude") {
setLatitude(e.target.value);
} else if (e.target.name.toLowerCase() === "longitude") {
setLongitude(e.target.value);
}
}
async function handelSubmit() {
setLoading(true);
if (
!company ||
!address ||
!city ||
!state ||
!country ||
!pincode ||
!website ||
!contact ||
!email ||
!longitude ||
!latitude
) {
setLoading(false);
return swal("Fill all the required filed!");
}
let data = {
company,
address,
@ -75,6 +99,8 @@ function Address() {
website,
contact,
email,
longitude,
latitude,
};
let res = await axios.post(`/api/config/address`, data, {
@ -82,10 +108,10 @@ function Address() {
Authorization: `Bearer ${token}`,
},
});
console.log(res);
if (res) {
setLoading(false);
console.log(res);
swal("Success!", res.data.message);
} else {
@ -238,6 +264,34 @@ function Address() {
className="form-control input-field "
id="basicpill-phoneno-input"
/>
<label
htmlFor="basicpill-phoneno-input"
className="label-100 mt-3"
>
Latitude
</label>
<input
value={latitude}
type="text"
name="latitude"
onChange={(e) => handelChange(e)}
className="form-control input-field "
id="basicpill-phoneno-input"
/>
<label
htmlFor="basicpill-phoneno-input"
className="label-100 mt-3"
>
Longitude
</label>
<input
value={longitude}
type="text"
name="longitude"
onChange={(e) => handelChange(e)}
className="form-control input-field "
id="basicpill-phoneno-input"
/>
</>
</div>
</div>