@jsb188/graphql 1.1.1 → 1.1.3

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.
@@ -6,5 +6,8 @@ export const accountFragment = `fragment accountFragment on Account {
6
6
  id
7
7
  firstName
8
8
  lastName
9
+
10
+ photoId
11
+ photoUri
9
12
  }
10
13
  }`;
@@ -8,6 +8,7 @@ export const phoneFragment = `fragment phoneFragment on Phone {
8
8
  id
9
9
  number
10
10
  verified
11
+ primary
11
12
  }`;
12
13
 
13
14
  export const alertFragment = `fragment alertFragment on Alert {
@@ -51,3 +51,31 @@ mutation authenticateWithToken (
51
51
  }
52
52
  ${authenticateFragments}
53
53
  `;
54
+
55
+ export const signInWithGoogleMtn = gql`
56
+ mutation signInWithGoogle (
57
+ $oauthToken: String!
58
+ ) {
59
+ signInWithGoogle (
60
+ oauthToken: $oauthToken
61
+ ) {
62
+ ${authenticateResultText}
63
+ }
64
+ }
65
+ ${authenticateFragments}
66
+ `;
67
+
68
+ export const signInWithAppleMtn = gql`
69
+ mutation signInWithApple (
70
+ $code: String!
71
+ $idToken: String!
72
+ ) {
73
+ signInWithApple (
74
+ code: $code
75
+ idToken: $idToken
76
+ ) {
77
+ ${authenticateResultText}
78
+ }
79
+ }
80
+ ${authenticateFragments}
81
+ `;
@@ -142,19 +142,6 @@ mutation signIn (
142
142
  ${signInFragments}
143
143
  `;
144
144
 
145
- export const signInWithGoogleMtn = gql`
146
- mutation signInWithGoogle (
147
- $oauthToken: String!
148
- ) {
149
- signInWithGoogle (
150
- oauthToken: $oauthToken
151
- ) {
152
- ${signInResultText}
153
- }
154
- }
155
- ${signInFragments}
156
- `;
157
-
158
145
  export const signInWithDiscordMtn = gql`
159
146
  mutation signInWithDiscord (
160
147
  $oauthToken: String!
@@ -168,21 +155,6 @@ mutation signInWithDiscord (
168
155
  ${signInFragments}
169
156
  `;
170
157
 
171
- export const signInWithAppleMtn = gql`
172
- mutation signInWithApple (
173
- $code: String!
174
- $idToken: String!
175
- ) {
176
- signInWithApple (
177
- code: $code
178
- idToken: $idToken
179
- ) {
180
- ${signInResultText}
181
- }
182
- }
183
- ${signInFragments}
184
- `;
185
-
186
158
  export const changePasswordMtn = gql`
187
159
  mutation changePassword (
188
160
  $currentPassword: String!
@@ -1,4 +1,5 @@
1
1
  import { gql } from 'graphql-tag';
2
+ import { accountFragment } from '../fragments/accountFragments';
2
3
  import { journalEntryFragment } from '../fragments/journalFragments';
3
4
 
4
5
  export const journalEntriesQry = gql`
@@ -15,8 +16,13 @@ query journalEntries (
15
16
  limit: $limit
16
17
  ) {
17
18
  ...journalEntryFragment
19
+
20
+ account {
21
+ ...accountFragment
22
+ }
18
23
  }
19
24
  }
20
25
 
26
+ ${accountFragment}
21
27
  ${journalEntryFragment}
22
28
  `;
@@ -1,10 +1,11 @@
1
1
  import i18n from '@jsb188/app/i18n';
2
2
  import { useMutation } from './index';
3
- import { changePasswordMtn, checkUsernameOrEmailMtn, emailVerificationStatusMtn, requestTokenizedEmailMtn, sendEmailVerificationMtn, signInMtn } from '../gql/mutations/userAuthMutations';
4
3
  import type { UseMutationParams } from '@jsb188/graphql/types.d';
5
- import { useOpenModalPopUp, type OpenModalPopUpFn } from '@jsb188/react/states';
6
- import { useContext, useState } from 'react';
7
- import appContext, { onAccountLogin } from '~/shared/states/appContext';
4
+ import { deleteAuthToken } from '@jsb188/app/platform';
5
+ import { changePasswordMtn, checkUsernameOrEmailMtn, emailVerificationStatusMtn, requestTokenizedEmailMtn, sendEmailVerificationMtn, signInMtn, signUpMtn, signOutMtn } from '../gql/mutations/userAuthMutations';
6
+ import type { OpenModalPopUpFn } from '@jsb188/react/states';
7
+ import { AppContext, onAccountLogin, onGuestInit, useOpenModalPopUp } from '@jsb188/react/states';
8
+ import React, { useEffect, useContext, useState } from 'react';
8
9
 
9
10
  /**
10
11
  * Types
@@ -21,7 +22,7 @@ interface SignInParams extends UseMutationParams {
21
22
 
22
23
  export function useChangePassword(params: UseMutationParams = {}) {
23
24
 
24
- const { dispatchApp, appState: { hasPassword, account } } = useContext(appContext);
25
+ const { dispatchApp, appState: { hasPassword, account } } = useContext(AppContext);
25
26
  const openModalPopUp = useOpenModalPopUp();
26
27
  const { onCompleted, onError } = params;
27
28
 
@@ -75,7 +76,7 @@ export function useChangePassword(params: UseMutationParams = {}) {
75
76
 
76
77
  export function useChangePasswordForm(params: UseMutationParams = {}) {
77
78
 
78
- const { dispatchApp, appState: { hasPassword, account } } = useContext(appContext);
79
+ const { dispatchApp, appState: { hasPassword, account } } = useContext(AppContext);
79
80
  const { onCompleted, onError } = params;
80
81
 
81
82
  const onCompleted_ = (data: any, err: any, variables: any) => {
@@ -176,7 +177,7 @@ export function useRequestTokenizedEmail(params: UseMutationParams = {}, openMod
176
177
 
177
178
  export function useSignIn(params: SignInParams = {}, openModalPopUp?: OpenModalPopUpFn) {
178
179
  const { onError, onCompleted, initialError, initialFormData } = params;
179
- const { dispatchApp } = useContext<any>(appContext);
180
+ const { dispatchApp } = useContext<any>(AppContext);
180
181
 
181
182
  const [dataForSchema, setDataForSchema] = useState({
182
183
  hasInput: !!initialFormData?.usernameOrEmail,
@@ -232,3 +233,90 @@ export function useSignIn(params: SignInParams = {}, openModalPopUp?: OpenModalP
232
233
  setDataForSchema,
233
234
  };
234
235
  }
236
+
237
+ // Before are deprecated HOC that needs to be migrated to hooks
238
+ // Before are deprecated HOC that needs to be migrated to hooks
239
+ // Before are deprecated HOC that needs to be migrated to hooks
240
+ // Before are deprecated HOC that needs to be migrated to hooks
241
+ // Before are deprecated HOC that needs to be migrated to hooks
242
+
243
+ /**
244
+ * Sign up
245
+ */
246
+
247
+ export function composeSignUp(Cmp: React.FC<any>) {
248
+ const SignUpCnt = (p) => {
249
+ const { doNotAlertErrors, onError, onCompleted } = p;
250
+ const openModalPopUp = useOpenModalPopUp();
251
+
252
+ const [signUp, mtnValues, mtnHandlers] = useMutation(
253
+ signUpMtn,
254
+ {
255
+ openModalPopUp: doNotAlertErrors ? null : openModalPopUp,
256
+ onError,
257
+ onCompleted,
258
+ },
259
+ );
260
+
261
+ // return (
262
+ // <Cmp
263
+ // {...p}
264
+ // {...mtnValues}
265
+ // {...mtnHandlers}
266
+ // signUp={signUp}
267
+ // />
268
+ // );
269
+
270
+ return 'This page is not done yet.'
271
+ };
272
+
273
+ return SignUpCnt;
274
+ }
275
+
276
+ /**
277
+ * Sign out
278
+ */
279
+
280
+ export function composeSignOut(Cmp: React.FC<any>) {
281
+ const SignOutCnt = (p) => {
282
+ const { doNotAlertErrors, onError, onCompleted } = p;
283
+ const openModalPopUp = useOpenModalPopUp();
284
+ const { dispatchApp } = useContext<any>(AppContext);
285
+
286
+ const [signOut, mtnValues, mtnHandlers] = useMutation(
287
+ signOutMtn,
288
+ {
289
+ openModalPopUp: doNotAlertErrors ? null : openModalPopUp,
290
+ onError,
291
+ onCompleted: (data) => {
292
+ if (data?.signOut) {
293
+ deleteAuthToken();
294
+ onGuestInit(null, dispatchApp);
295
+ }
296
+ if (onCompleted) {
297
+ onCompleted(data);
298
+ }
299
+ },
300
+ },
301
+ );
302
+
303
+ useEffect(() => {
304
+ const timer = setTimeout(() => {
305
+ signOut();
306
+ }, 1000);
307
+ return () => clearTimeout(timer);
308
+ }, []);
309
+
310
+ // return (
311
+ // <Cmp
312
+ // {...p}
313
+ // {...mtnValues}
314
+ // {...mtnHandlers}
315
+ // signOut={signOut}
316
+ // />
317
+ // );
318
+ return null;
319
+ };
320
+
321
+ return SignOutCnt;
322
+ }
@@ -1,6 +1,7 @@
1
1
  import type { PaginationArgs, UseQueryParams } from '../types.d';
2
2
  import { useQuery } from '../client';
3
3
  import { journalEntriesQry } from '../gql/queries/journalQueries';
4
+ import type { FilterJournalEntriesArgs } from '@jsb188/app/types/journal.d';
4
5
 
5
6
  /**
6
7
  * Constants
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@jsb188/graphql",
3
- "version": "1.1.1",
3
+ "version": "1.1.3",
4
4
  "description": "GraphQL client for react, using recoil",
5
5
  "license": "ISC",
6
6
  "author": "jsb188",
@@ -55,7 +55,7 @@
55
55
  "graphql-tag": "^2.12.6"
56
56
  },
57
57
  "peerDependencies": {
58
- "@jsb188/app": "1.1.1",
59
- "@jsb188/react": "1.1.1"
58
+ "@jsb188/app": "1.1.3",
59
+ "@jsb188/react": "1.1.3"
60
60
  }
61
61
  }