source: ReserveNGo-frontend/src/PiniaStores/UserStore.js@ 17bf12d

Last change on this file since 17bf12d was 17bf12d, checked in by Ljubomir Ilievski <ilievski.ljubomir@…>, 3 months ago

Zavrsen pogolem del Login/Register Logika

  • Property mode set to 100644
File size: 786 bytes
Line 
1
2import { defineStore } from 'pinia'
3
4
5
6export const userStore = defineStore('userStore', {
7
8 state() {
9 return {
10
11 data: {
12 id: 0,
13 firstName: "",
14 lastName: "",
15 email: "",
16 phoneNumber: "",
17 role: "UN_AUTHENTICATED",
18 token: ""
19 }
20
21 }
22 },
23 actions: {
24
25 setLocalStorage(jsonObject) {
26 //console.log("Local Storage object", jsonObject)
27
28 this.data = jsonObject
29
30 console.log("Local Storage data", this.data.firstName, this.data.lastName)
31
32 localStorage.setItem('userData', JSON.stringify(jsonObject));
33
34 },
35 getLocalStorage() {
36 let nonparsed = localStorage.getItem('userData');
37 if (nonparsed !== null) {
38 this.data = JSON.parse(nonparsed);
39 }
40 }
41
42
43 }
44
45
46
47
48
49
50})
Note: See TracBrowser for help on using the repository browser.