Skip to content

Commit fc5837a

Browse files
[Release 1] [Bug Bash] Fix 1 (#173) (#174)
Challenges-App MFE Bug Bash Release 1
1 parent cbdd2e2 commit fc5837a

File tree

31 files changed

+500
-206
lines changed

31 files changed

+500
-206
lines changed

.circleci/config.yml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,6 @@ workflows:
7777
branches:
7878
only:
7979
- dev
80-
- submission-page
8180

8281
# Production builds are exectuted only on tagged commits to the
8382
# master branch.

config/dev.js

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -139,4 +139,8 @@ module.exports = {
139139
process.env.FILESTACK_SUBMISSION_CONTAINER ||
140140
"topcoder-dev-submissions-dmz",
141141
},
142+
/* Time in MS to wait before refreshing challenge details after register
143+
* and unregister. Used to allow API sufficent time to update.
144+
*/
145+
CHALLENGE_DETAILS_REFRESH_DELAY: 3000,
142146
};

config/prod.js

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -134,4 +134,8 @@ module.exports = {
134134
process.env.FILESTACK_SUBMISSION_CONTAINER ||
135135
"topcoder-dev-submissions-dmz",
136136
},
137+
/* Time in MS to wait before refreshing challenge details after register
138+
* and unregister. Used to allow API sufficent time to update.
139+
*/
140+
CHALLENGE_DETAILS_REFRESH_DELAY: 3000,
137141
};

src/components/DateRangePicker/DateInput/index.jsx

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ const DateInput = ({
2020
onClickCalendarIcon,
2121
onStartEndDateChange,
2222
placeholder,
23+
enterToSubmit,
2324
}) => {
2425
const ref = useRef(null);
2526
const [focused, setFocused] = useState(false);
@@ -125,7 +126,14 @@ const DateInput = ({
125126
size="xs"
126127
value={rangeText}
127128
onChange={(value) => {
128-
onChangeRangeTextDebounced.current(() => onChangeRangeText(value));
129+
if (!enterToSubmit) {
130+
onChangeRangeTextDebounced.current(() =>
131+
onChangeRangeText(value)
132+
);
133+
}
134+
}}
135+
onEnterKey={(value) => {
136+
onChangeRangeText(value);
129137
}}
130138
placeholder={placeholder}
131139
/>

src/components/DateRangePicker/helpers.js

Lines changed: 15 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -50,39 +50,45 @@ const staticRangeHandler = {
5050
* @return {object[]} list of defined ranges
5151
*/
5252
export function createStaticRanges() {
53-
const now = moment().utcOffset(0);
54-
const pastWeek = now.clone().subtract(1, "week");
55-
const pastMonth = now.clone().subtract(1, "month");
56-
const past6Months = now.clone().subtract(6, "month");
57-
const pastYear = now.clone().subtract(1, "year");
53+
const today = moment();
54+
const endOfToday = today.set({
55+
hour: 23,
56+
minute: 59,
57+
second: 59,
58+
millisecond: 999,
59+
});
60+
const pastWeek = endOfToday.clone().subtract(1, "week");
61+
const pastMonth = endOfToday.clone().subtract(1, "month");
62+
const past6Months = endOfToday.clone().subtract(6, "month");
63+
const pastYear = endOfToday.clone().subtract(1, "year");
5864

5965
const ranges = [
6066
{
6167
label: "Past Week",
6268
range: () => ({
6369
startDate: pastWeek.startOf("day").toDate(),
64-
endDate: now.endOf("day").toDate(),
70+
endDate: endOfToday.toDate(),
6571
}),
6672
},
6773
{
6874
label: "Past Month",
6975
range: () => ({
7076
startDate: pastMonth.startOf("day").toDate(),
71-
endDate: now.endOf("day").toDate(),
77+
endDate: endOfToday.toDate(),
7278
}),
7379
},
7480
{
7581
label: "Past 6 Months",
7682
range: () => ({
7783
startDate: past6Months.startOf("day").toDate(),
78-
endDate: now.endOf("day").toDate(),
84+
endDate: endOfToday.toDate(),
7985
}),
8086
},
8187
{
8288
label: "Past Year",
8389
range: () => ({
8490
startDate: pastYear.startOf("day").toDate(),
85-
endDate: now.endOf("day").toDate(),
91+
endDate: endOfToday.toDate(),
8692
}),
8793
},
8894
];

src/components/DateRangePicker/index.jsx

Lines changed: 72 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ import {
1616
} from "./helpers";
1717

1818
function DateRangePicker(props) {
19-
const { id, range, onChange, placeholder } = props;
19+
const { id, range, onChange, placeholder, enterToSubmit = false } = props;
2020

2121
const [rangeString, setRangeString] = useState({
2222
startDateString: "",
@@ -269,6 +269,37 @@ function DateRangePicker(props) {
269269
setPreview(null);
270270
};
271271

272+
const onReset = (presetRange) => {
273+
let newStartDate;
274+
let newEndDate;
275+
276+
if (presetRange) {
277+
newStartDate = presetRange.startDate;
278+
newEndDate = presetRange.endDate;
279+
}
280+
281+
setFocusedRange([0, 0]);
282+
283+
setErrors({
284+
startDate: "",
285+
endDate: "",
286+
});
287+
288+
setRangeString({
289+
startDateString: newStartDate
290+
? moment(newStartDate).format("MMM D, YYYY")
291+
: "",
292+
endDateString: newEndDate ? moment(newEndDate).format("MMM D, YYYY") : "",
293+
});
294+
295+
onChange({
296+
startDate: newStartDate ? moment(newStartDate) : null,
297+
endDate: newEndDate ? moment(newEndDate) : null,
298+
});
299+
300+
setIsComponentVisible(false);
301+
}
302+
272303
/**
273304
* Event handler on date selection changes
274305
* @param {Object} newRange nnew range that has endDate and startDate data
@@ -344,8 +375,19 @@ function DateRangePicker(props) {
344375
const onPreviewChange = (date) => {
345376
if (!(date instanceof Date)) {
346377
setPreview(null);
347-
setActiveDate(null);
348-
setFocusedRange([0, focusedRange[1]]);
378+
379+
// ---
380+
// workaround for fixing issue 132:
381+
// - set the active range's background to transparent color
382+
// to prevent the calendar auto focusing on the day of today by default when no
383+
// start date nor end date are set.
384+
// - does not set focus on the selection range when mouse leaves.
385+
// ---
386+
387+
// setActiveDate(null);
388+
// if (range.startDate || range.endDate) {
389+
// setFocusedRange([0, focusedRange[1]]);
390+
// }
349391
return;
350392
}
351393

@@ -485,7 +527,7 @@ function DateRangePicker(props) {
485527
startDate: activeDate,
486528
endDate: activeDate,
487529
key: "active",
488-
color: "#D8FDD8",
530+
color: preview ? "#D8FDD8" : "#D8FDD800",
489531
},
490532
];
491533
}
@@ -538,6 +580,7 @@ function DateRangePicker(props) {
538580
}}
539581
onStartEndDateChange={onStartEndDateChange}
540582
placeholder={placeholder}
583+
enterToSubmit={enterToSubmit}
541584
/>
542585
</div>
543586
<div ref={calendarRef} styleName="calendar-container">
@@ -546,9 +589,13 @@ function DateRangePicker(props) {
546589
<ReactDateRangePicker
547590
focusedRange={focusedRange}
548591
onRangeFocusChange={setFocusedRange}
549-
onChange={(item) =>
550-
onDateRangePickerChange(item.selection || item.active)
551-
}
592+
onChange={(item) => {
593+
if (!preview) {
594+
onReset(item.selection || item.active);
595+
} else {
596+
onDateRangePickerChange(item.selection || item.active);
597+
}
598+
}}
552599
dateDisplayFormat="MM/dd/yyyy"
553600
showDateDisplay={false}
554601
staticRanges={createStaticRanges()}
@@ -562,18 +609,24 @@ function DateRangePicker(props) {
562609
preview={preview}
563610
onPreviewChange={onPreviewChange}
564611
/>
565-
<button
566-
type="button"
567-
styleName="reset-button"
568-
onClick={() => {
569-
onDateRangePickerChange({
570-
startDate: null,
571-
endDate: null,
572-
});
573-
}}
574-
>
575-
Reset
576-
</button>
612+
<div styleName="calendar-footer">
613+
<button
614+
type="button"
615+
styleName="calendar-button"
616+
onClick={onReset}
617+
>
618+
Reset
619+
</button>
620+
<button
621+
type="button"
622+
styleName="calendar-button"
623+
onClick={() => {
624+
setIsComponentVisible(false);
625+
}}
626+
>
627+
Close
628+
</button>
629+
</div>
577630
</div>
578631
)}
579632
</div>

src/components/DateRangePicker/style.scss

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -348,6 +348,10 @@ $darkGreen: #0AB88A;;
348348
}
349349
}
350350

351+
.rdrStartEdge.rdrEndEdge ~ .rdrDayNumber span {
352+
color: $tc-black;
353+
}
354+
351355
.rdrDayNumber {
352356
top: 0;
353357
bottom: 0;
@@ -391,6 +395,7 @@ $darkGreen: #0AB88A;;
391395
z-index: 10;
392396

393397
@include phone {
398+
width: 100vw;
394399
position: fixed;
395400
top: 0;
396401
left: 0;
@@ -402,7 +407,15 @@ $darkGreen: #0AB88A;;
402407
border-radius: 0;
403408
}
404409

405-
.reset-button {
410+
.calendar-footer {
411+
width: 100%;
412+
413+
@include phone {
414+
padding: 0 20px;
415+
}
416+
}
417+
418+
.calendar-button {
406419
@include roboto-bold;
407420

408421
width: 71px;
@@ -421,7 +434,7 @@ $darkGreen: #0AB88A;;
421434
height: 26px;
422435
line-height: 27px;
423436
font-size: 12px;
424-
margin: 20px 12px 0;
437+
margin: 0 12px 0;
425438
}
426439
}
427440
}

src/components/DropdownTerms/index.jsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -51,8 +51,8 @@ function DropdownTerms({
5151
}
5252
}, [focused, selectedOption]);
5353
useEffect(() => {
54-
setInternalTerms(terms);
55-
}, [terms]);
54+
setInternalTerms(terms); // eslint-disable-next-line react-hooks/exhaustive-deps
55+
}, [terms && terms.length]);
5656

5757
const CustomReactSelectRow = React.forwardRef(
5858
({ className, option, children, onSelect }, ref) =>
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
import React from "react";
2+
import IconNotFound from "assets/icons/not-found.png";
3+
4+
import "./styles.scss";
5+
6+
const NotFoundError = ({ message }) => (
7+
<div styleName="not-found-error">
8+
<div>
9+
<img src={IconNotFound} alt="not found" />
10+
</div>
11+
<h1>404 Not found</h1>
12+
<p>Sorry, we couldn’t find that page</p>
13+
</div>
14+
);
15+
16+
export default NotFoundError;
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
@import "styles/variables";
2+
3+
.not-found-error {
4+
padding: 16px 24px;
5+
min-height: 136px;
6+
margin-bottom: 35px;
7+
font-size: $font-size-sm;
8+
line-height: 22px;
9+
text-align: center;
10+
background: $white;
11+
border-radius: $border-radius-lg;
12+
13+
h1 {
14+
padding: 15px 0 10px;
15+
margin-bottom: 20px;
16+
}
17+
18+
p {
19+
margin-bottom: 8px;
20+
}
21+
}

0 commit comments

Comments
 (0)