From 92de3895d7a45597befa543b553d50c742e3b89f Mon Sep 17 00:00:00 2001 From: TDLaouer Date: Wed, 9 Jul 2025 13:10:38 +0200 Subject: [PATCH] clean css and fetch image uniterally --- src/App.vue | 3 ++ src/assets/base.css | 1 - src/components/Card.vue | 12 ++--- src/components/Game.vue | 57 +++++++++++++---------- src/components/LandingPage.vue | 18 +++++--- src/components/Login.vue | 74 ------------------------------ src/components/Result.vue | 18 +++++--- src/main.ts | 2 +- src/route.ts | 11 +---- src/services/visualAssetService.ts | 6 +-- src/stores/userStore.ts | 32 ------------- src/types/types.ts | 8 +++- 12 files changed, 79 insertions(+), 163 deletions(-) delete mode 100644 src/components/Login.vue delete mode 100644 src/stores/userStore.ts diff --git a/src/App.vue b/src/App.vue index 0f3ec68..9f95c23 100644 --- a/src/App.vue +++ b/src/App.vue @@ -2,6 +2,9 @@ \ No newline at end of file + diff --git a/src/main.ts b/src/main.ts index 9c93f09..e0a3a93 100644 --- a/src/main.ts +++ b/src/main.ts @@ -7,7 +7,7 @@ import 'vue3-toastify/dist/index.css' import axios from 'axios' import { createPinia } from 'pinia' -axios.defaults.baseURL = 'http://localhost:3000' +axios.defaults.baseURL = 'http://localhost:3001' const pinia = createPinia() diff --git a/src/route.ts b/src/route.ts index fdc2d4e..0f5b141 100644 --- a/src/route.ts +++ b/src/route.ts @@ -17,16 +17,7 @@ const routes: RouteRecordRaw[] = [ meta: { title: 'Smash or Pass Game', }, - }, - { - path: '/login', - name: 'login', - props: true, - component: () => import('@/components/Login.vue'), - meta: { - title: 'Login', - }, - }, + } ] const router = createRouter({ history: createWebHistory(), diff --git a/src/services/visualAssetService.ts b/src/services/visualAssetService.ts index c8c72a6..0873774 100644 --- a/src/services/visualAssetService.ts +++ b/src/services/visualAssetService.ts @@ -1,5 +1,5 @@ import axios from 'axios' -import type { FrontVisualAsset, VisualAsset } from '@/types/types.ts' +import type { FrontVisualAsset, FrontVisualAssetWithSrc, VisualAsset } from '@/types/types.ts' export const upload = async (visualAssets: VisualAsset[]): Promise => { try { @@ -44,10 +44,10 @@ export const fetchVisualAssetsByCollection = async ( } } -export const fetchVisualAssetById = async (id: string): Promise => { +export const fetchVisualAssetById = async (id: string): Promise => { try { const response = await axios.get(`/api/visualAssets/${id}`) - return response.data as FrontVisualAsset + return response.data as FrontVisualAssetWithSrc } catch (error) { console.error(`Error fetching visual asset with id ${id}:`, error) throw error diff --git a/src/stores/userStore.ts b/src/stores/userStore.ts deleted file mode 100644 index eb63d44..0000000 --- a/src/stores/userStore.ts +++ /dev/null @@ -1,32 +0,0 @@ -import { defineStore } from 'pinia' -import { ref, watch } from 'vue' - -export const useUserStore = defineStore('user', () => { - const user = ref(localStorage.getItem('user') || null) - const isLoggedIn = ref(!!user.value) - - function login(username: string) { - user.value = username - isLoggedIn.value = true - localStorage.setItem('user', username) - } - - function logout() { - user.value = null - isLoggedIn.value = false - localStorage.removeItem('user') - } - - // Keep session persistent if user changes - watch(user, (newUser) => { - if (newUser) { - localStorage.setItem('user', newUser) - isLoggedIn.value = true - } else { - localStorage.removeItem('user') - isLoggedIn.value = false - } - }) - - return { user, isLoggedIn, login, logout } -}) diff --git a/src/types/types.ts b/src/types/types.ts index 3d04e4b..2ae2d64 100644 --- a/src/types/types.ts +++ b/src/types/types.ts @@ -1,2 +1,8 @@ export type VisualAsset = { collection: string; image: File; name: string } -export type FrontVisualAsset = { _id: string; collection: string; imageSrc: string; name: string } +export type FrontVisualAsset = { _id: string; collection: string; name: string; imageSrc: string } +export type FrontVisualAssetWithSrc = { + _id: string + collection: string + name: string + imageSrc: string +}