nucleus-core-ts 0.8.7 → 0.8.9
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/client.js +1 -1
- package/dist/fe/components/AbstractAnimatedBackground/index.js +437 -0
- package/dist/fe/components/AuthorizationPage/components/AuthorizationPage.js +841 -0
- package/dist/fe/components/AuthorizationPage/components/ClaimList.js +100 -0
- package/dist/fe/components/AuthorizationPage/components/RoleClaimEditor.js +232 -0
- package/dist/fe/components/AuthorizationPage/components/RoleList.js +115 -0
- package/dist/fe/components/AuthorizationPage/index.js +6 -0
- package/dist/fe/components/AuthorizationPage/store/index.js +117 -0
- package/dist/fe/components/AuthorizationPage/theme/index.js +137 -0
- package/dist/fe/components/AuthorizationPage/types/index.js +1 -0
- package/dist/fe/components/Button/components/Button.js +158 -0
- package/dist/fe/components/Button/components/ButtonSpinner.js +52 -0
- package/dist/fe/components/Button/index.js +3 -0
- package/dist/fe/components/Button/theme/index.js +186 -0
- package/dist/fe/components/Button/types/index.js +1 -0
- package/dist/fe/components/Button/utils/cn.js +5 -0
- package/dist/fe/components/Captcha/components/Captcha.js +311 -0
- package/dist/fe/components/Captcha/index.js +2 -0
- package/dist/fe/components/Captcha/theme.js +52 -0
- package/dist/fe/components/Captcha/types.js +1 -0
- package/dist/fe/components/ChangePasswordPage/components/ChangePasswordForm.js +242 -0
- package/dist/fe/components/ChangePasswordPage/components/ChangePasswordHeader.js +39 -0
- package/dist/fe/components/ChangePasswordPage/components/ChangePasswordPage.js +60 -0
- package/dist/fe/components/ChangePasswordPage/index.js +5 -0
- package/dist/fe/components/ChangePasswordPage/store/index.js +44 -0
- package/dist/fe/components/ChangePasswordPage/theme/index.js +87 -0
- package/dist/fe/components/ChangePasswordPage/types/index.js +1 -0
- package/dist/fe/components/Checkbox/components/Checkbox.js +115 -0
- package/dist/fe/components/Checkbox/components/CheckboxIcon.js +119 -0
- package/dist/fe/components/Checkbox/components/SwitchTrack.js +178 -0
- package/dist/fe/components/Checkbox/index.js +4 -0
- package/dist/fe/components/Checkbox/theme/index.js +221 -0
- package/dist/fe/components/Checkbox/types/index.js +1 -0
- package/dist/fe/components/Checkbox/utils/cn.js +5 -0
- package/dist/fe/components/DataTable/DataTable.js +225 -0
- package/dist/fe/components/DataTable/components/ActionCell.js +26 -0
- package/dist/fe/components/DataTable/components/DataCell.js +76 -0
- package/dist/fe/components/DataTable/components/EditableCell.js +221 -0
- package/dist/fe/components/DataTable/components/EmptyState.js +29 -0
- package/dist/fe/components/DataTable/components/HeaderCell.js +64 -0
- package/dist/fe/components/DataTable/components/InfiniteScrollTrigger.js +66 -0
- package/dist/fe/components/DataTable/components/LoadingSpinner.js +19 -0
- package/dist/fe/components/DataTable/components/ResizeHandle.js +41 -0
- package/dist/fe/components/DataTable/components/SelectionCell.js +105 -0
- package/dist/fe/components/DataTable/components/SkeletonRow.js +56 -0
- package/dist/fe/components/DataTable/components/SkeletonTable.js +83 -0
- package/dist/fe/components/DataTable/components/SortIcon.js +39 -0
- package/dist/fe/components/DataTable/components/TableHeader.js +49 -0
- package/dist/fe/components/DataTable/components/TableRow.js +118 -0
- package/dist/fe/components/DataTable/components/index.js +14 -0
- package/dist/fe/components/DataTable/hooks/index.js +2 -0
- package/dist/fe/components/DataTable/hooks/useAutoFitColumn.js +23 -0
- package/dist/fe/components/DataTable/hooks/useResizeColumn.js +122 -0
- package/dist/fe/components/DataTable/index.js +3 -0
- package/dist/fe/components/DataTable/store/index.js +97 -0
- package/dist/fe/components/DataTable/theme/index.js +144 -0
- package/dist/fe/components/DataTable/types/index.js +1 -0
- package/dist/fe/components/DataTable/utils/cn.js +5 -0
- package/dist/fe/components/DatePicker/components/CalendarGrid.js +95 -0
- package/dist/fe/components/DatePicker/components/CalendarHeader.js +152 -0
- package/dist/fe/components/DatePicker/components/DatePicker.js +381 -0
- package/dist/fe/components/DatePicker/components/MonthYearSelector.js +93 -0
- package/dist/fe/components/DatePicker/index.js +7 -0
- package/dist/fe/components/DatePicker/locales/index.js +1113 -0
- package/dist/fe/components/DatePicker/theme/index.js +315 -0
- package/dist/fe/components/DatePicker/types/index.js +1 -0
- package/dist/fe/components/DatePicker/utils/cn.js +5 -0
- package/dist/fe/components/DatePicker/utils/date.js +132 -0
- package/dist/fe/components/DevicesPage/components/DeviceCard.js +251 -0
- package/dist/fe/components/DevicesPage/components/DevicesHeader.js +42 -0
- package/dist/fe/components/DevicesPage/components/DevicesPage.js +450 -0
- package/dist/fe/components/DevicesPage/index.js +5 -0
- package/dist/fe/components/DevicesPage/store/index.js +55 -0
- package/dist/fe/components/DevicesPage/theme/index.js +131 -0
- package/dist/fe/components/DevicesPage/types/index.js +1 -0
- package/dist/fe/components/ForgotPasswordPage/components/ForgotPasswordForm.js +214 -0
- package/dist/fe/components/ForgotPasswordPage/components/ForgotPasswordHeader.js +42 -0
- package/dist/fe/components/ForgotPasswordPage/components/ForgotPasswordPage.js +59 -0
- package/dist/fe/components/ForgotPasswordPage/index.js +5 -0
- package/dist/fe/components/ForgotPasswordPage/store/index.js +28 -0
- package/dist/fe/components/ForgotPasswordPage/theme/index.js +87 -0
- package/dist/fe/components/ForgotPasswordPage/types/index.js +1 -0
- package/dist/fe/components/FormBuilder/components/FormBuilder.js +156 -0
- package/dist/fe/components/FormBuilder/components/FormField.js +218 -0
- package/dist/fe/components/FormBuilder/hooks/useFormBuilder.js +152 -0
- package/dist/fe/components/FormBuilder/index.js +4 -0
- package/dist/fe/components/FormBuilder/theme/index.js +134 -0
- package/dist/fe/components/FormBuilder/types/index.js +1 -0
- package/dist/fe/components/FormBuilder/utils/cn.js +5 -0
- package/dist/fe/components/FormBuilder/utils/fieldMapping.js +216 -0
- package/dist/fe/components/FormBuilder/utils/validation.js +78 -0
- package/dist/fe/components/LoginPage/components/LoginForm.js +214 -0
- package/dist/fe/components/LoginPage/components/LoginHeader.js +24 -0
- package/dist/fe/components/LoginPage/components/LoginPage.js +138 -0
- package/dist/fe/components/LoginPage/index.js +5 -0
- package/dist/fe/components/LoginPage/store/index.js +59 -0
- package/dist/fe/components/LoginPage/theme/index.js +98 -0
- package/dist/fe/components/LoginPage/types/index.js +1 -0
- package/dist/fe/components/MagicLinkVerifyPage/components/MagicLinkVerifyPage.js +200 -0
- package/dist/fe/components/MagicLinkVerifyPage/index.js +3 -0
- package/dist/fe/components/MagicLinkVerifyPage/store.js +20 -0
- package/dist/fe/components/MagicLinkVerifyPage/theme.js +36 -0
- package/dist/fe/components/MagicLinkVerifyPage/types.js +1 -0
- package/dist/fe/components/NucleusEntityShowcase.js +1409 -0
- package/dist/fe/components/NucleusTextInput/components/FloatingLabel.js +56 -0
- package/dist/fe/components/NucleusTextInput/components/InputIcons.js +258 -0
- package/dist/fe/components/NucleusTextInput/components/NucleusTextInput.js +321 -0
- package/dist/fe/components/NucleusTextInput/components/PasswordStrengthIndicator.js +104 -0
- package/dist/fe/components/NucleusTextInput/components/TypewriterText.js +56 -0
- package/dist/fe/components/NucleusTextInput/index.js +7 -0
- package/dist/fe/components/NucleusTextInput/theme/index.js +121 -0
- package/dist/fe/components/NucleusTextInput/types/index.js +1 -0
- package/dist/fe/components/NucleusTextInput/utils/cn.js +5 -0
- package/dist/fe/components/NucleusTextInput/utils/format.js +62 -0
- package/dist/fe/components/NucleusTextInput/utils/validation.js +191 -0
- package/dist/fe/components/ProfilePage/components/AddressCard.js +196 -0
- package/dist/fe/components/ProfilePage/components/PhoneCard.js +206 -0
- package/dist/fe/components/ProfilePage/components/ProfileHeader.js +150 -0
- package/dist/fe/components/ProfilePage/components/ProfilePage.js +1336 -0
- package/dist/fe/components/ProfilePage/index.js +6 -0
- package/dist/fe/components/ProfilePage/store/index.js +115 -0
- package/dist/fe/components/ProfilePage/theme/index.js +168 -0
- package/dist/fe/components/ProfilePage/types/index.js +1 -0
- package/dist/fe/components/RangePicker/components/RangePicker.js +338 -0
- package/dist/fe/components/RangePicker/components/RangeThumb.js +68 -0
- package/dist/fe/components/RangePicker/components/RangeTooltip.js +45 -0
- package/dist/fe/components/RangePicker/components/RangeTrack.js +32 -0
- package/dist/fe/components/RangePicker/index.js +5 -0
- package/dist/fe/components/RangePicker/theme/index.js +88 -0
- package/dist/fe/components/RangePicker/types/index.js +1 -0
- package/dist/fe/components/RangePicker/utils/cn.js +3 -0
- package/dist/fe/components/RegisterPage/components/PasswordStrengthIndicator.js +107 -0
- package/dist/fe/components/RegisterPage/components/RegisterForm.js +322 -0
- package/dist/fe/components/RegisterPage/components/RegisterHeader.js +23 -0
- package/dist/fe/components/RegisterPage/components/RegisterPage.js +85 -0
- package/dist/fe/components/RegisterPage/index.js +6 -0
- package/dist/fe/components/RegisterPage/store/index.js +106 -0
- package/dist/fe/components/RegisterPage/theme/index.js +128 -0
- package/dist/fe/components/RegisterPage/types/index.js +1 -0
- package/dist/fe/components/ResetPasswordPage/components/ResetPasswordForm.js +347 -0
- package/dist/fe/components/ResetPasswordPage/components/ResetPasswordHeader.js +42 -0
- package/dist/fe/components/ResetPasswordPage/components/ResetPasswordPage.js +61 -0
- package/dist/fe/components/ResetPasswordPage/index.js +5 -0
- package/dist/fe/components/ResetPasswordPage/store/index.js +36 -0
- package/dist/fe/components/ResetPasswordPage/theme/index.js +99 -0
- package/dist/fe/components/ResetPasswordPage/types/index.js +1 -0
- package/dist/fe/components/SearchBox/components/SearchBox.js +271 -0
- package/dist/fe/components/SearchBox/components/SearchBoxDropdown.js +87 -0
- package/dist/fe/components/SearchBox/index.js +5 -0
- package/dist/fe/components/SearchBox/theme/index.js +184 -0
- package/dist/fe/components/SearchBox/types/index.js +1 -0
- package/dist/fe/components/SearchBox/utils/cn.js +5 -0
- package/dist/fe/components/SearchBox/utils/debounce.js +22 -0
- package/dist/fe/components/SearchBox/utils/sanitize.js +48 -0
- package/dist/fe/components/SelectBox/components/SelectBox.js +364 -0
- package/dist/fe/components/SelectBox/components/SelectDropdown.js +92 -0
- package/dist/fe/components/SelectBox/components/SelectOptionItem.js +43 -0
- package/dist/fe/components/SelectBox/components/SelectTrigger.js +22 -0
- package/dist/fe/components/SelectBox/index.js +5 -0
- package/dist/fe/components/SelectBox/theme/index.js +98 -0
- package/dist/fe/components/SelectBox/types/index.js +1 -0
- package/dist/fe/components/SelectBox/utils/cn.js +3 -0
- package/dist/fe/components/SetPasswordPage/components/PasswordStrengthIndicator.js +107 -0
- package/dist/fe/components/SetPasswordPage/components/SetPasswordForm.js +142 -0
- package/dist/fe/components/SetPasswordPage/components/SetPasswordHeader.js +23 -0
- package/dist/fe/components/SetPasswordPage/components/SetPasswordPage.js +263 -0
- package/dist/fe/components/SetPasswordPage/index.js +7 -0
- package/dist/fe/components/SetPasswordPage/store/index.js +79 -0
- package/dist/fe/components/SetPasswordPage/theme/index.js +98 -0
- package/dist/fe/components/SetPasswordPage/types/index.js +12 -0
- package/dist/fe/components/UsersPage/components/InviteUserModal.js +262 -0
- package/dist/fe/components/UsersPage/components/Pagination.js +147 -0
- package/dist/fe/components/UsersPage/components/RoleAssignmentModal.js +186 -0
- package/dist/fe/components/UsersPage/components/StatsCards.js +124 -0
- package/dist/fe/components/UsersPage/components/UserDetailDrawer.js +444 -0
- package/dist/fe/components/UsersPage/components/UserFilters.js +142 -0
- package/dist/fe/components/UsersPage/components/UserListItem.js +125 -0
- package/dist/fe/components/UsersPage/components/UserListSkeleton.js +40 -0
- package/dist/fe/components/UsersPage/components/UsersPage.js +556 -0
- package/dist/fe/components/UsersPage/index.js +10 -0
- package/dist/fe/components/UsersPage/store/index.js +151 -0
- package/dist/fe/components/UsersPage/theme/index.js +231 -0
- package/dist/fe/components/UsersPage/types/index.js +1 -0
- package/dist/fe/components/VerifyEmailPage/components/VerifyEmailPage.js +290 -0
- package/dist/fe/components/VerifyEmailPage/index.js +3 -0
- package/dist/fe/components/VerifyEmailPage/store/index.js +45 -0
- package/dist/fe/components/VerifyEmailPage/theme/index.js +52 -0
- package/dist/fe/components/VerifyEmailPage/types/index.js +1 -0
- package/dist/fe/hooks/useNucleusEntity.js +247 -0
- package/dist/fe/index.js +28 -157
- package/dist/fe/types/index.js +1 -0
- package/dist/fe/utils/cn.js +5 -0
- package/dist/fe/utils/columnUtils.js +189 -0
- package/dist/fe/utils/endpointKeys.js +44 -0
- package/dist/index.js +1 -1
- package/dist/nucleus.config.d.ts +2 -0
- package/dist/src/Client/ApiCaller/client.js +1 -0
- package/dist/src/Client/ApiCaller/examples/usage.example.js +1 -0
- package/dist/src/Client/ApiCaller/generator.js +1 -0
- package/dist/src/Client/ApiCaller/index.js +1 -0
- package/dist/src/Client/ApiCaller/server.js +1 -0
- package/dist/src/Client/ApiCaller/system-tables.js +1 -0
- package/dist/src/Client/ApiCaller/types.js +1 -0
- package/dist/src/Client/Proxy/httpProxy.js +1 -0
- package/dist/src/Client/Proxy/index.js +1 -1
- package/dist/src/Client/Proxy/server.js +1 -0
- package/dist/src/Client/Proxy/types.js +1 -0
- package/dist/src/Client/Proxy/utils.js +1 -0
- package/dist/src/Client/Proxy/wsProxy.js +1 -0
- package/dist/src/Client/ServerFetch/index.js +1 -0
- package/dist/src/Client/ServerFetch/types.js +1 -0
- package/dist/src/Client/index.js +1 -0
- package/package.json +1 -1
- package/scripts/build.ts +41 -16
|
@@ -0,0 +1,556 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
3
|
+
import { useGSAP } from "@gsap/react";
|
|
4
|
+
import gsap from "gsap";
|
|
5
|
+
import { useEffect, useEffectEvent, useRef, useState } from "react";
|
|
6
|
+
import { cn } from "../../../utils/cn";
|
|
7
|
+
import { Button } from "../../Button";
|
|
8
|
+
import { useUsersStore } from "../store";
|
|
9
|
+
import { usersPageTheme } from "../theme";
|
|
10
|
+
import { InviteUserModal } from "./InviteUserModal";
|
|
11
|
+
import { Pagination } from "./Pagination";
|
|
12
|
+
import { StatsCards } from "./StatsCards";
|
|
13
|
+
import { UserDetailDrawer } from "./UserDetailDrawer";
|
|
14
|
+
import { UserFilters } from "./UserFilters";
|
|
15
|
+
import { UserListItem } from "./UserListItem";
|
|
16
|
+
import { UserListSkeleton } from "./UserListSkeleton";
|
|
17
|
+
gsap.registerPlugin(useGSAP);
|
|
18
|
+
export function UsersPage({ title = "User Management", subtitle, className, theme: customTheme, getUsersAction, updateUserAction, getProfilesAction, getAddressesAction, getPhonesAction, getFilesAction, getRolesAction, getUserRolesAction, addUserRoleAction, deleteUserRoleAction, passwordResetRequestAction, magicLinkRequestAction, inviteUserAction, onUserUpdated, onRoleAssigned, onRoleRemoved, onUserInvited }) {
|
|
19
|
+
const theme = customTheme ? {
|
|
20
|
+
...usersPageTheme,
|
|
21
|
+
...customTheme
|
|
22
|
+
} : usersPageTheme;
|
|
23
|
+
const store = useUsersStore();
|
|
24
|
+
const containerRef = useRef(null);
|
|
25
|
+
const contentRef = useRef(null);
|
|
26
|
+
const [actionLoading, setActionLoading] = useState(null);
|
|
27
|
+
const [isInviteModalOpen, setIsInviteModalOpen] = useState(false);
|
|
28
|
+
const [isInviting, setIsInviting] = useState(false);
|
|
29
|
+
const searchTimeoutRef = useRef(null);
|
|
30
|
+
useGSAP(()=>{
|
|
31
|
+
if (!contentRef.current) return;
|
|
32
|
+
gsap.fromTo(contentRef.current, {
|
|
33
|
+
opacity: 0,
|
|
34
|
+
y: 10
|
|
35
|
+
}, {
|
|
36
|
+
opacity: 1,
|
|
37
|
+
y: 0,
|
|
38
|
+
duration: 0.3,
|
|
39
|
+
ease: "power2.out"
|
|
40
|
+
});
|
|
41
|
+
}, {
|
|
42
|
+
scope: containerRef
|
|
43
|
+
});
|
|
44
|
+
const fetchUsers = useEffectEvent((page = store.currentPage, limit = store.pageSize)=>{
|
|
45
|
+
store.setIsLoading(true);
|
|
46
|
+
getUsersAction.start({
|
|
47
|
+
payload: {
|
|
48
|
+
page,
|
|
49
|
+
limit
|
|
50
|
+
},
|
|
51
|
+
onAfterHandle: (data)=>{
|
|
52
|
+
store.setIsLoading(false);
|
|
53
|
+
if (data.data) {
|
|
54
|
+
store.setUsers(data.data.items || []);
|
|
55
|
+
store.setPagination(data.data.meta?.totalItems || 0, data.data.meta?.totalPages || 1);
|
|
56
|
+
}
|
|
57
|
+
},
|
|
58
|
+
onErrorHandle: ()=>{
|
|
59
|
+
store.setIsLoading(false);
|
|
60
|
+
}
|
|
61
|
+
});
|
|
62
|
+
});
|
|
63
|
+
const fetchRelatedData = useEffectEvent(()=>{
|
|
64
|
+
getProfilesAction.start({
|
|
65
|
+
payload: {
|
|
66
|
+
page: 1,
|
|
67
|
+
limit: 1000
|
|
68
|
+
},
|
|
69
|
+
onAfterHandle: (data)=>{
|
|
70
|
+
if (data.data?.items) store.setProfiles(data.data.items);
|
|
71
|
+
}
|
|
72
|
+
});
|
|
73
|
+
getAddressesAction.start({
|
|
74
|
+
payload: {
|
|
75
|
+
page: 1,
|
|
76
|
+
limit: 1000
|
|
77
|
+
},
|
|
78
|
+
onAfterHandle: (data)=>{
|
|
79
|
+
if (data.data?.items) store.setAddresses(data.data.items);
|
|
80
|
+
}
|
|
81
|
+
});
|
|
82
|
+
getPhonesAction.start({
|
|
83
|
+
payload: {
|
|
84
|
+
page: 1,
|
|
85
|
+
limit: 1000
|
|
86
|
+
},
|
|
87
|
+
onAfterHandle: (data)=>{
|
|
88
|
+
if (data.data?.items) store.setPhones(data.data.items);
|
|
89
|
+
}
|
|
90
|
+
});
|
|
91
|
+
getFilesAction.start({
|
|
92
|
+
payload: {
|
|
93
|
+
page: 1,
|
|
94
|
+
limit: 1000
|
|
95
|
+
},
|
|
96
|
+
onAfterHandle: (data)=>{
|
|
97
|
+
if (data.data?.items) store.setFiles(data.data.items);
|
|
98
|
+
}
|
|
99
|
+
});
|
|
100
|
+
getRolesAction.start({
|
|
101
|
+
payload: {
|
|
102
|
+
page: 1,
|
|
103
|
+
limit: 100
|
|
104
|
+
},
|
|
105
|
+
onAfterHandle: (data)=>{
|
|
106
|
+
if (data.data?.items) store.setRoles(data.data.items);
|
|
107
|
+
}
|
|
108
|
+
});
|
|
109
|
+
getUserRolesAction.start({
|
|
110
|
+
payload: {
|
|
111
|
+
page: 1,
|
|
112
|
+
limit: 5000
|
|
113
|
+
},
|
|
114
|
+
onAfterHandle: (data)=>{
|
|
115
|
+
if (data.data?.items) store.setUserRoles(data.data.items);
|
|
116
|
+
}
|
|
117
|
+
});
|
|
118
|
+
});
|
|
119
|
+
useEffect(()=>{
|
|
120
|
+
fetchUsers(1, store.pageSize);
|
|
121
|
+
fetchRelatedData();
|
|
122
|
+
}, []);
|
|
123
|
+
const handlePageChange = useEffectEvent((page)=>{
|
|
124
|
+
store.setCurrentPage(page);
|
|
125
|
+
fetchUsers(page, store.pageSize);
|
|
126
|
+
});
|
|
127
|
+
const handlePageSizeChange = useEffectEvent((size)=>{
|
|
128
|
+
store.setPageSize(size);
|
|
129
|
+
fetchUsers(1, size);
|
|
130
|
+
});
|
|
131
|
+
const handleRefresh = useEffectEvent(()=>{
|
|
132
|
+
fetchUsers(store.currentPage, store.pageSize);
|
|
133
|
+
fetchRelatedData();
|
|
134
|
+
});
|
|
135
|
+
const handleSearchChange = useEffectEvent((query)=>{
|
|
136
|
+
store.setSearchQuery(query);
|
|
137
|
+
if (searchTimeoutRef.current) {
|
|
138
|
+
clearTimeout(searchTimeoutRef.current);
|
|
139
|
+
}
|
|
140
|
+
searchTimeoutRef.current = setTimeout(()=>{
|
|
141
|
+
store.setCurrentPage(1);
|
|
142
|
+
}, 300);
|
|
143
|
+
});
|
|
144
|
+
const handleSelectUser = useEffectEvent((user)=>{
|
|
145
|
+
const userWithDetails = store.getUserWithDetails(user.id);
|
|
146
|
+
store.setSelectedUser(userWithDetails);
|
|
147
|
+
});
|
|
148
|
+
const handleClosePanel = useEffectEvent(()=>{
|
|
149
|
+
store.setDetailPanelOpen(false);
|
|
150
|
+
});
|
|
151
|
+
const handleVerifyEmail = useEffectEvent((userId)=>{
|
|
152
|
+
setActionLoading(`verify-${userId}`);
|
|
153
|
+
const user = store.users.find((u)=>u.id === userId);
|
|
154
|
+
if (!user) return;
|
|
155
|
+
store.updateUser(userId, {
|
|
156
|
+
verifiedAt: new Date().toISOString()
|
|
157
|
+
});
|
|
158
|
+
updateUserAction.start({
|
|
159
|
+
payload: {
|
|
160
|
+
id: userId,
|
|
161
|
+
verifiedAt: new Date().toISOString()
|
|
162
|
+
},
|
|
163
|
+
onAfterHandle: (data)=>{
|
|
164
|
+
setActionLoading(null);
|
|
165
|
+
if (data.data) {
|
|
166
|
+
onUserUpdated?.(data.data);
|
|
167
|
+
const updated = store.getUserWithDetails(userId);
|
|
168
|
+
if (updated) store.setSelectedUser(updated);
|
|
169
|
+
}
|
|
170
|
+
},
|
|
171
|
+
onErrorHandle: ()=>{
|
|
172
|
+
setActionLoading(null);
|
|
173
|
+
store.updateUser(userId, {
|
|
174
|
+
verifiedAt: user.verifiedAt
|
|
175
|
+
});
|
|
176
|
+
}
|
|
177
|
+
});
|
|
178
|
+
});
|
|
179
|
+
const handleLockAccount = useEffectEvent((userId)=>{
|
|
180
|
+
setActionLoading(`lock-${userId}`);
|
|
181
|
+
const user = store.users.find((u)=>u.id === userId);
|
|
182
|
+
if (!user) return;
|
|
183
|
+
store.updateUser(userId, {
|
|
184
|
+
isLocked: true
|
|
185
|
+
});
|
|
186
|
+
updateUserAction.start({
|
|
187
|
+
payload: {
|
|
188
|
+
id: userId,
|
|
189
|
+
isLocked: true
|
|
190
|
+
},
|
|
191
|
+
onAfterHandle: (data)=>{
|
|
192
|
+
setActionLoading(null);
|
|
193
|
+
if (data.data) {
|
|
194
|
+
onUserUpdated?.(data.data);
|
|
195
|
+
const updated = store.getUserWithDetails(userId);
|
|
196
|
+
if (updated) store.setSelectedUser(updated);
|
|
197
|
+
}
|
|
198
|
+
},
|
|
199
|
+
onErrorHandle: ()=>{
|
|
200
|
+
setActionLoading(null);
|
|
201
|
+
store.updateUser(userId, {
|
|
202
|
+
isLocked: user.isLocked
|
|
203
|
+
});
|
|
204
|
+
}
|
|
205
|
+
});
|
|
206
|
+
});
|
|
207
|
+
const handleUnlockAccount = useEffectEvent((userId)=>{
|
|
208
|
+
setActionLoading(`unlock-${userId}`);
|
|
209
|
+
const user = store.users.find((u)=>u.id === userId);
|
|
210
|
+
if (!user) return;
|
|
211
|
+
store.updateUser(userId, {
|
|
212
|
+
isLocked: false,
|
|
213
|
+
lockedUntil: undefined,
|
|
214
|
+
failedLoginAttempts: 0
|
|
215
|
+
});
|
|
216
|
+
updateUserAction.start({
|
|
217
|
+
payload: {
|
|
218
|
+
id: userId,
|
|
219
|
+
isLocked: false,
|
|
220
|
+
lockedUntil: undefined,
|
|
221
|
+
failedLoginAttempts: 0
|
|
222
|
+
},
|
|
223
|
+
onAfterHandle: (data)=>{
|
|
224
|
+
setActionLoading(null);
|
|
225
|
+
if (data.data) {
|
|
226
|
+
onUserUpdated?.(data.data);
|
|
227
|
+
const updated = store.getUserWithDetails(userId);
|
|
228
|
+
if (updated) store.setSelectedUser(updated);
|
|
229
|
+
}
|
|
230
|
+
},
|
|
231
|
+
onErrorHandle: ()=>{
|
|
232
|
+
setActionLoading(null);
|
|
233
|
+
store.updateUser(userId, {
|
|
234
|
+
isLocked: user.isLocked,
|
|
235
|
+
lockedUntil: user.lockedUntil,
|
|
236
|
+
failedLoginAttempts: user.failedLoginAttempts
|
|
237
|
+
});
|
|
238
|
+
}
|
|
239
|
+
});
|
|
240
|
+
});
|
|
241
|
+
const handleResetPassword = useEffectEvent((email)=>{
|
|
242
|
+
if (!passwordResetRequestAction) return;
|
|
243
|
+
setActionLoading(`reset-${email}`);
|
|
244
|
+
passwordResetRequestAction.start({
|
|
245
|
+
payload: {
|
|
246
|
+
email
|
|
247
|
+
},
|
|
248
|
+
onAfterHandle: ()=>{
|
|
249
|
+
setActionLoading(null);
|
|
250
|
+
},
|
|
251
|
+
onErrorHandle: ()=>{
|
|
252
|
+
setActionLoading(null);
|
|
253
|
+
}
|
|
254
|
+
});
|
|
255
|
+
});
|
|
256
|
+
const handleSendMagicLink = useEffectEvent((email)=>{
|
|
257
|
+
if (!magicLinkRequestAction) return;
|
|
258
|
+
setActionLoading(`magic-${email}`);
|
|
259
|
+
magicLinkRequestAction.start({
|
|
260
|
+
payload: {
|
|
261
|
+
email
|
|
262
|
+
},
|
|
263
|
+
onAfterHandle: ()=>{
|
|
264
|
+
setActionLoading(null);
|
|
265
|
+
},
|
|
266
|
+
onErrorHandle: ()=>{
|
|
267
|
+
setActionLoading(null);
|
|
268
|
+
}
|
|
269
|
+
});
|
|
270
|
+
});
|
|
271
|
+
const handleAssignRole = useEffectEvent((userId, roleId)=>{
|
|
272
|
+
const tempId = `temp-${Date.now()}`;
|
|
273
|
+
store.addUserRole({
|
|
274
|
+
id: tempId,
|
|
275
|
+
userId,
|
|
276
|
+
roleId
|
|
277
|
+
});
|
|
278
|
+
addUserRoleAction.start({
|
|
279
|
+
payload: {
|
|
280
|
+
userId,
|
|
281
|
+
roleId
|
|
282
|
+
},
|
|
283
|
+
onAfterHandle: (data)=>{
|
|
284
|
+
store.removeUserRole(tempId);
|
|
285
|
+
if (data.data) {
|
|
286
|
+
store.addUserRole(data.data);
|
|
287
|
+
onRoleAssigned?.(userId, roleId);
|
|
288
|
+
const updated = store.getUserWithDetails(userId);
|
|
289
|
+
if (updated) store.setSelectedUser(updated);
|
|
290
|
+
}
|
|
291
|
+
},
|
|
292
|
+
onErrorHandle: ()=>{
|
|
293
|
+
store.removeUserRole(tempId);
|
|
294
|
+
}
|
|
295
|
+
});
|
|
296
|
+
});
|
|
297
|
+
const handleRemoveRole = useEffectEvent((userRoleId)=>{
|
|
298
|
+
const userRole = store.userRoles.find((ur)=>ur.id === userRoleId);
|
|
299
|
+
if (!userRole) return;
|
|
300
|
+
store.removeUserRole(userRoleId);
|
|
301
|
+
deleteUserRoleAction.start({
|
|
302
|
+
payload: {
|
|
303
|
+
id: userRoleId
|
|
304
|
+
},
|
|
305
|
+
onAfterHandle: ()=>{
|
|
306
|
+
onRoleRemoved?.(userRole.userId, userRole.roleId);
|
|
307
|
+
const updated = store.getUserWithDetails(userRole.userId);
|
|
308
|
+
if (updated) store.setSelectedUser(updated);
|
|
309
|
+
},
|
|
310
|
+
onErrorHandle: ()=>{
|
|
311
|
+
store.addUserRole(userRole);
|
|
312
|
+
}
|
|
313
|
+
});
|
|
314
|
+
});
|
|
315
|
+
const handleInviteUser = useEffectEvent((email)=>{
|
|
316
|
+
if (!inviteUserAction) return;
|
|
317
|
+
setIsInviting(true);
|
|
318
|
+
inviteUserAction.start({
|
|
319
|
+
payload: {
|
|
320
|
+
email
|
|
321
|
+
},
|
|
322
|
+
onAfterHandle: ()=>{
|
|
323
|
+
setIsInviting(false);
|
|
324
|
+
setIsInviteModalOpen(false);
|
|
325
|
+
onUserInvited?.(email);
|
|
326
|
+
fetchUsers(store.currentPage, store.pageSize);
|
|
327
|
+
},
|
|
328
|
+
onErrorHandle: ()=>{
|
|
329
|
+
setIsInviting(false);
|
|
330
|
+
}
|
|
331
|
+
});
|
|
332
|
+
});
|
|
333
|
+
const handleResendInvite = useEffectEvent((email)=>{
|
|
334
|
+
if (!inviteUserAction) return;
|
|
335
|
+
setActionLoading(`invite-${email}`);
|
|
336
|
+
inviteUserAction.start({
|
|
337
|
+
payload: {
|
|
338
|
+
email
|
|
339
|
+
},
|
|
340
|
+
onAfterHandle: ()=>{
|
|
341
|
+
setActionLoading(null);
|
|
342
|
+
},
|
|
343
|
+
onErrorHandle: ()=>{
|
|
344
|
+
setActionLoading(null);
|
|
345
|
+
}
|
|
346
|
+
});
|
|
347
|
+
});
|
|
348
|
+
const stats = {
|
|
349
|
+
total: store.totalItems,
|
|
350
|
+
verified: store.users.filter((u)=>u.verifiedAt).length,
|
|
351
|
+
unverified: store.users.filter((u)=>!u.verifiedAt).length,
|
|
352
|
+
locked: store.users.filter((u)=>u.isLocked).length
|
|
353
|
+
};
|
|
354
|
+
const filteredUsers = store.users.filter((user)=>{
|
|
355
|
+
const profile = store.profiles.find((p)=>p.userId === user.id);
|
|
356
|
+
const displayName = profile?.firstName || profile?.lastName ? `${profile.firstName || ""} ${profile.lastName || ""}`.toLowerCase() : "";
|
|
357
|
+
const matchesSearch = store.searchQuery === "" || user.email.toLowerCase().includes(store.searchQuery.toLowerCase()) || displayName.includes(store.searchQuery.toLowerCase());
|
|
358
|
+
const matchesStatus = store.statusFilter === "all" || store.statusFilter === "locked" && user.isLocked || store.statusFilter === "active" && !user.isLocked && user.verifiedAt || store.statusFilter === "unverified" && !user.verifiedAt;
|
|
359
|
+
const matchesRole = store.roleFilter === "all" || store.userRoles.some((ur)=>ur.userId === user.id && ur.roleId === store.roleFilter);
|
|
360
|
+
return matchesSearch && matchesStatus && matchesRole;
|
|
361
|
+
});
|
|
362
|
+
const getUserWithDetailsForList = (userId)=>{
|
|
363
|
+
const user = store.users.find((u)=>u.id === userId);
|
|
364
|
+
if (!user) return {};
|
|
365
|
+
const profile = store.profiles.find((p)=>p.userId === userId);
|
|
366
|
+
const userRoles = store.userRoles.filter((ur)=>ur.userId === userId).map((ur)=>({
|
|
367
|
+
...ur,
|
|
368
|
+
role: store.roles.find((r)=>r.id === ur.roleId)
|
|
369
|
+
}));
|
|
370
|
+
return {
|
|
371
|
+
...user,
|
|
372
|
+
profile: profile || null,
|
|
373
|
+
userRoles
|
|
374
|
+
};
|
|
375
|
+
};
|
|
376
|
+
return /*#__PURE__*/ _jsxs("div", {
|
|
377
|
+
ref: containerRef,
|
|
378
|
+
className: cn(theme.container.base, "p-3 sm:p-4 md:p-6 lg:p-8 xl:p-10", className),
|
|
379
|
+
children: [
|
|
380
|
+
/*#__PURE__*/ _jsxs("div", {
|
|
381
|
+
ref: contentRef,
|
|
382
|
+
className: "max-w-7xl mx-auto",
|
|
383
|
+
children: [
|
|
384
|
+
/*#__PURE__*/ _jsxs("header", {
|
|
385
|
+
className: cn(theme.header.wrapper),
|
|
386
|
+
children: [
|
|
387
|
+
/*#__PURE__*/ _jsxs("div", {
|
|
388
|
+
children: [
|
|
389
|
+
/*#__PURE__*/ _jsx("h1", {
|
|
390
|
+
className: cn(theme.header.title),
|
|
391
|
+
children: title
|
|
392
|
+
}),
|
|
393
|
+
subtitle && /*#__PURE__*/ _jsx("p", {
|
|
394
|
+
className: cn(theme.header.subtitle),
|
|
395
|
+
children: subtitle
|
|
396
|
+
})
|
|
397
|
+
]
|
|
398
|
+
}),
|
|
399
|
+
/*#__PURE__*/ _jsx("div", {
|
|
400
|
+
className: cn(theme.header.actions),
|
|
401
|
+
children: inviteUserAction && /*#__PURE__*/ _jsxs(Button, {
|
|
402
|
+
variant: "primary",
|
|
403
|
+
size: "md",
|
|
404
|
+
onClick: ()=>setIsInviteModalOpen(true),
|
|
405
|
+
leftIcon: /*#__PURE__*/ _jsx("svg", {
|
|
406
|
+
className: "w-4 h-4",
|
|
407
|
+
fill: "none",
|
|
408
|
+
stroke: "currentColor",
|
|
409
|
+
viewBox: "0 0 24 24",
|
|
410
|
+
"aria-hidden": "true",
|
|
411
|
+
children: /*#__PURE__*/ _jsx("path", {
|
|
412
|
+
strokeLinecap: "round",
|
|
413
|
+
strokeLinejoin: "round",
|
|
414
|
+
strokeWidth: 2,
|
|
415
|
+
d: "M18 9v3m0 0v3m0-3h3m-3 0h-3m-2-5a4 4 0 11-8 0 4 4 0 018 0zM3 20a6 6 0 0112 0v1H3v-1z"
|
|
416
|
+
})
|
|
417
|
+
}),
|
|
418
|
+
children: [
|
|
419
|
+
/*#__PURE__*/ _jsx("span", {
|
|
420
|
+
className: "hidden sm:inline",
|
|
421
|
+
children: "Invite User"
|
|
422
|
+
}),
|
|
423
|
+
/*#__PURE__*/ _jsx("span", {
|
|
424
|
+
className: "sm:hidden",
|
|
425
|
+
children: "Invite"
|
|
426
|
+
})
|
|
427
|
+
]
|
|
428
|
+
})
|
|
429
|
+
})
|
|
430
|
+
]
|
|
431
|
+
}),
|
|
432
|
+
/*#__PURE__*/ _jsx(StatsCards, {
|
|
433
|
+
theme: theme,
|
|
434
|
+
totalUsers: stats.total,
|
|
435
|
+
verifiedUsers: stats.verified,
|
|
436
|
+
lockedUsers: stats.locked,
|
|
437
|
+
unverifiedUsers: stats.unverified
|
|
438
|
+
}),
|
|
439
|
+
/*#__PURE__*/ _jsxs("div", {
|
|
440
|
+
className: cn(theme.layout.wrapper),
|
|
441
|
+
children: [
|
|
442
|
+
/*#__PURE__*/ _jsxs("div", {
|
|
443
|
+
className: cn(theme.layout.sidebar.base, store.isDetailPanelOpen ? theme.layout.sidebar.expanded : theme.layout.sidebar.collapsed),
|
|
444
|
+
children: [
|
|
445
|
+
/*#__PURE__*/ _jsx(UserFilters, {
|
|
446
|
+
theme: theme,
|
|
447
|
+
searchQuery: store.searchQuery,
|
|
448
|
+
statusFilter: store.statusFilter,
|
|
449
|
+
roleFilter: store.roleFilter,
|
|
450
|
+
roles: store.roles,
|
|
451
|
+
totalCount: store.totalItems,
|
|
452
|
+
filteredCount: filteredUsers.length,
|
|
453
|
+
onSearchChange: handleSearchChange,
|
|
454
|
+
onStatusChange: store.setStatusFilter,
|
|
455
|
+
onRoleChange: store.setRoleFilter,
|
|
456
|
+
onRefresh: handleRefresh,
|
|
457
|
+
isLoading: store.isLoading
|
|
458
|
+
}),
|
|
459
|
+
/*#__PURE__*/ _jsx("div", {
|
|
460
|
+
className: cn(theme.table.wrapper),
|
|
461
|
+
children: /*#__PURE__*/ _jsx("div", {
|
|
462
|
+
className: "max-h-[calc(100vh-380px)] sm:max-h-[calc(100vh-340px)] lg:max-h-[calc(100vh-300px)] overflow-y-auto",
|
|
463
|
+
children: store.isLoading ? /*#__PURE__*/ _jsx(UserListSkeleton, {
|
|
464
|
+
theme: theme,
|
|
465
|
+
count: store.pageSize > 10 ? 10 : store.pageSize
|
|
466
|
+
}) : filteredUsers.length === 0 ? /*#__PURE__*/ _jsxs("div", {
|
|
467
|
+
className: cn(theme.emptyState.wrapper),
|
|
468
|
+
children: [
|
|
469
|
+
/*#__PURE__*/ _jsx("svg", {
|
|
470
|
+
className: cn(theme.emptyState.icon),
|
|
471
|
+
fill: "none",
|
|
472
|
+
stroke: "currentColor",
|
|
473
|
+
viewBox: "0 0 24 24",
|
|
474
|
+
"aria-hidden": "true",
|
|
475
|
+
children: /*#__PURE__*/ _jsx("path", {
|
|
476
|
+
strokeLinecap: "round",
|
|
477
|
+
strokeLinejoin: "round",
|
|
478
|
+
strokeWidth: 1.5,
|
|
479
|
+
d: "M17 20h5v-2a3 3 0 00-5.356-1.857M17 20H7m10 0v-2c0-.656-.126-1.283-.356-1.857M7 20H2v-2a3 3 0 015.356-1.857M7 20v-2c0-.656.126-1.283.356-1.857m0 0a5.002 5.002 0 019.288 0M15 7a3 3 0 11-6 0 3 3 0 016 0zm6 3a2 2 0 11-4 0 2 2 0 014 0zM7 10a2 2 0 11-4 0 2 2 0 014 0z"
|
|
480
|
+
})
|
|
481
|
+
}),
|
|
482
|
+
/*#__PURE__*/ _jsx("h3", {
|
|
483
|
+
className: cn(theme.emptyState.title),
|
|
484
|
+
children: "No users found"
|
|
485
|
+
}),
|
|
486
|
+
/*#__PURE__*/ _jsx("p", {
|
|
487
|
+
className: cn(theme.emptyState.description),
|
|
488
|
+
children: store.searchQuery || store.statusFilter !== "all" || store.roleFilter !== "all" ? "Try adjusting your filters" : "No users have been created yet"
|
|
489
|
+
})
|
|
490
|
+
]
|
|
491
|
+
}) : /*#__PURE__*/ _jsx("div", {
|
|
492
|
+
className: "divide-y divide-zinc-100 dark:divide-zinc-800/50",
|
|
493
|
+
children: filteredUsers.map((user)=>/*#__PURE__*/ _jsx(UserListItem, {
|
|
494
|
+
theme: theme,
|
|
495
|
+
user: getUserWithDetailsForList(user.id),
|
|
496
|
+
roles: store.roles,
|
|
497
|
+
isSelected: store.selectedUser?.id === user.id,
|
|
498
|
+
onSelect: handleSelectUser
|
|
499
|
+
}, user.id))
|
|
500
|
+
})
|
|
501
|
+
})
|
|
502
|
+
}),
|
|
503
|
+
store.totalPages > 1 && /*#__PURE__*/ _jsx(Pagination, {
|
|
504
|
+
theme: theme,
|
|
505
|
+
currentPage: store.currentPage,
|
|
506
|
+
totalPages: store.totalPages,
|
|
507
|
+
totalItems: store.totalItems,
|
|
508
|
+
pageSize: store.pageSize,
|
|
509
|
+
pageSizeOptions: [
|
|
510
|
+
10,
|
|
511
|
+
25,
|
|
512
|
+
50,
|
|
513
|
+
100
|
|
514
|
+
],
|
|
515
|
+
onPageChange: handlePageChange,
|
|
516
|
+
onPageSizeChange: handlePageSizeChange
|
|
517
|
+
})
|
|
518
|
+
]
|
|
519
|
+
}),
|
|
520
|
+
store.isDetailPanelOpen && /*#__PURE__*/ _jsx("div", {
|
|
521
|
+
className: cn(theme.layout.main),
|
|
522
|
+
children: /*#__PURE__*/ _jsx(UserDetailDrawer, {
|
|
523
|
+
theme: theme,
|
|
524
|
+
user: store.selectedUser,
|
|
525
|
+
roles: store.roles,
|
|
526
|
+
allUserRoles: store.userRoles,
|
|
527
|
+
isOpen: store.isDetailPanelOpen,
|
|
528
|
+
actionLoading: actionLoading,
|
|
529
|
+
onClose: handleClosePanel,
|
|
530
|
+
onVerifyEmail: handleVerifyEmail,
|
|
531
|
+
onLockAccount: handleLockAccount,
|
|
532
|
+
onUnlockAccount: handleUnlockAccount,
|
|
533
|
+
onResetPassword: handleResetPassword,
|
|
534
|
+
onSendMagicLink: handleSendMagicLink,
|
|
535
|
+
onResendInvite: handleResendInvite,
|
|
536
|
+
onAssignRole: handleAssignRole,
|
|
537
|
+
onRemoveRole: handleRemoveRole,
|
|
538
|
+
hasPasswordReset: !!passwordResetRequestAction,
|
|
539
|
+
hasMagicLink: !!magicLinkRequestAction,
|
|
540
|
+
hasInvite: !!inviteUserAction
|
|
541
|
+
})
|
|
542
|
+
})
|
|
543
|
+
]
|
|
544
|
+
})
|
|
545
|
+
]
|
|
546
|
+
}),
|
|
547
|
+
/*#__PURE__*/ _jsx(InviteUserModal, {
|
|
548
|
+
theme: theme,
|
|
549
|
+
isOpen: isInviteModalOpen,
|
|
550
|
+
isLoading: isInviting,
|
|
551
|
+
onClose: ()=>setIsInviteModalOpen(false),
|
|
552
|
+
onInvite: handleInviteUser
|
|
553
|
+
})
|
|
554
|
+
]
|
|
555
|
+
});
|
|
556
|
+
}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
export { InviteUserModal } from "./components/InviteUserModal";
|
|
2
|
+
export { Pagination } from "./components/Pagination";
|
|
3
|
+
export { StatsCards } from "./components/StatsCards";
|
|
4
|
+
export { UserDetailDrawer } from "./components/UserDetailDrawer";
|
|
5
|
+
export { UserFilters } from "./components/UserFilters";
|
|
6
|
+
export { UserListItem } from "./components/UserListItem";
|
|
7
|
+
export { UserListSkeleton } from "./components/UserListSkeleton";
|
|
8
|
+
export { UsersPage } from "./components/UsersPage";
|
|
9
|
+
export { useUsersStore } from "./store";
|
|
10
|
+
export { extendUsersPageTheme, usersPageTheme } from "./theme";
|