From 5465e1491d65b8c598a024f753d4df6b2ce05ad6 Mon Sep 17 00:00:00 2001 From: Blake Matthes Date: Mon, 3 Mar 2025 12:30:29 -0600 Subject: [PATCH] feat(frontend): auth work --- apiDocs/lstV2/Auth/getUserroles.bru | 2 +- frontend/eslint.config.js | 50 +++++++++---------- frontend/package-lock.json | 13 +++++ frontend/package.json | 1 + frontend/src/components/auth/LoginForm.tsx | 3 +- .../src/components/providers/Providers.tsx | 6 +-- frontend/src/routes/index.tsx | 9 ++-- frontend/vite.config.ts | 6 ++- 8 files changed, 55 insertions(+), 35 deletions(-) diff --git a/apiDocs/lstV2/Auth/getUserroles.bru b/apiDocs/lstV2/Auth/getUserroles.bru index a45e363..23918f9 100644 --- a/apiDocs/lstV2/Auth/getUserroles.bru +++ b/apiDocs/lstV2/Auth/getUserroles.bru @@ -11,5 +11,5 @@ get { } auth:bearer { - token: eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJ1c2VyIjp7InVzZXJfaWQiOiIyYzYzODQ3Zi1mMWVjLTRkNTAtOGFkMi05ODBkMWYzZTgwZWIiLCJ1c2VybmFtZSI6Im1hdHRoZXMwMSIsImVtYWlsIjoiYmxha2UubWF0dGhlc0BhbHBsYS5jb20iLCJyb2xlcyI6W10sInJvbGUiOiJ1c2VyIn0sImlhdCI6MTc0MDY3NTMyMiwiZXhwIjoxNzQwNjc4OTIyfQ.D4rLIBAZfo0larMGUmXF6Z2KVnZvRLvth2116JyK2z8 + token: eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJ1c2VyIjp7InVzZXJfaWQiOiIyYzYzODQ3Zi1mMWVjLTRkNTAtOGFkMi05ODBkMWYzZTgwZWIiLCJ1c2VybmFtZSI6Im1hdHRoZXMwMSIsImVtYWlsIjoiYmxha2UubWF0dGhlc0BhbHBsYS5jb20iLCJyb2xlcyI6W10sInJvbGUiOiJ1c2VyIn0sImlhdCI6MTc0MDg2ODMzNCwiZXhwIjoxNzQwODcxOTM0fQ.HpPh56_8API25IeO5FSfYSvAqf97_tKUT_GEBqbggO0 } diff --git a/frontend/eslint.config.js b/frontend/eslint.config.js index 092408a..a96deed 100644 --- a/frontend/eslint.config.js +++ b/frontend/eslint.config.js @@ -1,28 +1,26 @@ -import js from '@eslint/js' -import globals from 'globals' -import reactHooks from 'eslint-plugin-react-hooks' -import reactRefresh from 'eslint-plugin-react-refresh' -import tseslint from 'typescript-eslint' +import js from "@eslint/js"; +import globals from "globals"; +import reactHooks from "eslint-plugin-react-hooks"; +import reactRefresh from "eslint-plugin-react-refresh"; +import tseslint from "typescript-eslint"; export default tseslint.config( - { ignores: ['dist'] }, - { - extends: [js.configs.recommended, ...tseslint.configs.recommended], - files: ['**/*.{ts,tsx}'], - languageOptions: { - ecmaVersion: 2020, - globals: globals.browser, - }, - plugins: { - 'react-hooks': reactHooks, - 'react-refresh': reactRefresh, - }, - rules: { - ...reactHooks.configs.recommended.rules, - 'react-refresh/only-export-components': [ - 'warn', - { allowConstantExport: true }, - ], - }, - }, -) + {ignores: ["dist"]}, + { + extends: [js.configs.recommended, ...tseslint.configs.recommended], + files: ["**/*.{ts,tsx}"], + languageOptions: { + ecmaVersion: 2020, + globals: globals.browser, + }, + plugins: { + "react-hooks": reactHooks, + "react-refresh": reactRefresh, + }, + rules: { + ...reactHooks.configs.recommended.rules, + "react-refresh/only-export-components": ["warn", {allowConstantExport: true}], + "no-console": ["error", {allow: ["warn", "error"]}], + }, + } +); diff --git a/frontend/package-lock.json b/frontend/package-lock.json index 712312e..861e78d 100644 --- a/frontend/package-lock.json +++ b/frontend/package-lock.json @@ -23,6 +23,7 @@ "@tanstack/react-router": "^1.111.11", "class-variance-authority": "^0.7.1", "clsx": "^2.1.1", + "dotenv": "^16.4.7", "hono": "^4.7.2", "js-cookie": "^3.0.5", "jsonwebtoken": "^9.0.2", @@ -3552,6 +3553,18 @@ "node": ">=0.3.1" } }, + "node_modules/dotenv": { + "version": "16.4.7", + "resolved": "https://registry.npmjs.org/dotenv/-/dotenv-16.4.7.tgz", + "integrity": "sha512-47qPchRCykZC03FhkYAhrvwU4xDBFIj1QPqaarj6mdM/hgUzfPHcpkHJOn3mJAufFeeAxAzeGsr5X0M4k6fLZQ==", + "license": "BSD-2-Clause", + "engines": { + "node": ">=12" + }, + "funding": { + "url": "https://dotenvx.com" + } + }, "node_modules/ecdsa-sig-formatter": { "version": "1.0.11", "resolved": "https://registry.npmjs.org/ecdsa-sig-formatter/-/ecdsa-sig-formatter-1.0.11.tgz", diff --git a/frontend/package.json b/frontend/package.json index 454e862..1f5404a 100644 --- a/frontend/package.json +++ b/frontend/package.json @@ -26,6 +26,7 @@ "@tanstack/react-router": "^1.111.11", "class-variance-authority": "^0.7.1", "clsx": "^2.1.1", + "dotenv": "^16.4.7", "hono": "^4.7.2", "js-cookie": "^3.0.5", "jsonwebtoken": "^9.0.2", diff --git a/frontend/src/components/auth/LoginForm.tsx b/frontend/src/components/auth/LoginForm.tsx index cbe233f..998bff4 100644 --- a/frontend/src/components/auth/LoginForm.tsx +++ b/frontend/src/components/auth/LoginForm.tsx @@ -26,7 +26,7 @@ const LoginForm = () => { // } const data = await response.json(); - console.log("Response", data.data); + // console.log("Response", data.data); // Store token in localStorage localStorage.setItem("auth_token", data.data.token); @@ -41,6 +41,7 @@ const LoginForm = () => { setUsername(""); setPassword(""); } catch (err) { + console.error(err); setError("Invalid credentials"); } }; diff --git a/frontend/src/components/providers/Providers.tsx b/frontend/src/components/providers/Providers.tsx index 6a4c6b3..fffefc5 100644 --- a/frontend/src/components/providers/Providers.tsx +++ b/frontend/src/components/providers/Providers.tsx @@ -1,17 +1,17 @@ import {QueryClient, QueryClientProvider} from "@tanstack/react-query"; import {useModuleStore} from "../../lib/store/useModuleStore"; import {useEffect} from "react"; -import {useGetUserRoles} from "@/lib/store/useGetRoles"; +//import {useGetUserRoles} from "@/lib/store/useGetRoles"; const queryClient = new QueryClient(); export const SessionProvider = ({children}: {children: React.ReactNode}) => { const {fetchModules} = useModuleStore(); - const {fetchUserRoles} = useGetUserRoles(); + //const {fetchUserRoles} = useGetUserRoles(); useEffect(() => { fetchModules(); - fetchUserRoles(); + //fetchUserRoles(); }, []); return {children}; }; diff --git a/frontend/src/routes/index.tsx b/frontend/src/routes/index.tsx index 5b7d356..3b68380 100644 --- a/frontend/src/routes/index.tsx +++ b/frontend/src/routes/index.tsx @@ -1,5 +1,5 @@ import {createFileRoute} from "@tanstack/react-router"; -import GridLayout from "react-grid-layout"; +//import GridLayout from "react-grid-layout"; import "../../node_modules/react-grid-layout/css/styles.css"; import "../../node_modules/react-resizable/css/styles.css"; @@ -32,7 +32,7 @@ function Index() { return ( <> {/* */} - + {/*
a
@@ -42,7 +42,10 @@ function Index() {
c
-
+
*/} +
+ Empty Space why dont you add some cards? +
); } diff --git a/frontend/vite.config.ts b/frontend/vite.config.ts index 8c2dcce..485b1e7 100644 --- a/frontend/vite.config.ts +++ b/frontend/vite.config.ts @@ -4,6 +4,10 @@ import tailwindcss from "@tailwindcss/vite"; import {TanStackRouterVite} from "@tanstack/router-plugin/vite"; import path from "path"; +import dotenv from "dotenv"; +import {fileURLToPath} from "url"; +dotenv.config({path: path.resolve(path.dirname(fileURLToPath(import.meta.url)), "../.env")}); + // https://vite.dev/config/ export default defineConfig({ plugins: [react(), tailwindcss(), TanStackRouterVite({target: "react", autoCodeSplitting: true})], @@ -14,7 +18,7 @@ export default defineConfig({ }, server: { proxy: { - "/api": {target: `http://localhost:4400`, changeOrigin: true}, + "/api": {target: `http://localhost:${Number(process.env.VITE_SERVER_PORT || 4400)}`, changeOrigin: true}, }, }, });