|
|
|
@ -3,13 +3,14 @@ import onInput from "~/util/onInput"; |
|
|
|
|
import Input from "../Input/index"; |
|
|
|
|
import "./index.scss"; |
|
|
|
|
import moment from "jalali-moment"; |
|
|
|
|
|
|
|
|
|
export default function Birthdate(props) { |
|
|
|
|
const { defaultValue, parent, name } = props; |
|
|
|
|
let momentDate = moment(defaultValue[name]); |
|
|
|
|
let isvalid = momentDate.isValid(); |
|
|
|
|
const day = isvalid ? momentDate.format("jDD") : null, |
|
|
|
|
month = isvalid ? momentDate.format("jMM") : null, |
|
|
|
|
year = isvalid ? momentDate.format("jYYYY") : null; |
|
|
|
|
let isvalid = momentDate?.isValid(); |
|
|
|
|
const day = isvalid ? momentDate?.format("jDD") : null, |
|
|
|
|
month = isvalid ? momentDate?.format("jMM") : null, |
|
|
|
|
year = isvalid ? momentDate?.format("jYYYY") : null; |
|
|
|
|
const [state, setState] = useState({ day, month, year }); |
|
|
|
|
const onChange = (_name, value) => { |
|
|
|
|
let _state = { ...state, [_name]: value }; |
|
|
|
@ -18,7 +19,11 @@ export default function Birthdate(props) { |
|
|
|
|
parent.onChange( |
|
|
|
|
name, |
|
|
|
|
moment |
|
|
|
|
.from(`${_state.year}/${_state.month}/${_state.day}`, "fa", "YYYY/M/D") |
|
|
|
|
.from( |
|
|
|
|
`${_state?.year}/${_state?.month}/${_state?.day}`, |
|
|
|
|
"fa", |
|
|
|
|
"YYYY/M/D" |
|
|
|
|
) |
|
|
|
|
.locale("en") |
|
|
|
|
); |
|
|
|
|
}; |
|
|
|
|