formatting
This commit is contained in:
@@ -8,16 +8,11 @@ const PersianTextField = (props) => {
|
||||
|
||||
const handleChange = (value) => {
|
||||
fieldOnChange(value);
|
||||
}
|
||||
};
|
||||
|
||||
usePersianInput(inputRef, handleChange);
|
||||
|
||||
return (
|
||||
<TextField
|
||||
ref={inputRef}
|
||||
{...rest}
|
||||
/>
|
||||
);
|
||||
return <TextField ref={inputRef} {...rest} />;
|
||||
};
|
||||
|
||||
export default PersianTextField
|
||||
export default PersianTextField;
|
||||
|
||||
@@ -5,7 +5,7 @@ function SelectBox({
|
||||
value,
|
||||
onChange,
|
||||
isDependency = false,
|
||||
dependencyLabel = '',
|
||||
dependencyLabel = "",
|
||||
onBlur,
|
||||
selectors,
|
||||
label,
|
||||
@@ -31,11 +31,17 @@ function SelectBox({
|
||||
onBlur={onBlur}
|
||||
>
|
||||
{isDependency ? (
|
||||
<MenuItem value={'dependency'} sx={{ color: "primary.main" }}>{dependencyLabel}</MenuItem>
|
||||
<MenuItem value={"dependency"} sx={{ color: "primary.main" }}>
|
||||
{dependencyLabel}
|
||||
</MenuItem>
|
||||
) : isLoading ? (
|
||||
<MenuItem value={'loading'} sx={{ color: "primary.main" }}>درحال دریافت اطلاعات...</MenuItem>
|
||||
<MenuItem value={"loading"} sx={{ color: "primary.main" }}>
|
||||
درحال دریافت اطلاعات...
|
||||
</MenuItem>
|
||||
) : errorEcured ? (
|
||||
<MenuItem value={'error'} sx={{ color: "secondary.main" }}>خطا در دریافت اطلاعات!!!</MenuItem>
|
||||
<MenuItem value={"error"} sx={{ color: "secondary.main" }}>
|
||||
خطا در دریافت اطلاعات!!!
|
||||
</MenuItem>
|
||||
) : (
|
||||
selectors.map((selector) => {
|
||||
return (
|
||||
|
||||
@@ -1,11 +1,21 @@
|
||||
function validateNationalCode(code) {
|
||||
const invalidCodes = ["1111111111", "2222222222", "3333333333", "4444444444", "5555555555", "6666666666", "7777777777", "8888888888", "9999999999"];
|
||||
const invalidCodes = [
|
||||
"1111111111",
|
||||
"2222222222",
|
||||
"3333333333",
|
||||
"4444444444",
|
||||
"5555555555",
|
||||
"6666666666",
|
||||
"7777777777",
|
||||
"8888888888",
|
||||
"9999999999",
|
||||
];
|
||||
if (invalidCodes.includes(code)) return false;
|
||||
|
||||
const L = code.length;
|
||||
if (L < 8 || parseInt(code, 10) === 0) return false;
|
||||
|
||||
code = code.padStart(10, '0');
|
||||
code = code.padStart(10, "0");
|
||||
if (parseInt(code.substr(3, 6), 10) === 0) return false;
|
||||
|
||||
const c = parseInt(code.charAt(9), 10);
|
||||
@@ -14,7 +24,7 @@ function validateNationalCode(code) {
|
||||
s += parseInt(code.charAt(i), 10) * (10 - i);
|
||||
}
|
||||
s = s % 11;
|
||||
return (s < 2 && c === s) || (s >= 2 && c === (11 - s));
|
||||
return (s < 2 && c === s) || (s >= 2 && c === 11 - s);
|
||||
}
|
||||
|
||||
export default validateNationalCode;
|
||||
export default validateNationalCode;
|
||||
|
||||
Reference in New Issue
Block a user