@teamvortexsoftware/vortex-react-native 0.0.13 → 1.0.0
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/LICENSE +201 -0
- package/README.md +1227 -11
- package/package.json +93 -20
- package/dist/components/Clipboard.js +0 -64
- package/dist/components/ShareButtons.js +0 -180
- package/dist/hooks/useThemeStyles.js +0 -39
- package/dist/hooks/useVortexInvite.js +0 -321
- package/dist/index.js +0 -5
- package/dist/shared/InvitationResult.js +0 -2
- package/dist/shared/api.js +0 -90
- package/dist/tests/TestVortexInvite.js +0 -134
- package/dist/types/components/Clipboard.d.ts +0 -16
- package/dist/types/components/Clipboard.d.ts.map +0 -1
- package/dist/types/components/ShareButtons.d.ts +0 -29
- package/dist/types/components/ShareButtons.d.ts.map +0 -1
- package/dist/types/hooks/useThemeStyles.d.ts +0 -34
- package/dist/types/hooks/useThemeStyles.d.ts.map +0 -1
- package/dist/types/hooks/useVortexInvite.d.ts +0 -44
- package/dist/types/hooks/useVortexInvite.d.ts.map +0 -1
- package/dist/types/index.d.ts +0 -2
- package/dist/types/index.d.ts.map +0 -1
- package/dist/types/shared/InvitationResult.d.ts +0 -24
- package/dist/types/shared/InvitationResult.d.ts.map +0 -1
- package/dist/types/shared/api.d.ts +0 -14
- package/dist/types/shared/api.d.ts.map +0 -1
- package/dist/types/tests/TestVortexInvite.d.ts +0 -4
- package/dist/types/tests/TestVortexInvite.d.ts.map +0 -1
- package/dist/types/utils/formUtils.d.ts +0 -85
- package/dist/types/utils/formUtils.d.ts.map +0 -1
- package/dist/types/utils/themeUtils.d.ts +0 -36
- package/dist/types/utils/themeUtils.d.ts.map +0 -1
- package/dist/types/vortexInvite.d.ts +0 -25
- package/dist/types/vortexInvite.d.ts.map +0 -1
- package/dist/utils/formUtils.js +0 -174
- package/dist/utils/themeUtils.js +0 -56
- package/dist/vortexInvite.js +0 -172
|
@@ -1,321 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
-
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
|
-
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
-
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
-
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
-
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
-
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
-
});
|
|
10
|
-
};
|
|
11
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
12
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
13
|
-
};
|
|
14
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
15
|
-
exports.useVortexInvite = useVortexInvite;
|
|
16
|
-
const react_1 = require("react");
|
|
17
|
-
const react_native_1 = require("react-native");
|
|
18
|
-
const themeUtils_1 = require("../utils/themeUtils");
|
|
19
|
-
const Clipboard_1 = require("../components/Clipboard");
|
|
20
|
-
const useThemeStyles_1 = require("./useThemeStyles");
|
|
21
|
-
const react_native_uuid_1 = __importDefault(require("react-native-uuid"));
|
|
22
|
-
const formUtils_1 = require("../utils/formUtils");
|
|
23
|
-
const vortex_shared_ui_1 = require("@teamvortexsoftware/vortex-shared-ui");
|
|
24
|
-
function useVortexInvite({ widgetId, environmentId, vortexApiUrl, contentTokens, isLoading = false, jwt, onSuccess, onError, }) {
|
|
25
|
-
const vortexClient = (0, react_1.useMemo)(() => new vortex_shared_ui_1.VortexClient(vortexApiUrl, react_native_uuid_1.default.v4()), [vortexApiUrl]);
|
|
26
|
-
const [widgetConfiguration, setWidgetConfiguration] = (0, react_1.useState)();
|
|
27
|
-
const [error, setError] = (0, react_1.useState)(null);
|
|
28
|
-
const [fetching, setFetching] = (0, react_1.useState)(isLoading);
|
|
29
|
-
const [loading, setLoading] = (0, react_1.useState)(true);
|
|
30
|
-
const [email, setEmail] = (0, react_1.useState)('');
|
|
31
|
-
const [shareableLink, setShareableLink] = (0, react_1.useState)();
|
|
32
|
-
const [inviteLoading, setInviteLoading] = (0, react_1.useState)(false);
|
|
33
|
-
const [showSuccessMessage, setShowSuccessMessage] = (0, react_1.useState)(false);
|
|
34
|
-
const opacity = new react_native_1.Animated.Value(0.3);
|
|
35
|
-
// Extract theme colors and feature flags using utility functions
|
|
36
|
-
const themeColors = (0, react_1.useMemo)(() => (0, themeUtils_1.extractThemeColors)(widgetConfiguration), [widgetConfiguration]);
|
|
37
|
-
// Extract form configuration
|
|
38
|
-
const formConfig = (0, react_1.useMemo)(() => (0, formUtils_1.extractFormConfiguration)(widgetConfiguration), [widgetConfiguration]);
|
|
39
|
-
// Get base theme styles
|
|
40
|
-
const baseThemeStyles = (0, useThemeStyles_1.useThemeStyles)(themeColors);
|
|
41
|
-
// Merge theme styles with component-specific styles from form configuration
|
|
42
|
-
const themeStyles = (0, react_1.useMemo)(() => (0, formUtils_1.mergeThemeAndComponentStyles)(baseThemeStyles, themeColors, formConfig), [baseThemeStyles, themeColors, formConfig]);
|
|
43
|
-
const options = (0, react_1.useMemo)(() => {
|
|
44
|
-
var _a;
|
|
45
|
-
return ((_a = widgetConfiguration === null || widgetConfiguration === void 0 ? void 0 : widgetConfiguration.configuration) === null || _a === void 0 ? void 0 : _a.props) || {};
|
|
46
|
-
}, [widgetConfiguration]);
|
|
47
|
-
// Extract form layout information
|
|
48
|
-
const formLayout = (0, react_1.useMemo)(() => ({
|
|
49
|
-
emailPlaceholder: (0, formUtils_1.getEmailPlaceholder)(formConfig),
|
|
50
|
-
submitButtonLabel: (0, formUtils_1.getSubmitButtonLabel)(formConfig),
|
|
51
|
-
isGridLayout: (0, formUtils_1.hasGridLayout)(formConfig),
|
|
52
|
-
hasSeparateColumns: (0, formUtils_1.hasEmailAndShareInSeparateColumns)(formConfig),
|
|
53
|
-
formConfig,
|
|
54
|
-
}), [formConfig]);
|
|
55
|
-
const has = (0, react_1.useMemo)(() => {
|
|
56
|
-
const flags = (0, themeUtils_1.extractFeatureFlags)(widgetConfiguration);
|
|
57
|
-
console.log('[Vortex] Invite has', flags);
|
|
58
|
-
return flags;
|
|
59
|
-
}, [widgetConfiguration]);
|
|
60
|
-
// Log the host only once when the hook mounts
|
|
61
|
-
(0, react_1.useEffect)(() => {
|
|
62
|
-
if (vortexApiUrl.indexOf('localhost') > -1) {
|
|
63
|
-
console.warn('[Vortex] Invite Using localhost as host');
|
|
64
|
-
}
|
|
65
|
-
}, [vortexApiUrl]);
|
|
66
|
-
// Loading animation effect
|
|
67
|
-
(0, react_1.useEffect)(() => {
|
|
68
|
-
const animation = react_native_1.Animated.loop(react_native_1.Animated.sequence([
|
|
69
|
-
react_native_1.Animated.timing(opacity, {
|
|
70
|
-
toValue: 1,
|
|
71
|
-
duration: 1000,
|
|
72
|
-
useNativeDriver: false,
|
|
73
|
-
}),
|
|
74
|
-
react_native_1.Animated.timing(opacity, {
|
|
75
|
-
toValue: 0.3,
|
|
76
|
-
duration: 1000,
|
|
77
|
-
useNativeDriver: false,
|
|
78
|
-
}),
|
|
79
|
-
]));
|
|
80
|
-
animation.start();
|
|
81
|
-
setTimeout(() => {
|
|
82
|
-
setLoading(false);
|
|
83
|
-
animation.stop();
|
|
84
|
-
}, 2000);
|
|
85
|
-
}, [opacity]);
|
|
86
|
-
// Fetch widget configuration if needed
|
|
87
|
-
(0, react_1.useEffect)(() => {
|
|
88
|
-
// Case: If `widgetConfiguration` is already set, do nothing
|
|
89
|
-
if (widgetConfiguration) {
|
|
90
|
-
console.log('[Vortex] Invite Already has widgetConfiguration, skipping fetch');
|
|
91
|
-
return;
|
|
92
|
-
}
|
|
93
|
-
if (!jwt) {
|
|
94
|
-
console.log('[Vortex] Invite JWT is required');
|
|
95
|
-
return;
|
|
96
|
-
}
|
|
97
|
-
const fetchData = () => __awaiter(this, void 0, void 0, function* () {
|
|
98
|
-
var _a;
|
|
99
|
-
console.log('[Vortex] Invite Fetching Data...');
|
|
100
|
-
setFetching(true);
|
|
101
|
-
setLoading(true);
|
|
102
|
-
setError(null);
|
|
103
|
-
try {
|
|
104
|
-
const result = yield vortexClient.getWidgetConfiguration(widgetId, jwt, environmentId);
|
|
105
|
-
if ((_a = result === null || result === void 0 ? void 0 : result.data) === null || _a === void 0 ? void 0 : _a.widgetConfiguration) {
|
|
106
|
-
setWidgetConfiguration(result.data.widgetConfiguration);
|
|
107
|
-
console.log('[Vortex] Invite Successfully fetched widgetConfiguration', JSON.stringify(result.data.widgetConfiguration));
|
|
108
|
-
}
|
|
109
|
-
else {
|
|
110
|
-
const error = (result === null || result === void 0 ? void 0 : result.error) || 'No configuration data found.';
|
|
111
|
-
console.error(`[Vortex] Invite ${error}`);
|
|
112
|
-
throw new Error(error);
|
|
113
|
-
}
|
|
114
|
-
}
|
|
115
|
-
catch (err) {
|
|
116
|
-
if (err instanceof Error) {
|
|
117
|
-
const fetchError = err;
|
|
118
|
-
console.error('[Vortex] Invite Error Details:', {
|
|
119
|
-
message: fetchError.message,
|
|
120
|
-
status: fetchError.status || 'unknown',
|
|
121
|
-
statusText: fetchError.statusText,
|
|
122
|
-
body: fetchError.body,
|
|
123
|
-
stack: fetchError.stack,
|
|
124
|
-
});
|
|
125
|
-
}
|
|
126
|
-
console.error('[Vortex] Invite Error', err);
|
|
127
|
-
setError({
|
|
128
|
-
message: err.message || 'Something went wrong!',
|
|
129
|
-
});
|
|
130
|
-
}
|
|
131
|
-
finally {
|
|
132
|
-
setFetching(false);
|
|
133
|
-
setLoading(false);
|
|
134
|
-
}
|
|
135
|
-
});
|
|
136
|
-
fetchData();
|
|
137
|
-
}, [widgetId, jwt, environmentId, vortexClient, widgetConfiguration]);
|
|
138
|
-
const handleInviteClick = (contentTokens) => __awaiter(this, void 0, void 0, function* () {
|
|
139
|
-
try {
|
|
140
|
-
setInviteLoading(true);
|
|
141
|
-
setShowSuccessMessage(false);
|
|
142
|
-
if (!(widgetConfiguration === null || widgetConfiguration === void 0 ? void 0 : widgetConfiguration.id)) {
|
|
143
|
-
console.log('[Vortex Invite] Widget configuration ID is required');
|
|
144
|
-
return;
|
|
145
|
-
}
|
|
146
|
-
// const url = `${host}/api/v1/no-auth/components/widget-configuration/${widgetConfigurationId}/invite`; // TODO should we use options.widgetHost?.value ?
|
|
147
|
-
console.log('[Vortex] Invite Sending invitation', {
|
|
148
|
-
email,
|
|
149
|
-
widgetId,
|
|
150
|
-
environmentId,
|
|
151
|
-
});
|
|
152
|
-
if (!jwt) {
|
|
153
|
-
throw new Error('[Vortex Invite] JWT is required');
|
|
154
|
-
}
|
|
155
|
-
const payload = Object.assign(Object.assign({}, contentTokens), { email: {
|
|
156
|
-
value: email,
|
|
157
|
-
type: 'email',
|
|
158
|
-
} });
|
|
159
|
-
const body = yield vortexClient.createInvite(jwt, widgetConfiguration === null || widgetConfiguration === void 0 ? void 0 : widgetConfiguration.id, environmentId, payload);
|
|
160
|
-
console.log('[Vortex] Invite Response', body);
|
|
161
|
-
if (onSuccess) {
|
|
162
|
-
onSuccess({
|
|
163
|
-
type: 'invite',
|
|
164
|
-
data: 'Email invite sent',
|
|
165
|
-
});
|
|
166
|
-
}
|
|
167
|
-
setShowSuccessMessage(true);
|
|
168
|
-
// Auto-hide success message after 5 seconds
|
|
169
|
-
setTimeout(() => {
|
|
170
|
-
setShowSuccessMessage(false);
|
|
171
|
-
}, 5000);
|
|
172
|
-
return;
|
|
173
|
-
}
|
|
174
|
-
catch (error) {
|
|
175
|
-
console.error('[Vortex]', error);
|
|
176
|
-
if (onError) {
|
|
177
|
-
onError(error instanceof Error ? error : new Error(String(error)), 'invite');
|
|
178
|
-
}
|
|
179
|
-
throw error; // Re-throw the error to be caught by the component
|
|
180
|
-
}
|
|
181
|
-
finally {
|
|
182
|
-
setInviteLoading(false);
|
|
183
|
-
}
|
|
184
|
-
});
|
|
185
|
-
const getShareableLink = () => {
|
|
186
|
-
return vortexClient.getShareableLinkFormatted();
|
|
187
|
-
};
|
|
188
|
-
const handleSmsShare = () => __awaiter(this, void 0, void 0, function* () {
|
|
189
|
-
var _a, _b, _c;
|
|
190
|
-
try {
|
|
191
|
-
const template = (_c = (_b = (_a = widgetConfiguration === null || widgetConfiguration === void 0 ? void 0 : widgetConfiguration.configuration) === null || _a === void 0 ? void 0 : _a.props) === null || _b === void 0 ? void 0 : _b['vortex.components.share.template.body']) === null || _c === void 0 ? void 0 : _c.value;
|
|
192
|
-
if (!template)
|
|
193
|
-
throw new Error('No template available');
|
|
194
|
-
const shareableLink = yield getShareableInviteLink();
|
|
195
|
-
if (!shareableLink)
|
|
196
|
-
throw new Error('No shareable link available');
|
|
197
|
-
const body = encodeURIComponent(template.replace(/{{vortex-share-link}}/g, shareableLink));
|
|
198
|
-
const smsUrl = `sms:?body=${body}`;
|
|
199
|
-
yield react_native_1.Linking.openURL(smsUrl);
|
|
200
|
-
}
|
|
201
|
-
catch (error) {
|
|
202
|
-
console.error('[Vortex] Failed to open SMS app:', error);
|
|
203
|
-
if (onError)
|
|
204
|
-
onError(error instanceof Error ? error : new Error(String(error)), 'share');
|
|
205
|
-
}
|
|
206
|
-
});
|
|
207
|
-
const handleEmailShare = () => __awaiter(this, void 0, void 0, function* () {
|
|
208
|
-
var _a, _b, _c, _d, _e, _f, _g;
|
|
209
|
-
try {
|
|
210
|
-
const template = (_c = (_b = (_a = widgetConfiguration === null || widgetConfiguration === void 0 ? void 0 : widgetConfiguration.configuration) === null || _a === void 0 ? void 0 : _a.props) === null || _b === void 0 ? void 0 : _b['vortex.components.share.template.body']) === null || _c === void 0 ? void 0 : _c.value;
|
|
211
|
-
if (!template)
|
|
212
|
-
throw new Error('No template available');
|
|
213
|
-
const subject = ((_g = (_f = (_e = (_d = widgetConfiguration === null || widgetConfiguration === void 0 ? void 0 : widgetConfiguration.configuration) === null || _d === void 0 ? void 0 : _d.props) === null || _e === void 0 ? void 0 : _e['vortex.components.share.template.subject']) === null || _f === void 0 ? void 0 : _f.value) === null || _g === void 0 ? void 0 : _g.trim()) || "You're Invited";
|
|
214
|
-
const shareableLink = yield getShareableInviteLink();
|
|
215
|
-
if (!shareableLink)
|
|
216
|
-
throw new Error('No shareable link available');
|
|
217
|
-
const body = encodeURIComponent(template.replace(/{{vortex-share-link}}/g, shareableLink));
|
|
218
|
-
const mailtoUrl = `mailto:?subject=${encodeURIComponent(subject)}&body=${body}`;
|
|
219
|
-
yield react_native_1.Linking.openURL(mailtoUrl);
|
|
220
|
-
}
|
|
221
|
-
catch (error) {
|
|
222
|
-
console.error('[Vortex] Failed to open Email app:', error);
|
|
223
|
-
if (onError)
|
|
224
|
-
onError(error instanceof Error ? error : new Error(String(error)), 'share');
|
|
225
|
-
}
|
|
226
|
-
});
|
|
227
|
-
const getShareableInviteLink = (contentTokens) => __awaiter(this, void 0, void 0, function* () {
|
|
228
|
-
// if (this.isLoading || !this.vortex) {
|
|
229
|
-
// return;
|
|
230
|
-
// }
|
|
231
|
-
if (!jwt || !(widgetConfiguration === null || widgetConfiguration === void 0 ? void 0 : widgetConfiguration.id) || !vortexClient) {
|
|
232
|
-
return;
|
|
233
|
-
}
|
|
234
|
-
if (shareableLink) {
|
|
235
|
-
return shareableLink;
|
|
236
|
-
}
|
|
237
|
-
const invite = yield vortexClient.createShareableInvite(jwt, widgetConfiguration.id, environmentId);
|
|
238
|
-
if (!invite || !invite.data || !invite.data.invitation.id) {
|
|
239
|
-
console.error('No shareable link found');
|
|
240
|
-
onError === null || onError === void 0 ? void 0 : onError(new Error('No shareable link found'), 'share');
|
|
241
|
-
// this.error = {
|
|
242
|
-
// message: 'No sharable link found',
|
|
243
|
-
// };
|
|
244
|
-
// this.host.requestUpdate();
|
|
245
|
-
return;
|
|
246
|
-
}
|
|
247
|
-
const link = `${vortexApiUrl}/noauth/invite/${invite.data.invitation.id}`;
|
|
248
|
-
console.log(`getShareableInviteLink: ${link}`);
|
|
249
|
-
setShareableLink(link); // TODO - need to differentiate invite host vs api host even though they are the same for now)
|
|
250
|
-
return link;
|
|
251
|
-
});
|
|
252
|
-
const handleShareLink = () => __awaiter(this, void 0, void 0, function* () {
|
|
253
|
-
try {
|
|
254
|
-
const shareableLink = yield getShareableInviteLink(contentTokens);
|
|
255
|
-
if (!shareableLink) {
|
|
256
|
-
throw new Error('No shareable link available');
|
|
257
|
-
}
|
|
258
|
-
yield react_native_1.Share.share({
|
|
259
|
-
message: shareableLink,
|
|
260
|
-
title: 'Share Invite Link',
|
|
261
|
-
});
|
|
262
|
-
console.log('[Vortex] handleShareLink', 'The invite link has been shared.');
|
|
263
|
-
if (onSuccess) {
|
|
264
|
-
onSuccess({
|
|
265
|
-
type: 'share',
|
|
266
|
-
data: 'Sharable link used',
|
|
267
|
-
});
|
|
268
|
-
}
|
|
269
|
-
}
|
|
270
|
-
catch (error) {
|
|
271
|
-
console.error('[Vortex] Failed to share link:', error);
|
|
272
|
-
if (onError) {
|
|
273
|
-
onError(error instanceof Error ? error : new Error(String(error)), 'share');
|
|
274
|
-
}
|
|
275
|
-
}
|
|
276
|
-
});
|
|
277
|
-
const handleCopyLink = () => __awaiter(this, void 0, void 0, function* () {
|
|
278
|
-
try {
|
|
279
|
-
const shareableLink = yield getShareableInviteLink();
|
|
280
|
-
if (!shareableLink) {
|
|
281
|
-
throw new Error('No shareable link available');
|
|
282
|
-
}
|
|
283
|
-
yield Clipboard_1.Clipboard.setString(shareableLink);
|
|
284
|
-
console.log('[Vortex] handleCopyLink', 'The invite link has been copied.');
|
|
285
|
-
if (onSuccess) {
|
|
286
|
-
onSuccess({
|
|
287
|
-
type: 'share',
|
|
288
|
-
data: 'Sharable copied',
|
|
289
|
-
});
|
|
290
|
-
}
|
|
291
|
-
}
|
|
292
|
-
catch (error) {
|
|
293
|
-
console.error('[Vortex] Failed to copy link:', error);
|
|
294
|
-
if (onError) {
|
|
295
|
-
onError(error instanceof Error ? error : new Error(String(error)), 'share');
|
|
296
|
-
}
|
|
297
|
-
}
|
|
298
|
-
});
|
|
299
|
-
return {
|
|
300
|
-
widgetConfiguration,
|
|
301
|
-
error,
|
|
302
|
-
fetching,
|
|
303
|
-
loading,
|
|
304
|
-
email,
|
|
305
|
-
setEmail,
|
|
306
|
-
opacity,
|
|
307
|
-
themeColors,
|
|
308
|
-
themeStyles,
|
|
309
|
-
has,
|
|
310
|
-
options,
|
|
311
|
-
inviteLoading,
|
|
312
|
-
showSuccessMessage,
|
|
313
|
-
handleInviteClick,
|
|
314
|
-
handleShareLink,
|
|
315
|
-
handleCopyLink,
|
|
316
|
-
handleSmsShare,
|
|
317
|
-
handleEmailShare,
|
|
318
|
-
getShareableLink,
|
|
319
|
-
formLayout,
|
|
320
|
-
};
|
|
321
|
-
}
|
package/dist/index.js
DELETED
|
@@ -1,5 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.VortexInvite = void 0;
|
|
4
|
-
var vortexInvite_1 = require("./vortexInvite");
|
|
5
|
-
Object.defineProperty(exports, "VortexInvite", { enumerable: true, get: function () { return vortexInvite_1.VortexInvite; } });
|
package/dist/shared/api.js
DELETED
|
@@ -1,90 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
-
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
|
-
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
-
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
-
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
-
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
-
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
-
});
|
|
10
|
-
};
|
|
11
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
-
class VortexClient {
|
|
13
|
-
constructor(baseUrl, sessionId) {
|
|
14
|
-
this.sessionId = sessionId;
|
|
15
|
-
// trim ending /
|
|
16
|
-
this.baseUrl = baseUrl.replace(/\/+$/, '');
|
|
17
|
-
}
|
|
18
|
-
getWidgetConfiguration(widgetId, jwt, environmentId) {
|
|
19
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
20
|
-
const url = `${this.baseUrl}/api/v1/environment/${environmentId}/widgets/${widgetId}`;
|
|
21
|
-
console.log('[VortexClient] getWidgetConfiguration', { url });
|
|
22
|
-
const response = yield fetch(url, {
|
|
23
|
-
headers: {
|
|
24
|
-
Authorization: `Bearer ${jwt}`,
|
|
25
|
-
'x-session-id': this.sessionId,
|
|
26
|
-
},
|
|
27
|
-
});
|
|
28
|
-
if (!response.ok) {
|
|
29
|
-
const body = yield response.text();
|
|
30
|
-
console.error('[VortexClient] getWidgetConfiguration', { status: response.status, body });
|
|
31
|
-
throw new Error(`Error fetching widget configuration from ${url}: ${response.status}`);
|
|
32
|
-
}
|
|
33
|
-
const data = yield response.json();
|
|
34
|
-
console.log('[VortexClient] getWidgetConfiguration', { data });
|
|
35
|
-
return data;
|
|
36
|
-
});
|
|
37
|
-
}
|
|
38
|
-
createInvite(jwt, widgetConfigurationId, environmentId, payload) {
|
|
39
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
40
|
-
const response = yield fetch(`${this.baseUrl}/api/v1/environment/${environmentId}/widget-configuration/${widgetConfigurationId}/invite`, {
|
|
41
|
-
method: 'POST',
|
|
42
|
-
headers: {
|
|
43
|
-
'Content-Type': 'application/json',
|
|
44
|
-
Authorization: `Bearer ${jwt}`,
|
|
45
|
-
'x-session-id': this.sessionId,
|
|
46
|
-
},
|
|
47
|
-
body: JSON.stringify({
|
|
48
|
-
data: {
|
|
49
|
-
payload,
|
|
50
|
-
},
|
|
51
|
-
}),
|
|
52
|
-
});
|
|
53
|
-
if (!response.ok) {
|
|
54
|
-
const body = yield response.text();
|
|
55
|
-
console.error('[VortexClient] createInvite', { status: response.status, body });
|
|
56
|
-
throw new Error(`Error POSTing widget invite: ${response.status}`);
|
|
57
|
-
}
|
|
58
|
-
const data = yield response.json();
|
|
59
|
-
console.log('[VortexClient] createInvite', data);
|
|
60
|
-
return data;
|
|
61
|
-
});
|
|
62
|
-
}
|
|
63
|
-
getShareableLinkFormatted() {
|
|
64
|
-
return `${this.baseUrl}/noauth/invite/...`;
|
|
65
|
-
}
|
|
66
|
-
createShareableInvite(jwt, widgetConfigurationId, environmentId) {
|
|
67
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
68
|
-
console.debug('[VortexClient] createShareableInvite request', {
|
|
69
|
-
widgetConfigurationId,
|
|
70
|
-
environmentId,
|
|
71
|
-
jwt,
|
|
72
|
-
});
|
|
73
|
-
const response = yield fetch(`${this.baseUrl}/api/v1/environment/${environmentId}/widget-configuration/${widgetConfigurationId}/generate-shareable-link-invite`, {
|
|
74
|
-
method: 'POST',
|
|
75
|
-
headers: {
|
|
76
|
-
'Content-Type': 'application/json',
|
|
77
|
-
Authorization: `Bearer ${jwt}`,
|
|
78
|
-
'x-session-id': this.sessionId,
|
|
79
|
-
},
|
|
80
|
-
});
|
|
81
|
-
if (!response.ok) {
|
|
82
|
-
throw new Error(`Error POSTing widget invite: ${response.statusText}`);
|
|
83
|
-
}
|
|
84
|
-
const data = yield response.json();
|
|
85
|
-
console.debug(`[VortexClient] createShareableInvite response ${JSON.stringify(data)}`);
|
|
86
|
-
return data;
|
|
87
|
-
});
|
|
88
|
-
}
|
|
89
|
-
}
|
|
90
|
-
exports.default = VortexClient;
|
|
@@ -1,134 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
-
if (k2 === undefined) k2 = k;
|
|
4
|
-
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
-
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
-
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
-
}
|
|
8
|
-
Object.defineProperty(o, k2, desc);
|
|
9
|
-
}) : (function(o, m, k, k2) {
|
|
10
|
-
if (k2 === undefined) k2 = k;
|
|
11
|
-
o[k2] = m[k];
|
|
12
|
-
}));
|
|
13
|
-
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
-
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
-
}) : function(o, v) {
|
|
16
|
-
o["default"] = v;
|
|
17
|
-
});
|
|
18
|
-
var __importStar = (this && this.__importStar) || (function () {
|
|
19
|
-
var ownKeys = function(o) {
|
|
20
|
-
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
21
|
-
var ar = [];
|
|
22
|
-
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
23
|
-
return ar;
|
|
24
|
-
};
|
|
25
|
-
return ownKeys(o);
|
|
26
|
-
};
|
|
27
|
-
return function (mod) {
|
|
28
|
-
if (mod && mod.__esModule) return mod;
|
|
29
|
-
var result = {};
|
|
30
|
-
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
31
|
-
__setModuleDefault(result, mod);
|
|
32
|
-
return result;
|
|
33
|
-
};
|
|
34
|
-
})();
|
|
35
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
36
|
-
const react_1 = __importStar(require("react"));
|
|
37
|
-
const react_native_1 = require("react-native");
|
|
38
|
-
const vortexInvite_1 = require("../vortexInvite");
|
|
39
|
-
const TestVortexInvite = () => {
|
|
40
|
-
const [isLoading, setIsLoading] = (0, react_1.useState)(false);
|
|
41
|
-
const [lastResult, setLastResult] = (0, react_1.useState)(null);
|
|
42
|
-
const [lastError, setLastError] = (0, react_1.useState)(null);
|
|
43
|
-
// Mock JWT - this would typically come from your auth system
|
|
44
|
-
const mockJwt = 'eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJzdWIiOiIxMjM0NTY3ODkwIiwibmFtZSI6IkpvaG4gRG9lIiwiaWF0IjoxNTE2MjM5MDIyfQ.SflKxwRJSMeKKF2QT4fwpMeJf36POk6yJV_adQssw5c';
|
|
45
|
-
const handleSuccess = (result) => {
|
|
46
|
-
setLastResult({ type: result.type, data: result.data });
|
|
47
|
-
setLastError(null);
|
|
48
|
-
};
|
|
49
|
-
const handleError = (error, type) => {
|
|
50
|
-
setLastError({ message: error.message, type });
|
|
51
|
-
setLastResult(null);
|
|
52
|
-
};
|
|
53
|
-
// Example content tokens
|
|
54
|
-
const contentTokens = {
|
|
55
|
-
'user.first_name': { value: 'John', type: 'string' },
|
|
56
|
-
'user.last_name': { value: 'Doe', type: 'string' },
|
|
57
|
-
'company.name': { value: 'Acme Inc', type: 'string' },
|
|
58
|
-
};
|
|
59
|
-
return (<react_native_1.SafeAreaView style={styles.container}>
|
|
60
|
-
<react_native_1.ScrollView contentContainerStyle={styles.scrollContainer}>
|
|
61
|
-
<react_native_1.Text style={styles.header}>Test VortexInvite Component</react_native_1.Text>
|
|
62
|
-
|
|
63
|
-
<react_native_1.View style={styles.controls}>
|
|
64
|
-
<react_native_1.Button title={isLoading ? 'Set Loading: False' : 'Set Loading: True'} onPress={() => setIsLoading(!isLoading)}/>
|
|
65
|
-
<react_native_1.Text style={styles.statusText}>Loading state: {isLoading ? 'true' : 'false'}</react_native_1.Text>
|
|
66
|
-
</react_native_1.View>
|
|
67
|
-
|
|
68
|
-
<react_native_1.View style={styles.inviteContainer}>
|
|
69
|
-
<vortexInvite_1.VortexInvite environmentId="env_123456789" widgetId="widget_123456789" vortexApiHost="https://api.vortex.com" isLoading={isLoading} jwt={mockJwt} onSuccess={handleSuccess} onError={handleError} contentTokens={contentTokens}/>
|
|
70
|
-
</react_native_1.View>
|
|
71
|
-
|
|
72
|
-
{lastResult && (<react_native_1.View style={styles.resultContainer}>
|
|
73
|
-
<react_native_1.Text style={styles.resultTitle}>Last Success:</react_native_1.Text>
|
|
74
|
-
<react_native_1.Text>Type: {lastResult.type}</react_native_1.Text>
|
|
75
|
-
<react_native_1.Text>Data: {lastResult.data}</react_native_1.Text>
|
|
76
|
-
</react_native_1.View>)}
|
|
77
|
-
|
|
78
|
-
{lastError && (<react_native_1.View style={styles.errorContainer}>
|
|
79
|
-
<react_native_1.Text style={styles.errorTitle}>Last Error:</react_native_1.Text>
|
|
80
|
-
<react_native_1.Text>Type: {lastError.type}</react_native_1.Text>
|
|
81
|
-
<react_native_1.Text>Message: {lastError.message}</react_native_1.Text>
|
|
82
|
-
</react_native_1.View>)}
|
|
83
|
-
</react_native_1.ScrollView>
|
|
84
|
-
</react_native_1.SafeAreaView>);
|
|
85
|
-
};
|
|
86
|
-
const styles = react_native_1.StyleSheet.create({
|
|
87
|
-
container: {
|
|
88
|
-
flex: 1,
|
|
89
|
-
backgroundColor: 'whitesmoke',
|
|
90
|
-
},
|
|
91
|
-
scrollContainer: {
|
|
92
|
-
padding: 16,
|
|
93
|
-
},
|
|
94
|
-
header: {
|
|
95
|
-
fontSize: 24,
|
|
96
|
-
fontWeight: 'bold',
|
|
97
|
-
marginBottom: 20,
|
|
98
|
-
textAlign: 'center',
|
|
99
|
-
},
|
|
100
|
-
controls: {
|
|
101
|
-
marginBottom: 20,
|
|
102
|
-
alignItems: 'center',
|
|
103
|
-
},
|
|
104
|
-
statusText: {
|
|
105
|
-
marginTop: 8,
|
|
106
|
-
fontSize: 16,
|
|
107
|
-
},
|
|
108
|
-
inviteContainer: {
|
|
109
|
-
marginBottom: 20,
|
|
110
|
-
},
|
|
111
|
-
resultContainer: {
|
|
112
|
-
padding: 12,
|
|
113
|
-
backgroundColor: 'honeydew',
|
|
114
|
-
borderRadius: 8,
|
|
115
|
-
marginTop: 16,
|
|
116
|
-
},
|
|
117
|
-
resultTitle: {
|
|
118
|
-
fontWeight: 'bold',
|
|
119
|
-
marginBottom: 8,
|
|
120
|
-
fontSize: 16,
|
|
121
|
-
},
|
|
122
|
-
errorContainer: {
|
|
123
|
-
padding: 12,
|
|
124
|
-
backgroundColor: 'mistyrose',
|
|
125
|
-
borderRadius: 8,
|
|
126
|
-
marginTop: 16,
|
|
127
|
-
},
|
|
128
|
-
errorTitle: {
|
|
129
|
-
fontWeight: 'bold',
|
|
130
|
-
marginBottom: 8,
|
|
131
|
-
fontSize: 16,
|
|
132
|
-
},
|
|
133
|
-
});
|
|
134
|
-
exports.default = TestVortexInvite;
|
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
export interface IClipboard {
|
|
2
|
-
/**
|
|
3
|
-
* Sets the content of the clipboard as a string
|
|
4
|
-
* @param content The string to save to the clipboard
|
|
5
|
-
*/
|
|
6
|
-
setString(content: string): Promise<void>;
|
|
7
|
-
/**
|
|
8
|
-
* Gets the content of the clipboard as a string
|
|
9
|
-
* @returns The current clipboard content
|
|
10
|
-
*/
|
|
11
|
-
getString(): Promise<string>;
|
|
12
|
-
}
|
|
13
|
-
declare let Clipboard: IClipboard;
|
|
14
|
-
export { Clipboard };
|
|
15
|
-
export default Clipboard;
|
|
16
|
-
//# sourceMappingURL=Clipboard.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"Clipboard.d.ts","sourceRoot":"","sources":["../../../src/components/Clipboard.ts"],"names":[],"mappings":"AAAA,MAAM,WAAW,UAAU;IACzB;;;OAGG;IACH,SAAS,CAAC,OAAO,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;IAE1C;;;OAGG;IACH,SAAS,IAAI,OAAO,CAAC,MAAM,CAAC,CAAC;CAC9B;AAKD,QAAA,IAAI,SAAS,EAAE,UAAU,CAAC;AAwD1B,OAAO,EAAE,SAAS,EAAE,CAAC;AACrB,eAAe,SAAS,CAAC"}
|
|
@@ -1,29 +0,0 @@
|
|
|
1
|
-
import React from 'react';
|
|
2
|
-
import { ThemeColors } from '../utils/themeUtils';
|
|
3
|
-
/**
|
|
4
|
-
* ShareButton component for rendering a single share option button
|
|
5
|
-
*/
|
|
6
|
-
interface ShareButtonProps {
|
|
7
|
-
iconName: string;
|
|
8
|
-
label: string;
|
|
9
|
-
onPress: () => void;
|
|
10
|
-
themeColors: ThemeColors;
|
|
11
|
-
themeStyles: any;
|
|
12
|
-
}
|
|
13
|
-
export declare function ShareButton({ iconName, label, onPress, themeColors, themeStyles, }: ShareButtonProps): React.JSX.Element;
|
|
14
|
-
/**
|
|
15
|
-
* ShareButtons component for rendering all available share options
|
|
16
|
-
*/
|
|
17
|
-
export interface ShareButtonsProps {
|
|
18
|
-
has: any;
|
|
19
|
-
themeColors: ThemeColors;
|
|
20
|
-
themeStyles: any;
|
|
21
|
-
handleShareLink: () => void;
|
|
22
|
-
handleCopyLink: () => void;
|
|
23
|
-
handleSmsShare: () => void;
|
|
24
|
-
handleEmailShare: () => void;
|
|
25
|
-
shareableLink?: string;
|
|
26
|
-
}
|
|
27
|
-
export declare function ShareButtons({ has, themeColors, themeStyles, handleShareLink, handleCopyLink, handleSmsShare, handleEmailShare, shareableLink, }: ShareButtonsProps): React.JSX.Element;
|
|
28
|
-
export {};
|
|
29
|
-
//# sourceMappingURL=ShareButtons.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"ShareButtons.d.ts","sourceRoot":"","sources":["../../../src/components/ShareButtons.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAmB,MAAM,OAAO,CAAC;AAGxC,OAAO,EAAE,WAAW,EAAE,MAAM,qBAAqB,CAAC;AAGlD;;GAEG;AACH,UAAU,gBAAgB;IACxB,QAAQ,EAAE,MAAM,CAAC;IACjB,KAAK,EAAE,MAAM,CAAC;IACd,OAAO,EAAE,MAAM,IAAI,CAAC;IACpB,WAAW,EAAE,WAAW,CAAC;IACzB,WAAW,EAAE,GAAG,CAAC;CAClB;AAED,wBAAgB,WAAW,CAAC,EAC1B,QAAQ,EACR,KAAK,EACL,OAAO,EACP,WAAW,EACX,WAAW,GACZ,EAAE,gBAAgB,qBAWlB;AAED;;GAEG;AACH,MAAM,WAAW,iBAAiB;IAChC,GAAG,EAAE,GAAG,CAAC;IACT,WAAW,EAAE,WAAW,CAAC;IACzB,WAAW,EAAE,GAAG,CAAC;IACjB,eAAe,EAAE,MAAM,IAAI,CAAC;IAC5B,cAAc,EAAE,MAAM,IAAI,CAAC;IAC3B,cAAc,EAAE,MAAM,IAAI,CAAC;IAC3B,gBAAgB,EAAE,MAAM,IAAI,CAAC;IAC7B,aAAa,CAAC,EAAE,MAAM,CAAC;CACxB;AAED,wBAAgB,YAAY,CAAC,EAC3B,GAAG,EACH,WAAW,EACX,WAAW,EACX,eAAe,EACf,cAAc,EACd,cAAc,EACd,gBAAgB,EAChB,aAAa,GACd,EAAE,iBAAiB,qBA2GnB"}
|
|
@@ -1,34 +0,0 @@
|
|
|
1
|
-
import { ThemeColors } from "../utils/themeUtils";
|
|
2
|
-
/**
|
|
3
|
-
* Hook to generate dynamic styles based on theme colors
|
|
4
|
-
* @param themeColors The theme colors object
|
|
5
|
-
* @returns Object containing styled components based on the theme
|
|
6
|
-
*/
|
|
7
|
-
export declare function useThemeStyles(themeColors: ThemeColors): {
|
|
8
|
-
primaryButton: {
|
|
9
|
-
backgroundColor: string;
|
|
10
|
-
borderColor: string;
|
|
11
|
-
};
|
|
12
|
-
primaryButtonText: {
|
|
13
|
-
color: string;
|
|
14
|
-
};
|
|
15
|
-
secondaryButton: {
|
|
16
|
-
backgroundColor: string;
|
|
17
|
-
borderColor: string;
|
|
18
|
-
};
|
|
19
|
-
secondaryButtonText: {
|
|
20
|
-
color: string;
|
|
21
|
-
};
|
|
22
|
-
containerStyles: {
|
|
23
|
-
backgroundColor: string;
|
|
24
|
-
};
|
|
25
|
-
textStyles: {
|
|
26
|
-
color: string;
|
|
27
|
-
};
|
|
28
|
-
inputStyles: {
|
|
29
|
-
borderColor: string;
|
|
30
|
-
color: string;
|
|
31
|
-
backgroundColor: string;
|
|
32
|
-
};
|
|
33
|
-
};
|
|
34
|
-
//# sourceMappingURL=useThemeStyles.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"useThemeStyles.d.ts","sourceRoot":"","sources":["../../../src/hooks/useThemeStyles.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,WAAW,EAAE,MAAM,qBAAqB,CAAC;AAElD;;;;GAIG;AACH,wBAAgB,cAAc,CAAC,WAAW,EAAE,WAAW;;;;;;;;;;;;;;;;;;;;;;;;;;EAiCtD"}
|