diff --git a/frontend/src/auth/auth.ts b/frontend/src/auth/auth.ts index 5d0da0b..c94b8ed 100644 --- a/frontend/src/auth/auth.ts +++ b/frontend/src/auth/auth.ts @@ -161,9 +161,6 @@ async function handleRegister(e: Event): Promise { function init(): void { id('login-form-element').addEventListener('submit', handleLogin); id('register-form-element').addEventListener('submit', handleRegister); - - id("login-link").addEventListener("click", showLogin); - id("register-link").addEventListener("click", showRegister); } init(); \ No newline at end of file diff --git a/frontend/src/ui/App.tsx b/frontend/src/ui/App.tsx index cead101..8cb594d 100644 --- a/frontend/src/ui/App.tsx +++ b/frontend/src/ui/App.tsx @@ -1,3 +1,33 @@ +import ChatScreen from "./screen/ChatScreen"; +import LoginScreen from "./screen/LoginScreen"; +import RegisterScreen from "./screen/RegisterScreen"; +import { useAppState } from "./state" + export default function App() { - return <> + const { currentPage } = useAppState(); + + let page = ; + + switch (currentPage) { + case "login": { + page = + break; + } + case "register": { + page = + break; + } + case "chat": { + page = + break; + } + } + + return ( + <> +
+ {page} +
+ + ) } \ No newline at end of file diff --git a/frontend/src/ui/components/Auth.tsx b/frontend/src/ui/components/Auth.tsx new file mode 100644 index 0000000..2a52519 --- /dev/null +++ b/frontend/src/ui/components/Auth.tsx @@ -0,0 +1,11 @@ +import type React from "react"; + +export function AuthContainer({ children }: { children?: React.ReactNode }) { + return ( +
+
+ {children} +
+
+ ) +} \ No newline at end of file diff --git a/frontend/src/ui/screen/ChatScreen.tsx b/frontend/src/ui/screen/ChatScreen.tsx new file mode 100644 index 0000000..605acd0 --- /dev/null +++ b/frontend/src/ui/screen/ChatScreen.tsx @@ -0,0 +1,5 @@ +export default function ChatScreen() { + return ( +

test

+ ) +} \ No newline at end of file diff --git a/frontend/src/ui/screen/LoginScreen.tsx b/frontend/src/ui/screen/LoginScreen.tsx new file mode 100644 index 0000000..0121543 --- /dev/null +++ b/frontend/src/ui/screen/LoginScreen.tsx @@ -0,0 +1,57 @@ +import { showLogin, showRegister } from "../../navigation"; +import { AuthContainer } from "../components/Auth"; + +export default function LoginScreen() { + return ( + +
+

+ login + Добро пожаловать! +

+

Войдите в свой аккаунт

+
+
+
+ +
+ + + + + + Войти +
+ +
+

+ Ещё нет аккаунта? + + Зарегистрируйтесь + +

+
+
+
+ ) +} \ No newline at end of file diff --git a/frontend/src/ui/screen/RegisterScreen.tsx b/frontend/src/ui/screen/RegisterScreen.tsx new file mode 100644 index 0000000..8940ecf --- /dev/null +++ b/frontend/src/ui/screen/RegisterScreen.tsx @@ -0,0 +1,70 @@ +import { showLogin } from "../../navigation"; +import { AuthContainer } from "../components/Auth"; + +export default function RegisterScreen() { + return ( + +
+

+ person_add + Регистрация +

+

Создайте новый аккаунт

+
+
+
+ +
+ + + + + + + + Зарегистрироваться +
+ +
+

+ Уже есть аккаунт? + + Войдите + +

+
+
+
+ ) +} \ No newline at end of file diff --git a/frontend/src/ui/state.ts b/frontend/src/ui/state.ts new file mode 100644 index 0000000..022678a --- /dev/null +++ b/frontend/src/ui/state.ts @@ -0,0 +1,13 @@ +import { create } from "zustand"; + +type Page = "login" | "register" | "chat" + +interface AppState { + currentPage: Page; + setCurrentPage: (page: Page) => void; +} + +export const useAppState = create((set) => ({ + currentPage: "login", // default page + setCurrentPage: (page: Page) => set({ currentPage: page }) +})); \ No newline at end of file diff --git a/frontend/src/vite-env.d.ts b/frontend/src/vite-env.d.ts index 151aa68..1f13624 100644 --- a/frontend/src/vite-env.d.ts +++ b/frontend/src/vite-env.d.ts @@ -1 +1,2 @@ -/// \ No newline at end of file +/// +/// \ No newline at end of file diff --git a/package.json b/package.json index 5082110..8d2999b 100644 --- a/package.json +++ b/package.json @@ -29,6 +29,9 @@ "prepare": "husky" }, "devDependencies": { + "@types/react": "^19.1.12", + "@types/react-dom": "^19.1.9", + "@vitejs/plugin-react": "^5.0.2", "autoprefixer": "^10.4.21", "concurrently": "^9.2.0", "dotenv-cli": "^10.0.0", @@ -41,15 +44,13 @@ "vite": "^7.1.2", "vite-plugin-electron": "^0.29.0", "vite-plugin-electron-renderer": "^0.14.6", - "vite-plugin-html": "^3.2.2", - "@vitejs/plugin-react": "^5.0.2", - "@types/react": "^19.1.12", - "@types/react-dom": "^19.1.9" + "vite-plugin-html": "^3.2.2" }, "dependencies": { "mdui": "^2.1.4", - "tweetnacl": "^1.0.3", "react": "^19.1.1", - "react-dom": "^19.1.1" + "react-dom": "^19.1.1", + "tweetnacl": "^1.0.3", + "zustand": "^5.0.8" } }