minor changes

This commit is contained in:
VividTruthKeeper 2022-04-11 23:11:39 +05:00
parent c386afa16e
commit 719b03c732
6 changed files with 40 additions and 182 deletions

View File

@ -1,7 +1,6 @@
import axios from "axios";
// import { getDate } from "../helpers/Date";
export const sendRequestCard = (url, token, data, setLoader, setError) => {
export const sendRequestCard = (url, token, data) => {
let today = new Date();
let dd = String(today.getDate()).padStart(2, "0");
let mm = String(today.getMonth() + 1).padStart(2, "0");
@ -34,15 +33,6 @@ export const sendRequestCard = (url, token, data, setLoader, setError) => {
.post(`${url}?token=${token}`, form)
.then((res) => {
window.open(res.data, "_self").focus();
if (setLoader) {
setLoader(false);
}
})
.catch(() => {
setLoader(false);
setError(true);
setTimeout(() => {
setError(false);
}, 2000);
});
.catch(() => {});
};

View File

@ -4,8 +4,6 @@ import { UserContext } from "../../backend/UserContext";
import { LanguageContext } from "../../backend/LanguageContext";
// IMPORT VALIDATORS
import { ValidateEmail } from "../../validators/ValidateEmail";
import { ValidatePhoneNumber } from "../../validators/ValidatePhoneNumber";
import { getDate } from "../../helpers/Date";
// IMPORT IMAGES
@ -15,7 +13,10 @@ import next_reverse from "../../icons/next-reverse.svg";
const CardStage2 = ({ setStage, data, setData }) => {
const { locale } = useContext(LanguageContext);
const { user } = useContext(UserContext);
const [inputValid, setInputValid] = useState({
const [
inputValid,
// setInputValid
] = useState({
surname: data.surname ? data.surname : user ? user.surname : null,
name: data.name ? data.name : user ? user.name : null,
fathers: data.middlename ? data.middlename : user ? user.middle_name : null,
@ -76,16 +77,10 @@ const CardStage2 = ({ setStage, data, setData }) => {
<span>*</span>
</label>
<input
readOnly
type="text"
id="surname"
defaultValue={inputValid.surname}
onChange={(e) => {
if (e.target.value !== "") {
setInputValid({ ...inputValid, surname: e.target.value });
} else {
setInputValid({ ...inputValid, surname: false });
}
}}
/>
</div>
<div className="input-block">
@ -94,16 +89,10 @@ const CardStage2 = ({ setStage, data, setData }) => {
<span>*</span>
</label>
<input
readOnly
type="text"
id="name"
defaultValue={inputValid.name}
onChange={(e) => {
if (e.target.value !== "") {
setInputValid({ ...inputValid, name: e.target.value });
} else {
setInputValid({ ...inputValid, name: false });
}
}}
/>
</div>
<div className="input-block">
@ -112,16 +101,10 @@ const CardStage2 = ({ setStage, data, setData }) => {
<span>*</span>
</label>
<input
readOnly
type="text"
id="fathers"
defaultValue={inputValid.fathers}
onChange={(e) => {
if (e.target.value !== "") {
setInputValid({ ...inputValid, fathers: e.target.value });
} else {
setInputValid({ ...inputValid, fathers: false });
}
}}
/>
</div>
<div className="input-block">
@ -130,18 +113,12 @@ const CardStage2 = ({ setStage, data, setData }) => {
<span>*</span>
</label>
<input
readOnly
type="date"
id="date"
defaultValue={inputValid.date}
min="1900-01-01"
max={getDate(18)}
onChange={(e) => {
if (e.target.value !== "") {
setInputValid({ ...inputValid, date: e.target.value });
} else {
setInputValid({ ...inputValid, date: false });
}
}}
/>
</div>
<div className="input-block">
@ -150,16 +127,10 @@ const CardStage2 = ({ setStage, data, setData }) => {
<span>*</span>
</label>
<input
readOnly
type="text"
id="passport"
defaultValue={inputValid.passport}
onChange={(e) => {
if (e.target.value !== "") {
setInputValid({ ...inputValid, passport: e.target.value });
} else {
setInputValid({ ...inputValid, passport: false });
}
}}
/>
</div>
<div className="input-block">
@ -170,16 +141,10 @@ const CardStage2 = ({ setStage, data, setData }) => {
<span>*</span>
</label>
<input
readOnly
type="text"
id="p-address"
defaultValue={inputValid.p_address}
onChange={(e) => {
if (e.target.value !== "") {
setInputValid({ ...inputValid, p_address: e.target.value });
} else {
setInputValid({ ...inputValid, p_address: false });
}
}}
/>
</div>
<div className="input-block">
@ -188,16 +153,10 @@ const CardStage2 = ({ setStage, data, setData }) => {
<span>*</span>
</label>
<input
readOnly
type="text"
id="address"
defaultValue={inputValid.address}
onChange={(e) => {
if (e.target.value !== "") {
setInputValid({ ...inputValid, address: e.target.value });
} else {
setInputValid({ ...inputValid, address: false });
}
}}
/>
</div>
<div className="input-block">
@ -206,16 +165,10 @@ const CardStage2 = ({ setStage, data, setData }) => {
<span>*</span>
</label>
<input
readOnly
type="email"
id="mail"
defaultValue={inputValid.mail}
onChange={(e) => {
if (ValidateEmail(e.target.value)) {
setInputValid({ ...inputValid, mail: e.target.value });
} else {
setInputValid({ ...inputValid, mail: false });
}
}}
/>
</div>
<div className="input-block">
@ -224,16 +177,10 @@ const CardStage2 = ({ setStage, data, setData }) => {
<span>*</span>
</label>
<input
readOnly
type="text"
id="mobile"
defaultValue={inputValid.mobile}
onChange={(e) => {
if (ValidatePhoneNumber(e.target.value)) {
setInputValid({ ...inputValid, mobile: e.target.value });
} else {
setInputValid({ ...inputValid, mobile: false });
}
}}
/>
</div>
<div className="input-block">
@ -241,16 +188,10 @@ const CardStage2 = ({ setStage, data, setData }) => {
{locale === "TUK" ? "Öý telefon" : "Домашний телефон"}
</label>
<input
readOnly
type="text"
id="homeTel"
defaultValue={inputValid.home}
onChange={(e) => {
if (ValidatePhoneNumber(e.target.value)) {
setInputValid({ ...inputValid, home: e.target.value });
} else {
setInputValid({ ...inputValid, home: false });
}
}}
/>
</div>
</div>

View File

@ -71,15 +71,6 @@ const CardStage6 = ({
: data.sms_notification
? "Да"
: "Нет"}
{/* {data.sms_notification
? locale === "RUS"
? data.sms_notification === true
? "Да"
: "Нет"
: data.sms_notification === true
? "Hawa"
: "Ýok"
: "-"} */}
</h4>
</li>
<li>
@ -157,20 +148,7 @@ const CardStage6 = ({
onClick={() => {
setLoader(true);
setModalOpen(false);
sendRequestCard(
postUrl,
token,
data,
() => {
setSuccess(true);
setLoader(false);
setTimeout(() => {
setSuccess(false);
getUserInfo(getUrl, token, setUser, () => null);
}, 2000);
},
setError
);
sendRequestCard(postUrl, token, data);
}}
>
<div>

View File

@ -17,7 +17,7 @@ const CreditStage1 = ({ setStage, data, setData, creditData, id, setId }) => {
});
const [input, setInput] = useState(data.type ? data.type : null);
const [dropdown, setDropdown] = useState({
one: true,
one: false,
two: false,
});
const parser = new DOMParser();

View File

@ -4,8 +4,6 @@ import { UserContext } from "../../backend/UserContext";
import { LanguageContext } from "../../backend/LanguageContext";
// IMPORT VALIDATORS
import { ValidateEmail } from "../../validators/ValidateEmail";
import { ValidatePhoneNumber } from "../../validators/ValidatePhoneNumber";
import { getDate } from "../../helpers/Date";
// IMPORT IMAGES
@ -15,7 +13,10 @@ import next_reverse from "../../icons/next-reverse.svg";
const CreditStage3 = ({ setStage, data, setData }) => {
const { locale } = useContext(LanguageContext);
const { user } = useContext(UserContext);
const [inputValid, setInputValid] = useState({
const [
inputValid,
// setInputValid
] = useState({
surname: data.surname ? data.surname : user ? user.surname : null,
name: data.name ? data.name : user ? user.name : null,
fathers: data.fathers ? data.fathers : user ? user.middle_name : null,
@ -60,16 +61,10 @@ const CreditStage3 = ({ setStage, data, setData }) => {
<span>*</span>
</label>
<input
readOnly
type="text"
id="surname"
defaultValue={inputValid.surname}
onChange={(e) => {
if (e.target.value !== "") {
setInputValid({ ...inputValid, surname: e.target.value });
} else {
setInputValid({ ...inputValid, surname: false });
}
}}
/>
</div>
<div className="input-block">
@ -78,16 +73,10 @@ const CreditStage3 = ({ setStage, data, setData }) => {
<span>*</span>
</label>
<input
readOnly
type="text"
id="name"
defaultValue={inputValid.name}
onChange={(e) => {
if (e.target.value !== "") {
setInputValid({ ...inputValid, name: e.target.value });
} else {
setInputValid({ ...inputValid, name: false });
}
}}
/>
</div>
<div className="input-block">
@ -96,16 +85,10 @@ const CreditStage3 = ({ setStage, data, setData }) => {
<span>*</span>
</label>
<input
readOnly
type="text"
id="fathers"
defaultValue={inputValid.fathers}
onChange={(e) => {
if (e.target.value !== "") {
setInputValid({ ...inputValid, fathers: e.target.value });
} else {
setInputValid({ ...inputValid, fathers: false });
}
}}
/>
</div>
<div className="input-block">
@ -114,18 +97,12 @@ const CreditStage3 = ({ setStage, data, setData }) => {
<span>*</span>
</label>
<input
readOnly
type="date"
id="date"
defaultValue={inputValid.date}
min="1900-01-01"
max={getDate(18)}
onChange={(e) => {
if (e.target.value !== "") {
setInputValid({ ...inputValid, date: e.target.value });
} else {
setInputValid({ ...inputValid, date: false });
}
}}
/>
</div>
<div className="input-block">
@ -134,16 +111,10 @@ const CreditStage3 = ({ setStage, data, setData }) => {
<span>*</span>
</label>
<input
readOnly
type="text"
id="passport"
defaultValue={inputValid.passport}
onChange={(e) => {
if (e.target.value !== "") {
setInputValid({ ...inputValid, passport: e.target.value });
} else {
setInputValid({ ...inputValid, passport: false });
}
}}
/>
</div>
<div className="input-block">
@ -154,16 +125,10 @@ const CreditStage3 = ({ setStage, data, setData }) => {
<span>*</span>
</label>
<input
readOnly
type="text"
id="p-address"
defaultValue={inputValid.p_address}
onChange={(e) => {
if (e.target.value !== "") {
setInputValid({ ...inputValid, p_address: e.target.value });
} else {
setInputValid({ ...inputValid, p_address: false });
}
}}
/>
</div>
<div className="input-block">
@ -172,16 +137,10 @@ const CreditStage3 = ({ setStage, data, setData }) => {
<span>*</span>
</label>
<input
readOnly
type="text"
id="address"
defaultValue={inputValid.address}
onChange={(e) => {
if (e.target.value !== "") {
setInputValid({ ...inputValid, address: e.target.value });
} else {
setInputValid({ ...inputValid, address: false });
}
}}
/>
</div>
<div className="input-block">
@ -190,16 +149,10 @@ const CreditStage3 = ({ setStage, data, setData }) => {
<span>*</span>
</label>
<input
readOnly
type="email"
id="mail"
defaultValue={inputValid.mail}
onChange={(e) => {
if (ValidateEmail(e.target.value)) {
setInputValid({ ...inputValid, mail: e.target.value });
} else {
setInputValid({ ...inputValid, mail: false });
}
}}
/>
</div>
<div className="input-block">
@ -208,16 +161,10 @@ const CreditStage3 = ({ setStage, data, setData }) => {
<span>*</span>
</label>
<input
readOnly
type="text"
id="mobile"
defaultValue={inputValid.mobile}
onChange={(e) => {
if (ValidatePhoneNumber(e.target.value)) {
setInputValid({ ...inputValid, mobile: e.target.value });
} else {
setInputValid({ ...inputValid, mobile: false });
}
}}
/>
</div>
<div className="input-block">
@ -225,16 +172,10 @@ const CreditStage3 = ({ setStage, data, setData }) => {
{locale === "TUK" ? "Öý telefon" : "Домашний телефон"}
</label>
<input
readOnly
type="text"
id="homeTel"
defaultValue={inputValid.home}
onChange={(e) => {
if (ValidatePhoneNumber(e.target.value)) {
setInputValid({ ...inputValid, home: e.target.value });
} else {
setInputValid({ ...inputValid, home: false });
}
}}
/>
</div>
</div>

View File

@ -125,8 +125,16 @@ const LoggedNav = ({ sideOpen, setSideOpen }) => {
: "Данные профиля"}
</Link>
</li>
<li>
<Link to="/home/recovery">
{locale === "TUK"
? "Açar sözüni çalyşmak"
: "Смена пароля"}
</Link>
</li>
<li>
<button
type="button"
className="sign-out-btn"
onClick={() => {
deleteUser();