Skip to content

Commit bfba9d7

Browse files
committed
Enable to Clear Date
1 parent d2ff899 commit bfba9d7

File tree

3 files changed

+30
-7
lines changed

3 files changed

+30
-7
lines changed

src/shared/components/Settings/Profile/Work/index.jsx

+12-6
Original file line numberDiff line numberDiff line change
@@ -148,12 +148,10 @@ export default class Work extends ConsentComponent {
148148
}
149149

150150
onUpdateDate(date, timePeriod) {
151-
if (date) {
152-
const { newWork: oldWork } = this.state;
153-
const newWork = { ...oldWork };
154-
newWork[timePeriod] = date;
155-
this.setState({ newWork, isSubmit: false });
156-
}
151+
const { newWork: oldWork } = this.state;
152+
const newWork = { ...oldWork };
153+
newWork[timePeriod] = date;
154+
this.setState({ newWork, isSubmit: false });
157155
}
158156

159157
/**
@@ -491,11 +489,13 @@ export default class Work extends ConsentComponent {
491489
<div styleName="field col-2">
492490
<DatePicker
493491
readOnly
492+
showClearDate
494493
numberOfMonths={1}
495494
isOutsideRange={moment().subtract(1, 'd')}
496495
date={newWork.timePeriodFrom}
497496
id="date-from1"
498497
onDateChange={date => this.onUpdateDate(date, 'timePeriodFrom')}
498+
onClearDate={date => this.onUpdateDate('', 'timePeriodFrom')}
499499
placeholder="dd/mm/yyyy"
500500
/>
501501
{
@@ -518,12 +518,14 @@ export default class Work extends ConsentComponent {
518518
<div styleName="field col-2">
519519
<DatePicker
520520
readOnly
521+
showClearDate
521522
disabled={endDateDisabled}
522523
numberOfMonths={1}
523524
isOutsideRange={moment().subtract(1, 'd')}
524525
date={newWork.timePeriodTo}
525526
id="date-to1"
526527
onDateChange={date => this.onUpdateDate(date, 'timePeriodTo')}
528+
onClearDate={date => this.onUpdateDate('', 'timePeriodTo')}
527529
placeholder="dd/mm/yyyy"
528530
/>
529531
{
@@ -642,11 +644,13 @@ export default class Work extends ConsentComponent {
642644
</label>
643645
<DatePicker
644646
readOnly
647+
showClearDate
645648
numberOfMonths={1}
646649
isOutsideRange={moment().subtract(1, 'd')}
647650
date={newWork.timePeriodFrom}
648651
id="date-from2"
649652
onDateChange={date => this.onUpdateDate(date, 'timePeriodFrom')}
653+
onClearDate={date => this.onUpdateDate('', 'timePeriodFrom')}
650654
placeholder="dd/mm/yyyy"
651655
/>
652656
{
@@ -665,12 +669,14 @@ export default class Work extends ConsentComponent {
665669
</label>
666670
<DatePicker
667671
readOnly
672+
showClearDate
668673
disabled={endDateDisabled}
669674
numberOfMonths={1}
670675
isOutsideRange={moment().subtract(1, 'd')}
671676
date={newWork.timePeriodTo}
672677
id="date-to2"
673678
onDateChange={date => this.onUpdateDate(date, 'timePeriodTo')}
679+
onClearDate={date => this.onUpdateDate('', 'timePeriodTo')}
674680
placeholder="dd/mm/yyyy"
675681
/>
676682
{

src/shared/components/Settings/Profile/Work/styles.scss

+14
Original file line numberDiff line numberDiff line change
@@ -349,6 +349,20 @@ label {
349349
display: none;
350350
}
351351
}
352+
353+
:global {
354+
.SingleDatePickerInput_clearDate {
355+
height: 35px;
356+
width: 35px;
357+
display: flex;
358+
align-items: center;
359+
top: calc(50% - 5px);
360+
}
361+
362+
.SingleDatePickerInput__showClearDate {
363+
padding-right: 0;
364+
}
365+
}
352366
}
353367

354368
.button-container {

src/shared/components/challenge-listing/Filters/DatePicker.jsx

+4-1
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ import './_fix_SingleDatePicker.css';
1212

1313
const propTypes = {
1414
autoFocus: PropTypes.bool,
15+
showClearDate: PropTypes.bool,
1516
allowFutureYear: PropTypes.bool,
1617

1718
...omit({}, [
@@ -25,6 +26,7 @@ const propTypes = {
2526
const defaultProps = {
2627
autoFocus: false,
2728
allowFutureYear: false,
29+
showClearDate: false,
2830
};
2931

3032
class DatePicker extends React.Component {
@@ -53,7 +55,7 @@ class DatePicker extends React.Component {
5355
render() {
5456
const { focused, allowFutureYear } = this.state;
5557
const {
56-
id, date, onDateChange, isOutsideRange,
58+
id, date, onDateChange, isOutsideRange, showClearDate,
5759
} = this.props;
5860

5961
const props = omit(this.props, [
@@ -75,6 +77,7 @@ class DatePicker extends React.Component {
7577
focused={focused}
7678
onDateChange={onDateChange}
7779
onFocusChange={this.onFocusChange}
80+
showClearDate={showClearDate}
7881
renderMonthElement={({ month, onMonthSelect, onYearSelect }) => (
7982
<div style={{ display: 'flex', justifyContent: 'center' }}>
8083
<div>

0 commit comments

Comments
 (0)