@bid-scents/shared-sdk 1.1.6 → 1.1.7
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/stores/auth.d.ts +8 -0
- package/dist/stores/auth.d.ts.map +1 -1
- package/dist/stores/auth.js +44 -3
- package/package.json +1 -1
package/dist/stores/auth.d.ts
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import type { User } from '../api/models/User';
|
|
2
2
|
import type { LoginResponse } from '../api/models/LoginResponse';
|
|
3
|
+
import type { PaymentData } from '../api/models/PaymentData';
|
|
3
4
|
interface AuthState {
|
|
4
5
|
user: User | null;
|
|
5
6
|
session: any | null;
|
|
@@ -8,6 +9,10 @@ interface AuthState {
|
|
|
8
9
|
loading: boolean;
|
|
9
10
|
error: string | null;
|
|
10
11
|
deviceToken: string | null;
|
|
12
|
+
favorites: string[];
|
|
13
|
+
paymentDetails: PaymentData | null;
|
|
14
|
+
unreadMessages: number;
|
|
15
|
+
unseenNotifications: number;
|
|
11
16
|
setUser: (user: User | null) => void;
|
|
12
17
|
setSession: (session: any | null) => void;
|
|
13
18
|
setAuthState: (session: any | null, loginResponse: LoginResponse | null) => void;
|
|
@@ -15,6 +20,9 @@ interface AuthState {
|
|
|
15
20
|
setError: (error: string | null) => void;
|
|
16
21
|
logout: () => void;
|
|
17
22
|
setDeviceToken: (deviceToken: string | null) => void;
|
|
23
|
+
setFavorites: (favorites: string[]) => void;
|
|
24
|
+
setPaymentDetails: (paymentDetails: PaymentData | null) => void;
|
|
25
|
+
setMessageCounts: (unreadMessages: number, unseenNotifications: number) => void;
|
|
18
26
|
}
|
|
19
27
|
/**
|
|
20
28
|
* Zustand store for authentication state management with Supabase.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"auth.d.ts","sourceRoot":"","sources":["../../src/stores/auth.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,oBAAoB,CAAA;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AAY,EAAE,CAAC,SAAS,EAAE,MAAM,EAAE,KAAK,IAAI,CAAA;IAC3C,iBAAiB,EAAE,CAAC,cAAc,EAAE,WAAW,GAAG,IAAI,KAAK,IAAI,CAAA;IAC/D,gBAAgB,EAAE,CAAC,cAAc,EAAE,MAAM,EAAE,mBAAmB,EAAE,MAAM,KAAK,IAAI,CAAA;CAChF;AAED;;;;;;;;;;;;;;;;;;;;GAoBG;AACH,eAAO,MAAM,YAAY;;;;;;;;;;EAuJxB,CAAA"}
|
package/dist/stores/auth.js
CHANGED
|
@@ -22,7 +22,7 @@ import AsyncStorage from '@react-native-async-storage/async-storage';
|
|
|
22
22
|
*
|
|
23
23
|
* @returns Auth store with user state, session, loading, and actions
|
|
24
24
|
*/
|
|
25
|
-
export const useAuthStore = create()(persist((set) => ({
|
|
25
|
+
export const useAuthStore = create()(persist((set, get) => ({
|
|
26
26
|
user: null,
|
|
27
27
|
session: null,
|
|
28
28
|
isAuthenticated: false,
|
|
@@ -30,6 +30,10 @@ export const useAuthStore = create()(persist((set) => ({
|
|
|
30
30
|
loading: true,
|
|
31
31
|
error: null,
|
|
32
32
|
deviceToken: null,
|
|
33
|
+
favorites: [],
|
|
34
|
+
paymentDetails: null,
|
|
35
|
+
unreadMessages: 0,
|
|
36
|
+
unseenNotifications: 0,
|
|
33
37
|
/**
|
|
34
38
|
* Updates the current user only (without changing auth state).
|
|
35
39
|
* Use setAuthState() for complete auth state updates.
|
|
@@ -64,6 +68,10 @@ export const useAuthStore = create()(persist((set) => ({
|
|
|
64
68
|
isAuthenticated: !!session,
|
|
65
69
|
isOnboarded: loginResponse?.onboarded || false,
|
|
66
70
|
user: loginResponse?.profile || null,
|
|
71
|
+
favorites: loginResponse?.favorites || [],
|
|
72
|
+
paymentDetails: loginResponse?.payment_details || null,
|
|
73
|
+
unreadMessages: loginResponse?.unread_messages || 0,
|
|
74
|
+
unseenNotifications: loginResponse?.unseen_notifications || 0,
|
|
67
75
|
loading: false,
|
|
68
76
|
error: null
|
|
69
77
|
});
|
|
@@ -94,7 +102,11 @@ export const useAuthStore = create()(persist((set) => ({
|
|
|
94
102
|
isAuthenticated: false,
|
|
95
103
|
isOnboarded: false,
|
|
96
104
|
loading: false,
|
|
97
|
-
error: null
|
|
105
|
+
error: null,
|
|
106
|
+
favorites: [],
|
|
107
|
+
paymentDetails: null,
|
|
108
|
+
unreadMessages: 0,
|
|
109
|
+
unseenNotifications: 0
|
|
98
110
|
});
|
|
99
111
|
},
|
|
100
112
|
/**
|
|
@@ -104,6 +116,31 @@ export const useAuthStore = create()(persist((set) => ({
|
|
|
104
116
|
*/
|
|
105
117
|
setDeviceToken: (deviceToken) => {
|
|
106
118
|
set({ deviceToken });
|
|
119
|
+
},
|
|
120
|
+
/**
|
|
121
|
+
* Updates the user's favorite listings.
|
|
122
|
+
*
|
|
123
|
+
* @param favorites - Array of listing IDs
|
|
124
|
+
*/
|
|
125
|
+
setFavorites: (favorites) => {
|
|
126
|
+
set({ favorites });
|
|
127
|
+
},
|
|
128
|
+
/**
|
|
129
|
+
* Updates the user's payment details.
|
|
130
|
+
*
|
|
131
|
+
* @param paymentDetails - Payment data or null to clear
|
|
132
|
+
*/
|
|
133
|
+
setPaymentDetails: (paymentDetails) => {
|
|
134
|
+
set({ paymentDetails });
|
|
135
|
+
},
|
|
136
|
+
/**
|
|
137
|
+
* Updates message and notification counts.
|
|
138
|
+
*
|
|
139
|
+
* @param unreadMessages - Number of unread messages
|
|
140
|
+
* @param unseenNotifications - Number of unseen notifications
|
|
141
|
+
*/
|
|
142
|
+
setMessageCounts: (unreadMessages, unseenNotifications) => {
|
|
143
|
+
set({ unreadMessages, unseenNotifications });
|
|
107
144
|
}
|
|
108
145
|
}), {
|
|
109
146
|
name: 'auth-storage',
|
|
@@ -113,7 +150,11 @@ export const useAuthStore = create()(persist((set) => ({
|
|
|
113
150
|
session: state.session,
|
|
114
151
|
isAuthenticated: state.isAuthenticated,
|
|
115
152
|
isOnboarded: state.isOnboarded,
|
|
116
|
-
deviceToken: state.deviceToken
|
|
153
|
+
deviceToken: state.deviceToken,
|
|
154
|
+
favorites: state.favorites,
|
|
155
|
+
paymentDetails: state.paymentDetails,
|
|
156
|
+
unreadMessages: state.unreadMessages,
|
|
157
|
+
unseenNotifications: state.unseenNotifications,
|
|
117
158
|
// Don't persist loading or error states
|
|
118
159
|
})
|
|
119
160
|
}));
|