Skip to content

Commit 003b678

Browse files
authored
update deps last version (#24)
- new auth and prisma versions - address the type safety on new version adapter - address migration to eslint 9+ - some new eslint rules and necessary changes - several other updates
1 parent fdc4f93 commit 003b678

22 files changed

+1467
-1201
lines changed

.eslintrc.json

-87
This file was deleted.

app/(auth)/layout.tsx

+4-6
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,9 @@
1-
export default function AuthLayout({ children }: { children: React.ReactNode }) {
1+
import type { ReactNode } from 'react';
2+
3+
export default function AuthLayout({ children }: { children: ReactNode }) {
24
return (
35
<>
4-
<div
5-
className='flex h-full items-center justify-center
6-
bg-[radial-gradient(ellipse_at_top,_var(--tw-gradient-stops))]
7-
from-sky-400 to-blue-800'
8-
>
6+
<div className='flex h-full items-center justify-center bg-[radial-gradient(ellipse_at_top,_var(--tw-gradient-stops))] from-sky-400 to-blue-800'>
97
{children}
108
</div>
119
</>

app/(protected)/client/client-component.tsx

+2-1
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,8 @@ export default function ClientComponent() {
1616
const userSession: Session['user'] | undefined = useCurrentUser();
1717
return (
1818
<div className=''>
19-
{/* This userInfo component is what we call a hybrid component, as children of a client component, is a client component */}
19+
{/* This userInfo component is what we call a hybrid component,
20+
as children of a client component, it is a client component */}
2021
<UserInfo label='💃Client component' user={userSession} />
2122
</div>
2223
);

app/(protected)/layout.tsx

+4-5
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,11 @@ import { Navbar } from '@/components/layout/Navbar';
22
import { NavigationMenu } from '@/components/layout/navbar/NavigationMenu';
33
import { UserAvatarMenu } from '@/components/layout/navbar/UserAvatarMenu';
44

5-
export default function ProtectedLayout(props: { children: React.ReactNode }) {
5+
import type { ReactNode } from 'react';
6+
7+
export default function ProtectedLayout(props: { children: ReactNode }) {
68
return (
7-
<div
8-
className='flex min-h-svh w-full flex-col items-center gap-y-10 bg-[radial-gradient(ellipse_at_top,_var(--tw-gradient-stops))]
9-
from-sky-400 to-blue-800 py-5'
10-
>
9+
<div className='flex min-h-svh w-full flex-col items-center gap-y-10 bg-[radial-gradient(ellipse_at_top,_var(--tw-gradient-stops))] from-sky-400 to-blue-800 py-5'>
1110
<Navbar>
1211
<NavigationMenu />
1312
<UserAvatarMenu />

app/layout.tsx

+2-1
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ import { Inter } from 'next/font/google';
33
import { Toaster } from '@/components/ui/sonner';
44

55
import type { Metadata } from 'next';
6+
import type { ReactNode } from 'react';
67

78
import './globals.css';
89

@@ -16,7 +17,7 @@ export const metadata: Metadata = {
1617
export default async function RootLayout({
1718
children,
1819
}: Readonly<{
19-
children: React.ReactNode;
20+
children: ReactNode;
2021
}>) {
2122
return (
2223
<html lang='en'>

app/page.tsx

+1-4
Original file line numberDiff line numberDiff line change
@@ -10,10 +10,7 @@ const font = Poppins({
1010
});
1111
export default function Home() {
1212
return (
13-
<main
14-
className='flex h-full flex-col items-center justify-center
15-
bg-[radial-gradient(ellipse_at_top,_var(--tw-gradient-stops))] from-sky-400 to-blue-800'
16-
>
13+
<main className='flex h-full flex-col items-center justify-center bg-[radial-gradient(ellipse_at_top,_var(--tw-gradient-stops))] from-sky-400 to-blue-800'>
1714
<div className='space-y-6 text-center'>
1815
<h1 className={cn('text-6xl font-semibold text-white drop-shadow-md', font.className)}>
1916
<span aria-label='icon' role='img'>

auth.config.ts

+6-8
Original file line numberDiff line numberDiff line change
@@ -24,11 +24,9 @@ const adapter = {
2424
* Used when sending magic links
2525
*
2626
* @note If it fails, the email will still be sent, a bug, or intended? Did not bother much.
27-
* @note Remove id and hashedIp from the return object to match PrismaAdapter original patterns
27+
* @note Remove id from the return object to match PrismaAdapter original patterns, we do not have id tho, currently.
2828
*/
29-
async createVerificationToken(
30-
data: VerificationToken
31-
): Promise<{ identifier: string; expires: Date; token: string }> {
29+
async createVerificationToken(data: VerificationToken): Promise<VerificationToken & { hashedIp: string }> {
3230
const hashedIp = await getHashedUserIpFromHeaders();
3331

3432
const token = await db.verificationToken.create({
@@ -43,18 +41,18 @@ const adapter = {
4341
if ('id' in token) {
4442
delete (token as any).id;
4543
}
46-
if ('hashedIp' in token) {
47-
delete (token as any).hashedIp;
48-
}
4944

5045
return token;
5146
},
5247
// Follow PrismaAdapter pattern of removing id
53-
createUser: ({ id, ...data }: AdapterUser) => {
48+
createUser: (data: AdapterUser) => {
5449
const userData = {
5550
...data,
5651
name: data.name || 'your pretty fake name',
5752
};
53+
if ('id' in userData) {
54+
delete (userData as any).id;
55+
}
5856

5957
return db.user.create({
6058
data: userData,

components/access-control/RoleGate.tsx

+3-1
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,10 @@ import { UserRole } from '@prisma/client';
33
import { FormError } from '@/components/forms/messages/FormError';
44
import { currentSessionRole } from '@/lib/auth/auth-utils';
55

6+
import type { ReactNode } from 'react';
7+
68
interface RoleGateProps {
7-
children: React.ReactNode;
9+
children: ReactNode;
810
allowedRole: UserRole;
911
}
1012

components/auth/buttons/LoginButton.tsx

+3-1
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,10 @@ import { useRouter } from 'next/navigation';
55
import { LoginForm } from '@/components/auth/forms/LoginForm';
66
import { Dialog, DialogContent, DialogTrigger } from '@/components/ui/dialog';
77

8+
import type { ReactNode } from 'react';
9+
810
interface LoginButtonProps {
9-
children: React.ReactNode;
11+
children: ReactNode;
1012
mode?: 'modal' | 'redirect';
1113
asChild?: boolean;
1214
}

components/auth/shared/CardWrapper.tsx

+3-1
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,10 @@ import { SocialButtons } from '@/components/auth/buttons/SocialButtons';
55
import { AuthFormHeader } from '@/components/auth/shared/AuthFormHeader';
66
import { Card, CardContent, CardFooter, CardHeader } from '@/components/ui/card';
77

8+
import type { ReactNode } from 'react';
9+
810
interface CardWrapperProps {
9-
children: React.ReactNode;
11+
children: ReactNode;
1012
headerLabel: string;
1113
backButtonLabel: string;
1214
backButtonHref: string;

components/forms/SettingsForm.tsx

+1-1
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ import { UserRole } from '@prisma/client';
55
import { useRouter } from 'next/navigation';
66
import { type Session } from 'next-auth';
77
import { useState, useTransition } from 'react';
8-
import { useForm, UseFormReturn } from 'react-hook-form';
8+
import { useForm, type UseFormReturn } from 'react-hook-form';
99
import * as zod from 'zod';
1010

1111
import { settingsAction } from '@/actions/settings';

components/layout/Navbar.tsx

+3-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
1-
export const Navbar = ({ children }: { children: React.ReactNode }) => {
1+
import type { ReactNode } from 'react';
2+
3+
export const Navbar = ({ children }: { children: ReactNode }) => {
24
return (
35
<nav className='flex w-[600px] items-center justify-between rounded-xl bg-secondary p-4 shadow-sm'>{children}</nav>
46
);

components/ui/dialog.tsx

+1-1
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ const DialogOverlay = React.forwardRef<
2020
>(({ className, ...props }, ref) => (
2121
<DialogPrimitive.Overlay
2222
className={cn(
23-
'fixed inset-0 z-50 bg-black/80 data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0',
23+
'fixed inset-0 z-50 bg-black/80 data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0',
2424
className
2525
)}
2626
ref={ref}

components/ui/form.tsx

+3-1
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,13 @@
11
import * as LabelPrimitive from '@radix-ui/react-label';
22
import { Slot } from '@radix-ui/react-slot';
33
import * as React from 'react';
4-
import { Controller, ControllerProps, FieldPath, FieldValues, FormProvider, useFormContext } from 'react-hook-form';
4+
import { Controller, FormProvider, useFormContext } from 'react-hook-form';
55

66
import { Label } from '@/components/ui/label';
77
import { cn } from '@/lib/utils';
88

9+
import type { ControllerProps, FieldPath, FieldValues } from 'react-hook-form';
10+
911
const Form = FormProvider;
1012

1113
type FormFieldContextValue<

components/ui/sonner.tsx

+3-1
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,9 @@
33
import { useTheme } from 'next-themes';
44
import { Toaster as Sonner } from 'sonner';
55

6-
type ToasterProps = React.ComponentProps<typeof Sonner>;
6+
import type { ComponentProps } from 'react';
7+
8+
type ToasterProps = ComponentProps<typeof Sonner>;
79

810
const Toaster = ({ ...props }: ToasterProps) => {
911
const { theme = 'system' } = useTheme();

components/user/actions/LogoutButton.tsx

+3-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,9 @@
22

33
import { logoutAction } from '@/actions/logout';
44

5-
export const LogoutButton = (props: { children: React.ReactNode }) => {
5+
import type { ReactNode } from 'react';
6+
7+
export const LogoutButton = (props: { children: ReactNode }) => {
68
return (
79
<span
810
className='cursor-pointer'

0 commit comments

Comments
 (0)