Skip to content

Commit 6c6acc9

Browse files
lint: fix lint error
1 parent bbcdeaa commit 6c6acc9

File tree

6 files changed

+90
-120
lines changed

6 files changed

+90
-120
lines changed

prisma/seeds/user.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,9 @@ export async function seedUsers() {
88
const userId = nanoid()
99

1010
const hashedPassword = await bcrypt.hash(
11-
(process.env.DEFAULT_PASSWORD as string) || 'Password1',
12-
10
13-
)
11+
(process.env.DEFAULT_PASSWORD as string) || 'Password1',
12+
10
13+
)
1414

1515
await prisma.user.upsert({
1616
where: { email: '[email protected]' },

src/app/auth/login/page.tsx

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,20 @@
1-
import { redirect } from "next/navigation";
2-
import { auth } from "@/lib/auth";
3-
import { LoginForm } from "./_components/login-form";
4-
import { headers } from "next/headers";
1+
import { redirect } from 'next/navigation'
2+
import { auth } from '@/lib/auth'
3+
import { LoginForm } from './_components/login-form'
4+
import { headers } from 'next/headers'
55

66
export default async function LoginPage() {
77
const session = await auth.api.getSession({
88
headers: await headers(),
9-
});
9+
})
1010

1111
if (session?.user) {
12-
redirect("/dashboard");
12+
redirect('/dashboard')
1313
}
1414

1515
return (
1616
<div className="w-screen h-screen flex items-center justify-center">
1717
<LoginForm />
1818
</div>
1919
)
20-
}
20+
}

src/components/ui/alert-dialog.tsx

Lines changed: 19 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -1,31 +1,23 @@
1-
"use client"
1+
'use client'
22

3-
import * as React from "react"
4-
import * as AlertDialogPrimitive from "@radix-ui/react-alert-dialog"
3+
import * as React from 'react'
4+
import * as AlertDialogPrimitive from '@radix-ui/react-alert-dialog'
55

6-
import { cn } from "@/lib/utils"
7-
import { buttonVariants } from "@/components/ui/button"
6+
import { cn } from '@/lib/utils'
7+
import { buttonVariants } from '@/components/ui/button'
88

9-
function AlertDialog({
10-
...props
11-
}: React.ComponentProps<typeof AlertDialogPrimitive.Root>) {
9+
function AlertDialog({ ...props }: React.ComponentProps<typeof AlertDialogPrimitive.Root>) {
1210
return <AlertDialogPrimitive.Root data-slot="alert-dialog" {...props} />
1311
}
1412

1513
function AlertDialogTrigger({
1614
...props
1715
}: React.ComponentProps<typeof AlertDialogPrimitive.Trigger>) {
18-
return (
19-
<AlertDialogPrimitive.Trigger data-slot="alert-dialog-trigger" {...props} />
20-
)
16+
return <AlertDialogPrimitive.Trigger data-slot="alert-dialog-trigger" {...props} />
2117
}
2218

23-
function AlertDialogPortal({
24-
...props
25-
}: React.ComponentProps<typeof AlertDialogPrimitive.Portal>) {
26-
return (
27-
<AlertDialogPrimitive.Portal data-slot="alert-dialog-portal" {...props} />
28-
)
19+
function AlertDialogPortal({ ...props }: React.ComponentProps<typeof AlertDialogPrimitive.Portal>) {
20+
return <AlertDialogPrimitive.Portal data-slot="alert-dialog-portal" {...props} />
2921
}
3022

3123
function AlertDialogOverlay({
@@ -36,7 +28,7 @@ function AlertDialogOverlay({
3628
<AlertDialogPrimitive.Overlay
3729
data-slot="alert-dialog-overlay"
3830
className={cn(
39-
"data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 fixed inset-0 z-50 bg-black/50",
31+
'data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 fixed inset-0 z-50 bg-black/50',
4032
className
4133
)}
4234
{...props}
@@ -54,7 +46,7 @@ function AlertDialogContent({
5446
<AlertDialogPrimitive.Content
5547
data-slot="alert-dialog-content"
5648
className={cn(
57-
"bg-background data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 fixed top-[50%] left-[50%] z-50 grid w-full max-w-[calc(100%-2rem)] translate-x-[-50%] translate-y-[-50%] gap-4 rounded-lg border p-6 shadow-lg duration-200 sm:max-w-lg",
49+
'bg-background data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 fixed top-[50%] left-[50%] z-50 grid w-full max-w-[calc(100%-2rem)] translate-x-[-50%] translate-y-[-50%] gap-4 rounded-lg border p-6 shadow-lg duration-200 sm:max-w-lg',
5850
className
5951
)}
6052
{...props}
@@ -63,30 +55,21 @@ function AlertDialogContent({
6355
)
6456
}
6557

66-
function AlertDialogHeader({
67-
className,
68-
...props
69-
}: React.ComponentProps<"div">) {
58+
function AlertDialogHeader({ className, ...props }: React.ComponentProps<'div'>) {
7059
return (
7160
<div
7261
data-slot="alert-dialog-header"
73-
className={cn("flex flex-col gap-2 text-center sm:text-left", className)}
62+
className={cn('flex flex-col gap-2 text-center sm:text-left', className)}
7463
{...props}
7564
/>
7665
)
7766
}
7867

79-
function AlertDialogFooter({
80-
className,
81-
...props
82-
}: React.ComponentProps<"div">) {
68+
function AlertDialogFooter({ className, ...props }: React.ComponentProps<'div'>) {
8369
return (
8470
<div
8571
data-slot="alert-dialog-footer"
86-
className={cn(
87-
"flex flex-col-reverse gap-2 sm:flex-row sm:justify-end",
88-
className
89-
)}
72+
className={cn('flex flex-col-reverse gap-2 sm:flex-row sm:justify-end', className)}
9073
{...props}
9174
/>
9275
)
@@ -99,7 +82,7 @@ function AlertDialogTitle({
9982
return (
10083
<AlertDialogPrimitive.Title
10184
data-slot="alert-dialog-title"
102-
className={cn("text-lg font-semibold", className)}
85+
className={cn('text-lg font-semibold', className)}
10386
{...props}
10487
/>
10588
)
@@ -112,7 +95,7 @@ function AlertDialogDescription({
11295
return (
11396
<AlertDialogPrimitive.Description
11497
data-slot="alert-dialog-description"
115-
className={cn("text-muted-foreground text-sm", className)}
98+
className={cn('text-muted-foreground text-sm', className)}
11699
{...props}
117100
/>
118101
)
@@ -122,12 +105,7 @@ function AlertDialogAction({
122105
className,
123106
...props
124107
}: React.ComponentProps<typeof AlertDialogPrimitive.Action>) {
125-
return (
126-
<AlertDialogPrimitive.Action
127-
className={cn(buttonVariants(), className)}
128-
{...props}
129-
/>
130-
)
108+
return <AlertDialogPrimitive.Action className={cn(buttonVariants(), className)} {...props} />
131109
}
132110

133111
function AlertDialogCancel({
@@ -136,7 +114,7 @@ function AlertDialogCancel({
136114
}: React.ComponentProps<typeof AlertDialogPrimitive.Cancel>) {
137115
return (
138116
<AlertDialogPrimitive.Cancel
139-
className={cn(buttonVariants({ variant: "outline" }), className)}
117+
className={cn(buttonVariants({ variant: 'outline' }), className)}
140118
{...props}
141119
/>
142120
)

src/components/ui/alert.tsx

Lines changed: 12 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,20 @@
1-
import * as React from "react"
2-
import { cva, type VariantProps } from "class-variance-authority"
1+
import * as React from 'react'
2+
import { cva, type VariantProps } from 'class-variance-authority'
33

4-
import { cn } from "@/lib/utils"
4+
import { cn } from '@/lib/utils'
55

66
const alertVariants = cva(
7-
"relative w-full rounded-lg border px-4 py-3 text-sm grid has-[>svg]:grid-cols-[calc(var(--spacing)*4)_1fr] grid-cols-[0_1fr] has-[>svg]:gap-x-3 gap-y-0.5 items-start [&>svg]:size-4 [&>svg]:translate-y-0.5 [&>svg]:text-current",
7+
'relative w-full rounded-lg border px-4 py-3 text-sm grid has-[>svg]:grid-cols-[calc(var(--spacing)*4)_1fr] grid-cols-[0_1fr] has-[>svg]:gap-x-3 gap-y-0.5 items-start [&>svg]:size-4 [&>svg]:translate-y-0.5 [&>svg]:text-current',
88
{
99
variants: {
1010
variant: {
11-
default: "bg-card text-card-foreground",
11+
default: 'bg-card text-card-foreground',
1212
destructive:
13-
"text-destructive bg-card [&>svg]:text-current *:data-[slot=alert-description]:text-destructive/90",
13+
'text-destructive bg-card [&>svg]:text-current *:data-[slot=alert-description]:text-destructive/90',
1414
},
1515
},
1616
defaultVariants: {
17-
variant: "default",
17+
variant: 'default',
1818
},
1919
}
2020
)
@@ -23,7 +23,7 @@ function Alert({
2323
className,
2424
variant,
2525
...props
26-
}: React.ComponentProps<"div"> & VariantProps<typeof alertVariants>) {
26+
}: React.ComponentProps<'div'> & VariantProps<typeof alertVariants>) {
2727
return (
2828
<div
2929
data-slot="alert"
@@ -34,28 +34,22 @@ function Alert({
3434
)
3535
}
3636

37-
function AlertTitle({ className, ...props }: React.ComponentProps<"div">) {
37+
function AlertTitle({ className, ...props }: React.ComponentProps<'div'>) {
3838
return (
3939
<div
4040
data-slot="alert-title"
41-
className={cn(
42-
"col-start-2 line-clamp-1 min-h-4 font-medium tracking-tight",
43-
className
44-
)}
41+
className={cn('col-start-2 line-clamp-1 min-h-4 font-medium tracking-tight', className)}
4542
{...props}
4643
/>
4744
)
4845
}
4946

50-
function AlertDescription({
51-
className,
52-
...props
53-
}: React.ComponentProps<"div">) {
47+
function AlertDescription({ className, ...props }: React.ComponentProps<'div'>) {
5448
return (
5549
<div
5650
data-slot="alert-description"
5751
className={cn(
58-
"text-muted-foreground col-start-2 grid justify-items-start gap-1 text-sm [&_p]:leading-relaxed",
52+
'text-muted-foreground col-start-2 grid justify-items-start gap-1 text-sm [&_p]:leading-relaxed',
5953
className
6054
)}
6155
{...props}

src/components/ui/button.tsx

Lines changed: 18 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1,35 +1,33 @@
1-
import * as React from "react"
2-
import { Slot } from "@radix-ui/react-slot"
3-
import { cva, type VariantProps } from "class-variance-authority"
1+
import * as React from 'react'
2+
import { Slot } from '@radix-ui/react-slot'
3+
import { cva, type VariantProps } from 'class-variance-authority'
44

5-
import { cn } from "@/lib/utils"
5+
import { cn } from '@/lib/utils'
66

77
const buttonVariants = cva(
88
"inline-flex items-center justify-center gap-2 whitespace-nowrap rounded-md text-sm font-medium transition-all disabled:pointer-events-none disabled:opacity-50 [&_svg]:pointer-events-none [&_svg:not([class*='size-'])]:size-4 shrink-0 [&_svg]:shrink-0 outline-none focus-visible:border-ring focus-visible:ring-ring/50 focus-visible:ring-[3px] aria-invalid:ring-destructive/20 dark:aria-invalid:ring-destructive/40 aria-invalid:border-destructive",
99
{
1010
variants: {
1111
variant: {
12-
default: "bg-primary text-primary-foreground hover:bg-primary/90",
12+
default: 'bg-primary text-primary-foreground hover:bg-primary/90',
1313
destructive:
14-
"bg-destructive text-white hover:bg-destructive/90 focus-visible:ring-destructive/20 dark:focus-visible:ring-destructive/40 dark:bg-destructive/60",
14+
'bg-destructive text-white hover:bg-destructive/90 focus-visible:ring-destructive/20 dark:focus-visible:ring-destructive/40 dark:bg-destructive/60',
1515
outline:
16-
"border bg-background shadow-xs hover:bg-accent hover:text-accent-foreground dark:bg-input/30 dark:border-input dark:hover:bg-input/50",
17-
secondary:
18-
"bg-secondary text-secondary-foreground hover:bg-secondary/80",
19-
ghost:
20-
"hover:bg-accent hover:text-accent-foreground dark:hover:bg-accent/50",
21-
link: "text-primary underline-offset-4 hover:underline",
16+
'border bg-background shadow-xs hover:bg-accent hover:text-accent-foreground dark:bg-input/30 dark:border-input dark:hover:bg-input/50',
17+
secondary: 'bg-secondary text-secondary-foreground hover:bg-secondary/80',
18+
ghost: 'hover:bg-accent hover:text-accent-foreground dark:hover:bg-accent/50',
19+
link: 'text-primary underline-offset-4 hover:underline',
2220
},
2321
size: {
24-
default: "h-9 px-4 py-2 has-[>svg]:px-3",
25-
sm: "h-8 rounded-md gap-1.5 px-3 has-[>svg]:px-2.5",
26-
lg: "h-10 rounded-md px-6 has-[>svg]:px-4",
27-
icon: "size-9",
22+
default: 'h-9 px-4 py-2 has-[>svg]:px-3',
23+
sm: 'h-8 rounded-md gap-1.5 px-3 has-[>svg]:px-2.5',
24+
lg: 'h-10 rounded-md px-6 has-[>svg]:px-4',
25+
icon: 'size-9',
2826
},
2927
},
3028
defaultVariants: {
31-
variant: "default",
32-
size: "default",
29+
variant: 'default',
30+
size: 'default',
3331
},
3432
}
3533
)
@@ -40,11 +38,11 @@ function Button({
4038
size,
4139
asChild = false,
4240
...props
43-
}: React.ComponentProps<"button"> &
41+
}: React.ComponentProps<'button'> &
4442
VariantProps<typeof buttonVariants> & {
4543
asChild?: boolean
4644
}) {
47-
const Comp = asChild ? Slot : "button"
45+
const Comp = asChild ? Slot : 'button'
4846

4947
return (
5048
<Comp

src/lib/authz.ts

Lines changed: 31 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -1,42 +1,42 @@
1-
"use server"
1+
'use server'
22

3-
import { headers } from "next/headers";
4-
import { NextResponse } from "next/server";
5-
import type { Role } from "@prisma/client";
6-
import { auth } from "@/lib/auth";
3+
import { headers } from 'next/headers'
4+
import { NextResponse } from 'next/server'
5+
import type { Role } from '@prisma/client'
6+
import { auth } from '@/lib/auth'
77

88
/**
99
* Running on server !!!
1010
* Use this to protect your api route or server action with roles based
1111
*/
1212
export async function requireAuth(options?: { roles?: Role[] }) {
13-
const session = await auth.api.getSession({
14-
headers: await headers(),
15-
});
13+
const session = await auth.api.getSession({
14+
headers: await headers(),
15+
})
1616

17-
if (!session?.user) {
18-
return {
19-
error: NextResponse.json(
20-
{
21-
status: "failed",
22-
message: "Unauthorized: Login required",
23-
},
24-
{ status: 401 },
25-
),
26-
};
27-
}
17+
if (!session?.user) {
18+
return {
19+
error: NextResponse.json(
20+
{
21+
status: 'failed',
22+
message: 'Unauthorized: Login required',
23+
},
24+
{ status: 401 }
25+
),
26+
}
27+
}
2828

29-
if (options?.roles && !options.roles.includes(session.user.role as Role)) {
30-
return {
31-
error: NextResponse.json(
32-
{
33-
status: "failed",
34-
message: "Forbidden: Insufficient role",
35-
},
36-
{ status: 403 },
37-
),
38-
};
39-
}
29+
if (options?.roles && !options.roles.includes(session.user.role as Role)) {
30+
return {
31+
error: NextResponse.json(
32+
{
33+
status: 'failed',
34+
message: 'Forbidden: Insufficient role',
35+
},
36+
{ status: 403 }
37+
),
38+
}
39+
}
4040

41-
return { session };
41+
return { session }
4242
}

0 commit comments

Comments
 (0)