Skip to content

Commit

Permalink
fix: Datetimepicker typecheck (#244)
Browse files Browse the repository at this point in the history
  • Loading branch information
adityachoudhari26 authored Dec 2, 2024
1 parent 8c72cc0 commit d9d948e
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 12 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -148,10 +148,13 @@ export const RolloutAndTiming: React.FC<{
onChange={(t) => {
onChange({
...value,
startTime: t.toDate(
Intl.DateTimeFormat().resolvedOptions()
.timeZone,
),
startTime:
t != null
? t.toDate(
Intl.DateTimeFormat().resolvedOptions()
.timeZone,
)
: new Date(),
});
}}
/>{" "}
Expand All @@ -161,10 +164,13 @@ export const RolloutAndTiming: React.FC<{
onChange={(t) => {
onChange({
...value,
endTime: t.toDate(
Intl.DateTimeFormat().resolvedOptions()
.timeZone,
),
endTime:
t != null
? t.toDate(
Intl.DateTimeFormat().resolvedOptions()
.timeZone,
)
: new Date(),
});
}}
aria-label="End Time"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ export const DateConditionRender: React.FC<DateConditionRenderProps> = ({
<div className="col-span-7">
<DateTimePicker
value={toZonedDateTime(new Date(value))}
onChange={setDate}
onChange={(value) => value != null && setDate(value)}
aria-label={type}
variant="filter"
/>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -272,7 +272,7 @@ export const JobHistoryChart: React.FC<{
animationDuration={animationDuration}
fill={color}
onClick={(e) => {
const start = new Date(e.date);
const start = new Date((e as any).date);
const end = addDays(start, 1);

const afterStartCondition: JobCondition = {
Expand Down
3 changes: 1 addition & 2 deletions packages/ui/src/date-time-picker/date-time-picker.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
/* eslint-disable @typescript-eslint/unbound-method */
"use client";

import type { DateValue } from "react-aria";
Expand Down Expand Up @@ -71,7 +70,7 @@ const DateTimePicker = React.forwardRef<
<TimeField
aria-label="time-field"
value={state.timeValue}
onChange={state.setTimeValue}
onChange={(value) => value != null && state.setTimeValue(value)}
/>
)}
</div>
Expand Down

0 comments on commit d9d948e

Please sign in to comment.