diff --git a/packages/frontend/app/admin/login/layout.tsx b/packages/frontend/app/admin/login/layout.tsx
new file mode 100644
index 0000000..7ffa567
--- /dev/null
+++ b/packages/frontend/app/admin/login/layout.tsx
@@ -0,0 +1,17 @@
+export default function loginLayout({
+ children,
+ }: {
+ children: React.ReactNode
+ }) {
+ return (
+
-
Admin Login
-
- {error &&
{error}
}
+
+
- )
+ );
}
-
-export default Login
diff --git a/packages/frontend/components/Login.tsx b/packages/frontend/components/Login.tsx
new file mode 100644
index 0000000..5022b54
--- /dev/null
+++ b/packages/frontend/components/Login.tsx
@@ -0,0 +1,83 @@
+"use client"
+
+import { useRouter } from 'next/navigation'
+import { useState } from 'react'
+
+type UserCredentials = {
+ email: string
+ password: string
+}
+
+// TODO replace react-form, zod
+function isValidUser({ email, password }: UserCredentials): boolean {
+ const validUsersString = process.env.NEXT_PUBLIC_VALID_USERS
+
+ if (!validUsersString) {
+ console.error('Environment variable NEXT_PUBLIC_VALID_USERS is not defined')
+ return false
+ }
+
+ const validUsers = validUsersString.split(',')
+
+
+ return validUsers.some((user) => {
+ const [validEmail, validPassword] = user.split(':')
+ return validEmail === email && validPassword === password
+ })
+}
+
+const Login = () => {
+ const [email, setEmail] = useState('')
+ const [password, setPassword] = useState('')
+ const [error, setError] = useState('')
+ const router = useRouter()
+
+ const handleLogin = (e: React.FormEvent) => {
+ e.preventDefault()
+
+ const credentials: UserCredentials = { email, password }
+
+ if (isValidUser(credentials)) {
+ localStorage.setItem('isLoggedIn', 'true')
+ router.push('/admin/dashboard')
+ } else {
+ setError('Invalid email or password')
+ }
+ }
+
+ return (
+
+ )
+}
+
+export default Login
diff --git a/packages/frontend/src/components/Login.tsx b/packages/frontend/src/components/Login.tsx
new file mode 100644
index 0000000..f7f4f1a
--- /dev/null
+++ b/packages/frontend/src/components/Login.tsx
@@ -0,0 +1,83 @@
+"use client"
+
+import { useRouter } from 'next/navigation'
+import { useState } from 'react'
+
+type UserCredentials = {
+ email: string
+ password: string
+}
+
+// TODO replace react-form, zod
+function isValidUser({ email, password }: UserCredentials): boolean {
+ const validUsersString = process.env.NEXT_PUBLIC_VALID_USERS
+
+ if (!validUsersString) {
+ console.error('Environment variable NEXT_PUBLIC_VALID_USERS is not defined')
+ return false
+ }
+
+ const validUsers = validUsersString.split(',')
+
+
+ return validUsers.some((user) => {
+ const [validEmail, validPassword] = user.split(':')
+ return validEmail === email && validPassword === password
+ })
+}
+
+const Login = () => {
+ const [email, setEmail] = useState('')
+ const [password, setPassword] = useState('')
+ const [error, setError] = useState('')
+ const router = useRouter()
+
+ const handleLogin = (e: React.FormEvent) => {
+ e.preventDefault()
+
+ const credentials: UserCredentials = { email, password }
+
+ if (isValidUser(credentials)) {
+ localStorage.setItem('isLoggedIn', 'true')
+ router.push('/admin/dashboard')
+ } else {
+ setError('Invalid email or password')
+ }
+ }
+
+ return (
+
+ )
+}
+
+export default Login
diff --git a/packages/frontend/tailwind.config.ts b/packages/frontend/tailwind.config.ts
index 86c441d..84a5976 100644
--- a/packages/frontend/tailwind.config.ts
+++ b/packages/frontend/tailwind.config.ts
@@ -4,7 +4,7 @@ export default {
content: [
"./src/pages/**/*.{js,ts,jsx,tsx,mdx}",
"./src/components/**/*.{js,ts,jsx,tsx,mdx}",
- "./src/app/**/*.{js,ts,jsx,tsx,mdx}",
+ "./app/**/*.{js,ts,jsx,tsx,mdx}",
],
theme: {
extend: {
@@ -14,7 +14,9 @@ export default {
"letter-grey": "#8D8D8B",
"stroke-line": "#8B8484",
"yellow-cta": "#F6C114",
- "black-text": "1E1E1E"
+ "black-text": '1E1E1E',
+ 'nav-bg': '#1E1E1E',
+ 'nav-bg-hover': '#8D8D8B'
},
fontFamily: {
"bebas-neue": ['Bebas Neue', 'sans-serif'],