Web: People: fixed profile dates

This commit is contained in:
Nikita Gopienko 2022-02-24 15:48:02 +03:00
parent 356e00ceed
commit 2e000f1d9d
3 changed files with 16 additions and 10 deletions

View File

@ -146,7 +146,6 @@ class Calendar extends Component {
const openToDateYear = openToDate.getFullYear(); const openToDateYear = openToDate.getFullYear();
let disabled = false;
const listMonths = []; const listMonths = [];
let i = 0; let i = 0;
@ -154,12 +153,12 @@ class Calendar extends Component {
listMonths.push({ listMonths.push({
key: `${i}`, key: `${i}`,
label: `${months[i]}`, label: `${months[i]}`,
disabled: disabled, disabled: false,
}); });
i++; i++;
} }
if (openToDateYear <= minDateYear) { if (openToDateYear < minDateYear) {
i = 0; i = 0;
while (i != 12) { while (i != 12) {
if (i != minDateMonth) listMonths[i].disabled = true; if (i != minDateMonth) listMonths[i].disabled = true;
@ -173,7 +172,9 @@ class Calendar extends Component {
listMonths[i].disabled = true; listMonths[i].disabled = true;
i++; i++;
} }
} else if (openToDateYear === maxDateYear) { }
if (openToDateYear === maxDateYear) {
i = 11; i = 11;
while (i != maxDateMonth) { while (i != maxDateMonth) {
listMonths[i].disabled = true; listMonths[i].disabled = true;

View File

@ -20,6 +20,7 @@ class DateField extends React.Component {
inputOnChange, inputOnChange,
inputTabIndex, inputTabIndex,
calendarMinDate, calendarMinDate,
calendarMaxDate,
locale, locale,
maxLabelWidth, maxLabelWidth,
} = this.props; } = this.props;
@ -41,7 +42,7 @@ class DateField extends React.Component {
displayType="auto" displayType="auto"
calendarHeaderContent={calendarHeaderContent} calendarHeaderContent={calendarHeaderContent}
minDate={calendarMinDate ? calendarMinDate : new Date("1900/01/01")} minDate={calendarMinDate ? calendarMinDate : new Date("1900/01/01")}
maxDate={new Date()} maxDate={calendarMaxDate ? calendarMaxDate : new Date()}
locale={locale} locale={locale}
/> />
</FieldContainer> </FieldContainer>

View File

@ -249,7 +249,13 @@ class UpdateUserForm extends React.Component {
onBirthdayDateChange = (value) => { onBirthdayDateChange = (value) => {
var stateCopy = Object.assign({}, this.state); var stateCopy = Object.assign({}, this.state);
stateCopy.profile.birthday = value ? value.toJSON() : null; const birthday = value ? value.toJSON() : stateCopy.profile.workFrom;
stateCopy.profile.birthday = birthday;
if (new Date(birthday) > new Date(stateCopy.profile.workFrom)) {
stateCopy.profile.workFrom = birthday;
}
this.setState(stateCopy); this.setState(stateCopy);
this.setIsEdit(); this.setIsEdit();
}; };
@ -705,9 +711,6 @@ class UpdateUserForm extends React.Component {
? new Date(profile.birthday) ? new Date(profile.birthday)
: new Date(this.props.profile.workFrom); : new Date(this.props.profile.workFrom);
const workFromDateValue =
calendarWorkFrom <= calendarMinDate ? calendarMinDate : calendarWorkFrom;
return ( return (
<> <>
<MainContainer> <MainContainer>
@ -881,7 +884,7 @@ class UpdateUserForm extends React.Component {
calendarHeaderContent={`${t("CalendarSelectDate")}:`} calendarHeaderContent={`${t("CalendarSelectDate")}:`}
labelText={`${regDateCaption}:`} labelText={`${regDateCaption}:`}
inputName="workFrom" inputName="workFrom"
inputValue={workFromDateValue} inputValue={calendarWorkFrom}
inputIsDisabled={ inputIsDisabled={
isLoading || isLoading ||
!isAdmin || !isAdmin ||
@ -892,6 +895,7 @@ class UpdateUserForm extends React.Component {
calendarMinDate={calendarMinDate} calendarMinDate={calendarMinDate}
locale={language} locale={language}
maxLabelWidth={maxLabelWidth} maxLabelWidth={maxLabelWidth}
//calendarMaxDate={calendarMinDate}
/> />
)} )}
<TextField <TextField