Skip to content

Commit

Permalink
fix(actionDate): use string instead of date
Browse files Browse the repository at this point in the history
  • Loading branch information
Clm-Roig committed May 14, 2022
1 parent 2d68c36 commit 91e6bcb
Show file tree
Hide file tree
Showing 5 changed files with 15 additions and 8 deletions.
2 changes: 1 addition & 1 deletion src/components/TrackerCard/TrackerCardActions.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ const TrackerCardActions: FC<Props> = ({
tracker
}) => {
const { requiredCompletions } = tracker;
const selectedDate = new Date(useAppSelector(selectSelectedDate));
const selectedDate = useAppSelector(selectSelectedDate);
const dispatch = useAppDispatch();
const { enqueueSnackbar, closeSnackbar } = useSnackbar();
const [isCompleteValidationOpen, setIsCompleteValidationOpen] = useState(false);
Expand Down
7 changes: 5 additions & 2 deletions src/store/trackers/reducers/archive.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ describe('trackers reducer', () => {
...initialState,
trackers: [{ ...testTracker1, status: TrackerStatus.ACTIVE }]
},
archiveTracker({ id: testTracker1.id, date: tenDaysAgo })
archiveTracker({ id: testTracker1.id, date: tenDaysAgo.toString() })
);
const t1 = finalState.trackers.find((t) => t.id === testTracker1Id)!;

Expand All @@ -37,7 +37,10 @@ describe('trackers reducer', () => {
{ ...testTracker3, status: TrackerStatus.ACTIVE }
]
},
archiveTrackers({ trackerIds: [testTracker1.id, testTracker2.id], date: tenDaysAgo })
archiveTrackers({
trackerIds: [testTracker1.id, testTracker2.id],
date: tenDaysAgo.toString()
})
);
const t1 = finalState.trackers.find((t) => t.id === testTracker1Id)!;
const t2 = finalState.trackers.find((t) => t.id === testTracker2Id)!;
Expand Down
2 changes: 1 addition & 1 deletion src/store/trackers/reducers/hide.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ describe('trackers reducer', () => {
const fiveDaysAgo = subDays(new Date(), 5);
const finalState = trackersReducer(
{ ...initialState, trackers: [testTracker1] },
hideTracker({ id: testTracker1.id, date: fiveDaysAgo })
hideTracker({ id: testTracker1.id, date: fiveDaysAgo.toString() })
);
const t1 = finalState.trackers.find((t) => t.id === testTracker1Id)!;
expect(isSameDay(new Date(t1.dateHidden!), fiveDaysAgo)).toBeTruthy();
Expand Down
4 changes: 2 additions & 2 deletions src/store/trackers/reducers/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,10 @@ import Tracker from '../../../models/Tracker';

export type TrackerIdAndDate = {
id: Tracker['id'];
date?: Date;
date?: string;
};

export type MultipleTrackerIdsAndDate = {
trackerIds: Array<Tracker['id']>;
date?: Date;
date?: string;
};
8 changes: 6 additions & 2 deletions src/store/trackers/reducers/validate.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ describe('trackers reducer', () => {
it('should handle a tracker complete validation at a given date', () => {
const finalState = trackersReducer(
{ ...initialState, trackers: [testTracker1] },
completelyValidate({ id: testTracker1Id, date: sevenDaysAgo })
completelyValidate({ id: testTracker1Id, date: sevenDaysAgo.toString() })
);

const res = finalState.trackers[0];
Expand All @@ -40,7 +40,11 @@ describe('trackers reducer', () => {
];
const finalState = trackersReducer(
{ ...initialState, trackers: [testTracker1] },
customValidate({ id: testTracker1Id, completions: partialCompletions, date: sevenDaysAgo })
customValidate({
id: testTracker1Id,
completions: partialCompletions,
date: sevenDaysAgo.toString()
})
);

const res = finalState.trackers[0];
Expand Down

0 comments on commit 91e6bcb

Please sign in to comment.