@greatapps/common 1.1.71 → 1.1.73
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/components/layouts/AppNavBar.mjs +0 -2
- package/dist/components/layouts/AppNavBar.mjs.map +1 -1
- package/dist/components/layouts/NotificationItem.mjs +4 -7
- package/dist/components/layouts/NotificationItem.mjs.map +1 -1
- package/dist/components/layouts/NotificationsPopover.mjs +22 -12
- package/dist/components/layouts/NotificationsPopover.mjs.map +1 -1
- package/dist/index.mjs +151 -21
- package/dist/index.mjs.map +1 -1
- package/dist/modules/auth/actions/login.action.mjs +1 -1
- package/dist/modules/auth/actions/login.action.mjs.map +1 -1
- package/dist/modules/auth/hooks/login.hook.mjs +5 -1
- package/dist/modules/auth/hooks/login.hook.mjs.map +1 -1
- package/dist/modules/auth/hooks/useUserQuery.mjs +2 -1
- package/dist/modules/auth/hooks/useUserQuery.mjs.map +1 -1
- package/dist/modules/auth/services/auth.service.mjs +2 -2
- package/dist/modules/auth/services/auth.service.mjs.map +1 -1
- package/dist/modules/users/action/list-messages.action.mjs +9 -0
- package/dist/modules/users/action/list-messages.action.mjs.map +1 -0
- package/dist/modules/users/action/mark-all-messages-as-read.action.mjs +9 -0
- package/dist/modules/users/action/mark-all-messages-as-read.action.mjs.map +1 -0
- package/dist/modules/users/action/mark-message-as-read.action.mjs +9 -0
- package/dist/modules/users/action/mark-message-as-read.action.mjs.map +1 -0
- package/dist/modules/users/hooks/messages.hook.mjs +38 -0
- package/dist/modules/users/hooks/messages.hook.mjs.map +1 -0
- package/dist/modules/users/schema/messages.schema.mjs +21 -0
- package/dist/modules/users/schema/messages.schema.mjs.map +1 -0
- package/dist/modules/users/services/messages.service.mjs +35 -0
- package/dist/modules/users/services/messages.service.mjs.map +1 -0
- package/dist/providers/auth.provider.mjs +3 -5
- package/dist/providers/auth.provider.mjs.map +1 -1
- package/dist/utils/safeServerAction.mjs +22 -0
- package/dist/utils/safeServerAction.mjs.map +1 -0
- package/package.json +1 -1
- package/src/components/layouts/AppNavBar.tsx +0 -4
- package/src/components/layouts/NotificationItem.tsx +2 -2
- package/src/components/layouts/NotificationsPopover.tsx +25 -22
- package/src/index.ts +267 -117
- package/src/modules/auth/actions/login.action.ts +1 -1
- package/src/modules/auth/hooks/login.hook.tsx +6 -1
- package/src/modules/auth/hooks/useUserQuery.ts +2 -1
- package/src/modules/auth/schema.ts +6 -4
- package/src/modules/auth/services/auth.service.ts +2 -2
- package/src/modules/users/action/list-messages.action.ts +10 -0
- package/src/modules/users/action/mark-all-messages-as-read.action.ts +8 -0
- package/src/modules/users/action/mark-message-as-read.action.ts +8 -0
- package/src/modules/users/hooks/messages.hook.ts +39 -0
- package/src/modules/users/schema/messages.schema.ts +46 -0
- package/src/modules/users/services/messages.service.ts +48 -0
- package/src/providers/auth.provider.tsx +6 -9
- package/src/utils/safeServerAction.ts +27 -0
package/src/index.ts
CHANGED
|
@@ -1,136 +1,286 @@
|
|
|
1
1
|
// Types
|
|
2
|
-
export * from
|
|
3
|
-
export * from
|
|
4
|
-
export * from
|
|
5
|
-
export * from
|
|
2
|
+
export * from "./modules/auth/schema";
|
|
3
|
+
export * from "./modules/users/schema";
|
|
4
|
+
export * from "./modules/whitelabel/schema";
|
|
5
|
+
export * from "./infra/api/types";
|
|
6
6
|
|
|
7
7
|
// Contexts
|
|
8
|
-
export * from
|
|
9
|
-
export * from
|
|
10
|
-
export * from
|
|
8
|
+
export * from "./providers/query.provider";
|
|
9
|
+
export * from "./providers/auth.provider";
|
|
10
|
+
export * from "./providers/whitelabel.provider";
|
|
11
11
|
|
|
12
12
|
// Hooks
|
|
13
|
-
export {
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
export {
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
export {
|
|
24
|
-
|
|
13
|
+
export {
|
|
14
|
+
useListProjectUsers,
|
|
15
|
+
LIST_PROJECT_USERS_QUERY_KEY,
|
|
16
|
+
LIST_PROJECT_USERS_BASE_KEY,
|
|
17
|
+
} from "./modules/projects/hooks/list-project-users.hook";
|
|
18
|
+
export {
|
|
19
|
+
useListAvailableUsers,
|
|
20
|
+
LIST_AVAILABLE_USERS_QUERY_KEY,
|
|
21
|
+
LIST_AVAILABLE_USERS_BASE_KEY,
|
|
22
|
+
} from "./modules/projects/hooks/list-available-users.hook";
|
|
23
|
+
export type {
|
|
24
|
+
ProjectUser,
|
|
25
|
+
AccountUser,
|
|
26
|
+
AddRemoveProjectUsersParams,
|
|
27
|
+
ListUsersParams,
|
|
28
|
+
UsersPage,
|
|
29
|
+
} from "./modules/projects/types";
|
|
30
|
+
export {
|
|
31
|
+
useUserQuery,
|
|
32
|
+
useUserValidateSession,
|
|
33
|
+
useInvalidateUser,
|
|
34
|
+
useSetUserData,
|
|
35
|
+
useTwoFactorVerify,
|
|
36
|
+
USER_QUERY_KEY,
|
|
37
|
+
} from "./modules/auth/hooks/useUserQuery";
|
|
38
|
+
export {
|
|
39
|
+
useSubscriptions,
|
|
40
|
+
SUBSCRIPTIONS_QUERY_KEY,
|
|
41
|
+
} from "./modules/subscriptions/hooks/list-subscriptions.hook";
|
|
42
|
+
export { useActiveSubscription } from "./modules/subscriptions/hooks/find-active-subscription.hook";
|
|
43
|
+
export { useIaCredits } from "./modules/ia-credits/hooks/ia-credits.hook";
|
|
44
|
+
export type {
|
|
45
|
+
IaCreditsSummary,
|
|
46
|
+
IaCreditOperation,
|
|
47
|
+
} from "./modules/ia-credits/types";
|
|
48
|
+
export type {
|
|
49
|
+
Subscription,
|
|
50
|
+
SubscriptionItem,
|
|
51
|
+
FindSubscriptionsParams,
|
|
52
|
+
} from "./modules/subscriptions/types";
|
|
53
|
+
export {
|
|
54
|
+
SubscriptionSchema,
|
|
55
|
+
SubscriptionItemSchema,
|
|
56
|
+
} from "./modules/subscriptions/types";
|
|
57
|
+
export { ADDON_IDS } from "./modules/subscriptions/constants/addons.constants";
|
|
58
|
+
export type { AddonKindEnum } from "./modules/subscriptions/constants/addons.constants";
|
|
25
59
|
|
|
26
60
|
// Providers
|
|
27
|
-
export { QueryProvider } from
|
|
61
|
+
export { QueryProvider } from "./providers/query.provider";
|
|
28
62
|
|
|
29
63
|
// Middleware
|
|
30
|
-
export { createAuthMiddleware } from
|
|
31
|
-
export { createMiddlewareChain } from
|
|
32
|
-
export { continueChain, stopChain } from
|
|
33
|
-
export type {
|
|
64
|
+
export { createAuthMiddleware } from "./middlewares/create-auth-middleware";
|
|
65
|
+
export { createMiddlewareChain } from "./middlewares/chain";
|
|
66
|
+
export { continueChain, stopChain } from "./middlewares/types";
|
|
67
|
+
export type {
|
|
68
|
+
MiddlewareFunction,
|
|
69
|
+
MiddlewareConfig,
|
|
70
|
+
MiddlewareResult,
|
|
71
|
+
} from "./middlewares/types";
|
|
34
72
|
|
|
35
73
|
// Utils
|
|
36
|
-
export { cn } from
|
|
37
|
-
export { buildQueryParams } from
|
|
38
|
-
export { parseSchema, parseResult } from
|
|
74
|
+
export { cn } from "./infra/utils/clsx";
|
|
75
|
+
export { buildQueryParams } from "./infra/utils/params";
|
|
76
|
+
export { parseSchema, parseResult } from "./infra/utils/parser";
|
|
39
77
|
|
|
40
78
|
// Layout
|
|
41
|
-
export {
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
export
|
|
48
|
-
export {
|
|
49
|
-
export {
|
|
50
|
-
export {
|
|
51
|
-
export
|
|
52
|
-
export {
|
|
53
|
-
export
|
|
54
|
-
export {
|
|
55
|
-
export
|
|
56
|
-
export {
|
|
57
|
-
export
|
|
58
|
-
export {
|
|
59
|
-
export
|
|
79
|
+
export {
|
|
80
|
+
MainLayout,
|
|
81
|
+
MainLayoutContent,
|
|
82
|
+
MainLayoutSpacer,
|
|
83
|
+
MainLayoutMain,
|
|
84
|
+
} from "./components/layouts/MainLayout";
|
|
85
|
+
export { NavBar } from "./components/layouts/NavBar";
|
|
86
|
+
export type { NavBarProps } from "./components/layouts/NavBar";
|
|
87
|
+
export { AppNavBar } from "./components/layouts/AppNavBar";
|
|
88
|
+
export type { AppNavBarProps } from "./components/layouts/AppNavBar";
|
|
89
|
+
export { AppMobileNavBar } from "./components/layouts/AppMobileNavBar";
|
|
90
|
+
export type { AppMobileNavBarProps } from "./components/layouts/AppMobileNavBar";
|
|
91
|
+
export { SideBarNavigation } from "./components/layouts/SideBarNavigation";
|
|
92
|
+
export { MdSideBarNavigation } from "./components/layouts/MdSideBarNavigation";
|
|
93
|
+
export { NotificationItem } from "./components/layouts/NotificationItem";
|
|
94
|
+
export type { NotificationItemProps } from "./components/layouts/NotificationItem";
|
|
95
|
+
export { NotificationsPopover } from "./components/layouts/NotificationsPopover";
|
|
96
|
+
export type { NotificationsPopoverProps } from "./components/layouts/NotificationsPopover";
|
|
97
|
+
export { UsersSelectorPopover } from "./components/layouts/UsersSelectorPopover";
|
|
98
|
+
export type { UsersSelectorPopoverProps } from "./components/layouts/UsersSelectorPopover";
|
|
99
|
+
export { ProfilePopover } from "./components/layouts/ProfilePopover";
|
|
100
|
+
export type {
|
|
101
|
+
ProfilePopoverProps,
|
|
102
|
+
ProfileMenuItem,
|
|
103
|
+
} from "./components/layouts/ProfilePopover";
|
|
104
|
+
export { NavBarItem } from "./components/layouts/NavBarItem";
|
|
105
|
+
export type { NavBarItemProps } from "./components/layouts/NavBarItem";
|
|
60
106
|
|
|
61
107
|
// UI - Buttons
|
|
62
|
-
export { Button, buttonVariants } from
|
|
63
|
-
export { CopyButton } from
|
|
64
|
-
export { default as CancelButton } from
|
|
108
|
+
export { Button, buttonVariants } from "./components/ui/buttons/Button";
|
|
109
|
+
export { CopyButton } from "./components/ui/buttons/CopyButton";
|
|
110
|
+
export { default as CancelButton } from "./components/ui/buttons/CancelButton";
|
|
65
111
|
|
|
66
112
|
// UI - Data Display
|
|
67
|
-
export {
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
export {
|
|
74
|
-
export {
|
|
75
|
-
|
|
76
|
-
|
|
113
|
+
export {
|
|
114
|
+
Accordion,
|
|
115
|
+
AccordionItem,
|
|
116
|
+
AccordionTrigger,
|
|
117
|
+
AccordionContent,
|
|
118
|
+
} from "./components/ui/data-display/Accordion";
|
|
119
|
+
export { Badge, badgeVariants } from "./components/ui/data-display/Badge";
|
|
120
|
+
export {
|
|
121
|
+
Card,
|
|
122
|
+
CardHeader,
|
|
123
|
+
CardFooter,
|
|
124
|
+
CardTitle,
|
|
125
|
+
CardAction,
|
|
126
|
+
CardDescription,
|
|
127
|
+
CardContent,
|
|
128
|
+
} from "./components/ui/data-display/Card";
|
|
129
|
+
export {
|
|
130
|
+
Pagination,
|
|
131
|
+
PaginationContent,
|
|
132
|
+
PaginationLink,
|
|
133
|
+
PaginationItem,
|
|
134
|
+
PaginationPrevious,
|
|
135
|
+
PaginationNext,
|
|
136
|
+
PaginationEllipsis,
|
|
137
|
+
} from "./components/ui/data-display/Pagination";
|
|
138
|
+
export { ScrollArea, ScrollBar } from "./components/ui/data-display/ScrollArea";
|
|
139
|
+
export { Separator } from "./components/ui/data-display/Separator";
|
|
140
|
+
export {
|
|
141
|
+
Table,
|
|
142
|
+
TableHeader,
|
|
143
|
+
TableBody,
|
|
144
|
+
TableFooter,
|
|
145
|
+
TableHead,
|
|
146
|
+
TableRow,
|
|
147
|
+
TableCell,
|
|
148
|
+
TableCaption,
|
|
149
|
+
} from "./components/ui/data-display/Table";
|
|
150
|
+
export {
|
|
151
|
+
Tabs,
|
|
152
|
+
TabsList,
|
|
153
|
+
TabsTrigger,
|
|
154
|
+
TabsContent,
|
|
155
|
+
} from "./components/ui/data-display/Tabs";
|
|
156
|
+
export { UserAvatar } from "./components/ui/data-display/UserAvatar";
|
|
157
|
+
export type { UserAvatarProps } from "./components/ui/data-display/UserAvatar";
|
|
77
158
|
|
|
78
159
|
// UI - Feedback
|
|
79
|
-
export { default as CircularProgress } from
|
|
80
|
-
export { default as DefaultCircularProgress } from
|
|
81
|
-
export { Progress } from
|
|
82
|
-
export { LoadingOverlay } from
|
|
83
|
-
export {
|
|
84
|
-
|
|
160
|
+
export { default as CircularProgress } from "./components/ui/feedback/CircularProgress";
|
|
161
|
+
export { default as DefaultCircularProgress } from "./components/ui/feedback/DefaultCircularProgress";
|
|
162
|
+
export { Progress } from "./components/ui/feedback/Progress";
|
|
163
|
+
export { LoadingOverlay } from "./components/ui/feedback/LoadingOverlay";
|
|
164
|
+
export {
|
|
165
|
+
Toast,
|
|
166
|
+
toastVariants,
|
|
167
|
+
toastIconContainerVariants,
|
|
168
|
+
} from "./components/ui/feedback/Toast";
|
|
169
|
+
export type { ToastProps } from "./components/ui/feedback/Toast";
|
|
85
170
|
|
|
86
171
|
// UI - Form
|
|
87
|
-
export { Calendar, CalendarDayButton } from
|
|
88
|
-
export { Checkbox } from
|
|
89
|
-
export { DatePicker } from
|
|
90
|
-
export { DateRangePicker } from
|
|
91
|
-
export { Input } from
|
|
92
|
-
export {
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
172
|
+
export { Calendar, CalendarDayButton } from "./components/ui/form/Calendar";
|
|
173
|
+
export { Checkbox } from "./components/ui/form/Checkbox";
|
|
174
|
+
export { DatePicker } from "./components/ui/form/DatePicker";
|
|
175
|
+
export { DateRangePicker } from "./components/ui/form/DateRangePicker";
|
|
176
|
+
export { Input } from "./components/ui/form/Input";
|
|
177
|
+
export {
|
|
178
|
+
InputOTP,
|
|
179
|
+
InputOTPGroup,
|
|
180
|
+
InputOTPSlot,
|
|
181
|
+
InputOTPSeparator,
|
|
182
|
+
} from "./components/ui/form/InputOtp";
|
|
183
|
+
export { RadioGroup, RadioGroupItem } from "./components/ui/form/RadioGroup";
|
|
184
|
+
export {
|
|
185
|
+
Select,
|
|
186
|
+
SelectContent,
|
|
187
|
+
SelectGroup,
|
|
188
|
+
SelectItem,
|
|
189
|
+
SelectLabel,
|
|
190
|
+
SelectScrollDownButton,
|
|
191
|
+
SelectScrollUpButton,
|
|
192
|
+
SelectSeparator,
|
|
193
|
+
SelectTrigger,
|
|
194
|
+
SelectValue,
|
|
195
|
+
} from "./components/ui/form/Select";
|
|
196
|
+
export { Switch } from "./components/ui/form/Switch";
|
|
197
|
+
export { Textarea } from "./components/ui/form/Textarea";
|
|
97
198
|
|
|
98
199
|
// UI - Overlay
|
|
99
|
-
export {
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
200
|
+
export {
|
|
201
|
+
Command,
|
|
202
|
+
CommandDialog,
|
|
203
|
+
CommandInput,
|
|
204
|
+
CommandList,
|
|
205
|
+
CommandEmpty,
|
|
206
|
+
CommandGroup,
|
|
207
|
+
CommandItem,
|
|
208
|
+
CommandShortcut,
|
|
209
|
+
CommandSeparator,
|
|
210
|
+
} from "./components/ui/overlay/Command";
|
|
211
|
+
export {
|
|
212
|
+
Dialog,
|
|
213
|
+
DialogClose,
|
|
214
|
+
DialogContent,
|
|
215
|
+
DialogDescription,
|
|
216
|
+
DialogFooter,
|
|
217
|
+
DialogHeader,
|
|
218
|
+
DialogOverlay,
|
|
219
|
+
DialogPortal,
|
|
220
|
+
DialogTitle,
|
|
221
|
+
DialogTrigger,
|
|
222
|
+
} from "./components/ui/overlay/Dialog";
|
|
223
|
+
export {
|
|
224
|
+
Popover,
|
|
225
|
+
PopoverTrigger,
|
|
226
|
+
PopoverContent,
|
|
227
|
+
PopoverAnchor,
|
|
228
|
+
} from "./components/ui/overlay/Popover";
|
|
229
|
+
export {
|
|
230
|
+
Sheet,
|
|
231
|
+
SheetTrigger,
|
|
232
|
+
SheetClose,
|
|
233
|
+
SheetContent,
|
|
234
|
+
SheetHeader,
|
|
235
|
+
SheetFooter,
|
|
236
|
+
SheetTitle,
|
|
237
|
+
SheetDescription,
|
|
238
|
+
} from "./components/ui/overlay/Sheet";
|
|
239
|
+
export {
|
|
240
|
+
Tooltip,
|
|
241
|
+
TooltipTrigger,
|
|
242
|
+
TooltipContent,
|
|
243
|
+
TooltipProvider,
|
|
244
|
+
} from "./components/ui/overlay/Tooltip";
|
|
104
245
|
|
|
105
246
|
// Store
|
|
106
|
-
export { useMdSidebarStore } from
|
|
107
|
-
export { useModalManager } from
|
|
108
|
-
export type { ModalData } from
|
|
247
|
+
export { useMdSidebarStore } from "./store/useMdSidebarStore";
|
|
248
|
+
export { useModalManager } from "./store/useModalManager";
|
|
249
|
+
export type { ModalData } from "./store/useModalManager";
|
|
109
250
|
|
|
110
251
|
// Enums
|
|
111
|
-
export { AccountSectionType } from
|
|
252
|
+
export { AccountSectionType } from "./enums/AccountSectionType";
|
|
112
253
|
|
|
113
254
|
// Hooks
|
|
114
|
-
export { default as usePasswordVisibility } from
|
|
115
|
-
export { default as useCountdownTimer } from
|
|
116
|
-
export { default as useIsMobile } from
|
|
255
|
+
export { default as usePasswordVisibility } from "./hooks/usePasswordVisibility";
|
|
256
|
+
export { default as useCountdownTimer } from "./hooks/useCountdownTimer";
|
|
257
|
+
export { default as useIsMobile } from "./hooks/useIsMobile";
|
|
117
258
|
|
|
118
259
|
// Utils
|
|
119
|
-
export {
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
260
|
+
export {
|
|
261
|
+
formatPhone,
|
|
262
|
+
formatTimer,
|
|
263
|
+
formatFullName,
|
|
264
|
+
formatCPF,
|
|
265
|
+
formatCardNumber,
|
|
266
|
+
} from "./utils/format/masks";
|
|
267
|
+
export { timezoneService } from "./modules/accounts/services/timezone.service";
|
|
268
|
+
export type { TimezoneOption } from "./modules/accounts/services/timezone.service";
|
|
269
|
+
export {
|
|
270
|
+
buildLocaleOptions,
|
|
271
|
+
LANGUAGE_OPTIONS as LOCALE_LANGUAGE_OPTIONS,
|
|
272
|
+
} from "./utils/intl/locales";
|
|
273
|
+
export type { LocaleOption } from "./utils/intl/locales";
|
|
274
|
+
export { copyToClipboard, readFromClipboard } from "./utils/browser/clipboard";
|
|
125
275
|
|
|
126
276
|
// UI - Form (new widgets)
|
|
127
|
-
export { FormField } from
|
|
128
|
-
export { SelectField } from
|
|
129
|
-
export { ComboboxField } from
|
|
130
|
-
export type { ComboboxOption } from
|
|
131
|
-
export { default as PhoneInput } from
|
|
132
|
-
export { default as SwitchOptionFieldWithIcon } from
|
|
133
|
-
export { TextAreaField } from
|
|
277
|
+
export { FormField } from "./components/ui/form/FormField";
|
|
278
|
+
export { SelectField } from "./components/ui/form/SelectField";
|
|
279
|
+
export { ComboboxField } from "./components/ui/form/ComboboxField";
|
|
280
|
+
export type { ComboboxOption } from "./components/ui/form/ComboboxField";
|
|
281
|
+
export { default as PhoneInput } from "./components/ui/form/PhoneInput";
|
|
282
|
+
export { default as SwitchOptionFieldWithIcon } from "./components/ui/form/SwitchOptionFieldWithIcon";
|
|
283
|
+
export { TextAreaField } from "./components/ui/form/TextAreaField";
|
|
134
284
|
|
|
135
285
|
// Account Module - Hooks
|
|
136
286
|
export {
|
|
@@ -139,7 +289,7 @@ export {
|
|
|
139
289
|
useUpdateAccountUserById,
|
|
140
290
|
useDeleteAccountUser,
|
|
141
291
|
useDeleteAccount,
|
|
142
|
-
} from
|
|
292
|
+
} from "./modules/accounts/hooks/useAccountManagement";
|
|
143
293
|
|
|
144
294
|
// Account Types
|
|
145
295
|
export type {
|
|
@@ -153,24 +303,24 @@ export type {
|
|
|
153
303
|
TwoFactorGenerateResult,
|
|
154
304
|
TwoFactorActionResult,
|
|
155
305
|
ContactResetResult,
|
|
156
|
-
} from
|
|
306
|
+
} from "./modules/accounts/types";
|
|
157
307
|
|
|
158
|
-
export { default as AccountModals } from
|
|
159
|
-
export { useAccountModals } from
|
|
160
|
-
export type { AccountModalsConfig } from
|
|
308
|
+
export { default as AccountModals } from "./components/account/AccountModals";
|
|
309
|
+
export { useAccountModals } from "./store/useAccountModals";
|
|
310
|
+
export type { AccountModalsConfig } from "./store/useAccountModals";
|
|
161
311
|
|
|
162
|
-
export { ModalManager } from
|
|
163
|
-
export { Modals } from
|
|
312
|
+
export { ModalManager } from "./components/modals/ModalManager";
|
|
313
|
+
export { Modals } from "./components/modals/Modals";
|
|
164
314
|
|
|
165
|
-
export { default as TwoFactorAuthModal } from
|
|
166
|
-
export { default as DisableTwoFactorAuthModal } from
|
|
167
|
-
export { default as ConfirmGlobalPreferencesModal } from
|
|
168
|
-
export { MyProfileSection } from
|
|
169
|
-
export { PreferencesSection } from
|
|
170
|
-
export { SecuritySection } from
|
|
171
|
-
export { ChangePasswordSection } from
|
|
172
|
-
export { ChangeEmailModal } from
|
|
173
|
-
export { ChangePhoneModal } from
|
|
315
|
+
export { default as TwoFactorAuthModal } from "./components/account/TwoFactorAuthModal";
|
|
316
|
+
export { default as DisableTwoFactorAuthModal } from "./components/account/DisableTwoFactorAuthModal";
|
|
317
|
+
export { default as ConfirmGlobalPreferencesModal } from "./components/account/ConfirmGlobalPreferencesModal";
|
|
318
|
+
export { MyProfileSection } from "./components/account/sections/MyProfileSection";
|
|
319
|
+
export { PreferencesSection } from "./components/account/sections/PreferencesSection";
|
|
320
|
+
export { SecuritySection } from "./components/account/sections/SecuritySection";
|
|
321
|
+
export { ChangePasswordSection } from "./components/account/sections/ChangePasswordSection";
|
|
322
|
+
export { ChangeEmailModal } from "./components/account/sections/ChangeEmailModal";
|
|
323
|
+
export { ChangePhoneModal } from "./components/account/sections/ChangePhoneModal";
|
|
174
324
|
|
|
175
325
|
// Account Constants
|
|
176
326
|
export {
|
|
@@ -179,4 +329,4 @@ export {
|
|
|
179
329
|
TIME_FORMAT_OPTIONS,
|
|
180
330
|
NOTIFICATION_TYPES,
|
|
181
331
|
LANGUAGE_OPTIONS,
|
|
182
|
-
} from
|
|
332
|
+
} from "./components/account/constants";
|
|
@@ -2,9 +2,14 @@
|
|
|
2
2
|
|
|
3
3
|
import { useMutation } from "@tanstack/react-query";
|
|
4
4
|
import { loginAction } from "../actions/login.action";
|
|
5
|
+
import { safeServerAction } from "../../../utils/safeServerAction";
|
|
6
|
+
import { LoginRequest, LoginSuccessResponse } from "../schema";
|
|
5
7
|
|
|
6
8
|
export function useLogin() {
|
|
7
9
|
return useMutation({
|
|
8
|
-
mutationFn:
|
|
10
|
+
mutationFn: async (credentials: LoginRequest): Promise<LoginSuccessResponse> => {
|
|
11
|
+
const data = await safeServerAction(loginAction, credentials);
|
|
12
|
+
return data as LoginSuccessResponse;
|
|
13
|
+
},
|
|
9
14
|
});
|
|
10
15
|
}
|
|
@@ -2,6 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
import { useMutation, useQuery, useQueryClient, UseQueryOptions } from '@tanstack/react-query';
|
|
4
4
|
import { User } from '../../users/schema';
|
|
5
|
+
import { safeServerAction } from '../../../utils/safeServerAction';
|
|
5
6
|
|
|
6
7
|
export const USER_QUERY_KEY = ['user'];
|
|
7
8
|
|
|
@@ -44,7 +45,7 @@ export function useTwoFactorVerify() {
|
|
|
44
45
|
return useMutation({
|
|
45
46
|
mutationFn: async ({ cookie, code }: { cookie: string; code: string }) => {
|
|
46
47
|
const { verifyTwoFactorAction } = await import('../actions/verify-two-factor.action');
|
|
47
|
-
return verifyTwoFactorAction
|
|
48
|
+
return safeServerAction(verifyTwoFactorAction, cookie, code);
|
|
48
49
|
},
|
|
49
50
|
onSuccess: () => {
|
|
50
51
|
queryClient.invalidateQueries({ queryKey: USER_QUERY_KEY });
|
|
@@ -17,17 +17,18 @@ export interface LoginApiResponse {
|
|
|
17
17
|
}
|
|
18
18
|
|
|
19
19
|
export type LoginResponse =
|
|
20
|
-
| {
|
|
21
|
-
| {
|
|
20
|
+
| { result: 'error'; message: string }
|
|
21
|
+
| { result: 'two_factor_required'; cookie: string }
|
|
22
22
|
| {
|
|
23
|
-
|
|
24
|
-
twoFactorRequired?: false;
|
|
23
|
+
result: 'success';
|
|
25
24
|
user: User;
|
|
26
25
|
accessToken: string;
|
|
27
26
|
refreshToken: string;
|
|
28
27
|
expiresAt: string;
|
|
29
28
|
};
|
|
30
29
|
|
|
30
|
+
export type LoginSuccessResponse = Exclude<LoginResponse, { result: 'error' }>;
|
|
31
|
+
|
|
31
32
|
export interface TwoFactorRequest {
|
|
32
33
|
location: GeoLocation;
|
|
33
34
|
ip: string;
|
|
@@ -46,6 +47,7 @@ export interface TwoFactorApiResponse {
|
|
|
46
47
|
|
|
47
48
|
export interface TwoFactorResponse {
|
|
48
49
|
status: 0 | 1;
|
|
50
|
+
message?: string;
|
|
49
51
|
}
|
|
50
52
|
|
|
51
53
|
export interface GeoLocation {
|
|
@@ -75,13 +75,13 @@ class AuthService {
|
|
|
75
75
|
}
|
|
76
76
|
|
|
77
77
|
if (response.two_factor_required) {
|
|
78
|
-
return {
|
|
78
|
+
return { result: 'two_factor_required', cookie: response.cookie };
|
|
79
79
|
}
|
|
80
80
|
|
|
81
81
|
await this.setAuthCookie(response.cookie);
|
|
82
82
|
|
|
83
83
|
return {
|
|
84
|
-
|
|
84
|
+
result: 'success',
|
|
85
85
|
user: {} as User,
|
|
86
86
|
accessToken: response.cookie,
|
|
87
87
|
refreshToken: "",
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
'use server';
|
|
2
|
+
|
|
3
|
+
import { messagesService } from '../services/messages.service';
|
|
4
|
+
import type { FindMessagesParams, ListMessagesApiResponse } from '../schema/messages.schema';
|
|
5
|
+
|
|
6
|
+
export async function listMessagesAction(
|
|
7
|
+
params?: Partial<FindMessagesParams>
|
|
8
|
+
): Promise<ListMessagesApiResponse> {
|
|
9
|
+
return messagesService.listMessages(params);
|
|
10
|
+
}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
'use server';
|
|
2
|
+
|
|
3
|
+
import { messagesService } from '../services/messages.service';
|
|
4
|
+
import type { MarkAllAsReadApiResponse } from '../schema/messages.schema';
|
|
5
|
+
|
|
6
|
+
export async function markAllMessagesAsReadAction(): Promise<MarkAllAsReadApiResponse> {
|
|
7
|
+
return messagesService.markAllAsRead();
|
|
8
|
+
}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
'use server';
|
|
2
|
+
|
|
3
|
+
import { messagesService } from '../services/messages.service';
|
|
4
|
+
import type { MarkAsReadApiResponse } from '../schema/messages.schema';
|
|
5
|
+
|
|
6
|
+
export async function markMessageAsReadAction(messageId: string): Promise<MarkAsReadApiResponse> {
|
|
7
|
+
return messagesService.markAsRead(messageId);
|
|
8
|
+
}
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
|
|
3
|
+
import { useMutation, useQuery, useQueryClient } from '@tanstack/react-query';
|
|
4
|
+
import { listMessagesAction } from '../action/list-messages.action';
|
|
5
|
+
import { markMessageAsReadAction } from '../action/mark-message-as-read.action';
|
|
6
|
+
import { markAllMessagesAsReadAction } from '../action/mark-all-messages-as-read.action';
|
|
7
|
+
import { safeServerAction } from '../../../utils/safeServerAction';
|
|
8
|
+
import type { FindMessagesParams } from '../schema/messages.schema';
|
|
9
|
+
|
|
10
|
+
export const MESSAGES_QUERY_KEY = ['messages'];
|
|
11
|
+
|
|
12
|
+
export function useMessages(params?: Partial<FindMessagesParams>) {
|
|
13
|
+
return useQuery({
|
|
14
|
+
queryKey: [...MESSAGES_QUERY_KEY, params],
|
|
15
|
+
queryFn: () => safeServerAction(listMessagesAction, params),
|
|
16
|
+
});
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
export function useMarkMessageAsRead() {
|
|
20
|
+
const queryClient = useQueryClient();
|
|
21
|
+
|
|
22
|
+
return useMutation({
|
|
23
|
+
mutationFn: (messageId: string) => safeServerAction(markMessageAsReadAction, messageId),
|
|
24
|
+
onSuccess: () => {
|
|
25
|
+
queryClient.invalidateQueries({ queryKey: MESSAGES_QUERY_KEY });
|
|
26
|
+
},
|
|
27
|
+
});
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
export function useMarkAllMessagesAsRead() {
|
|
31
|
+
const queryClient = useQueryClient();
|
|
32
|
+
|
|
33
|
+
return useMutation({
|
|
34
|
+
mutationFn: () => safeServerAction(markAllMessagesAsReadAction),
|
|
35
|
+
onSuccess: () => {
|
|
36
|
+
queryClient.invalidateQueries({ queryKey: MESSAGES_QUERY_KEY });
|
|
37
|
+
},
|
|
38
|
+
});
|
|
39
|
+
}
|