Skip to content

Commit f15ac33

Browse files
committed
fe: fix page size issue
1 parent e9f05b2 commit f15ac33

File tree

2 files changed

+9
-35
lines changed

2 files changed

+9
-35
lines changed

frontend/components/form/form-responses.tsx

Lines changed: 2 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -24,8 +24,6 @@ import { ScrollArea, ScrollBar } from "@/components/ui/scroll-area";
2424
import { FORM_URLS } from "@/config/api-urls";
2525
import { tokenService } from "@/lib/services/token";
2626
import { formatDate, formatDateTime } from "@/lib/utils";
27-
import { SelectTrigger, SelectValue } from "@radix-ui/react-select";
28-
import { Select, SelectContent, SelectItem } from "../ui/select";
2927

3028
// Define response type based on your API structure
3129
interface FormResponse {
@@ -44,7 +42,7 @@ export default function FormResponses({ form }: FormResponsesProps) {
4442
const [error, setError] = useState<string | null>(null);
4543
const [pagination, setPagination] = useState<PaginationState>({
4644
pageIndex: 0,
47-
pageSize: 10,
45+
pageSize: 10, // Fixed page size
4846
});
4947

5048
// Fetch form responses
@@ -218,34 +216,7 @@ export default function FormResponses({ form }: FormResponsesProps) {
218216
<ScrollBar orientation="horizontal" />
219217
</ScrollArea>
220218

221-
<div className="flex items-center px-2">
222-
{/* Rows per page selector */}
223-
<div className="flex items-center space-x-2">
224-
<span className="text-sm text-muted-foreground">
225-
Rows per page
226-
</span>
227-
<Select
228-
value={pagination.pageSize.toString()}
229-
onValueChange={(value: string) =>
230-
setPagination((prev) => ({
231-
...prev,
232-
pageSize: parseInt(value),
233-
}))
234-
}
235-
>
236-
<SelectTrigger className="h-8 w-[70px] border">
237-
<SelectValue placeholder={pagination.pageSize} />
238-
</SelectTrigger>
239-
<SelectContent side="top">
240-
{[10, 30, 50].map((pageSize) => (
241-
<SelectItem key={pageSize} value={pageSize.toString()}>
242-
{pageSize}
243-
</SelectItem>
244-
))}
245-
</SelectContent>
246-
</Select>
247-
</div>
248-
219+
<div className="flex items-center justify-center px-2">
249220
{/* Pagination controls */}
250221
<div className="flex items-center space-x-2">
251222
<Button

frontend/lib/schemas.ts

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import { z } from "zod";
22
import type { Form } from "@/types/form";
33
import type { DateField, Field, NumberField } from "@/types/field";
4+
import { formatDate } from "@/lib/utils";
45

56
// Base schemas
67
const emailSchema = z
@@ -116,15 +117,17 @@ export function generateFormwiseSchema(form: Form) {
116117
case "date":
117118
fieldSchema = z.date();
118119
if ((field as DateField).min_date) {
120+
const minDate = new Date((field as DateField).min_date!);
119121
fieldSchema = (fieldSchema as z.ZodDate).min(
120-
new Date((field as DateField).min_date!),
121-
"Date is too early"
122+
minDate,
123+
`Date must be on or after ${formatDate(minDate.toISOString())}`
122124
);
123125
}
124126
if ((field as DateField).max_date) {
127+
const maxDate = new Date((field as DateField).max_date!);
125128
fieldSchema = (fieldSchema as z.ZodDate).max(
126-
new Date((field as DateField).max_date!),
127-
"Date is too late"
129+
maxDate,
130+
`Date must be on or before ${formatDate(maxDate.toISOString())}`
128131
);
129132
}
130133
break;

0 commit comments

Comments
 (0)