nucleus-core-ts 0.8.6 → 0.8.8
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/dist/index.d.ts +475 -12
- 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 -110
- 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 +3 -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/package.json +1 -1
- package/scripts/build.ts +78 -8
- package/dist/dist/index-0yyw12k6.d.ts +0 -8
- package/dist/dist/index-tv67j5qd.d.ts +0 -488
- package/dist/index-0yyw12k6.js +0 -1
- package/dist/index-tv67j5qd.js +0 -1
|
@@ -0,0 +1,1336 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } 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 { AbstractAnimatedBackground } from "../../AbstractAnimatedBackground";
|
|
8
|
+
import { Button } from "../../Button";
|
|
9
|
+
import { useProfileStore } from "../store";
|
|
10
|
+
import { profilePageTheme } from "../theme";
|
|
11
|
+
import { AddressCard } from "./AddressCard";
|
|
12
|
+
import { PhoneCard } from "./PhoneCard";
|
|
13
|
+
import { ProfileHeader } from "./ProfileHeader";
|
|
14
|
+
gsap.registerPlugin(useGSAP);
|
|
15
|
+
export function ProfilePage({ meAction, addProfileAction, updateProfileAction, addAddressAction, updateAddressAction, deleteAddressAction, addPhoneAction, updatePhoneAction, deletePhoneAction, uploadFileAction, updateFileAction, deleteFileAction, fileProxyBasePath = "/file-proxy", onProfileUpdated, onAddressAdded, onAddressUpdated, onAddressDeleted, onPhoneAdded, onPhoneUpdated, onPhoneDeleted, onFileUploaded, onFileUpdated, onFileDeleted, onProfilePictureChanged, showBackground = false, allowProfileEdit = true, allowAddressEdit = true, allowPhoneEdit = true, allowFileUpload = true, changePasswordHref, devicesHref, onChangePassword, onViewDevices }) {
|
|
16
|
+
const theme = profilePageTheme;
|
|
17
|
+
const containerRef = useRef(null);
|
|
18
|
+
const cardRef = useRef(null);
|
|
19
|
+
const fileInputRef = useRef(null);
|
|
20
|
+
const store = useProfileStore();
|
|
21
|
+
const [editingAddress, setEditingAddress] = useState(null);
|
|
22
|
+
const [editingPhone, setEditingPhone] = useState(null);
|
|
23
|
+
const [showAddressModal, setShowAddressModal] = useState(false);
|
|
24
|
+
const [showPhoneModal, setShowPhoneModal] = useState(false);
|
|
25
|
+
const mouseDownTargetRef = useRef(null);
|
|
26
|
+
const [profileFormData, setProfileFormData] = useState({});
|
|
27
|
+
const [addressFormData, setAddressFormData] = useState({});
|
|
28
|
+
const [phoneFormData, setPhoneFormData] = useState({});
|
|
29
|
+
const fetchProfile = useEffectEvent(()=>{
|
|
30
|
+
meAction.start({
|
|
31
|
+
payload: undefined,
|
|
32
|
+
onAfterHandle: (response)=>{
|
|
33
|
+
const data = response.data;
|
|
34
|
+
if (!data?.user?.id) return;
|
|
35
|
+
const { user, profile, addresses, phones, files, roles } = data;
|
|
36
|
+
store.setUser(user);
|
|
37
|
+
store.setProfile(profile);
|
|
38
|
+
store.setAddresses(addresses);
|
|
39
|
+
store.setPhones(phones);
|
|
40
|
+
store.setFiles(files);
|
|
41
|
+
store.setRoles(roles || []);
|
|
42
|
+
const profilePics = files.filter((f)=>f.type === "profile_picture");
|
|
43
|
+
const profilePic = profilePics.length > 0 ? profilePics.sort((a, b)=>new Date(b.updatedAt).getTime() - new Date(a.updatedAt).getTime())[0] : null;
|
|
44
|
+
store.setProfilePicture(profilePic || null);
|
|
45
|
+
if (profile) {
|
|
46
|
+
setProfileFormData({
|
|
47
|
+
firstName: profile.firstName,
|
|
48
|
+
lastName: profile.lastName
|
|
49
|
+
});
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
});
|
|
53
|
+
});
|
|
54
|
+
useEffect(()=>{
|
|
55
|
+
fetchProfile();
|
|
56
|
+
}, []);
|
|
57
|
+
useGSAP(()=>{
|
|
58
|
+
if (!cardRef.current) return;
|
|
59
|
+
gsap.fromTo(cardRef.current, {
|
|
60
|
+
opacity: 0,
|
|
61
|
+
y: 30
|
|
62
|
+
}, {
|
|
63
|
+
opacity: 1,
|
|
64
|
+
y: 0,
|
|
65
|
+
duration: 0.6,
|
|
66
|
+
ease: "power3.out"
|
|
67
|
+
});
|
|
68
|
+
}, {
|
|
69
|
+
scope: containerRef
|
|
70
|
+
});
|
|
71
|
+
const handleSaveProfile = ()=>{
|
|
72
|
+
if (!store.user?.id) return;
|
|
73
|
+
const hasExistingProfile = !!store.profile?.id;
|
|
74
|
+
const previousProfile = store.profile;
|
|
75
|
+
const optimisticProfile = {
|
|
76
|
+
...previousProfile,
|
|
77
|
+
...profileFormData
|
|
78
|
+
};
|
|
79
|
+
store.setProfile(optimisticProfile);
|
|
80
|
+
store.setEditingProfile(false);
|
|
81
|
+
if (hasExistingProfile && previousProfile?.id) {
|
|
82
|
+
updateProfileAction.start({
|
|
83
|
+
payload: {
|
|
84
|
+
id: previousProfile.id,
|
|
85
|
+
...profileFormData
|
|
86
|
+
},
|
|
87
|
+
onAfterHandle: (response)=>{
|
|
88
|
+
const record = response.data;
|
|
89
|
+
if (record) {
|
|
90
|
+
store.setProfile(record);
|
|
91
|
+
onProfileUpdated?.(record);
|
|
92
|
+
}
|
|
93
|
+
},
|
|
94
|
+
onErrorHandle: ()=>{
|
|
95
|
+
store.setProfile(previousProfile);
|
|
96
|
+
}
|
|
97
|
+
});
|
|
98
|
+
} else {
|
|
99
|
+
addProfileAction.start({
|
|
100
|
+
payload: {
|
|
101
|
+
userId: store.user.id,
|
|
102
|
+
...profileFormData
|
|
103
|
+
},
|
|
104
|
+
onAfterHandle: (response)=>{
|
|
105
|
+
const record = response.data;
|
|
106
|
+
if (record) {
|
|
107
|
+
store.setProfile(record);
|
|
108
|
+
onProfileUpdated?.(record);
|
|
109
|
+
}
|
|
110
|
+
},
|
|
111
|
+
onErrorHandle: ()=>{
|
|
112
|
+
store.setProfile(previousProfile);
|
|
113
|
+
}
|
|
114
|
+
});
|
|
115
|
+
}
|
|
116
|
+
};
|
|
117
|
+
const handleAddAddress = ()=>{
|
|
118
|
+
if (!store.user?.id) return;
|
|
119
|
+
const tempId = `temp-${Date.now()}`;
|
|
120
|
+
const optimisticAddress = {
|
|
121
|
+
id: tempId,
|
|
122
|
+
...addressFormData,
|
|
123
|
+
ownerType: "user",
|
|
124
|
+
ownerId: store.user.id,
|
|
125
|
+
name: addressFormData.name || "New Address"
|
|
126
|
+
};
|
|
127
|
+
store.addAddress(optimisticAddress);
|
|
128
|
+
setShowAddressModal(false);
|
|
129
|
+
setAddressFormData({});
|
|
130
|
+
addAddressAction.start({
|
|
131
|
+
payload: {
|
|
132
|
+
...addressFormData,
|
|
133
|
+
ownerType: "user",
|
|
134
|
+
ownerId: store.user.id,
|
|
135
|
+
name: addressFormData.name || "New Address"
|
|
136
|
+
},
|
|
137
|
+
onAfterHandle: (response)=>{
|
|
138
|
+
const record = response.data;
|
|
139
|
+
if (record) {
|
|
140
|
+
store.removeAddress(tempId);
|
|
141
|
+
store.addAddress(record);
|
|
142
|
+
onAddressAdded?.(record);
|
|
143
|
+
}
|
|
144
|
+
},
|
|
145
|
+
onErrorHandle: ()=>{
|
|
146
|
+
store.removeAddress(tempId);
|
|
147
|
+
}
|
|
148
|
+
});
|
|
149
|
+
};
|
|
150
|
+
const handleUpdateAddress = ()=>{
|
|
151
|
+
if (!editingAddress?.id) return;
|
|
152
|
+
const addressId = editingAddress.id;
|
|
153
|
+
const previousAddress = store.addresses.find((a)=>a.id === addressId);
|
|
154
|
+
const optimisticAddress = {
|
|
155
|
+
...previousAddress,
|
|
156
|
+
...addressFormData,
|
|
157
|
+
id: addressId
|
|
158
|
+
};
|
|
159
|
+
store.updateAddress(optimisticAddress);
|
|
160
|
+
setEditingAddress(null);
|
|
161
|
+
setShowAddressModal(false);
|
|
162
|
+
setAddressFormData({});
|
|
163
|
+
updateAddressAction.start({
|
|
164
|
+
payload: {
|
|
165
|
+
id: addressId,
|
|
166
|
+
...addressFormData
|
|
167
|
+
},
|
|
168
|
+
onAfterHandle: (response)=>{
|
|
169
|
+
const record = response.data;
|
|
170
|
+
if (record) {
|
|
171
|
+
store.updateAddress(record);
|
|
172
|
+
onAddressUpdated?.(record);
|
|
173
|
+
}
|
|
174
|
+
},
|
|
175
|
+
onErrorHandle: ()=>{
|
|
176
|
+
if (previousAddress) store.updateAddress(previousAddress);
|
|
177
|
+
}
|
|
178
|
+
});
|
|
179
|
+
};
|
|
180
|
+
const handleDeleteAddress = (addressId)=>{
|
|
181
|
+
deleteAddressAction.start({
|
|
182
|
+
payload: {
|
|
183
|
+
id: addressId
|
|
184
|
+
},
|
|
185
|
+
onAfterHandle: ()=>{
|
|
186
|
+
store.removeAddress(addressId);
|
|
187
|
+
onAddressDeleted?.(addressId);
|
|
188
|
+
}
|
|
189
|
+
});
|
|
190
|
+
};
|
|
191
|
+
const handleAddPhone = ()=>{
|
|
192
|
+
if (!store.user?.id) return;
|
|
193
|
+
const tempId = `temp-${Date.now()}`;
|
|
194
|
+
const optimisticPhone = {
|
|
195
|
+
id: tempId,
|
|
196
|
+
...phoneFormData,
|
|
197
|
+
ownerType: "user",
|
|
198
|
+
ownerId: store.user.id,
|
|
199
|
+
name: phoneFormData.name || "New Phone",
|
|
200
|
+
number: phoneFormData.number || "",
|
|
201
|
+
countryCode: phoneFormData.countryCode || "+1"
|
|
202
|
+
};
|
|
203
|
+
store.addPhone(optimisticPhone);
|
|
204
|
+
setShowPhoneModal(false);
|
|
205
|
+
setPhoneFormData({});
|
|
206
|
+
addPhoneAction.start({
|
|
207
|
+
payload: {
|
|
208
|
+
...phoneFormData,
|
|
209
|
+
ownerType: "user",
|
|
210
|
+
ownerId: store.user.id,
|
|
211
|
+
name: phoneFormData.name || "New Phone",
|
|
212
|
+
number: phoneFormData.number || "",
|
|
213
|
+
countryCode: phoneFormData.countryCode || "+1"
|
|
214
|
+
},
|
|
215
|
+
onAfterHandle: (response)=>{
|
|
216
|
+
const record = response.data;
|
|
217
|
+
if (record) {
|
|
218
|
+
store.removePhone(tempId);
|
|
219
|
+
store.addPhone(record);
|
|
220
|
+
onPhoneAdded?.(record);
|
|
221
|
+
}
|
|
222
|
+
},
|
|
223
|
+
onErrorHandle: ()=>{
|
|
224
|
+
store.removePhone(tempId);
|
|
225
|
+
}
|
|
226
|
+
});
|
|
227
|
+
};
|
|
228
|
+
const handleUpdatePhone = ()=>{
|
|
229
|
+
if (!editingPhone?.id) return;
|
|
230
|
+
const phoneId = editingPhone.id;
|
|
231
|
+
const previousPhone = store.phones.find((p)=>p.id === phoneId);
|
|
232
|
+
const optimisticPhone = {
|
|
233
|
+
...previousPhone,
|
|
234
|
+
...phoneFormData,
|
|
235
|
+
id: phoneId
|
|
236
|
+
};
|
|
237
|
+
store.updatePhone(optimisticPhone);
|
|
238
|
+
setEditingPhone(null);
|
|
239
|
+
setShowPhoneModal(false);
|
|
240
|
+
setPhoneFormData({});
|
|
241
|
+
updatePhoneAction.start({
|
|
242
|
+
payload: {
|
|
243
|
+
id: phoneId,
|
|
244
|
+
...phoneFormData
|
|
245
|
+
},
|
|
246
|
+
onAfterHandle: (response)=>{
|
|
247
|
+
const record = response.data;
|
|
248
|
+
if (record) {
|
|
249
|
+
store.updatePhone(record);
|
|
250
|
+
onPhoneUpdated?.(record);
|
|
251
|
+
}
|
|
252
|
+
},
|
|
253
|
+
onErrorHandle: ()=>{
|
|
254
|
+
if (previousPhone) store.updatePhone(previousPhone);
|
|
255
|
+
}
|
|
256
|
+
});
|
|
257
|
+
};
|
|
258
|
+
const handleDeletePhone = (phoneId)=>{
|
|
259
|
+
deletePhoneAction.start({
|
|
260
|
+
payload: {
|
|
261
|
+
id: phoneId
|
|
262
|
+
},
|
|
263
|
+
onAfterHandle: ()=>{
|
|
264
|
+
store.removePhone(phoneId);
|
|
265
|
+
onPhoneDeleted?.(phoneId);
|
|
266
|
+
}
|
|
267
|
+
});
|
|
268
|
+
};
|
|
269
|
+
const handleUploadFile = (event)=>{
|
|
270
|
+
const file = event.target.files?.[0];
|
|
271
|
+
if (!file || !uploadFileAction) return;
|
|
272
|
+
const formData = new FormData();
|
|
273
|
+
formData.append("files", file);
|
|
274
|
+
formData.append("data", JSON.stringify({
|
|
275
|
+
type: "profile_picture"
|
|
276
|
+
}));
|
|
277
|
+
uploadFileAction.start({
|
|
278
|
+
payload: formData,
|
|
279
|
+
onAfterHandle: (response)=>{
|
|
280
|
+
const record = response.data;
|
|
281
|
+
if (record) {
|
|
282
|
+
store.addFile(record);
|
|
283
|
+
onFileUploaded?.(record);
|
|
284
|
+
onProfilePictureChanged?.(record);
|
|
285
|
+
}
|
|
286
|
+
}
|
|
287
|
+
});
|
|
288
|
+
};
|
|
289
|
+
const handleSetAsProfilePicture = (file)=>{
|
|
290
|
+
if (!updateFileAction) return;
|
|
291
|
+
const previousFile = store.files.find((f)=>f.id === file.id);
|
|
292
|
+
const optimisticFile = {
|
|
293
|
+
...file,
|
|
294
|
+
type: "profile_picture"
|
|
295
|
+
};
|
|
296
|
+
store.updateFile(optimisticFile);
|
|
297
|
+
updateFileAction.start({
|
|
298
|
+
payload: {
|
|
299
|
+
id: file.id,
|
|
300
|
+
type: "profile_picture"
|
|
301
|
+
},
|
|
302
|
+
onAfterHandle: (response)=>{
|
|
303
|
+
const record = response.data;
|
|
304
|
+
if (record) {
|
|
305
|
+
store.updateFile(record);
|
|
306
|
+
onFileUpdated?.(record);
|
|
307
|
+
onProfilePictureChanged?.(record);
|
|
308
|
+
}
|
|
309
|
+
},
|
|
310
|
+
onErrorHandle: ()=>{
|
|
311
|
+
if (previousFile) store.updateFile(previousFile);
|
|
312
|
+
}
|
|
313
|
+
});
|
|
314
|
+
};
|
|
315
|
+
const handleDeleteFile = (fileId)=>{
|
|
316
|
+
if (!deleteFileAction) return;
|
|
317
|
+
deleteFileAction.start({
|
|
318
|
+
payload: {
|
|
319
|
+
id: fileId
|
|
320
|
+
},
|
|
321
|
+
onAfterHandle: ()=>{
|
|
322
|
+
store.removeFile(fileId);
|
|
323
|
+
onFileDeleted?.(fileId);
|
|
324
|
+
}
|
|
325
|
+
});
|
|
326
|
+
};
|
|
327
|
+
const getFileUrl = (file)=>`${fileProxyBasePath}/${file.id}`;
|
|
328
|
+
const isImageFile = (file)=>{
|
|
329
|
+
const imageTypes = [
|
|
330
|
+
"image",
|
|
331
|
+
"profile_picture"
|
|
332
|
+
];
|
|
333
|
+
return imageTypes.includes(file.type || "") || file.mimeType?.startsWith("image/");
|
|
334
|
+
};
|
|
335
|
+
const openEditAddress = (address)=>{
|
|
336
|
+
setEditingAddress(address);
|
|
337
|
+
setAddressFormData({
|
|
338
|
+
name: address.name,
|
|
339
|
+
street: address.street,
|
|
340
|
+
city: address.city,
|
|
341
|
+
state: address.state,
|
|
342
|
+
zip: address.zip,
|
|
343
|
+
country: address.country
|
|
344
|
+
});
|
|
345
|
+
setShowAddressModal(true);
|
|
346
|
+
};
|
|
347
|
+
const openEditPhone = (phone)=>{
|
|
348
|
+
setEditingPhone(phone);
|
|
349
|
+
setPhoneFormData({
|
|
350
|
+
name: phone.name,
|
|
351
|
+
number: phone.number,
|
|
352
|
+
countryCode: phone.countryCode,
|
|
353
|
+
type: phone.type,
|
|
354
|
+
extension: phone.extension
|
|
355
|
+
});
|
|
356
|
+
setShowPhoneModal(true);
|
|
357
|
+
};
|
|
358
|
+
const openAddAddress = ()=>{
|
|
359
|
+
setEditingAddress(null);
|
|
360
|
+
setAddressFormData({});
|
|
361
|
+
setShowAddressModal(true);
|
|
362
|
+
};
|
|
363
|
+
const openAddPhone = ()=>{
|
|
364
|
+
setEditingPhone(null);
|
|
365
|
+
setPhoneFormData({});
|
|
366
|
+
setShowPhoneModal(true);
|
|
367
|
+
};
|
|
368
|
+
return /*#__PURE__*/ _jsxs("main", {
|
|
369
|
+
ref: containerRef,
|
|
370
|
+
className: cn(theme.container.base),
|
|
371
|
+
"aria-label": "Profile page",
|
|
372
|
+
children: [
|
|
373
|
+
showBackground && /*#__PURE__*/ _jsx(AbstractAnimatedBackground, {}),
|
|
374
|
+
/*#__PURE__*/ _jsx("div", {
|
|
375
|
+
className: theme.container.wrapper,
|
|
376
|
+
children: /*#__PURE__*/ _jsx("article", {
|
|
377
|
+
ref: cardRef,
|
|
378
|
+
className: cn(theme.card.base, theme.card.padding, theme.card.background, theme.card.border, theme.card.shadow, theme.card.rounded),
|
|
379
|
+
children: meAction.state.isPending ? /*#__PURE__*/ _jsxs("div", {
|
|
380
|
+
className: theme.loading.container,
|
|
381
|
+
children: [
|
|
382
|
+
/*#__PURE__*/ _jsx("div", {
|
|
383
|
+
className: theme.loading.spinner
|
|
384
|
+
}),
|
|
385
|
+
/*#__PURE__*/ _jsx("p", {
|
|
386
|
+
className: theme.loading.text,
|
|
387
|
+
children: "Loading profile..."
|
|
388
|
+
})
|
|
389
|
+
]
|
|
390
|
+
}) : /*#__PURE__*/ _jsxs(_Fragment, {
|
|
391
|
+
children: [
|
|
392
|
+
/*#__PURE__*/ _jsx(ProfileHeader, {
|
|
393
|
+
user: store.user || undefined,
|
|
394
|
+
profile: store.profile || undefined,
|
|
395
|
+
profilePicture: store.profilePicture || undefined,
|
|
396
|
+
fileProxyBasePath: fileProxyBasePath,
|
|
397
|
+
onUploadPicture: allowFileUpload && uploadFileAction ? ()=>fileInputRef.current?.click() : undefined,
|
|
398
|
+
isUploading: uploadFileAction?.state.isPending
|
|
399
|
+
}),
|
|
400
|
+
/*#__PURE__*/ _jsx("input", {
|
|
401
|
+
ref: fileInputRef,
|
|
402
|
+
type: "file",
|
|
403
|
+
accept: "image/*",
|
|
404
|
+
className: "hidden",
|
|
405
|
+
onChange: handleUploadFile
|
|
406
|
+
}),
|
|
407
|
+
/*#__PURE__*/ _jsxs("section", {
|
|
408
|
+
className: theme.section.container,
|
|
409
|
+
children: [
|
|
410
|
+
/*#__PURE__*/ _jsxs("div", {
|
|
411
|
+
className: theme.section.titleWrapper,
|
|
412
|
+
children: [
|
|
413
|
+
/*#__PURE__*/ _jsx("h2", {
|
|
414
|
+
className: theme.section.title,
|
|
415
|
+
children: "Profile Information"
|
|
416
|
+
}),
|
|
417
|
+
allowProfileEdit && !store.isEditingProfile && /*#__PURE__*/ _jsx("button", {
|
|
418
|
+
type: "button",
|
|
419
|
+
onClick: ()=>store.setEditingProfile(true),
|
|
420
|
+
className: theme.section.addButton,
|
|
421
|
+
children: "Edit"
|
|
422
|
+
})
|
|
423
|
+
]
|
|
424
|
+
}),
|
|
425
|
+
store.isEditingProfile ? /*#__PURE__*/ _jsxs("div", {
|
|
426
|
+
className: theme.profileForm.container,
|
|
427
|
+
children: [
|
|
428
|
+
/*#__PURE__*/ _jsxs("div", {
|
|
429
|
+
className: theme.profileForm.grid,
|
|
430
|
+
children: [
|
|
431
|
+
/*#__PURE__*/ _jsxs("div", {
|
|
432
|
+
className: theme.profileForm.field.container,
|
|
433
|
+
children: [
|
|
434
|
+
/*#__PURE__*/ _jsx("label", {
|
|
435
|
+
htmlFor: "firstName",
|
|
436
|
+
className: theme.profileForm.field.label,
|
|
437
|
+
children: "First Name"
|
|
438
|
+
}),
|
|
439
|
+
/*#__PURE__*/ _jsx("input", {
|
|
440
|
+
id: "firstName",
|
|
441
|
+
type: "text",
|
|
442
|
+
value: profileFormData.firstName || "",
|
|
443
|
+
onChange: (e)=>setProfileFormData((prev)=>({
|
|
444
|
+
...prev,
|
|
445
|
+
firstName: e.target.value
|
|
446
|
+
})),
|
|
447
|
+
className: theme.profileForm.field.input,
|
|
448
|
+
placeholder: "Enter first name"
|
|
449
|
+
})
|
|
450
|
+
]
|
|
451
|
+
}),
|
|
452
|
+
/*#__PURE__*/ _jsxs("div", {
|
|
453
|
+
className: theme.profileForm.field.container,
|
|
454
|
+
children: [
|
|
455
|
+
/*#__PURE__*/ _jsx("label", {
|
|
456
|
+
htmlFor: "lastName",
|
|
457
|
+
className: theme.profileForm.field.label,
|
|
458
|
+
children: "Last Name"
|
|
459
|
+
}),
|
|
460
|
+
/*#__PURE__*/ _jsx("input", {
|
|
461
|
+
id: "lastName",
|
|
462
|
+
type: "text",
|
|
463
|
+
value: profileFormData.lastName || "",
|
|
464
|
+
onChange: (e)=>setProfileFormData((prev)=>({
|
|
465
|
+
...prev,
|
|
466
|
+
lastName: e.target.value
|
|
467
|
+
})),
|
|
468
|
+
className: theme.profileForm.field.input,
|
|
469
|
+
placeholder: "Enter last name"
|
|
470
|
+
})
|
|
471
|
+
]
|
|
472
|
+
})
|
|
473
|
+
]
|
|
474
|
+
}),
|
|
475
|
+
/*#__PURE__*/ _jsxs("div", {
|
|
476
|
+
className: theme.profileForm.actions,
|
|
477
|
+
children: [
|
|
478
|
+
/*#__PURE__*/ _jsx(Button, {
|
|
479
|
+
variant: "outline",
|
|
480
|
+
size: "sm",
|
|
481
|
+
onClick: ()=>store.setEditingProfile(false),
|
|
482
|
+
children: "Cancel"
|
|
483
|
+
}),
|
|
484
|
+
/*#__PURE__*/ _jsx(Button, {
|
|
485
|
+
variant: "primary",
|
|
486
|
+
size: "sm",
|
|
487
|
+
onClick: handleSaveProfile,
|
|
488
|
+
disabled: updateProfileAction.state.isPending || addProfileAction.state.isPending,
|
|
489
|
+
children: updateProfileAction.state.isPending || addProfileAction.state.isPending ? "Saving..." : "Save Changes"
|
|
490
|
+
})
|
|
491
|
+
]
|
|
492
|
+
})
|
|
493
|
+
]
|
|
494
|
+
}) : /*#__PURE__*/ _jsxs("div", {
|
|
495
|
+
className: theme.profileForm.grid,
|
|
496
|
+
children: [
|
|
497
|
+
/*#__PURE__*/ _jsxs("div", {
|
|
498
|
+
children: [
|
|
499
|
+
/*#__PURE__*/ _jsx("p", {
|
|
500
|
+
className: "text-xs text-zinc-500 dark:text-zinc-400",
|
|
501
|
+
children: "First Name"
|
|
502
|
+
}),
|
|
503
|
+
/*#__PURE__*/ _jsx("p", {
|
|
504
|
+
className: "text-sm font-medium text-zinc-900 dark:text-white",
|
|
505
|
+
children: store.profile?.firstName || "Not set"
|
|
506
|
+
})
|
|
507
|
+
]
|
|
508
|
+
}),
|
|
509
|
+
/*#__PURE__*/ _jsxs("div", {
|
|
510
|
+
children: [
|
|
511
|
+
/*#__PURE__*/ _jsx("p", {
|
|
512
|
+
className: "text-xs text-zinc-500 dark:text-zinc-400",
|
|
513
|
+
children: "Last Name"
|
|
514
|
+
}),
|
|
515
|
+
/*#__PURE__*/ _jsx("p", {
|
|
516
|
+
className: "text-sm font-medium text-zinc-900 dark:text-white",
|
|
517
|
+
children: store.profile?.lastName || "Not set"
|
|
518
|
+
})
|
|
519
|
+
]
|
|
520
|
+
})
|
|
521
|
+
]
|
|
522
|
+
})
|
|
523
|
+
]
|
|
524
|
+
}),
|
|
525
|
+
/*#__PURE__*/ _jsxs("section", {
|
|
526
|
+
className: theme.section.container,
|
|
527
|
+
children: [
|
|
528
|
+
/*#__PURE__*/ _jsxs("div", {
|
|
529
|
+
className: theme.section.titleWrapper,
|
|
530
|
+
children: [
|
|
531
|
+
/*#__PURE__*/ _jsx("h2", {
|
|
532
|
+
className: theme.section.title,
|
|
533
|
+
children: "Addresses"
|
|
534
|
+
}),
|
|
535
|
+
allowAddressEdit && /*#__PURE__*/ _jsx("button", {
|
|
536
|
+
type: "button",
|
|
537
|
+
onClick: openAddAddress,
|
|
538
|
+
className: theme.section.addButton,
|
|
539
|
+
children: "+ Add Address"
|
|
540
|
+
})
|
|
541
|
+
]
|
|
542
|
+
}),
|
|
543
|
+
store.addresses.length === 0 ? /*#__PURE__*/ _jsxs("div", {
|
|
544
|
+
className: theme.section.empty.container,
|
|
545
|
+
children: [
|
|
546
|
+
/*#__PURE__*/ _jsxs("svg", {
|
|
547
|
+
className: theme.section.empty.icon,
|
|
548
|
+
viewBox: "0 0 24 24",
|
|
549
|
+
fill: "none",
|
|
550
|
+
stroke: "currentColor",
|
|
551
|
+
strokeWidth: "1.5",
|
|
552
|
+
children: [
|
|
553
|
+
/*#__PURE__*/ _jsx("title", {
|
|
554
|
+
children: "No addresses"
|
|
555
|
+
}),
|
|
556
|
+
/*#__PURE__*/ _jsx("path", {
|
|
557
|
+
strokeLinecap: "round",
|
|
558
|
+
strokeLinejoin: "round",
|
|
559
|
+
d: "M15 10.5a3 3 0 11-6 0 3 3 0 016 0z"
|
|
560
|
+
}),
|
|
561
|
+
/*#__PURE__*/ _jsx("path", {
|
|
562
|
+
strokeLinecap: "round",
|
|
563
|
+
strokeLinejoin: "round",
|
|
564
|
+
d: "M19.5 10.5c0 7.142-7.5 11.25-7.5 11.25S4.5 17.642 4.5 10.5a7.5 7.5 0 1115 0z"
|
|
565
|
+
})
|
|
566
|
+
]
|
|
567
|
+
}),
|
|
568
|
+
/*#__PURE__*/ _jsx("p", {
|
|
569
|
+
className: theme.section.empty.text,
|
|
570
|
+
children: "No addresses added yet"
|
|
571
|
+
})
|
|
572
|
+
]
|
|
573
|
+
}) : /*#__PURE__*/ _jsx("div", {
|
|
574
|
+
className: theme.section.content,
|
|
575
|
+
children: store.addresses.map((address)=>/*#__PURE__*/ _jsx(AddressCard, {
|
|
576
|
+
address: address,
|
|
577
|
+
onEdit: openEditAddress,
|
|
578
|
+
onDelete: handleDeleteAddress,
|
|
579
|
+
isUpdating: updateAddressAction.state.isPending,
|
|
580
|
+
isDeleting: deleteAddressAction.state.isPending,
|
|
581
|
+
allowEdit: allowAddressEdit
|
|
582
|
+
}, address.id))
|
|
583
|
+
})
|
|
584
|
+
]
|
|
585
|
+
}),
|
|
586
|
+
/*#__PURE__*/ _jsxs("section", {
|
|
587
|
+
className: theme.section.container,
|
|
588
|
+
children: [
|
|
589
|
+
/*#__PURE__*/ _jsxs("div", {
|
|
590
|
+
className: theme.section.titleWrapper,
|
|
591
|
+
children: [
|
|
592
|
+
/*#__PURE__*/ _jsx("h2", {
|
|
593
|
+
className: theme.section.title,
|
|
594
|
+
children: "Phone Numbers"
|
|
595
|
+
}),
|
|
596
|
+
allowPhoneEdit && /*#__PURE__*/ _jsx("button", {
|
|
597
|
+
type: "button",
|
|
598
|
+
onClick: openAddPhone,
|
|
599
|
+
className: theme.section.addButton,
|
|
600
|
+
children: "+ Add Phone"
|
|
601
|
+
})
|
|
602
|
+
]
|
|
603
|
+
}),
|
|
604
|
+
store.phones.length === 0 ? /*#__PURE__*/ _jsxs("div", {
|
|
605
|
+
className: theme.section.empty.container,
|
|
606
|
+
children: [
|
|
607
|
+
/*#__PURE__*/ _jsxs("svg", {
|
|
608
|
+
className: theme.section.empty.icon,
|
|
609
|
+
viewBox: "0 0 24 24",
|
|
610
|
+
fill: "none",
|
|
611
|
+
stroke: "currentColor",
|
|
612
|
+
strokeWidth: "1.5",
|
|
613
|
+
children: [
|
|
614
|
+
/*#__PURE__*/ _jsx("title", {
|
|
615
|
+
children: "No phones"
|
|
616
|
+
}),
|
|
617
|
+
/*#__PURE__*/ _jsx("path", {
|
|
618
|
+
strokeLinecap: "round",
|
|
619
|
+
strokeLinejoin: "round",
|
|
620
|
+
d: "M2.25 6.75c0 8.284 6.716 15 15 15h2.25a2.25 2.25 0 002.25-2.25v-1.372c0-.516-.351-.966-.852-1.091l-4.423-1.106c-.44-.11-.902.055-1.173.417l-.97 1.293c-.282.376-.769.542-1.21.38a12.035 12.035 0 01-7.143-7.143c-.162-.441.004-.928.38-1.21l1.293-.97c.363-.271.527-.734.417-1.173L6.963 3.102a1.125 1.125 0 00-1.091-.852H4.5A2.25 2.25 0 002.25 4.5v2.25z"
|
|
621
|
+
})
|
|
622
|
+
]
|
|
623
|
+
}),
|
|
624
|
+
/*#__PURE__*/ _jsx("p", {
|
|
625
|
+
className: theme.section.empty.text,
|
|
626
|
+
children: "No phone numbers added yet"
|
|
627
|
+
})
|
|
628
|
+
]
|
|
629
|
+
}) : /*#__PURE__*/ _jsx("div", {
|
|
630
|
+
className: theme.section.content,
|
|
631
|
+
children: store.phones.map((phone)=>/*#__PURE__*/ _jsx(PhoneCard, {
|
|
632
|
+
phone: phone,
|
|
633
|
+
onEdit: openEditPhone,
|
|
634
|
+
onDelete: handleDeletePhone,
|
|
635
|
+
isUpdating: updatePhoneAction.state.isPending,
|
|
636
|
+
isDeleting: deletePhoneAction.state.isPending,
|
|
637
|
+
allowEdit: allowPhoneEdit
|
|
638
|
+
}, phone.id))
|
|
639
|
+
})
|
|
640
|
+
]
|
|
641
|
+
}),
|
|
642
|
+
/*#__PURE__*/ _jsxs("section", {
|
|
643
|
+
className: theme.section.container,
|
|
644
|
+
children: [
|
|
645
|
+
/*#__PURE__*/ _jsxs("div", {
|
|
646
|
+
className: theme.section.titleWrapper,
|
|
647
|
+
children: [
|
|
648
|
+
/*#__PURE__*/ _jsx("h2", {
|
|
649
|
+
className: theme.section.title,
|
|
650
|
+
children: "My Files"
|
|
651
|
+
}),
|
|
652
|
+
allowFileUpload && uploadFileAction && /*#__PURE__*/ _jsx("button", {
|
|
653
|
+
type: "button",
|
|
654
|
+
onClick: ()=>fileInputRef.current?.click(),
|
|
655
|
+
className: theme.section.addButton,
|
|
656
|
+
children: "+ Upload File"
|
|
657
|
+
})
|
|
658
|
+
]
|
|
659
|
+
}),
|
|
660
|
+
store.files.length === 0 ? /*#__PURE__*/ _jsxs("div", {
|
|
661
|
+
className: theme.section.empty.container,
|
|
662
|
+
children: [
|
|
663
|
+
/*#__PURE__*/ _jsxs("svg", {
|
|
664
|
+
className: theme.section.empty.icon,
|
|
665
|
+
viewBox: "0 0 24 24",
|
|
666
|
+
fill: "none",
|
|
667
|
+
stroke: "currentColor",
|
|
668
|
+
strokeWidth: "1.5",
|
|
669
|
+
children: [
|
|
670
|
+
/*#__PURE__*/ _jsx("title", {
|
|
671
|
+
children: "No files"
|
|
672
|
+
}),
|
|
673
|
+
/*#__PURE__*/ _jsx("path", {
|
|
674
|
+
strokeLinecap: "round",
|
|
675
|
+
strokeLinejoin: "round",
|
|
676
|
+
d: "M19.5 14.25v-2.625a3.375 3.375 0 00-3.375-3.375h-1.5A1.125 1.125 0 0113.5 7.125v-1.5a3.375 3.375 0 00-3.375-3.375H8.25m2.25 0H5.625c-.621 0-1.125.504-1.125 1.125v17.25c0 .621.504 1.125 1.125 1.125h12.75c.621 0 1.125-.504 1.125-1.125V11.25a9 9 0 00-9-9z"
|
|
677
|
+
})
|
|
678
|
+
]
|
|
679
|
+
}),
|
|
680
|
+
/*#__PURE__*/ _jsx("p", {
|
|
681
|
+
className: theme.section.empty.text,
|
|
682
|
+
children: "No files uploaded yet"
|
|
683
|
+
})
|
|
684
|
+
]
|
|
685
|
+
}) : /*#__PURE__*/ _jsx("div", {
|
|
686
|
+
className: "grid grid-cols-2 sm:grid-cols-3 md:grid-cols-4 gap-3 sm:gap-4",
|
|
687
|
+
children: store.files.map((file)=>/*#__PURE__*/ _jsxs("div", {
|
|
688
|
+
className: cn("group relative rounded-lg overflow-hidden border border-zinc-200 dark:border-zinc-700", "hover:border-zinc-300 dark:hover:border-zinc-600 transition-all", file.type === "profile_picture" && "ring-2 ring-blue-500"),
|
|
689
|
+
children: [
|
|
690
|
+
isImageFile(file) ? /*#__PURE__*/ _jsx("img", {
|
|
691
|
+
src: getFileUrl(file),
|
|
692
|
+
alt: file.originalName || file.name,
|
|
693
|
+
className: "w-full aspect-square object-cover"
|
|
694
|
+
}) : /*#__PURE__*/ _jsx("div", {
|
|
695
|
+
className: "w-full aspect-square bg-zinc-100 dark:bg-zinc-800 flex items-center justify-center",
|
|
696
|
+
children: /*#__PURE__*/ _jsxs("svg", {
|
|
697
|
+
className: "w-8 h-8 text-zinc-400",
|
|
698
|
+
viewBox: "0 0 24 24",
|
|
699
|
+
fill: "none",
|
|
700
|
+
stroke: "currentColor",
|
|
701
|
+
strokeWidth: "1.5",
|
|
702
|
+
children: [
|
|
703
|
+
/*#__PURE__*/ _jsx("title", {
|
|
704
|
+
children: "File"
|
|
705
|
+
}),
|
|
706
|
+
/*#__PURE__*/ _jsx("path", {
|
|
707
|
+
strokeLinecap: "round",
|
|
708
|
+
strokeLinejoin: "round",
|
|
709
|
+
d: "M19.5 14.25v-2.625a3.375 3.375 0 00-3.375-3.375h-1.5A1.125 1.125 0 0113.5 7.125v-1.5a3.375 3.375 0 00-3.375-3.375H8.25m2.25 0H5.625c-.621 0-1.125.504-1.125 1.125v17.25c0 .621.504 1.125 1.125 1.125h12.75c.621 0 1.125-.504 1.125-1.125V11.25a9 9 0 00-9-9z"
|
|
710
|
+
})
|
|
711
|
+
]
|
|
712
|
+
})
|
|
713
|
+
}),
|
|
714
|
+
/*#__PURE__*/ _jsx("div", {
|
|
715
|
+
className: "absolute inset-0 bg-black/0 group-hover:bg-black/40 transition-all flex items-center justify-center opacity-0 group-hover:opacity-100",
|
|
716
|
+
children: /*#__PURE__*/ _jsxs("div", {
|
|
717
|
+
className: "flex gap-1",
|
|
718
|
+
children: [
|
|
719
|
+
isImageFile(file) && store.profilePicture?.id !== file.id && updateFileAction && /*#__PURE__*/ _jsx("button", {
|
|
720
|
+
type: "button",
|
|
721
|
+
onClick: ()=>handleSetAsProfilePicture(file),
|
|
722
|
+
disabled: updateFileAction.state.isPending,
|
|
723
|
+
className: "p-2 bg-white dark:bg-zinc-800 rounded-full shadow-md hover:bg-zinc-100 dark:hover:bg-zinc-700 transition-colors",
|
|
724
|
+
title: "Set as profile picture",
|
|
725
|
+
children: /*#__PURE__*/ _jsxs("svg", {
|
|
726
|
+
className: "w-4 h-4 text-blue-600",
|
|
727
|
+
viewBox: "0 0 24 24",
|
|
728
|
+
fill: "none",
|
|
729
|
+
stroke: "currentColor",
|
|
730
|
+
strokeWidth: "2",
|
|
731
|
+
children: [
|
|
732
|
+
/*#__PURE__*/ _jsx("title", {
|
|
733
|
+
children: "Set as profile"
|
|
734
|
+
}),
|
|
735
|
+
/*#__PURE__*/ _jsx("path", {
|
|
736
|
+
strokeLinecap: "round",
|
|
737
|
+
strokeLinejoin: "round",
|
|
738
|
+
d: "M15.75 6a3.75 3.75 0 11-7.5 0 3.75 3.75 0 017.5 0zM4.501 20.118a7.5 7.5 0 0114.998 0A17.933 17.933 0 0112 21.75c-2.676 0-5.216-.584-7.499-1.632z"
|
|
739
|
+
})
|
|
740
|
+
]
|
|
741
|
+
})
|
|
742
|
+
}),
|
|
743
|
+
deleteFileAction && /*#__PURE__*/ _jsx("button", {
|
|
744
|
+
type: "button",
|
|
745
|
+
onClick: ()=>handleDeleteFile(file.id),
|
|
746
|
+
disabled: deleteFileAction.state.isPending,
|
|
747
|
+
className: "p-2 bg-white dark:bg-zinc-800 rounded-full shadow-md hover:bg-red-50 dark:hover:bg-red-900/30 transition-colors",
|
|
748
|
+
title: "Delete file",
|
|
749
|
+
children: /*#__PURE__*/ _jsxs("svg", {
|
|
750
|
+
className: "w-4 h-4 text-red-600",
|
|
751
|
+
viewBox: "0 0 24 24",
|
|
752
|
+
fill: "none",
|
|
753
|
+
stroke: "currentColor",
|
|
754
|
+
strokeWidth: "2",
|
|
755
|
+
children: [
|
|
756
|
+
/*#__PURE__*/ _jsx("title", {
|
|
757
|
+
children: "Delete"
|
|
758
|
+
}),
|
|
759
|
+
/*#__PURE__*/ _jsx("path", {
|
|
760
|
+
strokeLinecap: "round",
|
|
761
|
+
strokeLinejoin: "round",
|
|
762
|
+
d: "M14.74 9l-.346 9m-4.788 0L9.26 9m9.968-3.21c.342.052.682.107 1.022.166m-1.022-.165L18.16 19.673a2.25 2.25 0 01-2.244 2.077H8.084a2.25 2.25 0 01-2.244-2.077L4.772 5.79m14.456 0a48.108 48.108 0 00-3.478-.397m-12 .562c.34-.059.68-.114 1.022-.165m0 0a48.11 48.11 0 013.478-.397m7.5 0v-.916c0-1.18-.91-2.164-2.09-2.201a51.964 51.964 0 00-3.32 0c-1.18.037-2.09 1.022-2.09 2.201v.916m7.5 0a48.667 48.667 0 00-7.5 0"
|
|
763
|
+
})
|
|
764
|
+
]
|
|
765
|
+
})
|
|
766
|
+
})
|
|
767
|
+
]
|
|
768
|
+
})
|
|
769
|
+
}),
|
|
770
|
+
file.type === "profile_picture" && /*#__PURE__*/ _jsx("div", {
|
|
771
|
+
className: "absolute top-1 left-1 px-1.5 py-0.5 bg-blue-500 text-white text-xs rounded-full",
|
|
772
|
+
children: "Profile"
|
|
773
|
+
}),
|
|
774
|
+
/*#__PURE__*/ _jsx("div", {
|
|
775
|
+
className: "p-2 bg-white dark:bg-zinc-800",
|
|
776
|
+
children: /*#__PURE__*/ _jsx("p", {
|
|
777
|
+
className: "text-xs text-zinc-700 dark:text-zinc-300 truncate",
|
|
778
|
+
children: file.originalName || file.name
|
|
779
|
+
})
|
|
780
|
+
})
|
|
781
|
+
]
|
|
782
|
+
}, file.id))
|
|
783
|
+
})
|
|
784
|
+
]
|
|
785
|
+
}),
|
|
786
|
+
store.roles.length > 0 && /*#__PURE__*/ _jsxs("section", {
|
|
787
|
+
className: theme.section.container,
|
|
788
|
+
children: [
|
|
789
|
+
/*#__PURE__*/ _jsx("div", {
|
|
790
|
+
className: theme.section.titleWrapper,
|
|
791
|
+
children: /*#__PURE__*/ _jsx("h2", {
|
|
792
|
+
className: theme.section.title,
|
|
793
|
+
children: "My Roles"
|
|
794
|
+
})
|
|
795
|
+
}),
|
|
796
|
+
/*#__PURE__*/ _jsx("div", {
|
|
797
|
+
className: "flex flex-wrap gap-2",
|
|
798
|
+
children: store.roles.map((role)=>/*#__PURE__*/ _jsxs("span", {
|
|
799
|
+
className: "inline-flex items-center gap-1.5 px-3 py-1.5 rounded-full text-sm font-medium bg-purple-100 dark:bg-purple-900/30 text-purple-700 dark:text-purple-300 border border-purple-200 dark:border-purple-800",
|
|
800
|
+
children: [
|
|
801
|
+
/*#__PURE__*/ _jsx("svg", {
|
|
802
|
+
className: "w-3.5 h-3.5",
|
|
803
|
+
viewBox: "0 0 24 24",
|
|
804
|
+
fill: "none",
|
|
805
|
+
stroke: "currentColor",
|
|
806
|
+
strokeWidth: "2",
|
|
807
|
+
"aria-hidden": "true",
|
|
808
|
+
children: /*#__PURE__*/ _jsx("path", {
|
|
809
|
+
strokeLinecap: "round",
|
|
810
|
+
strokeLinejoin: "round",
|
|
811
|
+
d: "M9 12.75L11.25 15 15 9.75m-3-7.036A11.959 11.959 0 013.598 6 11.99 11.99 0 003 9.749c0 5.592 3.824 10.29 9 11.623 5.176-1.332 9-6.03 9-11.622 0-1.31-.21-2.571-.598-3.751h-.152c-3.196 0-6.1-1.248-8.25-3.285z"
|
|
812
|
+
})
|
|
813
|
+
}),
|
|
814
|
+
role.name
|
|
815
|
+
]
|
|
816
|
+
}, role.id))
|
|
817
|
+
})
|
|
818
|
+
]
|
|
819
|
+
}),
|
|
820
|
+
(changePasswordHref || onChangePassword || devicesHref || onViewDevices) && /*#__PURE__*/ _jsxs("section", {
|
|
821
|
+
className: theme.section.container,
|
|
822
|
+
children: [
|
|
823
|
+
/*#__PURE__*/ _jsx("div", {
|
|
824
|
+
className: theme.section.titleWrapper,
|
|
825
|
+
children: /*#__PURE__*/ _jsx("h2", {
|
|
826
|
+
className: theme.section.title,
|
|
827
|
+
children: "Account Settings"
|
|
828
|
+
})
|
|
829
|
+
}),
|
|
830
|
+
/*#__PURE__*/ _jsxs("div", {
|
|
831
|
+
className: theme.accountSettings.container,
|
|
832
|
+
children: [
|
|
833
|
+
(changePasswordHref || onChangePassword) && /*#__PURE__*/ _jsxs("button", {
|
|
834
|
+
type: "button",
|
|
835
|
+
onClick: ()=>{
|
|
836
|
+
if (onChangePassword) {
|
|
837
|
+
onChangePassword();
|
|
838
|
+
} else if (changePasswordHref) {
|
|
839
|
+
window.location.href = changePasswordHref;
|
|
840
|
+
}
|
|
841
|
+
},
|
|
842
|
+
className: theme.accountSettings.item,
|
|
843
|
+
children: [
|
|
844
|
+
/*#__PURE__*/ _jsxs("div", {
|
|
845
|
+
className: theme.accountSettings.content,
|
|
846
|
+
children: [
|
|
847
|
+
/*#__PURE__*/ _jsx("div", {
|
|
848
|
+
className: cn(theme.accountSettings.iconWrapper, "bg-blue-100 dark:bg-blue-900/30"),
|
|
849
|
+
children: /*#__PURE__*/ _jsxs("svg", {
|
|
850
|
+
className: "w-5 h-5 text-blue-600 dark:text-blue-400",
|
|
851
|
+
fill: "none",
|
|
852
|
+
stroke: "currentColor",
|
|
853
|
+
viewBox: "0 0 24 24",
|
|
854
|
+
children: [
|
|
855
|
+
/*#__PURE__*/ _jsx("title", {
|
|
856
|
+
children: "Change Password"
|
|
857
|
+
}),
|
|
858
|
+
/*#__PURE__*/ _jsx("path", {
|
|
859
|
+
strokeLinecap: "round",
|
|
860
|
+
strokeLinejoin: "round",
|
|
861
|
+
strokeWidth: 2,
|
|
862
|
+
d: "M15 7a2 2 0 012 2m4 0a6 6 0 01-7.743 5.743L11 17H9v2H7v2H4a1 1 0 01-1-1v-2.586a1 1 0 01.293-.707l5.964-5.964A6 6 0 1121 9z"
|
|
863
|
+
})
|
|
864
|
+
]
|
|
865
|
+
})
|
|
866
|
+
}),
|
|
867
|
+
/*#__PURE__*/ _jsxs("div", {
|
|
868
|
+
children: [
|
|
869
|
+
/*#__PURE__*/ _jsx("p", {
|
|
870
|
+
className: theme.accountSettings.title,
|
|
871
|
+
children: "Change Password"
|
|
872
|
+
}),
|
|
873
|
+
/*#__PURE__*/ _jsx("p", {
|
|
874
|
+
className: theme.accountSettings.description,
|
|
875
|
+
children: "Update your account password"
|
|
876
|
+
})
|
|
877
|
+
]
|
|
878
|
+
})
|
|
879
|
+
]
|
|
880
|
+
}),
|
|
881
|
+
/*#__PURE__*/ _jsxs("svg", {
|
|
882
|
+
className: theme.accountSettings.arrow,
|
|
883
|
+
fill: "none",
|
|
884
|
+
stroke: "currentColor",
|
|
885
|
+
viewBox: "0 0 24 24",
|
|
886
|
+
children: [
|
|
887
|
+
/*#__PURE__*/ _jsx("title", {
|
|
888
|
+
children: "Go"
|
|
889
|
+
}),
|
|
890
|
+
/*#__PURE__*/ _jsx("path", {
|
|
891
|
+
strokeLinecap: "round",
|
|
892
|
+
strokeLinejoin: "round",
|
|
893
|
+
strokeWidth: 2,
|
|
894
|
+
d: "M9 5l7 7-7 7"
|
|
895
|
+
})
|
|
896
|
+
]
|
|
897
|
+
})
|
|
898
|
+
]
|
|
899
|
+
}),
|
|
900
|
+
(devicesHref || onViewDevices) && /*#__PURE__*/ _jsxs("button", {
|
|
901
|
+
type: "button",
|
|
902
|
+
onClick: ()=>{
|
|
903
|
+
if (onViewDevices) {
|
|
904
|
+
onViewDevices();
|
|
905
|
+
} else if (devicesHref) {
|
|
906
|
+
window.location.href = devicesHref;
|
|
907
|
+
}
|
|
908
|
+
},
|
|
909
|
+
className: theme.accountSettings.item,
|
|
910
|
+
children: [
|
|
911
|
+
/*#__PURE__*/ _jsxs("div", {
|
|
912
|
+
className: theme.accountSettings.content,
|
|
913
|
+
children: [
|
|
914
|
+
/*#__PURE__*/ _jsx("div", {
|
|
915
|
+
className: cn(theme.accountSettings.iconWrapper, "bg-green-100 dark:bg-green-900/30"),
|
|
916
|
+
children: /*#__PURE__*/ _jsxs("svg", {
|
|
917
|
+
className: "w-5 h-5 text-green-600 dark:text-green-400",
|
|
918
|
+
fill: "none",
|
|
919
|
+
stroke: "currentColor",
|
|
920
|
+
viewBox: "0 0 24 24",
|
|
921
|
+
children: [
|
|
922
|
+
/*#__PURE__*/ _jsx("title", {
|
|
923
|
+
children: "Devices"
|
|
924
|
+
}),
|
|
925
|
+
/*#__PURE__*/ _jsx("path", {
|
|
926
|
+
strokeLinecap: "round",
|
|
927
|
+
strokeLinejoin: "round",
|
|
928
|
+
strokeWidth: 2,
|
|
929
|
+
d: "M9.75 17L9 20l-1 1h8l-1-1-.75-3M3 13h18M5 17h14a2 2 0 002-2V5a2 2 0 00-2-2H5a2 2 0 00-2 2v10a2 2 0 002 2z"
|
|
930
|
+
})
|
|
931
|
+
]
|
|
932
|
+
})
|
|
933
|
+
}),
|
|
934
|
+
/*#__PURE__*/ _jsxs("div", {
|
|
935
|
+
children: [
|
|
936
|
+
/*#__PURE__*/ _jsx("p", {
|
|
937
|
+
className: theme.accountSettings.title,
|
|
938
|
+
children: "Active Sessions"
|
|
939
|
+
}),
|
|
940
|
+
/*#__PURE__*/ _jsx("p", {
|
|
941
|
+
className: theme.accountSettings.description,
|
|
942
|
+
children: "Manage your logged-in devices"
|
|
943
|
+
})
|
|
944
|
+
]
|
|
945
|
+
})
|
|
946
|
+
]
|
|
947
|
+
}),
|
|
948
|
+
/*#__PURE__*/ _jsxs("svg", {
|
|
949
|
+
className: theme.accountSettings.arrow,
|
|
950
|
+
fill: "none",
|
|
951
|
+
stroke: "currentColor",
|
|
952
|
+
viewBox: "0 0 24 24",
|
|
953
|
+
children: [
|
|
954
|
+
/*#__PURE__*/ _jsx("title", {
|
|
955
|
+
children: "Go"
|
|
956
|
+
}),
|
|
957
|
+
/*#__PURE__*/ _jsx("path", {
|
|
958
|
+
strokeLinecap: "round",
|
|
959
|
+
strokeLinejoin: "round",
|
|
960
|
+
strokeWidth: 2,
|
|
961
|
+
d: "M9 5l7 7-7 7"
|
|
962
|
+
})
|
|
963
|
+
]
|
|
964
|
+
})
|
|
965
|
+
]
|
|
966
|
+
})
|
|
967
|
+
]
|
|
968
|
+
})
|
|
969
|
+
]
|
|
970
|
+
})
|
|
971
|
+
]
|
|
972
|
+
})
|
|
973
|
+
})
|
|
974
|
+
}),
|
|
975
|
+
showAddressModal && /*#__PURE__*/ _jsx("div", {
|
|
976
|
+
className: theme.modal.overlay,
|
|
977
|
+
onMouseDown: (e)=>{
|
|
978
|
+
mouseDownTargetRef.current = e.target;
|
|
979
|
+
},
|
|
980
|
+
onClick: (e)=>{
|
|
981
|
+
if (e.target === e.currentTarget && mouseDownTargetRef.current === e.target) {
|
|
982
|
+
setShowAddressModal(false);
|
|
983
|
+
}
|
|
984
|
+
},
|
|
985
|
+
onKeyDown: (e)=>e.key === "Escape" && setShowAddressModal(false),
|
|
986
|
+
role: "dialog",
|
|
987
|
+
"aria-modal": "true",
|
|
988
|
+
children: /*#__PURE__*/ _jsxs("div", {
|
|
989
|
+
className: theme.modal.container,
|
|
990
|
+
role: "document",
|
|
991
|
+
children: [
|
|
992
|
+
/*#__PURE__*/ _jsx("h2", {
|
|
993
|
+
className: theme.modal.title,
|
|
994
|
+
children: editingAddress ? "Edit Address" : "Add Address"
|
|
995
|
+
}),
|
|
996
|
+
/*#__PURE__*/ _jsxs("div", {
|
|
997
|
+
className: theme.modal.form,
|
|
998
|
+
children: [
|
|
999
|
+
/*#__PURE__*/ _jsxs("div", {
|
|
1000
|
+
className: theme.profileForm.field.container,
|
|
1001
|
+
children: [
|
|
1002
|
+
/*#__PURE__*/ _jsx("label", {
|
|
1003
|
+
htmlFor: "addressName",
|
|
1004
|
+
className: theme.profileForm.field.label,
|
|
1005
|
+
children: "Name"
|
|
1006
|
+
}),
|
|
1007
|
+
/*#__PURE__*/ _jsx("input", {
|
|
1008
|
+
id: "addressName",
|
|
1009
|
+
type: "text",
|
|
1010
|
+
value: addressFormData.name || "",
|
|
1011
|
+
onChange: (e)=>setAddressFormData((prev)=>({
|
|
1012
|
+
...prev,
|
|
1013
|
+
name: e.target.value
|
|
1014
|
+
})),
|
|
1015
|
+
className: theme.profileForm.field.input,
|
|
1016
|
+
placeholder: "e.g., Home, Work"
|
|
1017
|
+
})
|
|
1018
|
+
]
|
|
1019
|
+
}),
|
|
1020
|
+
/*#__PURE__*/ _jsxs("div", {
|
|
1021
|
+
className: theme.profileForm.field.container,
|
|
1022
|
+
children: [
|
|
1023
|
+
/*#__PURE__*/ _jsx("label", {
|
|
1024
|
+
htmlFor: "street",
|
|
1025
|
+
className: theme.profileForm.field.label,
|
|
1026
|
+
children: "Street"
|
|
1027
|
+
}),
|
|
1028
|
+
/*#__PURE__*/ _jsx("input", {
|
|
1029
|
+
id: "street",
|
|
1030
|
+
type: "text",
|
|
1031
|
+
value: addressFormData.street || "",
|
|
1032
|
+
onChange: (e)=>setAddressFormData((prev)=>({
|
|
1033
|
+
...prev,
|
|
1034
|
+
street: e.target.value
|
|
1035
|
+
})),
|
|
1036
|
+
className: theme.profileForm.field.input,
|
|
1037
|
+
placeholder: "Street address"
|
|
1038
|
+
})
|
|
1039
|
+
]
|
|
1040
|
+
}),
|
|
1041
|
+
/*#__PURE__*/ _jsxs("div", {
|
|
1042
|
+
className: theme.profileForm.grid,
|
|
1043
|
+
children: [
|
|
1044
|
+
/*#__PURE__*/ _jsxs("div", {
|
|
1045
|
+
className: theme.profileForm.field.container,
|
|
1046
|
+
children: [
|
|
1047
|
+
/*#__PURE__*/ _jsx("label", {
|
|
1048
|
+
htmlFor: "city",
|
|
1049
|
+
className: theme.profileForm.field.label,
|
|
1050
|
+
children: "City"
|
|
1051
|
+
}),
|
|
1052
|
+
/*#__PURE__*/ _jsx("input", {
|
|
1053
|
+
id: "city",
|
|
1054
|
+
type: "text",
|
|
1055
|
+
value: addressFormData.city || "",
|
|
1056
|
+
onChange: (e)=>setAddressFormData((prev)=>({
|
|
1057
|
+
...prev,
|
|
1058
|
+
city: e.target.value
|
|
1059
|
+
})),
|
|
1060
|
+
className: theme.profileForm.field.input,
|
|
1061
|
+
placeholder: "City"
|
|
1062
|
+
})
|
|
1063
|
+
]
|
|
1064
|
+
}),
|
|
1065
|
+
/*#__PURE__*/ _jsxs("div", {
|
|
1066
|
+
className: theme.profileForm.field.container,
|
|
1067
|
+
children: [
|
|
1068
|
+
/*#__PURE__*/ _jsx("label", {
|
|
1069
|
+
htmlFor: "state",
|
|
1070
|
+
className: theme.profileForm.field.label,
|
|
1071
|
+
children: "State/Province"
|
|
1072
|
+
}),
|
|
1073
|
+
/*#__PURE__*/ _jsx("input", {
|
|
1074
|
+
id: "state",
|
|
1075
|
+
type: "text",
|
|
1076
|
+
value: addressFormData.state || "",
|
|
1077
|
+
onChange: (e)=>setAddressFormData((prev)=>({
|
|
1078
|
+
...prev,
|
|
1079
|
+
state: e.target.value
|
|
1080
|
+
})),
|
|
1081
|
+
className: theme.profileForm.field.input,
|
|
1082
|
+
placeholder: "State"
|
|
1083
|
+
})
|
|
1084
|
+
]
|
|
1085
|
+
})
|
|
1086
|
+
]
|
|
1087
|
+
}),
|
|
1088
|
+
/*#__PURE__*/ _jsxs("div", {
|
|
1089
|
+
className: theme.profileForm.grid,
|
|
1090
|
+
children: [
|
|
1091
|
+
/*#__PURE__*/ _jsxs("div", {
|
|
1092
|
+
className: theme.profileForm.field.container,
|
|
1093
|
+
children: [
|
|
1094
|
+
/*#__PURE__*/ _jsx("label", {
|
|
1095
|
+
htmlFor: "zip",
|
|
1096
|
+
className: theme.profileForm.field.label,
|
|
1097
|
+
children: "ZIP Code"
|
|
1098
|
+
}),
|
|
1099
|
+
/*#__PURE__*/ _jsx("input", {
|
|
1100
|
+
id: "zip",
|
|
1101
|
+
type: "text",
|
|
1102
|
+
value: addressFormData.zip || "",
|
|
1103
|
+
onChange: (e)=>setAddressFormData((prev)=>({
|
|
1104
|
+
...prev,
|
|
1105
|
+
zip: e.target.value
|
|
1106
|
+
})),
|
|
1107
|
+
className: theme.profileForm.field.input,
|
|
1108
|
+
placeholder: "ZIP"
|
|
1109
|
+
})
|
|
1110
|
+
]
|
|
1111
|
+
}),
|
|
1112
|
+
/*#__PURE__*/ _jsxs("div", {
|
|
1113
|
+
className: theme.profileForm.field.container,
|
|
1114
|
+
children: [
|
|
1115
|
+
/*#__PURE__*/ _jsx("label", {
|
|
1116
|
+
htmlFor: "country",
|
|
1117
|
+
className: theme.profileForm.field.label,
|
|
1118
|
+
children: "Country"
|
|
1119
|
+
}),
|
|
1120
|
+
/*#__PURE__*/ _jsx("input", {
|
|
1121
|
+
id: "country",
|
|
1122
|
+
type: "text",
|
|
1123
|
+
value: addressFormData.country || "",
|
|
1124
|
+
onChange: (e)=>setAddressFormData((prev)=>({
|
|
1125
|
+
...prev,
|
|
1126
|
+
country: e.target.value
|
|
1127
|
+
})),
|
|
1128
|
+
className: theme.profileForm.field.input,
|
|
1129
|
+
placeholder: "Country"
|
|
1130
|
+
})
|
|
1131
|
+
]
|
|
1132
|
+
})
|
|
1133
|
+
]
|
|
1134
|
+
})
|
|
1135
|
+
]
|
|
1136
|
+
}),
|
|
1137
|
+
/*#__PURE__*/ _jsxs("div", {
|
|
1138
|
+
className: theme.modal.actions,
|
|
1139
|
+
children: [
|
|
1140
|
+
/*#__PURE__*/ _jsx(Button, {
|
|
1141
|
+
variant: "outline",
|
|
1142
|
+
size: "sm",
|
|
1143
|
+
onClick: ()=>setShowAddressModal(false),
|
|
1144
|
+
children: "Cancel"
|
|
1145
|
+
}),
|
|
1146
|
+
/*#__PURE__*/ _jsx(Button, {
|
|
1147
|
+
variant: "primary",
|
|
1148
|
+
size: "sm",
|
|
1149
|
+
onClick: editingAddress ? handleUpdateAddress : handleAddAddress,
|
|
1150
|
+
disabled: addAddressAction.state.isPending || updateAddressAction.state.isPending,
|
|
1151
|
+
children: addAddressAction.state.isPending || updateAddressAction.state.isPending ? "Saving..." : "Save"
|
|
1152
|
+
})
|
|
1153
|
+
]
|
|
1154
|
+
})
|
|
1155
|
+
]
|
|
1156
|
+
})
|
|
1157
|
+
}),
|
|
1158
|
+
showPhoneModal && /*#__PURE__*/ _jsx("div", {
|
|
1159
|
+
className: theme.modal.overlay,
|
|
1160
|
+
onMouseDown: (e)=>{
|
|
1161
|
+
mouseDownTargetRef.current = e.target;
|
|
1162
|
+
},
|
|
1163
|
+
onClick: (e)=>{
|
|
1164
|
+
if (e.target === e.currentTarget && mouseDownTargetRef.current === e.target) {
|
|
1165
|
+
setShowPhoneModal(false);
|
|
1166
|
+
}
|
|
1167
|
+
},
|
|
1168
|
+
onKeyDown: (e)=>e.key === "Escape" && setShowPhoneModal(false),
|
|
1169
|
+
role: "dialog",
|
|
1170
|
+
"aria-modal": "true",
|
|
1171
|
+
children: /*#__PURE__*/ _jsxs("div", {
|
|
1172
|
+
className: theme.modal.container,
|
|
1173
|
+
role: "document",
|
|
1174
|
+
children: [
|
|
1175
|
+
/*#__PURE__*/ _jsx("h2", {
|
|
1176
|
+
className: theme.modal.title,
|
|
1177
|
+
children: editingPhone ? "Edit Phone" : "Add Phone"
|
|
1178
|
+
}),
|
|
1179
|
+
/*#__PURE__*/ _jsxs("div", {
|
|
1180
|
+
className: theme.modal.form,
|
|
1181
|
+
children: [
|
|
1182
|
+
/*#__PURE__*/ _jsxs("div", {
|
|
1183
|
+
className: theme.profileForm.field.container,
|
|
1184
|
+
children: [
|
|
1185
|
+
/*#__PURE__*/ _jsx("label", {
|
|
1186
|
+
htmlFor: "phoneName",
|
|
1187
|
+
className: theme.profileForm.field.label,
|
|
1188
|
+
children: "Name"
|
|
1189
|
+
}),
|
|
1190
|
+
/*#__PURE__*/ _jsx("input", {
|
|
1191
|
+
id: "phoneName",
|
|
1192
|
+
type: "text",
|
|
1193
|
+
value: phoneFormData.name || "",
|
|
1194
|
+
onChange: (e)=>setPhoneFormData((prev)=>({
|
|
1195
|
+
...prev,
|
|
1196
|
+
name: e.target.value
|
|
1197
|
+
})),
|
|
1198
|
+
className: theme.profileForm.field.input,
|
|
1199
|
+
placeholder: "e.g., Mobile, Work"
|
|
1200
|
+
})
|
|
1201
|
+
]
|
|
1202
|
+
}),
|
|
1203
|
+
/*#__PURE__*/ _jsxs("div", {
|
|
1204
|
+
className: theme.profileForm.field.container,
|
|
1205
|
+
children: [
|
|
1206
|
+
/*#__PURE__*/ _jsx("label", {
|
|
1207
|
+
htmlFor: "phoneType",
|
|
1208
|
+
className: theme.profileForm.field.label,
|
|
1209
|
+
children: "Type"
|
|
1210
|
+
}),
|
|
1211
|
+
/*#__PURE__*/ _jsxs("select", {
|
|
1212
|
+
id: "phoneType",
|
|
1213
|
+
value: phoneFormData.type || "",
|
|
1214
|
+
onChange: (e)=>{
|
|
1215
|
+
const value = e.target.value;
|
|
1216
|
+
setPhoneFormData((prev)=>({
|
|
1217
|
+
...prev,
|
|
1218
|
+
type: value || undefined
|
|
1219
|
+
}));
|
|
1220
|
+
},
|
|
1221
|
+
className: theme.profileForm.field.input,
|
|
1222
|
+
children: [
|
|
1223
|
+
/*#__PURE__*/ _jsx("option", {
|
|
1224
|
+
value: "",
|
|
1225
|
+
children: "Select type"
|
|
1226
|
+
}),
|
|
1227
|
+
/*#__PURE__*/ _jsx("option", {
|
|
1228
|
+
value: "mobile",
|
|
1229
|
+
children: "Mobile"
|
|
1230
|
+
}),
|
|
1231
|
+
/*#__PURE__*/ _jsx("option", {
|
|
1232
|
+
value: "office",
|
|
1233
|
+
children: "Office"
|
|
1234
|
+
}),
|
|
1235
|
+
/*#__PURE__*/ _jsx("option", {
|
|
1236
|
+
value: "fax",
|
|
1237
|
+
children: "Fax"
|
|
1238
|
+
})
|
|
1239
|
+
]
|
|
1240
|
+
})
|
|
1241
|
+
]
|
|
1242
|
+
}),
|
|
1243
|
+
/*#__PURE__*/ _jsxs("div", {
|
|
1244
|
+
className: theme.profileForm.grid,
|
|
1245
|
+
children: [
|
|
1246
|
+
/*#__PURE__*/ _jsxs("div", {
|
|
1247
|
+
className: theme.profileForm.field.container,
|
|
1248
|
+
children: [
|
|
1249
|
+
/*#__PURE__*/ _jsx("label", {
|
|
1250
|
+
htmlFor: "countryCode",
|
|
1251
|
+
className: theme.profileForm.field.label,
|
|
1252
|
+
children: "Country Code"
|
|
1253
|
+
}),
|
|
1254
|
+
/*#__PURE__*/ _jsx("input", {
|
|
1255
|
+
id: "countryCode",
|
|
1256
|
+
type: "text",
|
|
1257
|
+
value: phoneFormData.countryCode || "+1",
|
|
1258
|
+
onChange: (e)=>setPhoneFormData((prev)=>({
|
|
1259
|
+
...prev,
|
|
1260
|
+
countryCode: e.target.value
|
|
1261
|
+
})),
|
|
1262
|
+
className: theme.profileForm.field.input,
|
|
1263
|
+
placeholder: "+1"
|
|
1264
|
+
})
|
|
1265
|
+
]
|
|
1266
|
+
}),
|
|
1267
|
+
/*#__PURE__*/ _jsxs("div", {
|
|
1268
|
+
className: theme.profileForm.field.container,
|
|
1269
|
+
children: [
|
|
1270
|
+
/*#__PURE__*/ _jsx("label", {
|
|
1271
|
+
htmlFor: "phoneNumber",
|
|
1272
|
+
className: theme.profileForm.field.label,
|
|
1273
|
+
children: "Number"
|
|
1274
|
+
}),
|
|
1275
|
+
/*#__PURE__*/ _jsx("input", {
|
|
1276
|
+
id: "phoneNumber",
|
|
1277
|
+
type: "tel",
|
|
1278
|
+
value: phoneFormData.number || "",
|
|
1279
|
+
onChange: (e)=>setPhoneFormData((prev)=>({
|
|
1280
|
+
...prev,
|
|
1281
|
+
number: e.target.value
|
|
1282
|
+
})),
|
|
1283
|
+
className: theme.profileForm.field.input,
|
|
1284
|
+
placeholder: "Phone number"
|
|
1285
|
+
})
|
|
1286
|
+
]
|
|
1287
|
+
})
|
|
1288
|
+
]
|
|
1289
|
+
}),
|
|
1290
|
+
/*#__PURE__*/ _jsxs("div", {
|
|
1291
|
+
className: theme.profileForm.field.container,
|
|
1292
|
+
children: [
|
|
1293
|
+
/*#__PURE__*/ _jsx("label", {
|
|
1294
|
+
htmlFor: "extension",
|
|
1295
|
+
className: theme.profileForm.field.label,
|
|
1296
|
+
children: "Extension (optional)"
|
|
1297
|
+
}),
|
|
1298
|
+
/*#__PURE__*/ _jsx("input", {
|
|
1299
|
+
id: "extension",
|
|
1300
|
+
type: "text",
|
|
1301
|
+
value: phoneFormData.extension || "",
|
|
1302
|
+
onChange: (e)=>setPhoneFormData((prev)=>({
|
|
1303
|
+
...prev,
|
|
1304
|
+
extension: e.target.value
|
|
1305
|
+
})),
|
|
1306
|
+
className: theme.profileForm.field.input,
|
|
1307
|
+
placeholder: "Extension"
|
|
1308
|
+
})
|
|
1309
|
+
]
|
|
1310
|
+
})
|
|
1311
|
+
]
|
|
1312
|
+
}),
|
|
1313
|
+
/*#__PURE__*/ _jsxs("div", {
|
|
1314
|
+
className: theme.modal.actions,
|
|
1315
|
+
children: [
|
|
1316
|
+
/*#__PURE__*/ _jsx(Button, {
|
|
1317
|
+
variant: "outline",
|
|
1318
|
+
size: "sm",
|
|
1319
|
+
onClick: ()=>setShowPhoneModal(false),
|
|
1320
|
+
children: "Cancel"
|
|
1321
|
+
}),
|
|
1322
|
+
/*#__PURE__*/ _jsx(Button, {
|
|
1323
|
+
variant: "primary",
|
|
1324
|
+
size: "sm",
|
|
1325
|
+
onClick: editingPhone ? handleUpdatePhone : handleAddPhone,
|
|
1326
|
+
disabled: addPhoneAction.state.isPending || updatePhoneAction.state.isPending,
|
|
1327
|
+
children: addPhoneAction.state.isPending || updatePhoneAction.state.isPending ? "Saving..." : "Save"
|
|
1328
|
+
})
|
|
1329
|
+
]
|
|
1330
|
+
})
|
|
1331
|
+
]
|
|
1332
|
+
})
|
|
1333
|
+
})
|
|
1334
|
+
]
|
|
1335
|
+
});
|
|
1336
|
+
}
|