updated the add address code
This commit is contained in:
parent
28a12730fc
commit
d7dcbb3c43
@ -76,16 +76,21 @@ function Address() {
|
|||||||
contact,
|
contact,
|
||||||
email,
|
email,
|
||||||
};
|
};
|
||||||
|
|
||||||
let res = await axios.post(`/api/config/address`, data, {
|
let res = await axios.post(`/api/config/address`, data, {
|
||||||
headers: {
|
headers: {
|
||||||
Authorization: `Bearer ${token}`,
|
Authorization: `Bearer ${token}`,
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
console.log(res);
|
||||||
|
|
||||||
if (res) {
|
if (res) {
|
||||||
setLoading(false);
|
setLoading(false);
|
||||||
console.log(res);
|
|
||||||
swal("Success!", res.data.message, res.data.status);
|
swal("Success!", res.data.message);
|
||||||
|
} else {
|
||||||
|
setLoading(false);
|
||||||
|
swal("something went wrong!", res.data.message);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1,24 +1,24 @@
|
|||||||
import React, { useEffect, useState } from 'react'
|
import React, { useEffect, useState } from "react";
|
||||||
|
|
||||||
import swal from 'sweetalert'
|
import swal from "sweetalert";
|
||||||
import ClipLoader from 'react-spinners/ClipLoader'
|
import ClipLoader from "react-spinners/ClipLoader";
|
||||||
import { Link } from 'react-router-dom'
|
import { Link } from "react-router-dom";
|
||||||
import axios from 'axios'
|
import axios from "axios";
|
||||||
import { isAutheticated } from 'src/auth'
|
import { isAutheticated } from "src/auth";
|
||||||
|
|
||||||
function Logo() {
|
function Logo() {
|
||||||
const [loading, setLoading] = useState(false)
|
const [loading, setLoading] = useState(false);
|
||||||
const [Headerlogo, setHeaderlogo] = useState('')
|
const [Headerlogo, setHeaderlogo] = useState("");
|
||||||
const [Footerlogo, setFooterlogo] = useState('')
|
const [Footerlogo, setFooterlogo] = useState("");
|
||||||
const [Adminlogo, setAdminlogo] = useState('')
|
const [Adminlogo, setAdminlogo] = useState("");
|
||||||
const [display, setDisplay] = useState(true)
|
const [display, setDisplay] = useState(true);
|
||||||
const token = isAutheticated()
|
const token = isAutheticated();
|
||||||
|
|
||||||
// urlcreated images
|
// urlcreated images
|
||||||
|
|
||||||
const [HeaderlogoUrl, setHeaderlogoUrl] = useState('')
|
const [HeaderlogoUrl, setHeaderlogoUrl] = useState("");
|
||||||
const [FooterlogoUrl, setFooterlogoUrl] = useState('')
|
const [FooterlogoUrl, setFooterlogoUrl] = useState("");
|
||||||
const [AdminlogoUrl, setAdminlogoUrl] = useState('')
|
const [AdminlogoUrl, setAdminlogoUrl] = useState("");
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
async function getConfiguration() {
|
async function getConfiguration() {
|
||||||
@ -26,16 +26,16 @@ function Logo() {
|
|||||||
headers: {
|
headers: {
|
||||||
Authorization: `Bearer ${token}`,
|
Authorization: `Bearer ${token}`,
|
||||||
},
|
},
|
||||||
})
|
});
|
||||||
|
|
||||||
configDetails.data.result.map((item) => {
|
configDetails.data.result.map((item) => {
|
||||||
setHeaderlogo(item?.logo[0]?.Headerlogo)
|
setHeaderlogo(item?.logo[0]?.Headerlogo);
|
||||||
setFooterlogo(item?.logo[0]?.Footerlogo)
|
setFooterlogo(item?.logo[0]?.Footerlogo);
|
||||||
setAdminlogo(item?.logo[0]?.Adminlogo)
|
setAdminlogo(item?.logo[0]?.Adminlogo);
|
||||||
})
|
});
|
||||||
}
|
}
|
||||||
getConfiguration()
|
getConfiguration();
|
||||||
}, [])
|
}, []);
|
||||||
|
|
||||||
// async function handelChange(e) {
|
// async function handelChange(e) {
|
||||||
// setDisplay(false);
|
// setDisplay(false);
|
||||||
@ -51,26 +51,28 @@ function Logo() {
|
|||||||
// }
|
// }
|
||||||
|
|
||||||
async function handelSubmit() {
|
async function handelSubmit() {
|
||||||
setLoading(true)
|
setLoading(true);
|
||||||
|
|
||||||
const formdata = new FormData()
|
const formdata = new FormData();
|
||||||
formdata.append('Headerlogo', Headerlogo)
|
formdata.append("Headerlogo", Headerlogo);
|
||||||
formdata.append('Footerlogo', Footerlogo)
|
formdata.append("Footerlogo", Footerlogo);
|
||||||
formdata.append('Adminlogo', Adminlogo)
|
formdata.append("Adminlogo", Adminlogo);
|
||||||
|
|
||||||
await axios.post(`/api/config/logo`, formdata, {
|
await axios
|
||||||
|
.post(`/api/config/logo`, formdata, {
|
||||||
headers: {
|
headers: {
|
||||||
Authorization: `Bearer ${token}`,
|
Authorization: `Bearer ${token}`,
|
||||||
'Content-Type': 'multipart/formdata',
|
"Content-Type": "multipart/formdata",
|
||||||
'Access-Control-Allow-Origin': '*',
|
"Access-Control-Allow-Origin": "*",
|
||||||
},
|
},
|
||||||
}).then((res) => {
|
|
||||||
setLoading(false)
|
|
||||||
swal('Success!', res.data.message, res.data.status)
|
|
||||||
}
|
|
||||||
).catch(error => {
|
|
||||||
console.log(error)
|
|
||||||
})
|
})
|
||||||
|
.then((res) => {
|
||||||
|
setLoading(false);
|
||||||
|
swal("Success!", res.data.message, res.data.status);
|
||||||
|
})
|
||||||
|
.catch((error) => {
|
||||||
|
console.log(error);
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
return (
|
return (
|
||||||
@ -102,25 +104,35 @@ function Logo() {
|
|||||||
type="file"
|
type="file"
|
||||||
name="Logo htmlFor Website Header(148 x 48 px)"
|
name="Logo htmlFor Website Header(148 x 48 px)"
|
||||||
onChange={(e) => {
|
onChange={(e) => {
|
||||||
setHeaderlogo(e.target.files[0])
|
setHeaderlogo(e.target.files[0]);
|
||||||
if (e.target.files && e.target.files[0]) {
|
if (
|
||||||
|
e.target.files &&
|
||||||
|
e.target.files[0]
|
||||||
|
) {
|
||||||
setHeaderlogoUrl({
|
setHeaderlogoUrl({
|
||||||
image: URL.createObjectURL(e.target.files[0]),
|
image: URL.createObjectURL(
|
||||||
})
|
e.target.files[0]
|
||||||
console.log(setHeaderlogoUrl)
|
),
|
||||||
|
});
|
||||||
|
console.log(setHeaderlogoUrl);
|
||||||
}
|
}
|
||||||
}}
|
}}
|
||||||
className="form-control input-field mb-3 col-md-6 d-inline-block"
|
className="form-control input-field mb-3 col-md-6 d-inline-block"
|
||||||
id="basicpill-phoneno-input"
|
id="basicpill-phoneno-input"
|
||||||
/>
|
/>
|
||||||
{display ? (
|
{display ? (
|
||||||
<img className='ms-1'
|
<img
|
||||||
style={{ width: '100px' }}
|
className="ms-1"
|
||||||
src={HeaderlogoUrl.image ? HeaderlogoUrl.image : Headerlogo}
|
style={{ width: "100px" }}
|
||||||
|
src={
|
||||||
|
HeaderlogoUrl.image
|
||||||
|
? HeaderlogoUrl.image
|
||||||
|
: Headerlogo
|
||||||
|
}
|
||||||
alt="header logo"
|
alt="header logo"
|
||||||
/>
|
/>
|
||||||
) : (
|
) : (
|
||||||
''
|
""
|
||||||
)}
|
)}
|
||||||
</div>
|
</div>
|
||||||
<label
|
<label
|
||||||
@ -133,25 +145,31 @@ function Logo() {
|
|||||||
type="file"
|
type="file"
|
||||||
name="Logo htmlFor Website Footer(148 x 48 px)"
|
name="Logo htmlFor Website Footer(148 x 48 px)"
|
||||||
onChange={(e) => {
|
onChange={(e) => {
|
||||||
setFooterlogo(e.target.files[0])
|
setFooterlogo(e.target.files[0]);
|
||||||
|
|
||||||
if (e.target.files && e.target.files[0]) {
|
if (e.target.files && e.target.files[0]) {
|
||||||
setFooterlogoUrl({
|
setFooterlogoUrl({
|
||||||
image: URL.createObjectURL(e.target.files[0]),
|
image: URL.createObjectURL(
|
||||||
})
|
e.target.files[0]
|
||||||
|
),
|
||||||
|
});
|
||||||
}
|
}
|
||||||
}}
|
}}
|
||||||
className="form-control input-field mt-1 col-md-6 d-inline-block"
|
className="form-control input-field mt-1 col-md-6 d-inline-block"
|
||||||
id="basicpill-phoneno-input"
|
id="basicpill-phoneno-input"
|
||||||
/>{' '}
|
/>{" "}
|
||||||
{display ? (
|
{display ? (
|
||||||
<img
|
<img
|
||||||
style={{ width: '100px' }}
|
style={{ width: "100px" }}
|
||||||
src={FooterlogoUrl.image ? FooterlogoUrl.image : Footerlogo}
|
src={
|
||||||
|
FooterlogoUrl.image
|
||||||
|
? FooterlogoUrl.image
|
||||||
|
: Footerlogo
|
||||||
|
}
|
||||||
alt="Footer logo"
|
alt="Footer logo"
|
||||||
/>
|
/>
|
||||||
) : (
|
) : (
|
||||||
''
|
""
|
||||||
)}
|
)}
|
||||||
<label
|
<label
|
||||||
htmlFor="basicpill-phoneno-input"
|
htmlFor="basicpill-phoneno-input"
|
||||||
@ -163,25 +181,31 @@ function Logo() {
|
|||||||
type="file"
|
type="file"
|
||||||
name="Logo htmlFor Admin Header(148 x 48 px)"
|
name="Logo htmlFor Admin Header(148 x 48 px)"
|
||||||
onChange={(e) => {
|
onChange={(e) => {
|
||||||
setAdminlogo(e.target.files[0])
|
setAdminlogo(e.target.files[0]);
|
||||||
|
|
||||||
if (e.target.files && e.target.files[0]) {
|
if (e.target.files && e.target.files[0]) {
|
||||||
setAdminlogoUrl({
|
setAdminlogoUrl({
|
||||||
image: URL.createObjectURL(e.target.files[0]),
|
image: URL.createObjectURL(
|
||||||
})
|
e.target.files[0]
|
||||||
|
),
|
||||||
|
});
|
||||||
}
|
}
|
||||||
}}
|
}}
|
||||||
className="form-control input-field col-md-6 d-inline-block"
|
className="form-control input-field col-md-6 d-inline-block"
|
||||||
id="basicpill-phoneno-input"
|
id="basicpill-phoneno-input"
|
||||||
/>{' '}
|
/>{" "}
|
||||||
{display ? (
|
{display ? (
|
||||||
<img
|
<img
|
||||||
style={{ width: '100px' }}
|
style={{ width: "100px" }}
|
||||||
src={AdminlogoUrl.image ? AdminlogoUrl.image : Adminlogo}
|
src={
|
||||||
|
AdminlogoUrl.image
|
||||||
|
? AdminlogoUrl.image
|
||||||
|
: Adminlogo
|
||||||
|
}
|
||||||
alt="Admin logo"
|
alt="Admin logo"
|
||||||
/>
|
/>
|
||||||
) : (
|
) : (
|
||||||
''
|
""
|
||||||
)}
|
)}
|
||||||
</>
|
</>
|
||||||
</div>
|
</div>
|
||||||
@ -196,7 +220,7 @@ function Logo() {
|
|||||||
className="btn btn-success btn-login waves-effect waves-light mr-3 pt-2 pb-2 pr-4 pl-4"
|
className="btn btn-success btn-login waves-effect waves-light mr-3 pt-2 pb-2 pr-4 pl-4"
|
||||||
>
|
>
|
||||||
<ClipLoader loading={loading} size={18} />
|
<ClipLoader loading={loading} size={18} />
|
||||||
{!loading && 'Save'}
|
{!loading && "Save"}
|
||||||
</button>
|
</button>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
@ -216,7 +240,7 @@ function Logo() {
|
|||||||
{/* <!-- End Page-content --> */}
|
{/* <!-- End Page-content --> */}
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
)
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
export default Logo
|
export default Logo;
|
||||||
|
Loading…
Reference in New Issue
Block a user