change functionality req from ssr to csr
This commit is contained in:
@@ -20,7 +20,7 @@ function Information({
|
||||
const [disable, setDisable] = useState(true);
|
||||
const [insurance, setInsurance] = useState();
|
||||
const [loading, setLoading] = useState(false);
|
||||
const [errors, setErrors] = useState();
|
||||
const [errors, setErrors] = useState({});
|
||||
|
||||
useEffect(() => {
|
||||
request.getInsuranceType().then((res) => {
|
||||
@@ -31,12 +31,19 @@ function Information({
|
||||
// .catch((err) => {});
|
||||
}, []);
|
||||
|
||||
const changeData = (value, type, name) => {
|
||||
const changeData = (value, name) => {
|
||||
setInformation({
|
||||
...information,
|
||||
[name]: value,
|
||||
});
|
||||
if (errors && errors[name]) {
|
||||
setErrors({
|
||||
...errors,
|
||||
[name]: false,
|
||||
});
|
||||
}
|
||||
};
|
||||
console.log(information);
|
||||
|
||||
const validationInfo = () => {};
|
||||
|
||||
@@ -44,9 +51,11 @@ function Information({
|
||||
setLoading(true);
|
||||
console.log(prevInfo);
|
||||
console.log(prevInfo ? true : false);
|
||||
console.log(information);
|
||||
|
||||
if (!validationInfo())
|
||||
request[prevInfo ? "patchUserProfile" : "postUserProfile"](
|
||||
data,
|
||||
information,
|
||||
prevInfo ? prevInfo.uuid : Cookies.get("uuid")
|
||||
)
|
||||
.then((res) => {
|
||||
@@ -83,6 +92,7 @@ function Information({
|
||||
variant="contained"
|
||||
onClick={sendReq}
|
||||
loading={loading}
|
||||
disabled={Object.values(errors).find((error) => error)}
|
||||
className={`!gap-[4px] !mr-auto !text-nowrap !flex !flex-nowrap !py-[8px]
|
||||
!rounded-[4px] !text-[14px] md:!text-[16px] !font-medium
|
||||
!mt-[32px] sm:!mt-[38px] md:!mt-[43px] lg:!mt-[48px] !px-[16px] sm:!px-[19px] md:!px-[22px] lg:!px-[24px]
|
||||
|
||||
Reference in New Issue
Block a user