@jsb188/graphql 1.1.8 → 1.1.11
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/cache/config.ts +66 -42
- package/cache/index.test.ts +881 -0
- package/cache/index.ts +1815 -979
- package/cache/persist.ts +721 -0
- package/cache/store.ts +437 -0
- package/client/data-table-realtime-subscriptions.test.ts +740 -0
- package/client/data-table-realtime-subscriptions.ts +955 -0
- package/client/data-table-realtime.test.ts +792 -0
- package/client/data-table-realtime.ts +1218 -0
- package/client/fragment-realtime-sequence.ts +52 -0
- package/client/index.ts +4 -2
- package/client/open-sheet.ts +137 -0
- package/client/request-managed-session.test.ts +574 -0
- package/client/request-no-store.test.ts +157 -0
- package/client/request.ts +973 -143
- package/client/sse-ticket.test.ts +26 -0
- package/deno.lock +170 -0
- package/deno.test.json +10 -0
- package/drafts/index.ts +149 -0
- package/drafts/store.ts +397 -0
- package/gql/eagerQueryMap.ts +12 -0
- package/gql/fragments/accountAuthFragments.ts +5 -0
- package/gql/fragments/accountFragments.ts +1 -3
- package/gql/fragments/accountSessionFragments.ts +16 -0
- package/gql/fragments/agentDocFragments.ts +46 -0
- package/gql/fragments/agentMemoryFragments.ts +19 -0
- package/gql/fragments/aiChatFragments.ts +17 -0
- package/gql/fragments/billingFragments.ts +0 -11
- package/gql/fragments/campaignFragments.ts +277 -0
- package/gql/fragments/dataTableFragments.ts +102 -0
- package/gql/fragments/emailFragments.ts +36 -0
- package/gql/fragments/fieldDocFragments.ts +82 -0
- package/gql/fragments/inboundContactFragments.ts +15 -0
- package/gql/fragments/integrationFragments.ts +22 -0
- package/gql/fragments/logFragments.ts +33 -64
- package/gql/fragments/organizationFragments.ts +94 -21
- package/gql/fragments/scheduleFragments.ts +155 -0
- package/gql/fragments/sheetFragments.ts +675 -0
- package/gql/fragments/storageFragments.ts +21 -1
- package/gql/fragments/workflowFragments.ts +67 -0
- package/gql/mutations/accountMutations.ts +24 -4
- package/gql/mutations/agentDocMutations.ts +177 -0
- package/gql/mutations/agentMemoryMutations.ts +36 -0
- package/gql/mutations/aiChatMutations.ts +43 -3
- package/gql/mutations/authMutations.ts +160 -19
- package/gql/mutations/campaignMutations.ts +215 -0
- package/gql/mutations/dataTableMutations.ts +106 -0
- package/gql/mutations/fieldDocMutations.ts +24 -0
- package/gql/mutations/inboundContactMutations.ts +24 -0
- package/gql/mutations/index.ts +17 -8
- package/gql/mutations/integrationMutations.ts +25 -0
- package/gql/mutations/logMutations.ts +10 -19
- package/gql/mutations/organizationMutations.ts +160 -2
- package/gql/mutations/scheduleMutations.ts +423 -0
- package/gql/mutations/sheetMutations.ts +385 -0
- package/gql/mutations/storageMutations.ts +21 -2
- package/gql/mutations/workflowMutations.ts +42 -0
- package/gql/queries/agentDocQueries.ts +120 -0
- package/gql/queries/agentMemoryQueries.ts +22 -0
- package/gql/queries/aiChatQueries.ts +18 -2
- package/gql/queries/authQueries.ts +41 -0
- package/gql/queries/billingQueries.ts +24 -1
- package/gql/queries/campaignQueries.ts +127 -0
- package/gql/queries/dataTableQueries.ts +134 -0
- package/gql/queries/emailQueries.ts +96 -0
- package/gql/queries/fieldDocQueries.ts +158 -0
- package/gql/queries/inboundContactQueries.ts +40 -0
- package/gql/queries/index.ts +17 -6
- package/gql/queries/logQueries.ts +42 -32
- package/gql/queries/organizationQueries.ts +113 -8
- package/gql/queries/scheduleQueries.ts +315 -0
- package/gql/queries/sheetQueries.ts +383 -0
- package/gql/queries/storageQueries.ts +38 -0
- package/gql/queries/workflowQueries.ts +99 -0
- package/hooks/index.ts +2104 -860
- package/hooks/use-account-mtn.ts +91 -48
- package/hooks/use-agentDoc-mtn.ts +285 -0
- package/hooks/use-agentDoc-qry.ts +208 -0
- package/hooks/use-agentMemory-mtn.ts +73 -0
- package/hooks/use-agentMemory-qry.ts +44 -0
- package/hooks/use-aiChat-mtn.ts +248 -97
- package/hooks/use-aiChat-qry.ts +501 -191
- package/hooks/use-app-qry.ts +14 -11
- package/hooks/use-auth-mtn.ts +410 -256
- package/hooks/use-auth-qry.ts +51 -0
- package/hooks/use-campaign-mtn.ts +377 -0
- package/hooks/use-campaign-qry.ts +257 -0
- package/hooks/use-dataTable-mtn.ts +170 -0
- package/hooks/use-dataTable-qry.ts +996 -0
- package/hooks/use-email-qry.ts +227 -0
- package/hooks/use-fieldDoc-mtn.ts +50 -0
- package/hooks/use-fieldDoc-qry.ts +180 -0
- package/hooks/use-inboundContact-mtn.ts +34 -0
- package/hooks/use-inboundContact-qry.ts +96 -0
- package/hooks/use-integration-mtn.ts +77 -0
- package/hooks/use-integration-qry.ts +30 -0
- package/hooks/use-log-mtn.ts +77 -61
- package/hooks/use-log-qry.ts +99 -72
- package/hooks/use-organization-mtn.ts +409 -80
- package/hooks/use-organization-qry.ts +211 -92
- package/hooks/use-schedule-mtn.ts +416 -0
- package/hooks/use-schedule-qry.ts +157 -0
- package/hooks/use-sheet-mtn.ts +367 -0
- package/hooks/use-sheet-qry.ts +440 -0
- package/hooks/use-storage-mtn.ts +83 -42
- package/hooks/use-storage-qry.ts +104 -13
- package/hooks/use-workflow-mtn.ts +55 -0
- package/hooks/use-workflow-qry.ts +230 -0
- package/loaders/campaign.ts +137 -0
- package/package.json +94 -52
- package/sse.ts +158 -105
- package/tsconfig.json +13 -0
- package/types.d.ts +60 -29
- package/utils.ts +77 -50
- package/gql/fragments/actionFragments.ts +0 -16
- package/gql/fragments/productFragments.ts +0 -63
- package/gql/fragments/reportFragments.ts +0 -48
- package/gql/mutations/billingMutations.ts +0 -34
- package/gql/queries/productQueries.ts +0 -70
- package/gql/queries/reportQueries.ts +0 -66
- package/hooks/use-product-qry.ts +0 -109
- package/hooks/use-report-qry.ts +0 -69
package/hooks/use-auth-mtn.ts
CHANGED
|
@@ -1,20 +1,125 @@
|
|
|
1
|
-
import i18n from '@jsb188/app/i18n';
|
|
2
|
-
import { deleteAuthToken } from '@jsb188/app/platform';
|
|
1
|
+
import i18n from '@jsb188/app/i18n/index.ts';
|
|
2
|
+
import { deleteAuthToken } from '@jsb188/app/platform.ts';
|
|
3
3
|
import type { UseMutationParams } from '@jsb188/graphql/types.d';
|
|
4
4
|
import type { OpenModalPopUpFn } from '@jsb188/react/states';
|
|
5
|
-
import {
|
|
5
|
+
import {
|
|
6
|
+
AppContext,
|
|
7
|
+
onGuestInit,
|
|
8
|
+
useOpenModalPopUp,
|
|
9
|
+
} from '@jsb188/react/states';
|
|
6
10
|
import React, { useContext, useEffect, useState } from 'react';
|
|
7
|
-
import {
|
|
8
|
-
|
|
9
|
-
|
|
11
|
+
import {
|
|
12
|
+
changeAccountPasswordMtn,
|
|
13
|
+
checkUsernameOrEmailMtn,
|
|
14
|
+
confirmPasswordMtn,
|
|
15
|
+
confirmPhoneVerificationCodeMtn,
|
|
16
|
+
getSsoLoginOptionsMtn,
|
|
17
|
+
requestTokenizedEmailMtn,
|
|
18
|
+
revokeMyAccountSessionMtn,
|
|
19
|
+
revokeMyOtherAccountSessionsMtn,
|
|
20
|
+
revokeOrganizationMemberSessionMtn,
|
|
21
|
+
revokeOrganizationMemberSessionsMtn,
|
|
22
|
+
sendPhoneVerificationCodeMtn,
|
|
23
|
+
signUpWithEmailMtn,
|
|
24
|
+
} from '../gql/mutations/authMutations.ts';
|
|
25
|
+
import { signOutMtn } from '../gql/mutations/userAuthMutations.ts';
|
|
26
|
+
import { useMutation } from './index.ts';
|
|
10
27
|
|
|
11
28
|
/**
|
|
12
29
|
* Types
|
|
13
30
|
*/
|
|
14
31
|
|
|
15
32
|
interface AuthHookParams extends UseMutationParams {
|
|
16
|
-
|
|
17
|
-
|
|
33
|
+
initialError?: any;
|
|
34
|
+
initialFormData?: Record<string, any>;
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
/*
|
|
38
|
+
* Revoke one managed session owned by the current account.
|
|
39
|
+
*/
|
|
40
|
+
export function useRevokeMyAccountSession(
|
|
41
|
+
params: UseMutationParams = {},
|
|
42
|
+
openModalPopUp?: OpenModalPopUpFn,
|
|
43
|
+
) {
|
|
44
|
+
const [revokeMyAccountSession, mutation, handlers] = useMutation(
|
|
45
|
+
revokeMyAccountSessionMtn,
|
|
46
|
+
{
|
|
47
|
+
openModalPopUp,
|
|
48
|
+
...params,
|
|
49
|
+
},
|
|
50
|
+
);
|
|
51
|
+
|
|
52
|
+
return {
|
|
53
|
+
revokeMyAccountSession,
|
|
54
|
+
...mutation,
|
|
55
|
+
...handlers,
|
|
56
|
+
};
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
/*
|
|
60
|
+
* Revoke every other managed session owned by the current account.
|
|
61
|
+
*/
|
|
62
|
+
export function useRevokeMyOtherAccountSessions(
|
|
63
|
+
params: UseMutationParams = {},
|
|
64
|
+
openModalPopUp?: OpenModalPopUpFn,
|
|
65
|
+
) {
|
|
66
|
+
const [revokeMyOtherAccountSessions, mutation, handlers] = useMutation(
|
|
67
|
+
revokeMyOtherAccountSessionsMtn,
|
|
68
|
+
{
|
|
69
|
+
openModalPopUp,
|
|
70
|
+
...params,
|
|
71
|
+
},
|
|
72
|
+
);
|
|
73
|
+
|
|
74
|
+
return {
|
|
75
|
+
revokeMyOtherAccountSessions,
|
|
76
|
+
...mutation,
|
|
77
|
+
...handlers,
|
|
78
|
+
};
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
/*
|
|
82
|
+
* Revoke one member session's authorization for an organization.
|
|
83
|
+
*/
|
|
84
|
+
export function useRevokeOrganizationMemberSession(
|
|
85
|
+
params: UseMutationParams = {},
|
|
86
|
+
openModalPopUp?: OpenModalPopUpFn,
|
|
87
|
+
) {
|
|
88
|
+
const [revokeOrganizationMemberSession, mutation, handlers] = useMutation(
|
|
89
|
+
revokeOrganizationMemberSessionMtn,
|
|
90
|
+
{
|
|
91
|
+
openModalPopUp,
|
|
92
|
+
...params,
|
|
93
|
+
},
|
|
94
|
+
);
|
|
95
|
+
|
|
96
|
+
return {
|
|
97
|
+
revokeOrganizationMemberSession,
|
|
98
|
+
...mutation,
|
|
99
|
+
...handlers,
|
|
100
|
+
};
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
/*
|
|
104
|
+
* Revoke every managed-session authorization a member has for an organization.
|
|
105
|
+
*/
|
|
106
|
+
export function useRevokeOrganizationMemberSessions(
|
|
107
|
+
params: UseMutationParams = {},
|
|
108
|
+
openModalPopUp?: OpenModalPopUpFn,
|
|
109
|
+
) {
|
|
110
|
+
const [revokeOrganizationMemberSessions, mutation, handlers] = useMutation(
|
|
111
|
+
revokeOrganizationMemberSessionsMtn,
|
|
112
|
+
{
|
|
113
|
+
openModalPopUp,
|
|
114
|
+
...params,
|
|
115
|
+
},
|
|
116
|
+
);
|
|
117
|
+
|
|
118
|
+
return {
|
|
119
|
+
revokeOrganizationMemberSessions,
|
|
120
|
+
...mutation,
|
|
121
|
+
...handlers,
|
|
122
|
+
};
|
|
18
123
|
}
|
|
19
124
|
|
|
20
125
|
/**
|
|
@@ -22,65 +127,70 @@ interface AuthHookParams extends UseMutationParams {
|
|
|
22
127
|
*/
|
|
23
128
|
|
|
24
129
|
interface UseChangeAccountPasswordParams extends UseMutationParams {
|
|
25
|
-
|
|
130
|
+
doNotFinishForm?: boolean;
|
|
26
131
|
}
|
|
27
132
|
|
|
28
|
-
export function useChangeAccountPassword(
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
133
|
+
export function useChangeAccountPassword(
|
|
134
|
+
params: UseChangeAccountPasswordParams = {},
|
|
135
|
+
openModalPopUp?: OpenModalPopUpFn,
|
|
136
|
+
) {
|
|
137
|
+
const {
|
|
138
|
+
dispatchApp,
|
|
139
|
+
appState: { hasPassword, account },
|
|
140
|
+
} = useContext(AppContext);
|
|
141
|
+
const { onCompleted, onError, doNotFinishForm } = params;
|
|
142
|
+
|
|
143
|
+
const onFinishChangeAccountPassword = () => {
|
|
144
|
+
if (!hasPassword) {
|
|
145
|
+
dispatchApp({
|
|
146
|
+
__type: 'APP_EDIT_AUTH',
|
|
147
|
+
data: {
|
|
148
|
+
id: account?.id,
|
|
149
|
+
hasPassword: true,
|
|
150
|
+
},
|
|
151
|
+
});
|
|
152
|
+
}
|
|
153
|
+
};
|
|
154
|
+
|
|
155
|
+
const onCompleted_ = (data: any, err: any, variables: any) => {
|
|
156
|
+
const success = !!data?.changeAccountPassword;
|
|
157
|
+
if (success) {
|
|
158
|
+
openModalPopUp?.({
|
|
159
|
+
name: 'password_changed',
|
|
160
|
+
props: {
|
|
161
|
+
title: i18n.t('form.success'),
|
|
162
|
+
message: i18n.t('auth.password_changed_msg'),
|
|
163
|
+
iconName: 'lock-password-filled',
|
|
164
|
+
},
|
|
165
|
+
});
|
|
166
|
+
|
|
167
|
+
if (!doNotFinishForm) {
|
|
168
|
+
onFinishChangeAccountPassword();
|
|
169
|
+
}
|
|
170
|
+
|
|
171
|
+
if (onCompleted) {
|
|
172
|
+
onCompleted(success, err, variables);
|
|
173
|
+
}
|
|
174
|
+
}
|
|
175
|
+
};
|
|
176
|
+
|
|
177
|
+
const [changeAccountPassword, mtnValues, mtnHandlers] = useMutation(
|
|
178
|
+
changeAccountPasswordMtn,
|
|
179
|
+
{
|
|
180
|
+
openModalPopUp,
|
|
181
|
+
onCompleted: onCompleted_,
|
|
182
|
+
onError,
|
|
183
|
+
},
|
|
184
|
+
);
|
|
185
|
+
|
|
186
|
+
return {
|
|
187
|
+
openModalPopUp,
|
|
188
|
+
changeAccountPassword,
|
|
189
|
+
onFinishChangeAccountPassword,
|
|
190
|
+
account,
|
|
191
|
+
...mtnValues,
|
|
192
|
+
...mtnHandlers,
|
|
193
|
+
};
|
|
84
194
|
}
|
|
85
195
|
|
|
86
196
|
/**
|
|
@@ -88,171 +198,215 @@ export function useChangeAccountPassword(params: UseChangeAccountPasswordParams
|
|
|
88
198
|
*/
|
|
89
199
|
|
|
90
200
|
export function useChangeAccountPasswordForm(params: UseMutationParams = {}) {
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
201
|
+
const {
|
|
202
|
+
dispatchApp,
|
|
203
|
+
appState: { hasPassword, account },
|
|
204
|
+
} = useContext(AppContext);
|
|
205
|
+
const { onCompleted, onError } = params;
|
|
206
|
+
|
|
207
|
+
const onCompleted_ = (data: any, err: any, variables: any) => {
|
|
208
|
+
if (onCompleted) {
|
|
209
|
+
onCompleted(data, err, variables);
|
|
210
|
+
}
|
|
211
|
+
|
|
212
|
+
const success = !!data?.changeAccountPassword;
|
|
213
|
+
if (success) {
|
|
214
|
+
// It's possible for user to use this hook without being logged in
|
|
215
|
+
// So we have to check for ID first
|
|
216
|
+
if (account?.id && !hasPassword) {
|
|
217
|
+
dispatchApp({
|
|
218
|
+
__type: 'APP_EDIT_AUTH',
|
|
219
|
+
data: {
|
|
220
|
+
id: account?.id,
|
|
221
|
+
hasPassword: true,
|
|
222
|
+
},
|
|
223
|
+
});
|
|
224
|
+
}
|
|
225
|
+
}
|
|
226
|
+
};
|
|
227
|
+
|
|
228
|
+
const [changeAccountPassword, mtnValues, mtnHandlers] = useMutation(
|
|
229
|
+
changeAccountPasswordMtn,
|
|
230
|
+
{
|
|
231
|
+
checkMountedBeforeCallback: true,
|
|
232
|
+
onCompleted: onCompleted_,
|
|
233
|
+
onError,
|
|
234
|
+
},
|
|
235
|
+
);
|
|
236
|
+
|
|
237
|
+
return {
|
|
238
|
+
changeAccountPassword,
|
|
239
|
+
...mtnValues,
|
|
240
|
+
...mtnHandlers,
|
|
241
|
+
};
|
|
130
242
|
}
|
|
131
243
|
|
|
132
244
|
/**
|
|
133
245
|
* Request password reset (email with link)
|
|
134
246
|
*/
|
|
135
247
|
|
|
136
|
-
export function useRequestTokenizedEmail(
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
248
|
+
export function useRequestTokenizedEmail(
|
|
249
|
+
params: UseMutationParams = {},
|
|
250
|
+
openModalPopUp?: OpenModalPopUpFn,
|
|
251
|
+
) {
|
|
252
|
+
const { onCompleted, onError } = params;
|
|
253
|
+
const [requestTokenizedEmail, mtnValues, mtnHandlers] = useMutation(
|
|
254
|
+
requestTokenizedEmailMtn,
|
|
255
|
+
{
|
|
256
|
+
checkMountedBeforeCallback: true,
|
|
257
|
+
openModalPopUp,
|
|
258
|
+
onCompleted,
|
|
259
|
+
onError,
|
|
260
|
+
},
|
|
261
|
+
);
|
|
262
|
+
|
|
263
|
+
return {
|
|
264
|
+
requestTokenizedEmail,
|
|
265
|
+
...mtnValues,
|
|
266
|
+
...mtnHandlers,
|
|
267
|
+
};
|
|
153
268
|
}
|
|
154
269
|
|
|
155
270
|
/**
|
|
156
271
|
* Send verification code to phone number
|
|
157
272
|
*/
|
|
158
273
|
|
|
159
|
-
export function useSendPhoneVerificationCode(
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
274
|
+
export function useSendPhoneVerificationCode(
|
|
275
|
+
params: UseMutationParams = {},
|
|
276
|
+
openModalPopUp?: OpenModalPopUpFn,
|
|
277
|
+
) {
|
|
278
|
+
const { onCompleted, onError } = params;
|
|
279
|
+
const [sendPhoneVerificationCode, mtnValues, mtnHandlers] = useMutation(
|
|
280
|
+
sendPhoneVerificationCodeMtn,
|
|
281
|
+
{
|
|
282
|
+
checkMountedBeforeCallback: true,
|
|
283
|
+
openModalPopUp,
|
|
284
|
+
onCompleted,
|
|
285
|
+
onError,
|
|
286
|
+
},
|
|
287
|
+
);
|
|
288
|
+
|
|
289
|
+
return {
|
|
290
|
+
sendPhoneVerificationCode,
|
|
291
|
+
...mtnValues,
|
|
292
|
+
...mtnHandlers,
|
|
293
|
+
};
|
|
176
294
|
}
|
|
177
295
|
|
|
178
296
|
/**
|
|
179
297
|
* Confirm verification code
|
|
180
298
|
*/
|
|
181
299
|
|
|
182
|
-
export function useConfirmPhoneVerificationCode(
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
300
|
+
export function useConfirmPhoneVerificationCode(
|
|
301
|
+
params: UseMutationParams = {},
|
|
302
|
+
openModalPopUp?: OpenModalPopUpFn,
|
|
303
|
+
) {
|
|
304
|
+
const { onCompleted, onError } = params;
|
|
305
|
+
|
|
306
|
+
const [confirmPhoneVerificationCode, mtnValues, mtnHandlers] = useMutation(
|
|
307
|
+
confirmPhoneVerificationCodeMtn,
|
|
308
|
+
{
|
|
309
|
+
checkMountedBeforeCallback: true,
|
|
310
|
+
openModalPopUp,
|
|
311
|
+
onCompleted,
|
|
312
|
+
onError,
|
|
313
|
+
},
|
|
314
|
+
);
|
|
315
|
+
|
|
316
|
+
return {
|
|
317
|
+
confirmPhoneVerificationCode,
|
|
318
|
+
...mtnValues,
|
|
319
|
+
...mtnHandlers,
|
|
320
|
+
};
|
|
200
321
|
}
|
|
201
322
|
|
|
202
323
|
/**
|
|
203
324
|
* Sign in
|
|
204
325
|
*/
|
|
205
326
|
|
|
206
|
-
export function useCheckUsernameOrEmail(
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
327
|
+
export function useCheckUsernameOrEmail(
|
|
328
|
+
params: AuthHookParams = {},
|
|
329
|
+
openModalPopUp?: OpenModalPopUpFn,
|
|
330
|
+
) {
|
|
331
|
+
const { onError, onCompleted, initialError, initialFormData } = params;
|
|
332
|
+
|
|
333
|
+
const [dataForSchema, setDataForSchema] = useState({
|
|
334
|
+
hasInput: !!initialFormData?.usernameOrEmail,
|
|
335
|
+
lastIdentifier: initialFormData?.usernameOrEmail || '',
|
|
336
|
+
hidePassword: !initialFormData?.usernameOrEmail,
|
|
337
|
+
});
|
|
338
|
+
|
|
339
|
+
const [checkUsernameOrEmail, mtnValues, mtnHandlers] = useMutation(
|
|
340
|
+
checkUsernameOrEmailMtn,
|
|
341
|
+
{
|
|
342
|
+
openModalPopUp,
|
|
343
|
+
initialError,
|
|
344
|
+
onError,
|
|
345
|
+
onCompleted,
|
|
346
|
+
},
|
|
347
|
+
);
|
|
348
|
+
|
|
349
|
+
return {
|
|
350
|
+
...mtnValues,
|
|
351
|
+
...mtnHandlers,
|
|
352
|
+
checkUsernameOrEmail,
|
|
353
|
+
dataForSchema,
|
|
354
|
+
setDataForSchema,
|
|
355
|
+
};
|
|
356
|
+
}
|
|
357
|
+
|
|
358
|
+
/**
|
|
359
|
+
* Resolve SSO sign-in options for an email address (home realm discovery)
|
|
360
|
+
*/
|
|
361
|
+
|
|
362
|
+
export function useGetSsoLoginOptions(
|
|
363
|
+
params: UseMutationParams = {},
|
|
364
|
+
openModalPopUp?: OpenModalPopUpFn,
|
|
365
|
+
) {
|
|
366
|
+
const { onError, onCompleted } = params;
|
|
367
|
+
|
|
368
|
+
const [getSsoLoginOptions, mtnValues, mtnHandlers] = useMutation(
|
|
369
|
+
getSsoLoginOptionsMtn,
|
|
370
|
+
{
|
|
371
|
+
checkMountedBeforeCallback: true,
|
|
372
|
+
openModalPopUp,
|
|
373
|
+
onError,
|
|
374
|
+
onCompleted,
|
|
375
|
+
},
|
|
376
|
+
);
|
|
377
|
+
|
|
378
|
+
return {
|
|
379
|
+
...mtnValues,
|
|
380
|
+
...mtnHandlers,
|
|
381
|
+
getSsoLoginOptions,
|
|
382
|
+
};
|
|
232
383
|
}
|
|
233
384
|
|
|
234
385
|
/**
|
|
235
386
|
* Sign up with email
|
|
236
387
|
*/
|
|
237
388
|
|
|
238
|
-
export function useSignUpWithEmail(
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
389
|
+
export function useSignUpWithEmail(
|
|
390
|
+
params: AuthHookParams = {},
|
|
391
|
+
openModalPopUp?: OpenModalPopUpFn,
|
|
392
|
+
) {
|
|
393
|
+
const { onError, onCompleted, initialError } = params;
|
|
394
|
+
|
|
395
|
+
const [signUpWithEmail, mtnValues, mtnHandlers] = useMutation(
|
|
396
|
+
signUpWithEmailMtn,
|
|
397
|
+
{
|
|
398
|
+
openModalPopUp,
|
|
399
|
+
initialError,
|
|
400
|
+
onError,
|
|
401
|
+
onCompleted,
|
|
402
|
+
},
|
|
403
|
+
);
|
|
404
|
+
|
|
405
|
+
return {
|
|
406
|
+
...mtnValues,
|
|
407
|
+
...mtnHandlers,
|
|
408
|
+
signUpWithEmail,
|
|
409
|
+
};
|
|
256
410
|
}
|
|
257
411
|
|
|
258
412
|
/**
|
|
@@ -260,21 +414,24 @@ export function useSignUpWithEmail(params: AuthHookParams = {}, openModalPopUp?:
|
|
|
260
414
|
* NOTE: *must* be signed in already
|
|
261
415
|
*/
|
|
262
416
|
|
|
263
|
-
export function useConfirmPassword(
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
417
|
+
export function useConfirmPassword(
|
|
418
|
+
params: UseMutationParams = {},
|
|
419
|
+
openModalPopUp?: OpenModalPopUpFn,
|
|
420
|
+
) {
|
|
421
|
+
const [confirmPassword, mtnValues, mtnHandlers] = useMutation(
|
|
422
|
+
confirmPasswordMtn,
|
|
423
|
+
{
|
|
424
|
+
checkMountedBeforeCallback: true,
|
|
425
|
+
openModalPopUp,
|
|
426
|
+
...params,
|
|
427
|
+
},
|
|
428
|
+
);
|
|
429
|
+
|
|
430
|
+
return {
|
|
431
|
+
confirmPassword,
|
|
432
|
+
...mtnValues,
|
|
433
|
+
...mtnHandlers,
|
|
434
|
+
};
|
|
278
435
|
}
|
|
279
436
|
|
|
280
437
|
// Before are deprecated HOC that needs to be migrated to hooks
|
|
@@ -288,45 +445,42 @@ export function useConfirmPassword(params: UseMutationParams = {}, openModalPopU
|
|
|
288
445
|
*/
|
|
289
446
|
|
|
290
447
|
export function composeSignOut(Cmp: React.FC<any>) {
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
};
|
|
330
|
-
|
|
331
|
-
return SignOutCnt;
|
|
448
|
+
const SignOutCnt = (p: any) => {
|
|
449
|
+
const { doNotAlertErrors, onError, onCompleted } = p;
|
|
450
|
+
const openModalPopUp = useOpenModalPopUp();
|
|
451
|
+
const { dispatchApp } = useContext<any>(AppContext);
|
|
452
|
+
|
|
453
|
+
const [signOut, mtnValues, mtnHandlers] = useMutation(signOutMtn, {
|
|
454
|
+
openModalPopUp: doNotAlertErrors ? null : openModalPopUp,
|
|
455
|
+
onError,
|
|
456
|
+
onCompleted: (data) => {
|
|
457
|
+
if (data?.signOut) {
|
|
458
|
+
deleteAuthToken();
|
|
459
|
+
onGuestInit(null, dispatchApp);
|
|
460
|
+
}
|
|
461
|
+
if (onCompleted) {
|
|
462
|
+
onCompleted(data);
|
|
463
|
+
}
|
|
464
|
+
},
|
|
465
|
+
});
|
|
466
|
+
|
|
467
|
+
useEffect(() => {
|
|
468
|
+
const timer = setTimeout(() => {
|
|
469
|
+
signOut();
|
|
470
|
+
}, 1000);
|
|
471
|
+
return () => clearTimeout(timer);
|
|
472
|
+
}, []);
|
|
473
|
+
|
|
474
|
+
// return (
|
|
475
|
+
// <Cmp
|
|
476
|
+
// {...p}
|
|
477
|
+
// {...mtnValues}
|
|
478
|
+
// {...mtnHandlers}
|
|
479
|
+
// signOut={signOut}
|
|
480
|
+
// />
|
|
481
|
+
// );
|
|
482
|
+
return null;
|
|
483
|
+
};
|
|
484
|
+
|
|
485
|
+
return SignOutCnt;
|
|
332
486
|
}
|