csdk-test 1.0.27 → 1.0.28
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/index.esm.js +227 -0
- package/dist/index.js +232 -2
- package/package.json +20 -25
- package/dist/curator-sdk.css +0 -166
- package/dist/index.js.LICENSE.txt +0 -169
- package/unity-build/LiveFurnishBuild.data +0 -0
- package/unity-build/LiveFurnishBuild.framework.js +0 -7
- package/unity-build/LiveFurnishBuild.loader.js +0 -1
- package/unity-build/LiveFurnishBuild.wasm +0 -0
|
@@ -0,0 +1,227 @@
|
|
|
1
|
+
import React, { useState, useEffect } from 'react';
|
|
2
|
+
|
|
3
|
+
const API_BASE_URL = 'https://staging.imagine.io';
|
|
4
|
+
const styles = {
|
|
5
|
+
container: {
|
|
6
|
+
fontFamily: '-apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif',
|
|
7
|
+
padding: '24px',
|
|
8
|
+
maxWidth: '500px',
|
|
9
|
+
margin: '0 auto'
|
|
10
|
+
},
|
|
11
|
+
card: {
|
|
12
|
+
backgroundColor: '#fff',
|
|
13
|
+
borderRadius: '12px',
|
|
14
|
+
boxShadow: '0 2px 8px rgba(0, 0, 0, 0.1)',
|
|
15
|
+
padding: '24px'
|
|
16
|
+
},
|
|
17
|
+
header: {
|
|
18
|
+
display: 'flex',
|
|
19
|
+
alignItems: 'center',
|
|
20
|
+
marginBottom: '20px',
|
|
21
|
+
gap: '16px'
|
|
22
|
+
},
|
|
23
|
+
avatar: {
|
|
24
|
+
width: '64px',
|
|
25
|
+
height: '64px',
|
|
26
|
+
borderRadius: '50%',
|
|
27
|
+
backgroundColor: '#e0e0e0',
|
|
28
|
+
display: 'flex',
|
|
29
|
+
alignItems: 'center',
|
|
30
|
+
justifyContent: 'center',
|
|
31
|
+
fontSize: '24px',
|
|
32
|
+
color: '#666',
|
|
33
|
+
overflow: 'hidden'
|
|
34
|
+
},
|
|
35
|
+
avatarImage: {
|
|
36
|
+
width: '100%',
|
|
37
|
+
height: '100%',
|
|
38
|
+
objectFit: 'cover'
|
|
39
|
+
},
|
|
40
|
+
name: {
|
|
41
|
+
fontSize: '20px',
|
|
42
|
+
fontWeight: '600',
|
|
43
|
+
color: '#1a1a1a',
|
|
44
|
+
margin: 0
|
|
45
|
+
},
|
|
46
|
+
email: {
|
|
47
|
+
fontSize: '14px',
|
|
48
|
+
color: '#666',
|
|
49
|
+
margin: '4px 0 0 0'
|
|
50
|
+
},
|
|
51
|
+
detailsGrid: {
|
|
52
|
+
display: 'grid',
|
|
53
|
+
gap: '12px'
|
|
54
|
+
},
|
|
55
|
+
detailRow: {
|
|
56
|
+
display: 'flex',
|
|
57
|
+
justifyContent: 'space-between',
|
|
58
|
+
padding: '8px 0',
|
|
59
|
+
borderBottom: '1px solid #f0f0f0'
|
|
60
|
+
},
|
|
61
|
+
label: {
|
|
62
|
+
fontSize: '14px',
|
|
63
|
+
color: '#666'
|
|
64
|
+
},
|
|
65
|
+
value: {
|
|
66
|
+
fontSize: '14px',
|
|
67
|
+
color: '#1a1a1a',
|
|
68
|
+
fontWeight: '500'
|
|
69
|
+
},
|
|
70
|
+
loading: {
|
|
71
|
+
display: 'flex',
|
|
72
|
+
alignItems: 'center',
|
|
73
|
+
justifyContent: 'center',
|
|
74
|
+
padding: '40px',
|
|
75
|
+
color: '#666'
|
|
76
|
+
},
|
|
77
|
+
error: {
|
|
78
|
+
backgroundColor: '#fee',
|
|
79
|
+
color: '#c00',
|
|
80
|
+
padding: '16px',
|
|
81
|
+
borderRadius: '8px',
|
|
82
|
+
textAlign: 'center'
|
|
83
|
+
},
|
|
84
|
+
spinner: {
|
|
85
|
+
width: '24px',
|
|
86
|
+
height: '24px',
|
|
87
|
+
border: '3px solid #f0f0f0',
|
|
88
|
+
borderTop: '3px solid #666',
|
|
89
|
+
borderRadius: '50%',
|
|
90
|
+
animation: 'spin 1s linear infinite'
|
|
91
|
+
}
|
|
92
|
+
};
|
|
93
|
+
const UserDetails = _ref => {
|
|
94
|
+
let {
|
|
95
|
+
token,
|
|
96
|
+
apiBaseUrl,
|
|
97
|
+
onUserLoaded,
|
|
98
|
+
onError
|
|
99
|
+
} = _ref;
|
|
100
|
+
const [user, setUser] = useState(null);
|
|
101
|
+
const [loading, setLoading] = useState(true);
|
|
102
|
+
const [error, setError] = useState(null);
|
|
103
|
+
const baseUrl = apiBaseUrl || API_BASE_URL;
|
|
104
|
+
useEffect(() => {
|
|
105
|
+
if (!token) {
|
|
106
|
+
setError('Token is required');
|
|
107
|
+
setLoading(false);
|
|
108
|
+
return;
|
|
109
|
+
}
|
|
110
|
+
const fetchUserDetails = async () => {
|
|
111
|
+
try {
|
|
112
|
+
setLoading(true);
|
|
113
|
+
setError(null);
|
|
114
|
+
const response = await fetch("".concat(baseUrl, "/users/api/v3/user-details/"), {
|
|
115
|
+
method: 'GET',
|
|
116
|
+
headers: {
|
|
117
|
+
'Authorization': "Bearer ".concat(token),
|
|
118
|
+
'Content-Type': 'application/json'
|
|
119
|
+
}
|
|
120
|
+
});
|
|
121
|
+
if (!response.ok) {
|
|
122
|
+
throw new Error("Failed to fetch user details: ".concat(response.status));
|
|
123
|
+
}
|
|
124
|
+
const data = await response.json();
|
|
125
|
+
setUser(data);
|
|
126
|
+
if (onUserLoaded) {
|
|
127
|
+
onUserLoaded(data);
|
|
128
|
+
}
|
|
129
|
+
} catch (err) {
|
|
130
|
+
const errorMessage = err.message || 'Failed to fetch user details';
|
|
131
|
+
setError(errorMessage);
|
|
132
|
+
if (onError) {
|
|
133
|
+
onError(err);
|
|
134
|
+
}
|
|
135
|
+
} finally {
|
|
136
|
+
setLoading(false);
|
|
137
|
+
}
|
|
138
|
+
};
|
|
139
|
+
fetchUserDetails();
|
|
140
|
+
}, [token, baseUrl, onUserLoaded, onError]);
|
|
141
|
+
if (loading) {
|
|
142
|
+
return /*#__PURE__*/React.createElement("div", {
|
|
143
|
+
style: styles.container
|
|
144
|
+
}, /*#__PURE__*/React.createElement("div", {
|
|
145
|
+
style: styles.card
|
|
146
|
+
}, /*#__PURE__*/React.createElement("div", {
|
|
147
|
+
style: styles.loading
|
|
148
|
+
}, /*#__PURE__*/React.createElement("style", null, "@keyframes spin { 0% { transform: rotate(0deg); } 100% { transform: rotate(360deg); } }"), /*#__PURE__*/React.createElement("div", {
|
|
149
|
+
style: styles.spinner
|
|
150
|
+
}), /*#__PURE__*/React.createElement("span", {
|
|
151
|
+
style: {
|
|
152
|
+
marginLeft: '12px'
|
|
153
|
+
}
|
|
154
|
+
}, "Loading user details..."))));
|
|
155
|
+
}
|
|
156
|
+
if (error) {
|
|
157
|
+
return /*#__PURE__*/React.createElement("div", {
|
|
158
|
+
style: styles.container
|
|
159
|
+
}, /*#__PURE__*/React.createElement("div", {
|
|
160
|
+
style: styles.error
|
|
161
|
+
}, /*#__PURE__*/React.createElement("strong", null, "Error:"), " ", error));
|
|
162
|
+
}
|
|
163
|
+
if (!user) {
|
|
164
|
+
return null;
|
|
165
|
+
}
|
|
166
|
+
const getInitials = name => {
|
|
167
|
+
if (!name) return '?';
|
|
168
|
+
return name.split(' ').map(n => n[0]).join('').toUpperCase().slice(0, 2);
|
|
169
|
+
};
|
|
170
|
+
return /*#__PURE__*/React.createElement("div", {
|
|
171
|
+
style: styles.container
|
|
172
|
+
}, /*#__PURE__*/React.createElement("div", {
|
|
173
|
+
style: styles.card
|
|
174
|
+
}, /*#__PURE__*/React.createElement("div", {
|
|
175
|
+
style: styles.header
|
|
176
|
+
}, /*#__PURE__*/React.createElement("div", {
|
|
177
|
+
style: styles.avatar
|
|
178
|
+
}, user.profile_pic ? /*#__PURE__*/React.createElement("img", {
|
|
179
|
+
src: user.profile_pic,
|
|
180
|
+
alt: user.name,
|
|
181
|
+
style: styles.avatarImage
|
|
182
|
+
}) : getInitials(user.name || user.first_name)), /*#__PURE__*/React.createElement("div", null, /*#__PURE__*/React.createElement("h2", {
|
|
183
|
+
style: styles.name
|
|
184
|
+
}, user.name || "".concat(user.first_name || '', " ").concat(user.last_name || '').trim() || 'Unknown User'), /*#__PURE__*/React.createElement("p", {
|
|
185
|
+
style: styles.email
|
|
186
|
+
}, user.email))), /*#__PURE__*/React.createElement("div", {
|
|
187
|
+
style: styles.detailsGrid
|
|
188
|
+
}, user.id && /*#__PURE__*/React.createElement("div", {
|
|
189
|
+
style: styles.detailRow
|
|
190
|
+
}, /*#__PURE__*/React.createElement("span", {
|
|
191
|
+
style: styles.label
|
|
192
|
+
}, "User ID"), /*#__PURE__*/React.createElement("span", {
|
|
193
|
+
style: styles.value
|
|
194
|
+
}, user.id)), user.organization && /*#__PURE__*/React.createElement("div", {
|
|
195
|
+
style: styles.detailRow
|
|
196
|
+
}, /*#__PURE__*/React.createElement("span", {
|
|
197
|
+
style: styles.label
|
|
198
|
+
}, "Organization"), /*#__PURE__*/React.createElement("span", {
|
|
199
|
+
style: styles.value
|
|
200
|
+
}, user.organization.name || user.organization)), user.role && /*#__PURE__*/React.createElement("div", {
|
|
201
|
+
style: styles.detailRow
|
|
202
|
+
}, /*#__PURE__*/React.createElement("span", {
|
|
203
|
+
style: styles.label
|
|
204
|
+
}, "Role"), /*#__PURE__*/React.createElement("span", {
|
|
205
|
+
style: styles.value
|
|
206
|
+
}, user.role)), user.phone && /*#__PURE__*/React.createElement("div", {
|
|
207
|
+
style: styles.detailRow
|
|
208
|
+
}, /*#__PURE__*/React.createElement("span", {
|
|
209
|
+
style: styles.label
|
|
210
|
+
}, "Phone"), /*#__PURE__*/React.createElement("span", {
|
|
211
|
+
style: styles.value
|
|
212
|
+
}, user.phone)), user.created_at && /*#__PURE__*/React.createElement("div", {
|
|
213
|
+
style: styles.detailRow
|
|
214
|
+
}, /*#__PURE__*/React.createElement("span", {
|
|
215
|
+
style: styles.label
|
|
216
|
+
}, "Member Since"), /*#__PURE__*/React.createElement("span", {
|
|
217
|
+
style: styles.value
|
|
218
|
+
}, new Date(user.created_at).toLocaleDateString())), typeof user.is_verified !== 'undefined' && /*#__PURE__*/React.createElement("div", {
|
|
219
|
+
style: styles.detailRow
|
|
220
|
+
}, /*#__PURE__*/React.createElement("span", {
|
|
221
|
+
style: styles.label
|
|
222
|
+
}, "Verified"), /*#__PURE__*/React.createElement("span", {
|
|
223
|
+
style: styles.value
|
|
224
|
+
}, user.is_verified ? 'Yes' : 'No')))));
|
|
225
|
+
};
|
|
226
|
+
|
|
227
|
+
export { UserDetails, UserDetails as default };
|