Skip to content

Commit 41dc365

Browse files
committed
feat(frontend): resolve last day of month for date range
1 parent c51160b commit 41dc365

File tree

3 files changed

+19
-1
lines changed

3 files changed

+19
-1
lines changed

apps/frontend/package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@
2323
"@quassel/ui": "workspace:*",
2424
"@tanstack/react-query": "^5.59.20",
2525
"@tanstack/react-router": "^1.81.4",
26+
"date-fns": "^4.1.0",
2627
"nanostores": "^0.11.3",
2728
"openapi-fetch": "^0.13.0",
2829
"openapi-react-query": "^0.2.4",

apps/frontend/src/components/questionnaire/PeriodForm.tsx

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ import { Button, Flex, MonthPicker, Stack, TextInput } from "@quassel/ui";
33
import { i18n } from "../../stores/i18n";
44
import { useStore } from "@nanostores/react";
55
import { components } from "../../api.gen";
6+
import { endOfMonth } from "date-fns";
67

78
type FormValues = {
89
title: string;
@@ -27,9 +28,17 @@ export const messages = i18n("periodForm", {
2728
});
2829

2930
export function PeriodForm({ onSave, actionLabel }: PeriodFormProps) {
30-
const f = useForm<FormValues>({ mode: "uncontrolled" });
3131
const t = useStore(messages);
3232

33+
const f = useForm<FormValues>({
34+
mode: "uncontrolled",
35+
transformValues(values) {
36+
values.range[1] = endOfMonth(values.range[1]);
37+
38+
return values;
39+
},
40+
});
41+
3342
return (
3443
<form onSubmit={f.onSubmit((values) => onSave(mapValues(values)))}>
3544
<Stack>

pnpm-lock.yaml

Lines changed: 8 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)