refactor(web): extract DatePickerWithRange component from assignment form#324
Conversation
Contributor
Author
|
Warning This pull request is not mergeable via GitHub because a downstack PR is open. Once all requirements are satisfied, merge this PR as a stack on Graphite.
This stack of pull requests is managed by Graphite. Learn more about stacking. |
This was referenced Mar 25, 2026
Greptile SummaryThis PR extracts date/time picker logic from the new-assignment page into a standalone Issues found:
Confidence Score: 3/5
Important Files Changed
Prompt To Fix All With AIThis is a comment left during a code review.
Path: apps/nextjs/src/components/date-picker-with-range.tsx
Line: 18
Comment:
**Unused `label` prop in type definition**
The `label?: string` prop is declared in the props interface but is never read or rendered inside the component. This dead code should be removed to keep the API clean.
```suggestion
required?: boolean;
```
How can I resolve this? If you propose a fix, please make it concise.
---
This is a comment left during a code review.
Path: apps/nextjs/src/components/date-picker-with-range.tsx
Line: 93-96
Comment:
**`undefined` passed to `setHours` minutes parameter makes date invalid**
`dateRange.from?.getMinutes()` evaluates to `undefined` when `dateRange.from` is `undefined`. Passing `undefined` explicitly (not omitting the argument) causes JavaScript to convert it to `NaN`, producing an Invalid Date. The same issue exists on lines 103–104 for `dateRange.to?.getMinutes()`, which is a more realistic code path: when a user clicks a start date first (which sets `from` but leaves `to = undefined`) and then clicks an end date, `newDateRange.to` is defined but `dateRange.to` is still `undefined`, so `newTo.setHours(0, undefined, 59, 999)` will corrupt the date.
Fix by using `?? 0` as a fallback, consistent with how `getHours()` is already handled:
```suggestion
newFrom.setHours(
dateRange.from?.getHours() ?? 0,
dateRange.from?.getMinutes() ?? 0,
);
```
And on lines 103–104:
```
newTo.setHours(
dateRange.to?.getHours() ?? 0,
dateRange.to?.getMinutes() ?? 0,
59,
999,
);
```
How can I resolve this? If you propose a fix, please make it concise.
---
This is a comment left during a code review.
Path: apps/nextjs/src/components/date-picker-with-range.test.tsx
Line: 8
Comment:
**Relative import instead of absolute path**
The project convention requires absolute imports starting with `~/`. This relative import should use the configured alias.
```suggestion
} from "~/components/date-picker-with-range";
```
**Rule Used:** Always use absolute paths (starting with '~/' or s... ([source](https://app.greptile.com/review/custom-context?memory=b2963068-1d68-42ee-accd-2fab5b14abcd))
**Learnt From**
[deltahacks/landing-12#5](https://github.com/deltahacks/landing-12/pull/5)
How can I resolve this? If you propose a fix, please make it concise.
---
This is a comment left during a code review.
Path: apps/nextjs/src/components/date-picker-with-range.test.tsx
Line: 131-133
Comment:
**Misleading test description**
The description "should return empty DateRange when newDateRange is undefined" is inaccurate — the implementation (and the assertions below) actually return the *original* `dateRange`, not an empty one. The description should be corrected to reflect the real behaviour.
```suggestion
it("should return the original dateRange when newDateRange is undefined", () => {
```
How can I resolve this? If you propose a fix, please make it concise.Reviews (1): Last reviewed commit: "refactor(web): extract DatePickerWithRan..." | Re-trigger Greptile |
17e7fec to
f53098e
Compare
e68763d to
799d2df
Compare
f53098e to
58944e3
Compare
799d2df to
ae75e40
Compare
58944e3 to
00327a6
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.

TL;DR
Extracted date picker functionality into a reusable component with comprehensive test coverage.
What changed?
DatePickerWithRangecomponent that encapsulates calendar selection and time input functionalityformatTime,defaultDateRange,updateDateRange,updateDateRangeTime) to the new component filedefaultDateRangeto set the end date 7 days after the start date instead of the same dayHow to test?
/teacher/classroom/[id]/assignment/new)Why make this change?
This refactoring improves code reusability by extracting the date picker logic into a standalone component that can be used across different parts of the application. The comprehensive test coverage ensures the date/time manipulation functions work correctly and prevents regressions. The simplified labels make the interface cleaner and more user-friendly.