Skip to content

Commit

Permalink
Issue 14 create user pinia store (#38)
Browse files Browse the repository at this point in the history
* user.ts v1

* fixed file v1

* Comments Add

* Test included

* Fixed to fit with CI/CD process

* Properties Update & Poetry Fix

* Test files Update

* Repair user.ts

* Emergency Update

* Emergency Update v2

* Comments Update

* Remove Test
  • Loading branch information
mye9 authored Dec 13, 2024
1 parent 98bc2ed commit 36cd7b6
Show file tree
Hide file tree
Showing 4 changed files with 136 additions and 54 deletions.
151 changes: 97 additions & 54 deletions client/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions client/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
"format:check": "prettier --check src/"
},
"dependencies": {
"@vueuse/core": "^12.0.0",
"axios": "^1.7.7",
"pinia": "^2.2.6",
"vue": "^3.5.12",
Expand Down
27 changes: 27 additions & 0 deletions client/src/stores/user.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
import { defineStore } from 'pinia'
import { useStorage } from '@vueuse/core'
import { computed } from 'vue'
import type { User } from '@/types/user'

export const useUserStore = defineStore('user', () => {
const userData = useStorage<User | null>('userData', null)
const accessToken = useStorage<string | null>('accessToken', null)
const refreshToken = useStorage<string | null>('refreshToken', null)

const isLoggedIn = computed(() => userData.value !== null)

//Logout Status
const logout = () => {
userData.value = null
accessToken.value = null
refreshToken.value = null
}

return {
userData,
isLoggedIn,
accessToken,
refreshToken,
logout,
}
})
11 changes: 11 additions & 0 deletions client/src/types/user.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
export interface User {
userId: number
userName: string
firstName: string
lastName: string
bio: string
totalPoints: number
email: string
visibility: 0 | 1 | 2
avatar: 0 | 1 | 2 | 3 | 4 | 5
}

0 comments on commit 36cd7b6

Please sign in to comment.