Skip to content

Commit 645ccb4

Browse files
committed
chore: update deps
1 parent 53e2da1 commit 645ccb4

36 files changed

+994
-787
lines changed

app/(protected)/admin/memberships/new/page.tsx

Lines changed: 19 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -47,36 +47,39 @@ import { Library } from '@/lib/types/library'
4747
import { Input } from '@/components/ui/input'
4848

4949
const FormSchema = z.object({
50-
library_id: z
51-
.string({
52-
required_error: 'Please select a library.',
53-
})
54-
.uuid(),
50+
library_id: z.uuid(),
5551
name: z
5652
.string({
57-
required_error: 'Please name the membership.',
53+
error: (issue) =>
54+
issue.input === undefined ? 'Please name the membership.' : undefined,
5855
})
5956
.nonempty(),
60-
loan_period: z.coerce
57+
loan_period: z
6158
.number({
62-
required_error: 'Loan period is required.',
59+
error: (issue) =>
60+
issue.input === undefined ? 'Loan period is required.' : undefined,
6361
})
6462
.min(1),
65-
duration: z.coerce
63+
duration: z
6664
.number({
67-
required_error: 'Duration is required.',
65+
error: (issue) =>
66+
issue.input === undefined ? 'Duration is required.' : undefined,
6867
})
6968
.min(1),
70-
active_loan_limit: z.coerce
69+
active_loan_limit: z
7170
.number({
72-
required_error: 'Active loan limit is required.',
71+
error: (issue) =>
72+
issue.input === undefined
73+
? 'Active loan limit is required.'
74+
: undefined,
7375
})
7476
.min(1, 'Active loan limit must be at least 1.'),
75-
fine_per_day: z.coerce.number({
76-
required_error: 'Fine per day is required.',
77+
fine_per_day: z.number({
78+
error: (issue) =>
79+
issue.input === undefined ? 'Fine per day is required.' : undefined,
7780
}),
78-
price: z.coerce.number(),
79-
usage_limit: z.coerce.number(),
81+
price: z.number(),
82+
usage_limit: z.number(),
8083
})
8184

8285
export default function ComboboxForm() {

app/(protected)/admin/subscriptions/new/page.tsx

Lines changed: 3 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -47,21 +47,9 @@ import { Membership } from '@/lib/types/membership'
4747
import { createSubscription } from '@/lib/api/subscription'
4848

4949
const FormSchema = z.object({
50-
user_id: z
51-
.string({
52-
required_error: 'Please select user.',
53-
})
54-
.uuid(),
55-
library_id: z
56-
.string({
57-
required_error: 'Please select a library.',
58-
})
59-
.uuid(),
60-
membership_id: z
61-
.string({
62-
required_error: 'Please select a membership.',
63-
})
64-
.uuid(),
50+
user_id: z.uuid(),
51+
library_id: z.uuid(),
52+
membership_id: z.uuid(),
6553
})
6654

6755
export default function ComboboxForm() {

components/books/BookForm.tsx

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -49,29 +49,29 @@ type BookFormProps = {
4949
const FormSchema = z.object({
5050
title: z
5151
.string({
52-
required_error: 'Please enter book title.',
52+
error: (issue) =>
53+
issue.input === undefined ? 'Please enter book title.' : undefined,
5354
})
5455
.nonempty(),
5556
author: z
5657
.string({
57-
required_error: 'Please enter author name.',
58+
error: (issue) =>
59+
issue.input === undefined ? 'Please enter author name.' : undefined,
5860
})
5961
.nonempty(),
60-
year: z.coerce
62+
year: z
6163
.number({
62-
required_error: 'Please enter year.',
64+
error: (issue) =>
65+
issue.input === undefined ? 'Please enter year.' : undefined,
6366
})
6467
.gt(1000, 'Please enter valid year.'),
6568
code: z
6669
.string({
67-
required_error: 'Please set a code for book.',
70+
error: (issue) =>
71+
issue.input === undefined ? 'Please set a code for book.' : undefined,
6872
})
6973
.nonempty(),
70-
library_id: z
71-
.string({
72-
required_error: 'Please select the library.',
73-
})
74-
.uuid(),
74+
library_id: z.uuid(),
7575
cover: z.string().optional(),
7676
})
7777

components/borrows/FormBorrow.tsx

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -69,13 +69,16 @@ import Image from 'next/image'
6969
const FormSchema = z.object({
7070
user_id: z.string().optional(),
7171
book_id: z.string({
72-
required_error: 'Please select a book.',
72+
error: (issue) =>
73+
issue.input === undefined ? 'Please select a book.' : undefined,
7374
}),
7475
subscription_id: z.string({
75-
required_error: 'Please select a subscription.',
76+
error: (issue) =>
77+
issue.input === undefined ? 'Please select a subscription.' : undefined,
7678
}),
7779
staff_id: z.string({
78-
required_error: 'Please select a staff.',
80+
error: (issue) =>
81+
issue.input === undefined ? 'Please select a staff.' : undefined,
7982
}),
8083
})
8184

components/borrows/FormEditBorrow.tsx

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,14 +25,15 @@ import { TimeInput } from '../ui/time-input'
2525

2626
const FormSchema = z.object({
2727
id: z.string({
28-
required_error: 'Please select a borrow.',
28+
error: (issue) =>
29+
issue.input === undefined ? 'Please select a borrow.' : undefined,
2930
}),
3031
borrowed_at: z.string(),
3132
due_at: z.string(),
3233
returning: z
3334
.object({
3435
returned_at: z.string(),
35-
fine: z.coerce.number().nonnegative(),
36+
fine: z.number().nonnegative(),
3637
})
3738
.optional(),
3839
})

components/borrows/FormNewBorrow.tsx

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -45,16 +45,20 @@ import { toast } from 'sonner'
4545

4646
const FormSchema = z.object({
4747
user_id: z.string({
48-
required_error: 'Please select a user.',
48+
error: (issue) =>
49+
issue.input === undefined ? 'Please select a user.' : undefined,
4950
}),
5051
book_id: z.string({
51-
required_error: 'Please select a book.',
52+
error: (issue) =>
53+
issue.input === undefined ? 'Please select a book.' : undefined,
5254
}),
5355
subscription_id: z.string({
54-
required_error: 'Please select a subscription.',
56+
error: (issue) =>
57+
issue.input === undefined ? 'Please select a subscription.' : undefined,
5558
}),
5659
staff_id: z.string({
57-
required_error: 'Please select a staff.',
60+
error: (issue) =>
61+
issue.input === undefined ? 'Please select a staff.' : undefined,
5862
}),
5963
})
6064

components/libraries/LibraryForm.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
import { zodResolver } from '@hookform/resolvers/zod'
44
import { useForm } from 'react-hook-form'
5-
import { z } from 'zod/v4'
5+
import { z } from 'zod'
66
import {
77
Form,
88
FormControl,

components/nav-user.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,7 @@ export function NavUser({
9898
</DropdownMenuItem>
9999
</DropdownMenuGroup>
100100
<DropdownMenuSeparator />
101-
<DropdownMenuItem onClick={logoutAction} variant="destructive">
101+
<DropdownMenuItem onClick={logoutAction}>
102102
<LogOutIcon />
103103
Log out
104104
</DropdownMenuItem>

components/staffs/StaffForm.tsx

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -56,17 +56,20 @@ type StaffFormProps = {
5656
const FormSchema = z.object({
5757
user_id: z
5858
.string({
59-
required_error: 'Please select a user.',
59+
error: (issue) =>
60+
issue.input === undefined ? 'Please select a user.' : undefined,
6061
})
6162
.nonempty(),
6263
library_id: z
6364
.string({
64-
required_error: 'Please select a library.',
65+
error: (issue) =>
66+
issue.input === undefined ? 'Please select a library.' : undefined,
6567
})
6668
.nonempty(),
6769
name: z
6870
.string({
69-
required_error: 'Please enter staff name.',
71+
error: (issue) =>
72+
issue.input === undefined ? 'Please enter staff name.' : undefined,
7073
})
7174
.nonempty(),
7275
role: z.union([z.literal('ADMIN'), z.literal('STAFF')]),

components/ui/avatar.tsx

Lines changed: 39 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -5,49 +5,46 @@ import * as AvatarPrimitive from '@radix-ui/react-avatar'
55

66
import { cn } from '@/lib/utils'
77

8-
function Avatar({
9-
className,
10-
...props
11-
}: React.ComponentProps<typeof AvatarPrimitive.Root>) {
12-
return (
13-
<AvatarPrimitive.Root
14-
data-slot="avatar"
15-
className={cn(
16-
'relative flex size-8 shrink-0 overflow-hidden rounded-full',
17-
className
18-
)}
19-
{...props}
20-
/>
21-
)
22-
}
8+
const Avatar = React.forwardRef<
9+
React.ComponentRef<typeof AvatarPrimitive.Root>,
10+
React.ComponentPropsWithoutRef<typeof AvatarPrimitive.Root>
11+
>(({ className, ...props }, ref) => (
12+
<AvatarPrimitive.Root
13+
ref={ref}
14+
className={cn(
15+
'relative flex h-10 w-10 shrink-0 overflow-hidden rounded-full',
16+
className
17+
)}
18+
{...props}
19+
/>
20+
))
21+
Avatar.displayName = AvatarPrimitive.Root.displayName
2322

24-
function AvatarImage({
25-
className,
26-
...props
27-
}: React.ComponentProps<typeof AvatarPrimitive.Image>) {
28-
return (
29-
<AvatarPrimitive.Image
30-
data-slot="avatar-image"
31-
className={cn('aspect-square size-full', className)}
32-
{...props}
33-
/>
34-
)
35-
}
23+
const AvatarImage = React.forwardRef<
24+
React.ComponentRef<typeof AvatarPrimitive.Image>,
25+
React.ComponentPropsWithoutRef<typeof AvatarPrimitive.Image>
26+
>(({ className, ...props }, ref) => (
27+
<AvatarPrimitive.Image
28+
ref={ref}
29+
className={cn('aspect-square h-full w-full', className)}
30+
{...props}
31+
/>
32+
))
33+
AvatarImage.displayName = AvatarPrimitive.Image.displayName
3634

37-
function AvatarFallback({
38-
className,
39-
...props
40-
}: React.ComponentProps<typeof AvatarPrimitive.Fallback>) {
41-
return (
42-
<AvatarPrimitive.Fallback
43-
data-slot="avatar-fallback"
44-
className={cn(
45-
'bg-muted flex size-full items-center justify-center rounded-full',
46-
className
47-
)}
48-
{...props}
49-
/>
50-
)
51-
}
35+
const AvatarFallback = React.forwardRef<
36+
React.ComponentRef<typeof AvatarPrimitive.Fallback>,
37+
React.ComponentPropsWithoutRef<typeof AvatarPrimitive.Fallback>
38+
>(({ className, ...props }, ref) => (
39+
<AvatarPrimitive.Fallback
40+
ref={ref}
41+
className={cn(
42+
'flex h-full w-full items-center justify-center rounded-full bg-muted',
43+
className
44+
)}
45+
{...props}
46+
/>
47+
))
48+
AvatarFallback.displayName = AvatarPrimitive.Fallback.displayName
5249

5350
export { Avatar, AvatarImage, AvatarFallback }

0 commit comments

Comments
 (0)