@pfm-platform/users-feature 0.2.0 → 0.2.1
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/hooks/useCurrentUser.d.ts +111 -111
- package/dist/hooks/useUserSettings.d.ts +110 -110
- package/dist/index.cjs.map +1 -1
- package/dist/index.js.map +1 -1
- package/package.json +11 -11
|
@@ -2,10 +2,10 @@
|
|
|
2
2
|
* Hook for accessing current user profile
|
|
3
3
|
* Wraps useUser from data-access layer with feature-specific logic
|
|
4
4
|
*/
|
|
5
|
-
import type {
|
|
5
|
+
import type { UserProfileRow } from '@pfm-platform/shared';
|
|
6
6
|
import type { UseQueryOptions } from '@tanstack/react-query';
|
|
7
7
|
export interface CurrentUserProfile {
|
|
8
|
-
user:
|
|
8
|
+
user: UserProfileRow;
|
|
9
9
|
hasCustomSettings: boolean;
|
|
10
10
|
termsAccepted: boolean;
|
|
11
11
|
email: string;
|
|
@@ -35,7 +35,7 @@ export interface CurrentUserProfile {
|
|
|
35
35
|
* }
|
|
36
36
|
* ```
|
|
37
37
|
*/
|
|
38
|
-
export declare function useCurrentUser(options?: Omit<UseQueryOptions<
|
|
38
|
+
export declare function useCurrentUser(options?: Omit<UseQueryOptions<UserProfileRow>, 'queryKey' | 'queryFn'>): {
|
|
39
39
|
error: Error;
|
|
40
40
|
isError: true;
|
|
41
41
|
isPending: false;
|
|
@@ -63,18 +63,18 @@ export declare function useCurrentUser(options?: Omit<UseQueryOptions<User>, 'qu
|
|
|
63
63
|
login: string;
|
|
64
64
|
email: string;
|
|
65
65
|
login_count: number;
|
|
66
|
-
last_login_at: string;
|
|
67
|
-
custom_tags:
|
|
68
|
-
custom_settings:
|
|
69
|
-
[x: string]: unknown;
|
|
70
|
-
};
|
|
66
|
+
last_login_at: string | null;
|
|
67
|
+
custom_tags: unknown;
|
|
68
|
+
custom_settings: unknown;
|
|
71
69
|
first_name: string;
|
|
72
70
|
last_name: string;
|
|
73
71
|
postal_code: string;
|
|
74
|
-
birth_year: number;
|
|
75
|
-
sex: "Male" | "Female";
|
|
76
|
-
city
|
|
77
|
-
state
|
|
72
|
+
birth_year: number | null;
|
|
73
|
+
sex: "Male" | "Female" | null;
|
|
74
|
+
city: string | null;
|
|
75
|
+
state: string | null;
|
|
76
|
+
created_at: string | null;
|
|
77
|
+
updated_at: string | null;
|
|
78
78
|
}, Error>>;
|
|
79
79
|
fetchStatus: import("@tanstack/react-query").FetchStatus;
|
|
80
80
|
promise: Promise<{
|
|
@@ -82,18 +82,18 @@ export declare function useCurrentUser(options?: Omit<UseQueryOptions<User>, 'qu
|
|
|
82
82
|
login: string;
|
|
83
83
|
email: string;
|
|
84
84
|
login_count: number;
|
|
85
|
-
last_login_at: string;
|
|
86
|
-
custom_tags:
|
|
87
|
-
custom_settings:
|
|
88
|
-
[x: string]: unknown;
|
|
89
|
-
};
|
|
85
|
+
last_login_at: string | null;
|
|
86
|
+
custom_tags: unknown;
|
|
87
|
+
custom_settings: unknown;
|
|
90
88
|
first_name: string;
|
|
91
89
|
last_name: string;
|
|
92
90
|
postal_code: string;
|
|
93
|
-
birth_year: number;
|
|
94
|
-
sex: "Male" | "Female";
|
|
95
|
-
city
|
|
96
|
-
state
|
|
91
|
+
birth_year: number | null;
|
|
92
|
+
sex: "Male" | "Female" | null;
|
|
93
|
+
city: string | null;
|
|
94
|
+
state: string | null;
|
|
95
|
+
created_at: string | null;
|
|
96
|
+
updated_at: string | null;
|
|
97
97
|
}>;
|
|
98
98
|
data: CurrentUserProfile | null;
|
|
99
99
|
} | {
|
|
@@ -124,18 +124,18 @@ export declare function useCurrentUser(options?: Omit<UseQueryOptions<User>, 'qu
|
|
|
124
124
|
login: string;
|
|
125
125
|
email: string;
|
|
126
126
|
login_count: number;
|
|
127
|
-
last_login_at: string;
|
|
128
|
-
custom_tags:
|
|
129
|
-
custom_settings:
|
|
130
|
-
[x: string]: unknown;
|
|
131
|
-
};
|
|
127
|
+
last_login_at: string | null;
|
|
128
|
+
custom_tags: unknown;
|
|
129
|
+
custom_settings: unknown;
|
|
132
130
|
first_name: string;
|
|
133
131
|
last_name: string;
|
|
134
132
|
postal_code: string;
|
|
135
|
-
birth_year: number;
|
|
136
|
-
sex: "Male" | "Female";
|
|
137
|
-
city
|
|
138
|
-
state
|
|
133
|
+
birth_year: number | null;
|
|
134
|
+
sex: "Male" | "Female" | null;
|
|
135
|
+
city: string | null;
|
|
136
|
+
state: string | null;
|
|
137
|
+
created_at: string | null;
|
|
138
|
+
updated_at: string | null;
|
|
139
139
|
}, Error>>;
|
|
140
140
|
fetchStatus: import("@tanstack/react-query").FetchStatus;
|
|
141
141
|
promise: Promise<{
|
|
@@ -143,18 +143,18 @@ export declare function useCurrentUser(options?: Omit<UseQueryOptions<User>, 'qu
|
|
|
143
143
|
login: string;
|
|
144
144
|
email: string;
|
|
145
145
|
login_count: number;
|
|
146
|
-
last_login_at: string;
|
|
147
|
-
custom_tags:
|
|
148
|
-
custom_settings:
|
|
149
|
-
[x: string]: unknown;
|
|
150
|
-
};
|
|
146
|
+
last_login_at: string | null;
|
|
147
|
+
custom_tags: unknown;
|
|
148
|
+
custom_settings: unknown;
|
|
151
149
|
first_name: string;
|
|
152
150
|
last_name: string;
|
|
153
151
|
postal_code: string;
|
|
154
|
-
birth_year: number;
|
|
155
|
-
sex: "Male" | "Female";
|
|
156
|
-
city
|
|
157
|
-
state
|
|
152
|
+
birth_year: number | null;
|
|
153
|
+
sex: "Male" | "Female" | null;
|
|
154
|
+
city: string | null;
|
|
155
|
+
state: string | null;
|
|
156
|
+
created_at: string | null;
|
|
157
|
+
updated_at: string | null;
|
|
158
158
|
}>;
|
|
159
159
|
data: CurrentUserProfile | null;
|
|
160
160
|
} | {
|
|
@@ -185,18 +185,18 @@ export declare function useCurrentUser(options?: Omit<UseQueryOptions<User>, 'qu
|
|
|
185
185
|
login: string;
|
|
186
186
|
email: string;
|
|
187
187
|
login_count: number;
|
|
188
|
-
last_login_at: string;
|
|
189
|
-
custom_tags:
|
|
190
|
-
custom_settings:
|
|
191
|
-
[x: string]: unknown;
|
|
192
|
-
};
|
|
188
|
+
last_login_at: string | null;
|
|
189
|
+
custom_tags: unknown;
|
|
190
|
+
custom_settings: unknown;
|
|
193
191
|
first_name: string;
|
|
194
192
|
last_name: string;
|
|
195
193
|
postal_code: string;
|
|
196
|
-
birth_year: number;
|
|
197
|
-
sex: "Male" | "Female";
|
|
198
|
-
city
|
|
199
|
-
state
|
|
194
|
+
birth_year: number | null;
|
|
195
|
+
sex: "Male" | "Female" | null;
|
|
196
|
+
city: string | null;
|
|
197
|
+
state: string | null;
|
|
198
|
+
created_at: string | null;
|
|
199
|
+
updated_at: string | null;
|
|
200
200
|
}, Error>>;
|
|
201
201
|
fetchStatus: import("@tanstack/react-query").FetchStatus;
|
|
202
202
|
promise: Promise<{
|
|
@@ -204,18 +204,18 @@ export declare function useCurrentUser(options?: Omit<UseQueryOptions<User>, 'qu
|
|
|
204
204
|
login: string;
|
|
205
205
|
email: string;
|
|
206
206
|
login_count: number;
|
|
207
|
-
last_login_at: string;
|
|
208
|
-
custom_tags:
|
|
209
|
-
custom_settings:
|
|
210
|
-
[x: string]: unknown;
|
|
211
|
-
};
|
|
207
|
+
last_login_at: string | null;
|
|
208
|
+
custom_tags: unknown;
|
|
209
|
+
custom_settings: unknown;
|
|
212
210
|
first_name: string;
|
|
213
211
|
last_name: string;
|
|
214
212
|
postal_code: string;
|
|
215
|
-
birth_year: number;
|
|
216
|
-
sex: "Male" | "Female";
|
|
217
|
-
city
|
|
218
|
-
state
|
|
213
|
+
birth_year: number | null;
|
|
214
|
+
sex: "Male" | "Female" | null;
|
|
215
|
+
city: string | null;
|
|
216
|
+
state: string | null;
|
|
217
|
+
created_at: string | null;
|
|
218
|
+
updated_at: string | null;
|
|
219
219
|
}>;
|
|
220
220
|
data: CurrentUserProfile | null;
|
|
221
221
|
} | {
|
|
@@ -246,18 +246,18 @@ export declare function useCurrentUser(options?: Omit<UseQueryOptions<User>, 'qu
|
|
|
246
246
|
login: string;
|
|
247
247
|
email: string;
|
|
248
248
|
login_count: number;
|
|
249
|
-
last_login_at: string;
|
|
250
|
-
custom_tags:
|
|
251
|
-
custom_settings:
|
|
252
|
-
[x: string]: unknown;
|
|
253
|
-
};
|
|
249
|
+
last_login_at: string | null;
|
|
250
|
+
custom_tags: unknown;
|
|
251
|
+
custom_settings: unknown;
|
|
254
252
|
first_name: string;
|
|
255
253
|
last_name: string;
|
|
256
254
|
postal_code: string;
|
|
257
|
-
birth_year: number;
|
|
258
|
-
sex: "Male" | "Female";
|
|
259
|
-
city
|
|
260
|
-
state
|
|
255
|
+
birth_year: number | null;
|
|
256
|
+
sex: "Male" | "Female" | null;
|
|
257
|
+
city: string | null;
|
|
258
|
+
state: string | null;
|
|
259
|
+
created_at: string | null;
|
|
260
|
+
updated_at: string | null;
|
|
261
261
|
}, Error>>;
|
|
262
262
|
fetchStatus: import("@tanstack/react-query").FetchStatus;
|
|
263
263
|
promise: Promise<{
|
|
@@ -265,18 +265,18 @@ export declare function useCurrentUser(options?: Omit<UseQueryOptions<User>, 'qu
|
|
|
265
265
|
login: string;
|
|
266
266
|
email: string;
|
|
267
267
|
login_count: number;
|
|
268
|
-
last_login_at: string;
|
|
269
|
-
custom_tags:
|
|
270
|
-
custom_settings:
|
|
271
|
-
[x: string]: unknown;
|
|
272
|
-
};
|
|
268
|
+
last_login_at: string | null;
|
|
269
|
+
custom_tags: unknown;
|
|
270
|
+
custom_settings: unknown;
|
|
273
271
|
first_name: string;
|
|
274
272
|
last_name: string;
|
|
275
273
|
postal_code: string;
|
|
276
|
-
birth_year: number;
|
|
277
|
-
sex: "Male" | "Female";
|
|
278
|
-
city
|
|
279
|
-
state
|
|
274
|
+
birth_year: number | null;
|
|
275
|
+
sex: "Male" | "Female" | null;
|
|
276
|
+
city: string | null;
|
|
277
|
+
state: string | null;
|
|
278
|
+
created_at: string | null;
|
|
279
|
+
updated_at: string | null;
|
|
280
280
|
}>;
|
|
281
281
|
data: CurrentUserProfile | null;
|
|
282
282
|
} | {
|
|
@@ -307,18 +307,18 @@ export declare function useCurrentUser(options?: Omit<UseQueryOptions<User>, 'qu
|
|
|
307
307
|
login: string;
|
|
308
308
|
email: string;
|
|
309
309
|
login_count: number;
|
|
310
|
-
last_login_at: string;
|
|
311
|
-
custom_tags:
|
|
312
|
-
custom_settings:
|
|
313
|
-
[x: string]: unknown;
|
|
314
|
-
};
|
|
310
|
+
last_login_at: string | null;
|
|
311
|
+
custom_tags: unknown;
|
|
312
|
+
custom_settings: unknown;
|
|
315
313
|
first_name: string;
|
|
316
314
|
last_name: string;
|
|
317
315
|
postal_code: string;
|
|
318
|
-
birth_year: number;
|
|
319
|
-
sex: "Male" | "Female";
|
|
320
|
-
city
|
|
321
|
-
state
|
|
316
|
+
birth_year: number | null;
|
|
317
|
+
sex: "Male" | "Female" | null;
|
|
318
|
+
city: string | null;
|
|
319
|
+
state: string | null;
|
|
320
|
+
created_at: string | null;
|
|
321
|
+
updated_at: string | null;
|
|
322
322
|
}, Error>>;
|
|
323
323
|
fetchStatus: import("@tanstack/react-query").FetchStatus;
|
|
324
324
|
promise: Promise<{
|
|
@@ -326,18 +326,18 @@ export declare function useCurrentUser(options?: Omit<UseQueryOptions<User>, 'qu
|
|
|
326
326
|
login: string;
|
|
327
327
|
email: string;
|
|
328
328
|
login_count: number;
|
|
329
|
-
last_login_at: string;
|
|
330
|
-
custom_tags:
|
|
331
|
-
custom_settings:
|
|
332
|
-
[x: string]: unknown;
|
|
333
|
-
};
|
|
329
|
+
last_login_at: string | null;
|
|
330
|
+
custom_tags: unknown;
|
|
331
|
+
custom_settings: unknown;
|
|
334
332
|
first_name: string;
|
|
335
333
|
last_name: string;
|
|
336
334
|
postal_code: string;
|
|
337
|
-
birth_year: number;
|
|
338
|
-
sex: "Male" | "Female";
|
|
339
|
-
city
|
|
340
|
-
state
|
|
335
|
+
birth_year: number | null;
|
|
336
|
+
sex: "Male" | "Female" | null;
|
|
337
|
+
city: string | null;
|
|
338
|
+
state: string | null;
|
|
339
|
+
created_at: string | null;
|
|
340
|
+
updated_at: string | null;
|
|
341
341
|
}>;
|
|
342
342
|
data: CurrentUserProfile | null;
|
|
343
343
|
} | {
|
|
@@ -368,18 +368,18 @@ export declare function useCurrentUser(options?: Omit<UseQueryOptions<User>, 'qu
|
|
|
368
368
|
login: string;
|
|
369
369
|
email: string;
|
|
370
370
|
login_count: number;
|
|
371
|
-
last_login_at: string;
|
|
372
|
-
custom_tags:
|
|
373
|
-
custom_settings:
|
|
374
|
-
[x: string]: unknown;
|
|
375
|
-
};
|
|
371
|
+
last_login_at: string | null;
|
|
372
|
+
custom_tags: unknown;
|
|
373
|
+
custom_settings: unknown;
|
|
376
374
|
first_name: string;
|
|
377
375
|
last_name: string;
|
|
378
376
|
postal_code: string;
|
|
379
|
-
birth_year: number;
|
|
380
|
-
sex: "Male" | "Female";
|
|
381
|
-
city
|
|
382
|
-
state
|
|
377
|
+
birth_year: number | null;
|
|
378
|
+
sex: "Male" | "Female" | null;
|
|
379
|
+
city: string | null;
|
|
380
|
+
state: string | null;
|
|
381
|
+
created_at: string | null;
|
|
382
|
+
updated_at: string | null;
|
|
383
383
|
}, Error>>;
|
|
384
384
|
fetchStatus: import("@tanstack/react-query").FetchStatus;
|
|
385
385
|
promise: Promise<{
|
|
@@ -387,18 +387,18 @@ export declare function useCurrentUser(options?: Omit<UseQueryOptions<User>, 'qu
|
|
|
387
387
|
login: string;
|
|
388
388
|
email: string;
|
|
389
389
|
login_count: number;
|
|
390
|
-
last_login_at: string;
|
|
391
|
-
custom_tags:
|
|
392
|
-
custom_settings:
|
|
393
|
-
[x: string]: unknown;
|
|
394
|
-
};
|
|
390
|
+
last_login_at: string | null;
|
|
391
|
+
custom_tags: unknown;
|
|
392
|
+
custom_settings: unknown;
|
|
395
393
|
first_name: string;
|
|
396
394
|
last_name: string;
|
|
397
395
|
postal_code: string;
|
|
398
|
-
birth_year: number;
|
|
399
|
-
sex: "Male" | "Female";
|
|
400
|
-
city
|
|
401
|
-
state
|
|
396
|
+
birth_year: number | null;
|
|
397
|
+
sex: "Male" | "Female" | null;
|
|
398
|
+
city: string | null;
|
|
399
|
+
state: string | null;
|
|
400
|
+
created_at: string | null;
|
|
401
|
+
updated_at: string | null;
|
|
402
402
|
}>;
|
|
403
403
|
data: CurrentUserProfile | null;
|
|
404
404
|
};
|
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
* Provides type-safe access to nested custom_settings object
|
|
4
4
|
*/
|
|
5
5
|
import type { UseQueryOptions } from '@tanstack/react-query';
|
|
6
|
-
import type {
|
|
6
|
+
import type { UserProfileRow } from '@pfm-platform/shared';
|
|
7
7
|
export interface UserSettings {
|
|
8
8
|
aggregation?: {
|
|
9
9
|
termsAccepted?: boolean;
|
|
@@ -40,7 +40,7 @@ export interface UserSettingsResult {
|
|
|
40
40
|
* }
|
|
41
41
|
* ```
|
|
42
42
|
*/
|
|
43
|
-
export declare function useUserSettings(options?: Omit<UseQueryOptions<
|
|
43
|
+
export declare function useUserSettings(options?: Omit<UseQueryOptions<UserProfileRow>, 'queryKey' | 'queryFn'>): {
|
|
44
44
|
error: Error;
|
|
45
45
|
isError: true;
|
|
46
46
|
isPending: false;
|
|
@@ -68,18 +68,18 @@ export declare function useUserSettings(options?: Omit<UseQueryOptions<User>, 'q
|
|
|
68
68
|
login: string;
|
|
69
69
|
email: string;
|
|
70
70
|
login_count: number;
|
|
71
|
-
last_login_at: string;
|
|
72
|
-
custom_tags:
|
|
73
|
-
custom_settings:
|
|
74
|
-
[x: string]: unknown;
|
|
75
|
-
};
|
|
71
|
+
last_login_at: string | null;
|
|
72
|
+
custom_tags: unknown;
|
|
73
|
+
custom_settings: unknown;
|
|
76
74
|
first_name: string;
|
|
77
75
|
last_name: string;
|
|
78
76
|
postal_code: string;
|
|
79
|
-
birth_year: number;
|
|
80
|
-
sex: "Male" | "Female";
|
|
81
|
-
city
|
|
82
|
-
state
|
|
77
|
+
birth_year: number | null;
|
|
78
|
+
sex: "Male" | "Female" | null;
|
|
79
|
+
city: string | null;
|
|
80
|
+
state: string | null;
|
|
81
|
+
created_at: string | null;
|
|
82
|
+
updated_at: string | null;
|
|
83
83
|
}, Error>>;
|
|
84
84
|
fetchStatus: import("@tanstack/react-query").FetchStatus;
|
|
85
85
|
promise: Promise<{
|
|
@@ -87,18 +87,18 @@ export declare function useUserSettings(options?: Omit<UseQueryOptions<User>, 'q
|
|
|
87
87
|
login: string;
|
|
88
88
|
email: string;
|
|
89
89
|
login_count: number;
|
|
90
|
-
last_login_at: string;
|
|
91
|
-
custom_tags:
|
|
92
|
-
custom_settings:
|
|
93
|
-
[x: string]: unknown;
|
|
94
|
-
};
|
|
90
|
+
last_login_at: string | null;
|
|
91
|
+
custom_tags: unknown;
|
|
92
|
+
custom_settings: unknown;
|
|
95
93
|
first_name: string;
|
|
96
94
|
last_name: string;
|
|
97
95
|
postal_code: string;
|
|
98
|
-
birth_year: number;
|
|
99
|
-
sex: "Male" | "Female";
|
|
100
|
-
city
|
|
101
|
-
state
|
|
96
|
+
birth_year: number | null;
|
|
97
|
+
sex: "Male" | "Female" | null;
|
|
98
|
+
city: string | null;
|
|
99
|
+
state: string | null;
|
|
100
|
+
created_at: string | null;
|
|
101
|
+
updated_at: string | null;
|
|
102
102
|
}>;
|
|
103
103
|
data: UserSettingsResult | null;
|
|
104
104
|
} | {
|
|
@@ -129,18 +129,18 @@ export declare function useUserSettings(options?: Omit<UseQueryOptions<User>, 'q
|
|
|
129
129
|
login: string;
|
|
130
130
|
email: string;
|
|
131
131
|
login_count: number;
|
|
132
|
-
last_login_at: string;
|
|
133
|
-
custom_tags:
|
|
134
|
-
custom_settings:
|
|
135
|
-
[x: string]: unknown;
|
|
136
|
-
};
|
|
132
|
+
last_login_at: string | null;
|
|
133
|
+
custom_tags: unknown;
|
|
134
|
+
custom_settings: unknown;
|
|
137
135
|
first_name: string;
|
|
138
136
|
last_name: string;
|
|
139
137
|
postal_code: string;
|
|
140
|
-
birth_year: number;
|
|
141
|
-
sex: "Male" | "Female";
|
|
142
|
-
city
|
|
143
|
-
state
|
|
138
|
+
birth_year: number | null;
|
|
139
|
+
sex: "Male" | "Female" | null;
|
|
140
|
+
city: string | null;
|
|
141
|
+
state: string | null;
|
|
142
|
+
created_at: string | null;
|
|
143
|
+
updated_at: string | null;
|
|
144
144
|
}, Error>>;
|
|
145
145
|
fetchStatus: import("@tanstack/react-query").FetchStatus;
|
|
146
146
|
promise: Promise<{
|
|
@@ -148,18 +148,18 @@ export declare function useUserSettings(options?: Omit<UseQueryOptions<User>, 'q
|
|
|
148
148
|
login: string;
|
|
149
149
|
email: string;
|
|
150
150
|
login_count: number;
|
|
151
|
-
last_login_at: string;
|
|
152
|
-
custom_tags:
|
|
153
|
-
custom_settings:
|
|
154
|
-
[x: string]: unknown;
|
|
155
|
-
};
|
|
151
|
+
last_login_at: string | null;
|
|
152
|
+
custom_tags: unknown;
|
|
153
|
+
custom_settings: unknown;
|
|
156
154
|
first_name: string;
|
|
157
155
|
last_name: string;
|
|
158
156
|
postal_code: string;
|
|
159
|
-
birth_year: number;
|
|
160
|
-
sex: "Male" | "Female";
|
|
161
|
-
city
|
|
162
|
-
state
|
|
157
|
+
birth_year: number | null;
|
|
158
|
+
sex: "Male" | "Female" | null;
|
|
159
|
+
city: string | null;
|
|
160
|
+
state: string | null;
|
|
161
|
+
created_at: string | null;
|
|
162
|
+
updated_at: string | null;
|
|
163
163
|
}>;
|
|
164
164
|
data: UserSettingsResult | null;
|
|
165
165
|
} | {
|
|
@@ -190,18 +190,18 @@ export declare function useUserSettings(options?: Omit<UseQueryOptions<User>, 'q
|
|
|
190
190
|
login: string;
|
|
191
191
|
email: string;
|
|
192
192
|
login_count: number;
|
|
193
|
-
last_login_at: string;
|
|
194
|
-
custom_tags:
|
|
195
|
-
custom_settings:
|
|
196
|
-
[x: string]: unknown;
|
|
197
|
-
};
|
|
193
|
+
last_login_at: string | null;
|
|
194
|
+
custom_tags: unknown;
|
|
195
|
+
custom_settings: unknown;
|
|
198
196
|
first_name: string;
|
|
199
197
|
last_name: string;
|
|
200
198
|
postal_code: string;
|
|
201
|
-
birth_year: number;
|
|
202
|
-
sex: "Male" | "Female";
|
|
203
|
-
city
|
|
204
|
-
state
|
|
199
|
+
birth_year: number | null;
|
|
200
|
+
sex: "Male" | "Female" | null;
|
|
201
|
+
city: string | null;
|
|
202
|
+
state: string | null;
|
|
203
|
+
created_at: string | null;
|
|
204
|
+
updated_at: string | null;
|
|
205
205
|
}, Error>>;
|
|
206
206
|
fetchStatus: import("@tanstack/react-query").FetchStatus;
|
|
207
207
|
promise: Promise<{
|
|
@@ -209,18 +209,18 @@ export declare function useUserSettings(options?: Omit<UseQueryOptions<User>, 'q
|
|
|
209
209
|
login: string;
|
|
210
210
|
email: string;
|
|
211
211
|
login_count: number;
|
|
212
|
-
last_login_at: string;
|
|
213
|
-
custom_tags:
|
|
214
|
-
custom_settings:
|
|
215
|
-
[x: string]: unknown;
|
|
216
|
-
};
|
|
212
|
+
last_login_at: string | null;
|
|
213
|
+
custom_tags: unknown;
|
|
214
|
+
custom_settings: unknown;
|
|
217
215
|
first_name: string;
|
|
218
216
|
last_name: string;
|
|
219
217
|
postal_code: string;
|
|
220
|
-
birth_year: number;
|
|
221
|
-
sex: "Male" | "Female";
|
|
222
|
-
city
|
|
223
|
-
state
|
|
218
|
+
birth_year: number | null;
|
|
219
|
+
sex: "Male" | "Female" | null;
|
|
220
|
+
city: string | null;
|
|
221
|
+
state: string | null;
|
|
222
|
+
created_at: string | null;
|
|
223
|
+
updated_at: string | null;
|
|
224
224
|
}>;
|
|
225
225
|
data: UserSettingsResult | null;
|
|
226
226
|
} | {
|
|
@@ -251,18 +251,18 @@ export declare function useUserSettings(options?: Omit<UseQueryOptions<User>, 'q
|
|
|
251
251
|
login: string;
|
|
252
252
|
email: string;
|
|
253
253
|
login_count: number;
|
|
254
|
-
last_login_at: string;
|
|
255
|
-
custom_tags:
|
|
256
|
-
custom_settings:
|
|
257
|
-
[x: string]: unknown;
|
|
258
|
-
};
|
|
254
|
+
last_login_at: string | null;
|
|
255
|
+
custom_tags: unknown;
|
|
256
|
+
custom_settings: unknown;
|
|
259
257
|
first_name: string;
|
|
260
258
|
last_name: string;
|
|
261
259
|
postal_code: string;
|
|
262
|
-
birth_year: number;
|
|
263
|
-
sex: "Male" | "Female";
|
|
264
|
-
city
|
|
265
|
-
state
|
|
260
|
+
birth_year: number | null;
|
|
261
|
+
sex: "Male" | "Female" | null;
|
|
262
|
+
city: string | null;
|
|
263
|
+
state: string | null;
|
|
264
|
+
created_at: string | null;
|
|
265
|
+
updated_at: string | null;
|
|
266
266
|
}, Error>>;
|
|
267
267
|
fetchStatus: import("@tanstack/react-query").FetchStatus;
|
|
268
268
|
promise: Promise<{
|
|
@@ -270,18 +270,18 @@ export declare function useUserSettings(options?: Omit<UseQueryOptions<User>, 'q
|
|
|
270
270
|
login: string;
|
|
271
271
|
email: string;
|
|
272
272
|
login_count: number;
|
|
273
|
-
last_login_at: string;
|
|
274
|
-
custom_tags:
|
|
275
|
-
custom_settings:
|
|
276
|
-
[x: string]: unknown;
|
|
277
|
-
};
|
|
273
|
+
last_login_at: string | null;
|
|
274
|
+
custom_tags: unknown;
|
|
275
|
+
custom_settings: unknown;
|
|
278
276
|
first_name: string;
|
|
279
277
|
last_name: string;
|
|
280
278
|
postal_code: string;
|
|
281
|
-
birth_year: number;
|
|
282
|
-
sex: "Male" | "Female";
|
|
283
|
-
city
|
|
284
|
-
state
|
|
279
|
+
birth_year: number | null;
|
|
280
|
+
sex: "Male" | "Female" | null;
|
|
281
|
+
city: string | null;
|
|
282
|
+
state: string | null;
|
|
283
|
+
created_at: string | null;
|
|
284
|
+
updated_at: string | null;
|
|
285
285
|
}>;
|
|
286
286
|
data: UserSettingsResult | null;
|
|
287
287
|
} | {
|
|
@@ -312,18 +312,18 @@ export declare function useUserSettings(options?: Omit<UseQueryOptions<User>, 'q
|
|
|
312
312
|
login: string;
|
|
313
313
|
email: string;
|
|
314
314
|
login_count: number;
|
|
315
|
-
last_login_at: string;
|
|
316
|
-
custom_tags:
|
|
317
|
-
custom_settings:
|
|
318
|
-
[x: string]: unknown;
|
|
319
|
-
};
|
|
315
|
+
last_login_at: string | null;
|
|
316
|
+
custom_tags: unknown;
|
|
317
|
+
custom_settings: unknown;
|
|
320
318
|
first_name: string;
|
|
321
319
|
last_name: string;
|
|
322
320
|
postal_code: string;
|
|
323
|
-
birth_year: number;
|
|
324
|
-
sex: "Male" | "Female";
|
|
325
|
-
city
|
|
326
|
-
state
|
|
321
|
+
birth_year: number | null;
|
|
322
|
+
sex: "Male" | "Female" | null;
|
|
323
|
+
city: string | null;
|
|
324
|
+
state: string | null;
|
|
325
|
+
created_at: string | null;
|
|
326
|
+
updated_at: string | null;
|
|
327
327
|
}, Error>>;
|
|
328
328
|
fetchStatus: import("@tanstack/react-query").FetchStatus;
|
|
329
329
|
promise: Promise<{
|
|
@@ -331,18 +331,18 @@ export declare function useUserSettings(options?: Omit<UseQueryOptions<User>, 'q
|
|
|
331
331
|
login: string;
|
|
332
332
|
email: string;
|
|
333
333
|
login_count: number;
|
|
334
|
-
last_login_at: string;
|
|
335
|
-
custom_tags:
|
|
336
|
-
custom_settings:
|
|
337
|
-
[x: string]: unknown;
|
|
338
|
-
};
|
|
334
|
+
last_login_at: string | null;
|
|
335
|
+
custom_tags: unknown;
|
|
336
|
+
custom_settings: unknown;
|
|
339
337
|
first_name: string;
|
|
340
338
|
last_name: string;
|
|
341
339
|
postal_code: string;
|
|
342
|
-
birth_year: number;
|
|
343
|
-
sex: "Male" | "Female";
|
|
344
|
-
city
|
|
345
|
-
state
|
|
340
|
+
birth_year: number | null;
|
|
341
|
+
sex: "Male" | "Female" | null;
|
|
342
|
+
city: string | null;
|
|
343
|
+
state: string | null;
|
|
344
|
+
created_at: string | null;
|
|
345
|
+
updated_at: string | null;
|
|
346
346
|
}>;
|
|
347
347
|
data: UserSettingsResult | null;
|
|
348
348
|
} | {
|
|
@@ -373,18 +373,18 @@ export declare function useUserSettings(options?: Omit<UseQueryOptions<User>, 'q
|
|
|
373
373
|
login: string;
|
|
374
374
|
email: string;
|
|
375
375
|
login_count: number;
|
|
376
|
-
last_login_at: string;
|
|
377
|
-
custom_tags:
|
|
378
|
-
custom_settings:
|
|
379
|
-
[x: string]: unknown;
|
|
380
|
-
};
|
|
376
|
+
last_login_at: string | null;
|
|
377
|
+
custom_tags: unknown;
|
|
378
|
+
custom_settings: unknown;
|
|
381
379
|
first_name: string;
|
|
382
380
|
last_name: string;
|
|
383
381
|
postal_code: string;
|
|
384
|
-
birth_year: number;
|
|
385
|
-
sex: "Male" | "Female";
|
|
386
|
-
city
|
|
387
|
-
state
|
|
382
|
+
birth_year: number | null;
|
|
383
|
+
sex: "Male" | "Female" | null;
|
|
384
|
+
city: string | null;
|
|
385
|
+
state: string | null;
|
|
386
|
+
created_at: string | null;
|
|
387
|
+
updated_at: string | null;
|
|
388
388
|
}, Error>>;
|
|
389
389
|
fetchStatus: import("@tanstack/react-query").FetchStatus;
|
|
390
390
|
promise: Promise<{
|
|
@@ -392,18 +392,18 @@ export declare function useUserSettings(options?: Omit<UseQueryOptions<User>, 'q
|
|
|
392
392
|
login: string;
|
|
393
393
|
email: string;
|
|
394
394
|
login_count: number;
|
|
395
|
-
last_login_at: string;
|
|
396
|
-
custom_tags:
|
|
397
|
-
custom_settings:
|
|
398
|
-
[x: string]: unknown;
|
|
399
|
-
};
|
|
395
|
+
last_login_at: string | null;
|
|
396
|
+
custom_tags: unknown;
|
|
397
|
+
custom_settings: unknown;
|
|
400
398
|
first_name: string;
|
|
401
399
|
last_name: string;
|
|
402
400
|
postal_code: string;
|
|
403
|
-
birth_year: number;
|
|
404
|
-
sex: "Male" | "Female";
|
|
405
|
-
city
|
|
406
|
-
state
|
|
401
|
+
birth_year: number | null;
|
|
402
|
+
sex: "Male" | "Female" | null;
|
|
403
|
+
city: string | null;
|
|
404
|
+
state: string | null;
|
|
405
|
+
created_at: string | null;
|
|
406
|
+
updated_at: string | null;
|
|
407
407
|
}>;
|
|
408
408
|
data: UserSettingsResult | null;
|
|
409
409
|
};
|
package/dist/index.cjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/hooks/useCurrentUser.ts","../src/hooks/useUserSettings.ts"],"names":["useUserFromDataAccess","useMemo"],"mappings":";;;;;;AA0CO,SAAS,eACd,OAAA,EACA;AACA,EAAA,MAAM,EAAE,IAAA,EAAM,IAAA,EAAM,GAAG,WAAA,EAAY,GAAIA,+BAAsB,OAAO,CAAA;AAEpE,EAAA,MAAM,OAAA,GAAUC,cAAQ,MAAiC;AACvD,IAAA,IAAI,CAAC,MAAM,OAAO,IAAA;AAElB,IAAA,MAAM,cAAA,
|
|
1
|
+
{"version":3,"sources":["../src/hooks/useCurrentUser.ts","../src/hooks/useUserSettings.ts"],"names":["useUserFromDataAccess","useMemo"],"mappings":";;;;;;AA0CO,SAAS,eACd,OAAA,EACA;AACA,EAAA,MAAM,EAAE,IAAA,EAAM,IAAA,EAAM,GAAG,WAAA,EAAY,GAAIA,+BAAsB,OAAO,CAAA;AAEpE,EAAA,MAAM,OAAA,GAAUC,cAAQ,MAAiC;AACvD,IAAA,IAAI,CAAC,MAAM,OAAO,IAAA;AAElB,IAAA,MAAM,cAAA,GAAkB,IAAA,CAAK,eAAA,IAAmB,EAAC;AACjD,IAAA,MAAM,iBAAA,GAAoB,MAAA,CAAO,IAAA,CAAK,cAAc,EAAE,MAAA,GAAS,CAAA;AAG/D,IAAA,MAAM,cAAc,cAAA,CAAe,WAAA;AACnC,IAAA,MAAM,aAAA,GAAgB,aAAa,aAAA,IAAiB,KAAA;AACpD,IAAA,MAAM,QAAA,GAAW,CAAA,EAAG,IAAA,CAAK,UAAA,IAAc,EAAE,IAAI,IAAA,CAAK,SAAA,IAAa,EAAE,CAAA,CAAA,CAAG,IAAA,EAAK;AAEzE,IAAA,OAAO;AAAA,MACL,IAAA;AAAA,MACA,iBAAA;AAAA,MACA,aAAA;AAAA,MACA,OAAO,IAAA,CAAK,KAAA;AAAA,MACZ;AAAA,KACF;AAAA,EACF,CAAA,EAAG,CAAC,IAAI,CAAC,CAAA;AAET,EAAA,OAAO;AAAA,IACL,IAAA,EAAM,OAAA;AAAA,IACN,GAAG;AAAA,GACL;AACF;ACvBO,SAAS,gBACd,OAAA,EACA;AACA,EAAA,MAAM,EAAE,IAAA,EAAM,IAAA,EAAM,GAAG,WAAA,EAAY,GAAID,+BAAsB,OAAO,CAAA;AAEpE,EAAA,MAAM,MAAA,GAASC,cAAQ,MAAiC;AACtD,IAAA,IAAI,CAAC,MAAM,OAAO,IAAA;AAElB,IAAA,MAAM,QAAA,GAA0B,IAAA,CAAK,eAAA,IAAmB,EAAC;AACzD,IAAA,MAAM,WAAA,GAAc,MAAA,CAAO,IAAA,CAAK,QAAQ,EAAE,MAAA,GAAS,CAAA;AACnD,IAAA,MAAM,aAAA,GAAgB,QAAA,CAAS,WAAA,EAAa,aAAA,IAAiB,KAAA;AAG7D,IAAA,MAAM,UAAA,GAAa,CAAU,IAAA,KAAgC;AAC3D,MAAA,OAAO,IAAA,CAAK,KAAA,CAAM,GAAG,CAAA,CAAE,MAAA,CAAO,CAAC,GAAA,EAAU,GAAA,KAAQ,GAAA,GAAM,GAAG,CAAA,EAAG,QAAQ,CAAA;AAAA,IAGvE,CAAA;AAEA,IAAA,OAAO;AAAA,MACL,QAAA;AAAA,MACA,WAAA;AAAA,MACA,aAAA;AAAA,MACA;AAAA,KACF;AAAA,EACF,CAAA,EAAG,CAAC,IAAI,CAAC,CAAA;AAET,EAAA,OAAO;AAAA,IACL,IAAA,EAAM,MAAA;AAAA,IACN,GAAG;AAAA,GACL;AACF","file":"index.cjs","sourcesContent":["/**\n * Hook for accessing current user profile\n * Wraps useUser from data-access layer with feature-specific logic\n */\n\nimport { useMemo } from 'react';\nimport { useCurrentUser as useUserFromDataAccess } from '@pfm-platform/users-data-access';\nimport type { UserProfileRow } from '@pfm-platform/shared';\nimport type { UseQueryOptions } from '@tanstack/react-query';\n\nexport interface CurrentUserProfile {\n user: UserProfileRow;\n hasCustomSettings: boolean;\n termsAccepted: boolean;\n email: string;\n fullName: string;\n}\n\n/**\n * Get current user profile with computed properties\n * Replaces usersStore.currentUser with computed flags\n *\n * @param options - TanStack Query options\n * @returns Current user profile with computed properties\n *\n * @example\n * ```tsx\n * function UserProfile() {\n * const { data: profile } = useCurrentUser();\n *\n * if (!profile) return null;\n *\n * return (\n * <div>\n * <h1>{profile.fullName}</h1>\n * <p>{profile.email}</p>\n * {!profile.termsAccepted && <TermsPrompt />}\n * </div>\n * );\n * }\n * ```\n */\nexport function useCurrentUser(\n options?: Omit<UseQueryOptions<UserProfileRow>, 'queryKey' | 'queryFn'>\n) {\n const { data: user, ...queryResult } = useUserFromDataAccess(options);\n\n const profile = useMemo((): CurrentUserProfile | null => {\n if (!user) return null;\n\n const customSettings = (user.custom_settings || {}) as Record<string, unknown>;\n const hasCustomSettings = Object.keys(customSettings).length > 0;\n\n // Type assertion for custom_settings.aggregation\n const aggregation = customSettings.aggregation as { termsAccepted?: boolean } | undefined;\n const termsAccepted = aggregation?.termsAccepted || false;\n const fullName = `${user.first_name || ''} ${user.last_name || ''}`.trim();\n\n return {\n user,\n hasCustomSettings,\n termsAccepted,\n email: user.email,\n fullName,\n };\n }, [user]);\n\n return {\n data: profile,\n ...queryResult,\n };\n}\n","/**\n * Hook for managing user custom settings\n * Provides type-safe access to nested custom_settings object\n */\n\nimport { useMemo } from 'react';\nimport { useCurrentUser as useUserFromDataAccess } from '@pfm-platform/users-data-access';\nimport type { UseQueryOptions } from '@tanstack/react-query';\nimport type { UserProfileRow } from '@pfm-platform/shared';\n\nexport interface UserSettings {\n aggregation?: {\n termsAccepted?: boolean;\n [key: string]: any;\n };\n [key: string]: any;\n}\n\nexport interface UserSettingsResult {\n settings: UserSettings;\n hasSettings: boolean;\n termsAccepted: boolean;\n getSetting: <T = any>(path: string) => T | undefined;\n}\n\n/**\n * Get user custom settings with helper functions\n * Replaces usersStore.currentUser.custom_settings access\n *\n * @param options - TanStack Query options\n * @returns User settings with helper functions\n *\n * @example\n * ```tsx\n * function SettingsPanel() {\n * const { data } = useUserSettings();\n *\n * if (!data) return null;\n *\n * return (\n * <div>\n * <p>Terms Accepted: {data.termsAccepted ? 'Yes' : 'No'}</p>\n * <p>Custom Value: {data.getSetting('my.nested.value')}</p>\n * </div>\n * );\n * }\n * ```\n */\nexport function useUserSettings(\n options?: Omit<UseQueryOptions<UserProfileRow>, 'queryKey' | 'queryFn'>\n) {\n const { data: user, ...queryResult } = useUserFromDataAccess(options);\n\n const result = useMemo((): UserSettingsResult | null => {\n if (!user) return null;\n\n const settings: UserSettings = (user.custom_settings || {}) as UserSettings;\n const hasSettings = Object.keys(settings).length > 0;\n const termsAccepted = settings.aggregation?.termsAccepted || false;\n\n // Helper function to get nested setting value\n const getSetting = <T = any>(path: string): T | undefined => {\n return path.split('.').reduce((obj: any, key) => obj?.[key], settings) as\n | T\n | undefined;\n };\n\n return {\n settings,\n hasSettings,\n termsAccepted,\n getSetting,\n };\n }, [user]);\n\n return {\n data: result,\n ...queryResult,\n };\n}\n"]}
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/hooks/useCurrentUser.ts","../src/hooks/useUserSettings.ts"],"names":["useUserFromDataAccess","useMemo"],"mappings":";;;;AA0CO,SAAS,eACd,OAAA,EACA;AACA,EAAA,MAAM,EAAE,IAAA,EAAM,IAAA,EAAM,GAAG,WAAA,EAAY,GAAIA,iBAAsB,OAAO,CAAA;AAEpE,EAAA,MAAM,OAAA,GAAU,QAAQ,MAAiC;AACvD,IAAA,IAAI,CAAC,MAAM,OAAO,IAAA;AAElB,IAAA,MAAM,cAAA,
|
|
1
|
+
{"version":3,"sources":["../src/hooks/useCurrentUser.ts","../src/hooks/useUserSettings.ts"],"names":["useUserFromDataAccess","useMemo"],"mappings":";;;;AA0CO,SAAS,eACd,OAAA,EACA;AACA,EAAA,MAAM,EAAE,IAAA,EAAM,IAAA,EAAM,GAAG,WAAA,EAAY,GAAIA,iBAAsB,OAAO,CAAA;AAEpE,EAAA,MAAM,OAAA,GAAU,QAAQ,MAAiC;AACvD,IAAA,IAAI,CAAC,MAAM,OAAO,IAAA;AAElB,IAAA,MAAM,cAAA,GAAkB,IAAA,CAAK,eAAA,IAAmB,EAAC;AACjD,IAAA,MAAM,iBAAA,GAAoB,MAAA,CAAO,IAAA,CAAK,cAAc,EAAE,MAAA,GAAS,CAAA;AAG/D,IAAA,MAAM,cAAc,cAAA,CAAe,WAAA;AACnC,IAAA,MAAM,aAAA,GAAgB,aAAa,aAAA,IAAiB,KAAA;AACpD,IAAA,MAAM,QAAA,GAAW,CAAA,EAAG,IAAA,CAAK,UAAA,IAAc,EAAE,IAAI,IAAA,CAAK,SAAA,IAAa,EAAE,CAAA,CAAA,CAAG,IAAA,EAAK;AAEzE,IAAA,OAAO;AAAA,MACL,IAAA;AAAA,MACA,iBAAA;AAAA,MACA,aAAA;AAAA,MACA,OAAO,IAAA,CAAK,KAAA;AAAA,MACZ;AAAA,KACF;AAAA,EACF,CAAA,EAAG,CAAC,IAAI,CAAC,CAAA;AAET,EAAA,OAAO;AAAA,IACL,IAAA,EAAM,OAAA;AAAA,IACN,GAAG;AAAA,GACL;AACF;ACvBO,SAAS,gBACd,OAAA,EACA;AACA,EAAA,MAAM,EAAE,IAAA,EAAM,IAAA,EAAM,GAAG,WAAA,EAAY,GAAIA,iBAAsB,OAAO,CAAA;AAEpE,EAAA,MAAM,MAAA,GAASC,QAAQ,MAAiC;AACtD,IAAA,IAAI,CAAC,MAAM,OAAO,IAAA;AAElB,IAAA,MAAM,QAAA,GAA0B,IAAA,CAAK,eAAA,IAAmB,EAAC;AACzD,IAAA,MAAM,WAAA,GAAc,MAAA,CAAO,IAAA,CAAK,QAAQ,EAAE,MAAA,GAAS,CAAA;AACnD,IAAA,MAAM,aAAA,GAAgB,QAAA,CAAS,WAAA,EAAa,aAAA,IAAiB,KAAA;AAG7D,IAAA,MAAM,UAAA,GAAa,CAAU,IAAA,KAAgC;AAC3D,MAAA,OAAO,IAAA,CAAK,KAAA,CAAM,GAAG,CAAA,CAAE,MAAA,CAAO,CAAC,GAAA,EAAU,GAAA,KAAQ,GAAA,GAAM,GAAG,CAAA,EAAG,QAAQ,CAAA;AAAA,IAGvE,CAAA;AAEA,IAAA,OAAO;AAAA,MACL,QAAA;AAAA,MACA,WAAA;AAAA,MACA,aAAA;AAAA,MACA;AAAA,KACF;AAAA,EACF,CAAA,EAAG,CAAC,IAAI,CAAC,CAAA;AAET,EAAA,OAAO;AAAA,IACL,IAAA,EAAM,MAAA;AAAA,IACN,GAAG;AAAA,GACL;AACF","file":"index.js","sourcesContent":["/**\n * Hook for accessing current user profile\n * Wraps useUser from data-access layer with feature-specific logic\n */\n\nimport { useMemo } from 'react';\nimport { useCurrentUser as useUserFromDataAccess } from '@pfm-platform/users-data-access';\nimport type { UserProfileRow } from '@pfm-platform/shared';\nimport type { UseQueryOptions } from '@tanstack/react-query';\n\nexport interface CurrentUserProfile {\n user: UserProfileRow;\n hasCustomSettings: boolean;\n termsAccepted: boolean;\n email: string;\n fullName: string;\n}\n\n/**\n * Get current user profile with computed properties\n * Replaces usersStore.currentUser with computed flags\n *\n * @param options - TanStack Query options\n * @returns Current user profile with computed properties\n *\n * @example\n * ```tsx\n * function UserProfile() {\n * const { data: profile } = useCurrentUser();\n *\n * if (!profile) return null;\n *\n * return (\n * <div>\n * <h1>{profile.fullName}</h1>\n * <p>{profile.email}</p>\n * {!profile.termsAccepted && <TermsPrompt />}\n * </div>\n * );\n * }\n * ```\n */\nexport function useCurrentUser(\n options?: Omit<UseQueryOptions<UserProfileRow>, 'queryKey' | 'queryFn'>\n) {\n const { data: user, ...queryResult } = useUserFromDataAccess(options);\n\n const profile = useMemo((): CurrentUserProfile | null => {\n if (!user) return null;\n\n const customSettings = (user.custom_settings || {}) as Record<string, unknown>;\n const hasCustomSettings = Object.keys(customSettings).length > 0;\n\n // Type assertion for custom_settings.aggregation\n const aggregation = customSettings.aggregation as { termsAccepted?: boolean } | undefined;\n const termsAccepted = aggregation?.termsAccepted || false;\n const fullName = `${user.first_name || ''} ${user.last_name || ''}`.trim();\n\n return {\n user,\n hasCustomSettings,\n termsAccepted,\n email: user.email,\n fullName,\n };\n }, [user]);\n\n return {\n data: profile,\n ...queryResult,\n };\n}\n","/**\n * Hook for managing user custom settings\n * Provides type-safe access to nested custom_settings object\n */\n\nimport { useMemo } from 'react';\nimport { useCurrentUser as useUserFromDataAccess } from '@pfm-platform/users-data-access';\nimport type { UseQueryOptions } from '@tanstack/react-query';\nimport type { UserProfileRow } from '@pfm-platform/shared';\n\nexport interface UserSettings {\n aggregation?: {\n termsAccepted?: boolean;\n [key: string]: any;\n };\n [key: string]: any;\n}\n\nexport interface UserSettingsResult {\n settings: UserSettings;\n hasSettings: boolean;\n termsAccepted: boolean;\n getSetting: <T = any>(path: string) => T | undefined;\n}\n\n/**\n * Get user custom settings with helper functions\n * Replaces usersStore.currentUser.custom_settings access\n *\n * @param options - TanStack Query options\n * @returns User settings with helper functions\n *\n * @example\n * ```tsx\n * function SettingsPanel() {\n * const { data } = useUserSettings();\n *\n * if (!data) return null;\n *\n * return (\n * <div>\n * <p>Terms Accepted: {data.termsAccepted ? 'Yes' : 'No'}</p>\n * <p>Custom Value: {data.getSetting('my.nested.value')}</p>\n * </div>\n * );\n * }\n * ```\n */\nexport function useUserSettings(\n options?: Omit<UseQueryOptions<UserProfileRow>, 'queryKey' | 'queryFn'>\n) {\n const { data: user, ...queryResult } = useUserFromDataAccess(options);\n\n const result = useMemo((): UserSettingsResult | null => {\n if (!user) return null;\n\n const settings: UserSettings = (user.custom_settings || {}) as UserSettings;\n const hasSettings = Object.keys(settings).length > 0;\n const termsAccepted = settings.aggregation?.termsAccepted || false;\n\n // Helper function to get nested setting value\n const getSetting = <T = any>(path: string): T | undefined => {\n return path.split('.').reduce((obj: any, key) => obj?.[key], settings) as\n | T\n | undefined;\n };\n\n return {\n settings,\n hasSettings,\n termsAccepted,\n getSetting,\n };\n }, [user]);\n\n return {\n data: result,\n ...queryResult,\n };\n}\n"]}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@pfm-platform/users-feature",
|
|
3
|
-
"version": "0.2.
|
|
3
|
+
"version": "0.2.1",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"exports": {
|
|
6
6
|
".": {
|
|
@@ -10,20 +10,20 @@
|
|
|
10
10
|
}
|
|
11
11
|
},
|
|
12
12
|
"dependencies": {
|
|
13
|
-
"react": "19.2.
|
|
14
|
-
"@pfm-platform/shared": "0.1
|
|
15
|
-
"@pfm-platform/users-data-access": "0.2.
|
|
13
|
+
"react": "19.2.4",
|
|
14
|
+
"@pfm-platform/shared": "0.2.1",
|
|
15
|
+
"@pfm-platform/users-data-access": "0.2.1"
|
|
16
16
|
},
|
|
17
17
|
"devDependencies": {
|
|
18
|
-
"@tanstack/react-query": "5.90.
|
|
19
|
-
"@testing-library/react": "^16.3.
|
|
20
|
-
"@types/react": "^19.2.
|
|
21
|
-
"@vitejs/plugin-react": "^5.1.
|
|
22
|
-
"@vitest/coverage-v8": "^4.0.
|
|
18
|
+
"@tanstack/react-query": "5.90.21",
|
|
19
|
+
"@testing-library/react": "^16.3.2",
|
|
20
|
+
"@types/react": "^19.2.14",
|
|
21
|
+
"@vitejs/plugin-react": "^5.1.4",
|
|
22
|
+
"@vitest/coverage-v8": "^4.0.18",
|
|
23
23
|
"jsdom": "^27.2.0",
|
|
24
|
-
"react-dom": "19.2.
|
|
24
|
+
"react-dom": "19.2.4",
|
|
25
25
|
"typescript": "5.9.3",
|
|
26
|
-
"vitest": "4.0.
|
|
26
|
+
"vitest": "4.0.18"
|
|
27
27
|
},
|
|
28
28
|
"main": "./dist/index.js",
|
|
29
29
|
"module": "./dist/index.js",
|