diff --git a/src/components/Calendar/Calendar.js b/src/components/Calendar/Calendar.js index 4644b14..c4826b4 100644 --- a/src/components/Calendar/Calendar.js +++ b/src/components/Calendar/Calendar.js @@ -28,10 +28,25 @@ class Calendar extends Component { minDate: '', maxDate: '', defaultDate: '', + hideDefaultValue: false, + }; + + state = { + currentMonth, + currentYear, + currentDay: 1, + dates: [], + showCalendar: false, + selectedDate: '', + today: '', + language: 'NE', + theme: 'default', + hideDefaultValue: this.props.hideDefaultValue, }; wrapperRef = React.createRef(); inputRef = React.createRef(); + componentDidMount() { let { currentYear, currentMonth, currentDay } = adToBs(); const language = this.validateLanguage(this.props.language); @@ -61,13 +76,20 @@ class Calendar extends Component { theme, }, () => { - this.props.onChange( + if (this.state.hideDefaultValue) this.formatDate( language === 'NE' ? convertFullDateToNepali(currentYear + '-' + currentMonth + '-' + currentDay) : getFullEnglishDate(currentYear + '-' + currentMonth + '-' + currentDay) - ) - ); + ); + else + this.props.onChange( + this.formatDate( + language === 'NE' + ? convertFullDateToNepali(currentYear + '-' + currentMonth + '-' + currentDay) + : getFullEnglishDate(currentYear + '-' + currentMonth + '-' + currentDay) + ) + ); } ); document.addEventListener('mousedown', this.handleClickOutside); @@ -87,19 +109,6 @@ class Calendar extends Component { } }; - state = { - currentMonth, - currentYear, - currentDay: 1, - dates: [], - showCalendar: false, - selectedDate: '', - today: '', - language: 'NE', - theme: 'default', - hideDefaultValue: this.props.hideDefaultValue || false, - }; - validateTheme = (th) => { let theme = th || 'default'; theme = theme.toString().toLowerCase(); diff --git a/src/utils/Config.js b/src/utils/Config.js index ee4e774..5aa1e71 100644 --- a/src/utils/Config.js +++ b/src/utils/Config.js @@ -294,7 +294,6 @@ const getFormattedDay = (language, length, index) => { } }; const getFormattedMonth = (language, index) => { - console.log(index); if (language === 'NE') { index = getEnglishNumber(index); index--;