From fd0fc20b7d973de3e4e227afc2ab84e599e42303 Mon Sep 17 00:00:00 2001 From: Edd Date: Thu, 15 Jan 2026 23:26:14 +0000 Subject: [PATCH] login functionality + home page mock --- app/app.vue | 6 +- app/assets/css/tailwind.css | 2 +- app/layouts/default.vue | 68 +++++++++++++++++ app/pages/auth-test.vue | 84 +++++++++++++++++++++ app/pages/auth/login.vue | 147 ++++++++++++++++++++++++++++++++++++ app/pages/index.vue | 48 +++++++++++- app/stores/auth-store.js | 42 +++++++++++ nuxt.config.ts | 30 +++----- package.json | 2 + 9 files changed, 401 insertions(+), 28 deletions(-) create mode 100644 app/layouts/default.vue create mode 100644 app/pages/auth-test.vue create mode 100644 app/pages/auth/login.vue create mode 100644 app/stores/auth-store.js diff --git a/app/app.vue b/app/app.vue index fc2270b..f8eacfa 100644 --- a/app/app.vue +++ b/app/app.vue @@ -1,5 +1,5 @@ diff --git a/app/assets/css/tailwind.css b/app/assets/css/tailwind.css index f1fc49c..15c68bb 100644 --- a/app/assets/css/tailwind.css +++ b/app/assets/css/tailwind.css @@ -1,7 +1,7 @@ @import "tailwindcss"; @import "tw-animate-css"; -@custom-variant dark (&:is(.dark *)); +@custom-variant dark (&:where(.dark, .dark *)); @theme inline { --radius-sm: calc(var(--radius) - 4px); diff --git a/app/layouts/default.vue b/app/layouts/default.vue new file mode 100644 index 0000000..b0fbd8d --- /dev/null +++ b/app/layouts/default.vue @@ -0,0 +1,68 @@ + + diff --git a/app/pages/auth-test.vue b/app/pages/auth-test.vue new file mode 100644 index 0000000..a4bf2ed --- /dev/null +++ b/app/pages/auth-test.vue @@ -0,0 +1,84 @@ + + diff --git a/app/pages/auth/login.vue b/app/pages/auth/login.vue new file mode 100644 index 0000000..545ad25 --- /dev/null +++ b/app/pages/auth/login.vue @@ -0,0 +1,147 @@ + + + + \ No newline at end of file diff --git a/app/pages/index.vue b/app/pages/index.vue index 1e11da8..9b7905c 100644 --- a/app/pages/index.vue +++ b/app/pages/index.vue @@ -1,5 +1,47 @@ + \ No newline at end of file diff --git a/app/stores/auth-store.js b/app/stores/auth-store.js new file mode 100644 index 0000000..1db925e --- /dev/null +++ b/app/stores/auth-store.js @@ -0,0 +1,42 @@ +import { defineStore } from "pinia"; + +export const useAuthStore = defineStore("authStore", () => { + const token = useCookie("auth_token", { maxAge: 60 * 15 }); + const user = useCookie("auth_user", { maxAge: 60 * 15 }); + + if (process.client) { + token.value = localStorage.getItem("auth_token"); + + const savedUser = localStorage.getItem("auth_user"); + if (savedUser) { + try { + user.value = JSON.parse(savedUser); + } catch (e) { + console.error("Failed to parse user from storage", e); + } + } + } + + watch([token, user], ([newToken, newUser]) => { + if (!process.client) return; + + if (newToken) { + localStorage.setItem("auth_token", newToken); + } else { + localStorage.removeItem("auth_token"); + } + + if (newUser) { + localStorage.setItem("auth_user", JSON.stringify(newUser)); + } else { + localStorage.removeItem("auth_user"); + } + }, { deep: true }); + + function logout() { + token.value = null; + user.value = null; + } + + return { token, user, logout }; +}); \ No newline at end of file diff --git a/nuxt.config.ts b/nuxt.config.ts index b9d1747..2d111ff 100644 --- a/nuxt.config.ts +++ b/nuxt.config.ts @@ -1,32 +1,20 @@ import tailwindcss from "@tailwindcss/vite"; -// https://nuxt.com/docs/api/configuration/nuxt-config export default defineNuxtConfig({ - compatibilityDate: "2025-07-15", + compatibilityDate: "2026-01-01", devtools: { enabled: true }, css: ["~/assets/css/tailwind.css"], + vite: { plugins: [tailwindcss()], }, - modules: [ - "@nuxt/fonts", - "@nuxt/icon", - "@nuxt/image", - "@nuxt/eslint", - "shadcn-nuxt", - ], - - shadcn: { - /** - * Prefix for all the imported component - */ - prefix: "", - /** - * Directory that the component lives in. - * @default "./app/components/ui" - */ - componentDir: "./app/components/ui", + runtimeConfig: { + public: { + apiBase: "http://localhost:8080/academics/api/v1", + }, }, -}); + + modules: ["@pinia/nuxt"], +}); \ No newline at end of file diff --git a/package.json b/package.json index 9f6b78c..c0d7953 100644 --- a/package.json +++ b/package.json @@ -20,7 +20,9 @@ "clsx": "^2.1.1", "eslint": "^9.39.0", "lucide-vue-next": "^0.552.0", + "@pinia/nuxt": "0.11.3", "nuxt": "^4.2.0", + "pinia": "^3.0.4", "reka-ui": "^2.6.0", "shadcn-nuxt": "^2.3.2", "tailwind-merge": "^3.3.1",