diff --git a/.gitignore b/.gitignore index 174f2a6..bddcabc 100644 --- a/.gitignore +++ b/.gitignore @@ -41,4 +41,8 @@ yarn-error.log* next-env.d.ts # repomix -repomix-output.txt \ No newline at end of file +repomix-output.txt + +# vscode +.vscode/* +!.vscode/settings.json \ No newline at end of file diff --git a/.vscode/settings.json b/.vscode/settings.json new file mode 100644 index 0000000..84c191f --- /dev/null +++ b/.vscode/settings.json @@ -0,0 +1,3 @@ +{ + "scss.lint.unknownAtRules": "ignore" +} \ No newline at end of file diff --git a/bun.lockb b/bun.lockb index 4b91f47..02a3f78 100755 Binary files a/bun.lockb and b/bun.lockb differ diff --git a/package.json b/package.json index c9d540e..01bfa33 100644 --- a/package.json +++ b/package.json @@ -10,12 +10,14 @@ }, "dependencies": { "@mantine/core": "^7.16.1", + "@mantine/form": "^7.16.1", "@mantine/hooks": "^7.16.1", "@mantine/modals": "^7.16.1", "next": "15.1.5", "react": "^19.0.0", "react-dom": "^19.0.0", - "react-icons": "^5.4.0" + "react-icons": "^5.4.0", + "zod": "^3.24.1" }, "devDependencies": { "@eslint/eslintrc": "^3", diff --git a/src/app/admin/actions.ts b/src/app/admin/actions.ts new file mode 100644 index 0000000..0f9c94f --- /dev/null +++ b/src/app/admin/actions.ts @@ -0,0 +1,9 @@ +"use server"; + +import { redirect } from "next/navigation"; + +export async function login(formData: { name: string; password: string }) { + console.log("data"); + console.log(formData); + redirect("/admin/panel"); +} diff --git a/src/app/admin/admin.module.scss b/src/app/admin/admin.module.scss new file mode 100644 index 0000000..e69de29 diff --git a/src/app/admin/page.tsx b/src/app/admin/page.tsx new file mode 100644 index 0000000..4da4321 --- /dev/null +++ b/src/app/admin/page.tsx @@ -0,0 +1,60 @@ +"use client"; + +import { Button, Card, Flex, PasswordInput, Text, TextInput } from "@mantine/core"; +import { hasLength, useForm } from "@mantine/form"; +import { login } from "./actions"; + +interface FormValues { + name: string; + password: string; +} + +const AdminPage = () => { + const form = useForm({ + mode: "uncontrolled", + initialValues: { + name: "", + password: "", + }, + validate: { + name: hasLength({ min: 5 }, "Too short"), + password: hasLength({ min: 5 }, "Too short"), + }, + }); + + return ( + + +
+ + Admin + + + + + +
+
+ ); +}; + +export default AdminPage; diff --git a/src/app/admin/panel/page.tsx b/src/app/admin/panel/page.tsx new file mode 100644 index 0000000..1c45171 --- /dev/null +++ b/src/app/admin/panel/page.tsx @@ -0,0 +1,35 @@ +"use client"; +import { ActionIcon, AppShell, Burger, Flex, Group, Skeleton, useMantineColorScheme } from "@mantine/core"; +import { useDisclosure } from "@mantine/hooks"; +import { LuMoon, LuSun } from "react-icons/lu"; + +const PanelPage = () => { + const [opened, { toggle }] = useDisclosure(); + const { setColorScheme, colorScheme } = useMantineColorScheme(); + const changeColorScheme = () => { + setColorScheme(colorScheme === "light" ? "dark" : "light"); + }; + return ( + + + + + +
Logo
+
+ + {colorScheme === "light" ? : } + +
+
+ + {Array(15) + .fill(0) + .map((_, index) => ( + + ))} + +
+ ); +}; +export default PanelPage; diff --git a/src/app/api/route.ts b/src/app/api/route.ts new file mode 100644 index 0000000..a6b4ce5 --- /dev/null +++ b/src/app/api/route.ts @@ -0,0 +1,3 @@ +export async function GET() { + return Response.json({ test: 1 }); +} diff --git a/src/lib/auth.ts b/src/lib/auth.ts new file mode 100644 index 0000000..9579803 --- /dev/null +++ b/src/lib/auth.ts @@ -0,0 +1,3 @@ +export function isAuthenticated() { + return true; +} diff --git a/src/middleware.ts b/src/middleware.ts new file mode 100644 index 0000000..e387e2f --- /dev/null +++ b/src/middleware.ts @@ -0,0 +1,14 @@ +import { isAuthenticated } from "@/lib/auth"; +import { NextRequest, NextResponse } from "next/server"; + +export const config = { + matcher: "/admin/:path*", +}; + +export function middleware(request: NextRequest) { + const { pathname } = request.nextUrl; + if (pathname === "/admin" || isAuthenticated()) { + return NextResponse.next(); + } + return NextResponse.redirect(new URL("/admin", request.url)); +}