diff --git a/.gitignore b/.gitignore index 20d454c5..fd3dbb57 100644 --- a/.gitignore +++ b/.gitignore @@ -4,6 +4,7 @@ /node_modules /.pnp .pnp.js +.yarn/install-state.gz # testing /coverage @@ -24,12 +25,12 @@ npm-debug.log* yarn-debug.log* yarn-error.log* -# env files -.env -.env.local -.env.development.local -.env.test.local -.env.production.local +# local env files +.env*.local # vercel .vercel + +# typescript +*.tsbuildinfo +next-env.d.ts diff --git a/src/app/(app)/Header.js b/app/(app)/Header.tsx similarity index 81% rename from src/app/(app)/Header.js rename to app/(app)/Header.tsx index 73e9d028..6692def9 100644 --- a/src/app/(app)/Header.js +++ b/app/(app)/Header.tsx @@ -1,8 +1,7 @@ -const Header = ({ title }) => { +const Header = ({ title }: { title: string}) => { return (
-

{title}

@@ -11,4 +10,4 @@ const Header = ({ title }) => { ) } -export default Header \ No newline at end of file +export default Header diff --git a/src/app/(app)/Loading.js b/app/(app)/Loading.tsx similarity index 100% rename from src/app/(app)/Loading.js rename to app/(app)/Loading.tsx diff --git a/src/app/(app)/Navigation.js b/app/(app)/Navigation.tsx similarity index 98% rename from src/app/(app)/Navigation.js rename to app/(app)/Navigation.tsx index af4d45ce..7a8e5e03 100644 --- a/src/app/(app)/Navigation.js +++ b/app/(app)/Navigation.tsx @@ -9,8 +9,9 @@ import { DropdownButton } from '@/components/DropdownLink' import { useAuth } from '@/hooks/auth' import { usePathname } from 'next/navigation' import { useState } from 'react' +import { User } from '@/lib/definitions' -const Navigation = ({ user }) => { +const Navigation = ({ user }: { user: User }) => { const { logout } = useAuth() const [open, setOpen] = useState(false) @@ -154,4 +155,4 @@ const Navigation = ({ user }) => { ) } -export default Navigation \ No newline at end of file +export default Navigation diff --git a/src/app/(app)/dashboard/page.js b/app/(app)/dashboard/page.tsx similarity index 96% rename from src/app/(app)/dashboard/page.js rename to app/(app)/dashboard/page.tsx index c88a7315..37827a73 100644 --- a/src/app/(app)/dashboard/page.js +++ b/app/(app)/dashboard/page.tsx @@ -21,4 +21,4 @@ const Dashboard = () => { ) } -export default Dashboard \ No newline at end of file +export default Dashboard diff --git a/src/app/(app)/layout.js b/app/(app)/layout.tsx similarity index 83% rename from src/app/(app)/layout.js rename to app/(app)/layout.tsx index e8b03fae..d861583d 100644 --- a/src/app/(app)/layout.js +++ b/app/(app)/layout.tsx @@ -4,7 +4,11 @@ import { useAuth } from '@/hooks/auth' import Navigation from '@/app/(app)/Navigation' import Loading from '@/app/(app)/Loading' -const AppLayout = ({ children, header }) => { +const AppLayout = ({ + children, +}: Readonly<{ + children: React.ReactNode +}>) => { const { user } = useAuth({ middleware: 'auth' }) if (!user) { diff --git a/src/app/(auth)/AuthCard.js b/app/(auth)/AuthCard.tsx similarity index 71% rename from src/app/(auth)/AuthCard.js rename to app/(auth)/AuthCard.tsx index 13cdc35e..6173a3d3 100644 --- a/src/app/(auth)/AuthCard.js +++ b/app/(auth)/AuthCard.tsx @@ -1,4 +1,10 @@ -const AuthCard = ({ logo, children }) => ( +const AuthCard = ({ + logo, + children, +}: Readonly<{ + logo: React.ReactNode, + children: React.ReactNode, +}>) => (
{logo}
diff --git a/src/app/(auth)/AuthSessionStatus.js b/app/(auth)/AuthSessionStatus.tsx similarity index 56% rename from src/app/(auth)/AuthSessionStatus.js rename to app/(auth)/AuthSessionStatus.tsx index 130516fb..76996b44 100644 --- a/src/app/(auth)/AuthSessionStatus.js +++ b/app/(auth)/AuthSessionStatus.tsx @@ -1,4 +1,11 @@ -const AuthSessionStatus = ({ status, className, ...props }) => ( +const AuthSessionStatus = ({ + status, + className, + ...props +}: { + status: string | null + className?: string +} & React.HTMLAttributes): JSX.Element | null => ( <> {status && (
{ @@ -14,11 +14,11 @@ const Page = () => { redirectIfAuthenticated: '/dashboard', }) - const [email, setEmail] = useState('') - const [errors, setErrors] = useState([]) - const [status, setStatus] = useState(null) + const [email, setEmail] = useState('') + const [errors, setErrors] = useState<{ [key: string]: string[] }>({}) + const [status, setStatus] = useState(null) - const submitForm = event => { + const submitForm = (event: FormEvent) => { event.preventDefault() forgotPassword({ email, setErrors, setStatus }) diff --git a/src/app/(auth)/layout.js b/app/(auth)/layout.tsx similarity index 88% rename from src/app/(auth)/layout.js rename to app/(auth)/layout.tsx index ae2ae81b..3338e156 100644 --- a/src/app/(auth)/layout.js +++ b/app/(auth)/layout.tsx @@ -6,7 +6,11 @@ export const metadata = { title: 'Laravel', } -const Layout = ({ children }) => { +const Layout = ({ + children, +}: Readonly<{ + children: React.ReactNode +}>) => { return (
diff --git a/src/app/(auth)/login/page.js b/app/(auth)/login/page.tsx similarity index 82% rename from src/app/(auth)/login/page.js rename to app/(auth)/login/page.tsx index 9dd23a25..38631563 100644 --- a/src/app/(auth)/login/page.js +++ b/app/(auth)/login/page.tsx @@ -6,33 +6,38 @@ import InputError from '@/components/InputError' import Label from '@/components/Label' import Link from 'next/link' import { useAuth } from '@/hooks/auth' -import { useEffect, useState } from 'react' -import { useRouter } from 'next/navigation' +import { FormEvent, useEffect, useState } from 'react' +import { useSearchParams } from 'next/navigation' import AuthSessionStatus from '@/app/(auth)/AuthSessionStatus' const Login = () => { - const router = useRouter() + const searchParams = useSearchParams() const { login } = useAuth({ middleware: 'guest', redirectIfAuthenticated: '/dashboard', }) - const [email, setEmail] = useState('') - const [password, setPassword] = useState('') - const [shouldRemember, setShouldRemember] = useState(false) - const [errors, setErrors] = useState([]) - const [status, setStatus] = useState(null) + const [email, setEmail] = useState('') + const [password, setPassword] = useState('') + const [shouldRemember, setShouldRemember] = useState(false) + const [errors, setErrors] = useState<{ [key: string]: string[] }>({}) + const [status, setStatus] = useState(null) useEffect(() => { - if (router.reset?.length > 0 && errors.length === 0) { - setStatus(atob(router.reset)) + const resetParam = searchParams.get('reset') + if ( + resetParam && + resetParam.length > 0 && + Object.keys(errors).length === 0 + ) { + setStatus(atob(resetParam)) } else { setStatus(null) } }) - const submitForm = async event => { + const submitForm = async (event: FormEvent) => { event.preventDefault() login({ diff --git a/src/app/(auth)/password-reset/[token]/page.js b/app/(auth)/password-reset/[token]/page.tsx similarity index 87% rename from src/app/(auth)/password-reset/[token]/page.js rename to app/(auth)/password-reset/[token]/page.tsx index b2c467f6..0ffc8a8c 100644 --- a/src/app/(auth)/password-reset/[token]/page.js +++ b/app/(auth)/password-reset/[token]/page.tsx @@ -5,7 +5,7 @@ import Input from '@/components/Input' import InputError from '@/components/InputError' import Label from '@/components/Label' import { useAuth } from '@/hooks/auth' -import { useEffect, useState } from 'react' +import { FormEvent, useEffect, useState } from 'react' import { useSearchParams } from 'next/navigation' import AuthSessionStatus from '@/app/(auth)/AuthSessionStatus' @@ -14,13 +14,13 @@ const PasswordReset = () => { const { resetPassword } = useAuth({ middleware: 'guest' }) - const [email, setEmail] = useState('') - const [password, setPassword] = useState('') - const [passwordConfirmation, setPasswordConfirmation] = useState('') - const [errors, setErrors] = useState([]) - const [status, setStatus] = useState(null) + const [email, setEmail] = useState('') + const [password, setPassword] = useState('') + const [passwordConfirmation, setPasswordConfirmation] = useState('') + const [errors, setErrors] = useState<{ [key: string]: string[] }>({}) + const [status, setStatus] = useState(null) - const submitForm = event => { + const submitForm = (event: FormEvent) => { event.preventDefault() resetPassword({ @@ -33,7 +33,8 @@ const PasswordReset = () => { } useEffect(() => { - setEmail(searchParams.get('email')) + const emailParam = searchParams.get('email') + if (emailParam) setEmail(emailParam) }, [searchParams.get('email')]) return ( diff --git a/src/app/(auth)/register/page.js b/app/(auth)/register/page.tsx similarity index 90% rename from src/app/(auth)/register/page.js rename to app/(auth)/register/page.tsx index b2ecfdac..765d4173 100644 --- a/src/app/(auth)/register/page.js +++ b/app/(auth)/register/page.tsx @@ -6,7 +6,7 @@ import InputError from '@/components/InputError' import Label from '@/components/Label' import Link from 'next/link' import { useAuth } from '@/hooks/auth' -import { useState } from 'react' +import { FormEvent, useState } from 'react' const Page = () => { const { register } = useAuth({ @@ -14,13 +14,13 @@ const Page = () => { redirectIfAuthenticated: '/dashboard', }) - const [name, setName] = useState('') - const [email, setEmail] = useState('') - const [password, setPassword] = useState('') - const [passwordConfirmation, setPasswordConfirmation] = useState('') - const [errors, setErrors] = useState([]) + const [name, setName] = useState('') + const [email, setEmail] = useState('') + const [password, setPassword] = useState('') + const [passwordConfirmation, setPasswordConfirmation] = useState('') + const [errors, setErrors] = useState<{ [key: string]: string[] }>({}) - const submitForm = event => { + const submitForm = (event: FormEvent) => { event.preventDefault() register({ diff --git a/src/app/(auth)/verify-email/page.js b/app/(auth)/verify-email/page.tsx similarity index 96% rename from src/app/(auth)/verify-email/page.js rename to app/(auth)/verify-email/page.tsx index 3a258d4f..ee6b6dde 100644 --- a/src/app/(auth)/verify-email/page.js +++ b/app/(auth)/verify-email/page.tsx @@ -10,7 +10,7 @@ const Page = () => { redirectIfAuthenticated: '/dashboard', }) - const [status, setStatus] = useState(null) + const [status, setStatus] = useState(null) return ( <> diff --git a/src/app/LoginLinks.js b/app/LoginLinks.tsx similarity index 100% rename from src/app/LoginLinks.js rename to app/LoginLinks.tsx index 74d4422b..1ea72b0e 100644 --- a/src/app/LoginLinks.js +++ b/app/LoginLinks.tsx @@ -1,7 +1,7 @@ 'use client' -import Link from 'next/link' import { useAuth } from '@/hooks/auth' +import Link from 'next/link' const LoginLinks = () => { const { user } = useAuth({ middleware: 'guest' }) diff --git a/app/favicon.ico b/app/favicon.ico new file mode 100644 index 00000000..718d6fea Binary files /dev/null and b/app/favicon.ico differ diff --git a/src/app/global.css b/app/global.css similarity index 100% rename from src/app/global.css rename to app/global.css diff --git a/src/app/layout.js b/app/layout.tsx similarity index 55% rename from src/app/layout.js rename to app/layout.tsx index ccc84081..65e19657 100644 --- a/src/app/layout.js +++ b/app/layout.tsx @@ -1,9 +1,14 @@ +import type { Metadata } from 'next' import '@/app/global.css' -export const metadata = { +export const metadata: Metadata = { title: 'Laravel', } -const RootLayout = ({ children }) => { +const RootLayout = ({ + children, +}: Readonly<{ + children: React.ReactNode +}>) => { return ( {children} diff --git a/src/app/not-found.js b/app/not-found.tsx similarity index 100% rename from src/app/not-found.js rename to app/not-found.tsx diff --git a/src/app/page.js b/app/page.tsx similarity index 99% rename from src/app/page.js rename to app/page.tsx index f9b1e66c..4f0b2bbd 100644 --- a/src/app/page.js +++ b/app/page.tsx @@ -1,6 +1,7 @@ +import { Metadata } from 'next' import LoginLinks from '@/app/LoginLinks' -export const metadata = { +export const metadata: Metadata = { title: 'Laravel', } diff --git a/src/components/ApplicationLogo.js b/components/ApplicationLogo.tsx similarity index 96% rename from src/components/ApplicationLogo.js rename to components/ApplicationLogo.tsx index ffc52abe..ff27bcd1 100644 --- a/src/components/ApplicationLogo.js +++ b/components/ApplicationLogo.tsx @@ -1,4 +1,6 @@ -const ApplicationLogo = props => ( +import { SVGProps } from "react" + +const ApplicationLogo: React.FC> = props => ( diff --git a/src/components/Button.js b/components/Button.tsx similarity index 77% rename from src/components/Button.js rename to components/Button.tsx index 2b3c92ab..7a2c60ed 100644 --- a/src/components/Button.js +++ b/components/Button.tsx @@ -1,4 +1,8 @@ -const Button = ({ type = 'submit', className, ...props }) => ( +const Button = ({ + type = 'submit', + className, + ...props +}: React.ButtonHTMLAttributes) => (