@jsb188/graphql 1.1.3 → 1.1.4
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 +1 -0
- package/cache/index.ts +32 -9
- package/gql/fragments/logFragments.ts +26 -0
- package/gql/fragments/organizationFragments.ts +1 -0
- package/gql/mutations/{accountAuthMutations.ts → authMutations.ts} +27 -0
- package/gql/mutations/userAuthMutations.ts +0 -59
- package/gql/queries/logQueries.ts +37 -0
- package/hooks/index.ts +1 -1
- package/hooks/use-aiChat-qry.ts +1 -1
- package/hooks/use-auth-mtn.ts +29 -70
- package/hooks/use-log-qry.ts +55 -0
- package/package.json +8 -8
- package/gql/fragments/journalFragments.ts +0 -14
- package/gql/queries/journalQueries.ts +0 -28
- package/hooks/use-journal-qry.ts +0 -50
- /package/gql/mutations/{journalMutations.ts → logMutations.ts} +0 -0
package/cache/config.ts
CHANGED
package/cache/index.ts
CHANGED
|
@@ -167,10 +167,13 @@ export function loadFragment(id: string) {
|
|
|
167
167
|
|
|
168
168
|
function mapSelections(data: any, innerSelections: any[], updatedKeys: string[] = []) {
|
|
169
169
|
return innerSelections.map((inner) => {
|
|
170
|
+
|
|
171
|
+
let fragmentKey;
|
|
170
172
|
if (inner.kind === 'FragmentSpread') {
|
|
173
|
+
// These are fragment spreads
|
|
171
174
|
const frgName = inner.name.value;
|
|
172
175
|
const frgMap = PARTIALS_MAP[frgName];
|
|
173
|
-
|
|
176
|
+
fragmentKey = `$${frgMap || frgName}:${data.id || 'none'}`;
|
|
174
177
|
|
|
175
178
|
if (DO_LOG[0]) {
|
|
176
179
|
console.log('SETTING (1): ', fragmentKey);
|
|
@@ -178,11 +181,13 @@ function mapSelections(data: any, innerSelections: any[], updatedKeys: string[]
|
|
|
178
181
|
if (DO_LOG[1]) {
|
|
179
182
|
console.log('SETTING (1): ', extractFragment(data, innerSelections));
|
|
180
183
|
}
|
|
184
|
+
} else if (inner.kind === 'InlineFragment') {
|
|
185
|
+
// This is Union, etc
|
|
186
|
+
const frgNamesJoined = inner.selectionSet.selections.map((sel: any) => PARTIALS_MAP[sel.name.value] || sel.name.value).join('.');
|
|
187
|
+
fragmentKey = `$${frgNamesJoined}:${data.id || 'none'}`;
|
|
188
|
+
}
|
|
181
189
|
|
|
182
|
-
|
|
183
|
-
// console.log('---->', data.id);
|
|
184
|
-
// }
|
|
185
|
-
|
|
190
|
+
if (fragmentKey) {
|
|
186
191
|
// Whether fragment is partial or not, always merge data;
|
|
187
192
|
// Because partials might have data that's not in the main fragment
|
|
188
193
|
const currentData = loadFragment(fragmentKey);
|
|
@@ -194,7 +199,11 @@ function mapSelections(data: any, innerSelections: any[], updatedKeys: string[]
|
|
|
194
199
|
return fragmentKey;
|
|
195
200
|
}
|
|
196
201
|
|
|
197
|
-
|
|
202
|
+
// These are non-fragment fields
|
|
203
|
+
return [
|
|
204
|
+
inner.name.value,
|
|
205
|
+
data?.[inner.name.value]
|
|
206
|
+
];
|
|
198
207
|
// return {
|
|
199
208
|
// name: inner.name.value,
|
|
200
209
|
// value: data[key]?.[inner.name.value]
|
|
@@ -427,7 +436,7 @@ export function setDataToCache(
|
|
|
427
436
|
* Append fragment to cache
|
|
428
437
|
*/
|
|
429
438
|
|
|
430
|
-
export function appendFragmentToCache(cacheData: any) {
|
|
439
|
+
export function appendFragmentToCache(cacheData: any, testMode?: boolean) {
|
|
431
440
|
let newObj = cloneArrayLike(cacheData);
|
|
432
441
|
|
|
433
442
|
for (const key in newObj) {
|
|
@@ -442,7 +451,6 @@ export function appendFragmentToCache(cacheData: any) {
|
|
|
442
451
|
let item = {};
|
|
443
452
|
di.forEach((d) => {
|
|
444
453
|
if (Array.isArray(d)) {
|
|
445
|
-
// @ts-expect-error
|
|
446
454
|
item[d[0]] = d[1];
|
|
447
455
|
} else if (typeof d === 'string') {
|
|
448
456
|
const frgIndex = d.indexOf(':');
|
|
@@ -480,8 +488,15 @@ export function appendFragmentToCache(cacheData: any) {
|
|
|
480
488
|
});
|
|
481
489
|
} else {
|
|
482
490
|
newObj[key].data.forEach((d: any) => {
|
|
491
|
+
|
|
492
|
+
|
|
493
|
+
// if (testMode) {
|
|
494
|
+
// console.log('cachedObj', cachedObj);
|
|
495
|
+
// console.log('d', d);
|
|
496
|
+
// console.log('d', typeof d);
|
|
497
|
+
// }
|
|
498
|
+
|
|
483
499
|
if (Array.isArray(d)) {
|
|
484
|
-
// @ts-expect-error
|
|
485
500
|
cachedObj[d[0]] = d[1];
|
|
486
501
|
} else if (typeof d === 'string') {
|
|
487
502
|
const frgIndex = d.indexOf(':');
|
|
@@ -552,6 +567,14 @@ export function loadDataFromCache(
|
|
|
552
567
|
const data = { ...requestData };
|
|
553
568
|
const definitions = gqlQuery.definitions;
|
|
554
569
|
|
|
570
|
+
|
|
571
|
+
// console.log('loadDataFromCache()');
|
|
572
|
+
// console.log(data);
|
|
573
|
+
// console.log(definitions);
|
|
574
|
+
|
|
575
|
+
|
|
576
|
+
|
|
577
|
+
|
|
555
578
|
for (const def of definitions) {
|
|
556
579
|
if (def.kind === 'OperationDefinition') {
|
|
557
580
|
def?.selectionSet?.selections.forEach((selection: any) => {
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
|
|
2
|
+
export const logEntryFragment = `fragment logEntryFragment on LogEntry {
|
|
3
|
+
id
|
|
4
|
+
accountId
|
|
5
|
+
organizationId
|
|
6
|
+
|
|
7
|
+
createdAt
|
|
8
|
+
updatedAt
|
|
9
|
+
}`;
|
|
10
|
+
|
|
11
|
+
export const logEntryArableFragment = `fragment logEntryArableFragment on LogEntryArable {
|
|
12
|
+
__typename
|
|
13
|
+
|
|
14
|
+
id
|
|
15
|
+
type
|
|
16
|
+
activity
|
|
17
|
+
quantity
|
|
18
|
+
unit
|
|
19
|
+
price
|
|
20
|
+
notes
|
|
21
|
+
|
|
22
|
+
crop {
|
|
23
|
+
id
|
|
24
|
+
name
|
|
25
|
+
}
|
|
26
|
+
}`;
|
|
@@ -52,6 +52,33 @@ mutation authenticateWithToken (
|
|
|
52
52
|
${authenticateFragments}
|
|
53
53
|
`;
|
|
54
54
|
|
|
55
|
+
export const sendEmailVerificationMtn = gql`
|
|
56
|
+
mutation sendEmailVerification (
|
|
57
|
+
$userId: UserID!
|
|
58
|
+
$email: String!
|
|
59
|
+
) {
|
|
60
|
+
sendEmailVerification (
|
|
61
|
+
userId: $userId
|
|
62
|
+
email: $email
|
|
63
|
+
) {
|
|
64
|
+
token
|
|
65
|
+
userId
|
|
66
|
+
username
|
|
67
|
+
emailAddress
|
|
68
|
+
}
|
|
69
|
+
}`;
|
|
70
|
+
|
|
71
|
+
export const signUpWithEmailMtn = gql`
|
|
72
|
+
mutation signUpWithEmail (
|
|
73
|
+
$emailAddress: String!
|
|
74
|
+
$password: String!
|
|
75
|
+
) {
|
|
76
|
+
signUpWithEmail (
|
|
77
|
+
emailAddress: $emailAddress
|
|
78
|
+
password: $password
|
|
79
|
+
)
|
|
80
|
+
}`;
|
|
81
|
+
|
|
55
82
|
export const signInWithGoogleMtn = gql`
|
|
56
83
|
mutation signInWithGoogle (
|
|
57
84
|
$oauthToken: String!
|
|
@@ -63,52 +63,6 @@ mutation checkUsernameOrEmail (
|
|
|
63
63
|
}
|
|
64
64
|
}`;
|
|
65
65
|
|
|
66
|
-
export const emailVerificationStatusMtn = gql`
|
|
67
|
-
mutation emailVerificationStatus (
|
|
68
|
-
$token: Token!
|
|
69
|
-
) {
|
|
70
|
-
emailVerificationStatus (
|
|
71
|
-
token: $token
|
|
72
|
-
)
|
|
73
|
-
}`;
|
|
74
|
-
|
|
75
|
-
export const sendEmailVerificationMtn = gql`
|
|
76
|
-
mutation sendEmailVerification (
|
|
77
|
-
$userId: UserID!
|
|
78
|
-
$email: String!
|
|
79
|
-
) {
|
|
80
|
-
sendEmailVerification (
|
|
81
|
-
userId: $userId
|
|
82
|
-
email: $email
|
|
83
|
-
) {
|
|
84
|
-
token
|
|
85
|
-
userId
|
|
86
|
-
username
|
|
87
|
-
emailAddress
|
|
88
|
-
}
|
|
89
|
-
}`;
|
|
90
|
-
|
|
91
|
-
export const signUpMtn = gql`
|
|
92
|
-
mutation signUp (
|
|
93
|
-
$email: String!
|
|
94
|
-
$displayName: String!
|
|
95
|
-
$username: String!
|
|
96
|
-
$password: String!
|
|
97
|
-
) {
|
|
98
|
-
signUp (
|
|
99
|
-
email: $email
|
|
100
|
-
displayName: $displayName
|
|
101
|
-
username: $username
|
|
102
|
-
password: $password
|
|
103
|
-
) {
|
|
104
|
-
token
|
|
105
|
-
userId
|
|
106
|
-
username
|
|
107
|
-
emailAddress
|
|
108
|
-
}
|
|
109
|
-
}
|
|
110
|
-
`;
|
|
111
|
-
|
|
112
66
|
export const signOutMtn = gql`
|
|
113
67
|
mutation signOut {
|
|
114
68
|
signOut
|
|
@@ -142,19 +96,6 @@ mutation signIn (
|
|
|
142
96
|
${signInFragments}
|
|
143
97
|
`;
|
|
144
98
|
|
|
145
|
-
export const signInWithDiscordMtn = gql`
|
|
146
|
-
mutation signInWithDiscord (
|
|
147
|
-
$oauthToken: String!
|
|
148
|
-
) {
|
|
149
|
-
signInWithDiscord (
|
|
150
|
-
oauthToken: $oauthToken
|
|
151
|
-
) {
|
|
152
|
-
${signInResultText}
|
|
153
|
-
}
|
|
154
|
-
}
|
|
155
|
-
${signInFragments}
|
|
156
|
-
`;
|
|
157
|
-
|
|
158
99
|
export const changePasswordMtn = gql`
|
|
159
100
|
mutation changePassword (
|
|
160
101
|
$currentPassword: String!
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import { gql } from 'graphql-tag';
|
|
2
|
+
import { accountFragment } from '../fragments/accountFragments';
|
|
3
|
+
import { logEntryFragment, logEntryArableFragment } from '../fragments/logFragments';
|
|
4
|
+
|
|
5
|
+
export const logEntriesQry = gql`
|
|
6
|
+
query logEntries (
|
|
7
|
+
$organizationId: GenericID!
|
|
8
|
+
$filter: LogEntriesFilter!
|
|
9
|
+
$cursor: Cursor
|
|
10
|
+
$after: Boolean!
|
|
11
|
+
$limit: Int!
|
|
12
|
+
) {
|
|
13
|
+
logEntries (
|
|
14
|
+
organizationId: $organizationId
|
|
15
|
+
filter: $filter
|
|
16
|
+
cursor: $cursor
|
|
17
|
+
after: $after
|
|
18
|
+
limit: $limit
|
|
19
|
+
) {
|
|
20
|
+
...logEntryFragment
|
|
21
|
+
|
|
22
|
+
details {
|
|
23
|
+
...on LogEntryArable {
|
|
24
|
+
...logEntryArableFragment
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
account {
|
|
29
|
+
...accountFragment
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
${accountFragment}
|
|
35
|
+
${logEntryFragment}
|
|
36
|
+
${logEntryArableFragment}
|
|
37
|
+
`;
|
package/hooks/index.ts
CHANGED
package/hooks/use-aiChat-qry.ts
CHANGED
|
@@ -142,7 +142,7 @@ export function useAIChatMessages(aiChatId?: string, params: UseQueryParams = {}
|
|
|
142
142
|
* Fetch AI chats list
|
|
143
143
|
*/
|
|
144
144
|
|
|
145
|
-
export function useAIChats(filter?: 'CAL_DATE') {
|
|
145
|
+
export function useAIChats(filter?: 'CAL_DATE' | 'CHATS') {
|
|
146
146
|
const { data, ...other } = useQuery(aiChatsQry, {
|
|
147
147
|
variables: {
|
|
148
148
|
filter,
|
package/hooks/use-auth-mtn.ts
CHANGED
|
@@ -1,17 +1,18 @@
|
|
|
1
1
|
import i18n from '@jsb188/app/i18n';
|
|
2
|
-
import { useMutation } from './index';
|
|
3
|
-
import type { UseMutationParams } from '@jsb188/graphql/types.d';
|
|
4
2
|
import { deleteAuthToken } from '@jsb188/app/platform';
|
|
5
|
-
import {
|
|
3
|
+
import type { UseMutationParams } from '@jsb188/graphql/types.d';
|
|
6
4
|
import type { OpenModalPopUpFn } from '@jsb188/react/states';
|
|
7
5
|
import { AppContext, onAccountLogin, onGuestInit, useOpenModalPopUp } from '@jsb188/react/states';
|
|
8
|
-
import React, {
|
|
6
|
+
import React, { useContext, useEffect, useState } from 'react';
|
|
7
|
+
import { sendEmailVerificationMtn, signUpWithEmailMtn } from '../gql/mutations/authMutations';
|
|
8
|
+
import { changePasswordMtn, checkUsernameOrEmailMtn, requestTokenizedEmailMtn, signInMtn, signOutMtn } from '../gql/mutations/userAuthMutations';
|
|
9
|
+
import { useMutation } from './index';
|
|
9
10
|
|
|
10
11
|
/**
|
|
11
12
|
* Types
|
|
12
13
|
*/
|
|
13
14
|
|
|
14
|
-
interface
|
|
15
|
+
interface AuthHookParams extends UseMutationParams {
|
|
15
16
|
initialError?: any;
|
|
16
17
|
initialFormData?: Record<string, any>;
|
|
17
18
|
}
|
|
@@ -115,39 +116,6 @@ export function useChangePasswordForm(params: UseMutationParams = {}) {
|
|
|
115
116
|
};
|
|
116
117
|
}
|
|
117
118
|
|
|
118
|
-
/**
|
|
119
|
-
* Check email verification status
|
|
120
|
-
*/
|
|
121
|
-
|
|
122
|
-
export function useEmailVerification(params: UseMutationParams = {}, openModalPopUp?: OpenModalPopUpFn) {
|
|
123
|
-
|
|
124
|
-
const { onCompleted, onError } = params;
|
|
125
|
-
const [emailVerificationStatus, mtnValues1] = useMutation(
|
|
126
|
-
emailVerificationStatusMtn,
|
|
127
|
-
{
|
|
128
|
-
openModalPopUp,
|
|
129
|
-
onError,
|
|
130
|
-
onCompleted,
|
|
131
|
-
},
|
|
132
|
-
);
|
|
133
|
-
|
|
134
|
-
const [sendEmailVerification, mtnValues2] = useMutation(
|
|
135
|
-
sendEmailVerificationMtn,
|
|
136
|
-
{
|
|
137
|
-
openModalPopUp,
|
|
138
|
-
onError,
|
|
139
|
-
onCompleted,
|
|
140
|
-
},
|
|
141
|
-
);
|
|
142
|
-
|
|
143
|
-
return {
|
|
144
|
-
emailVerificationStatus,
|
|
145
|
-
sendEmailVerification,
|
|
146
|
-
verifying: mtnValues1.saving,
|
|
147
|
-
sending: mtnValues2.saving,
|
|
148
|
-
};
|
|
149
|
-
}
|
|
150
|
-
|
|
151
119
|
/**
|
|
152
120
|
* Request password reset (email with link)
|
|
153
121
|
*/
|
|
@@ -175,7 +143,7 @@ export function useRequestTokenizedEmail(params: UseMutationParams = {}, openMod
|
|
|
175
143
|
* Sign in
|
|
176
144
|
*/
|
|
177
145
|
|
|
178
|
-
export function useSignIn(params:
|
|
146
|
+
export function useSignIn(params: AuthHookParams = {}, openModalPopUp?: OpenModalPopUpFn) {
|
|
179
147
|
const { onError, onCompleted, initialError, initialFormData } = params;
|
|
180
148
|
const { dispatchApp } = useContext<any>(AppContext);
|
|
181
149
|
|
|
@@ -234,45 +202,36 @@ export function useSignIn(params: SignInParams = {}, openModalPopUp?: OpenModalP
|
|
|
234
202
|
};
|
|
235
203
|
}
|
|
236
204
|
|
|
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
205
|
/**
|
|
244
|
-
* Sign up
|
|
206
|
+
* Sign up with email
|
|
245
207
|
*/
|
|
246
208
|
|
|
247
|
-
export function
|
|
248
|
-
const
|
|
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
|
-
);
|
|
209
|
+
export function useSignUpWithEmail(params: AuthHookParams = {}, openModalPopUp?: OpenModalPopUpFn) {
|
|
210
|
+
const { onError, onCompleted, initialError } = params;
|
|
260
211
|
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
212
|
+
const [signUpWithEmail, mtnValues, mtnHandlers] = useMutation(
|
|
213
|
+
signUpWithEmailMtn,
|
|
214
|
+
{
|
|
215
|
+
openModalPopUp,
|
|
216
|
+
initialError,
|
|
217
|
+
onError,
|
|
218
|
+
onCompleted,
|
|
219
|
+
},
|
|
220
|
+
);
|
|
269
221
|
|
|
270
|
-
|
|
222
|
+
return {
|
|
223
|
+
...mtnValues,
|
|
224
|
+
...mtnHandlers,
|
|
225
|
+
signUpWithEmail,
|
|
271
226
|
};
|
|
272
|
-
|
|
273
|
-
return SignUpCnt;
|
|
274
227
|
}
|
|
275
228
|
|
|
229
|
+
// Before are deprecated HOC that needs to be migrated to hooks
|
|
230
|
+
// Before are deprecated HOC that needs to be migrated to hooks
|
|
231
|
+
// Before are deprecated HOC that needs to be migrated to hooks
|
|
232
|
+
// Before are deprecated HOC that needs to be migrated to hooks
|
|
233
|
+
// Before are deprecated HOC that needs to be migrated to hooks
|
|
234
|
+
|
|
276
235
|
/**
|
|
277
236
|
* Sign out
|
|
278
237
|
*/
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
import type { PaginationArgs, UseQueryParams } from '../types';
|
|
2
|
+
import { useQuery } from '../client';
|
|
3
|
+
import { logEntriesQry } from '../gql/queries/logQueries';
|
|
4
|
+
import type { FilterLogEntriesArgs } from '@jsb188/app/types/log.d';
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* Constants
|
|
8
|
+
*/
|
|
9
|
+
|
|
10
|
+
const LOG_ENTRIES_LIMIT = 50;
|
|
11
|
+
|
|
12
|
+
/**
|
|
13
|
+
* Helper; use this to get/use same filter for logEntries() query everywhere
|
|
14
|
+
*/
|
|
15
|
+
|
|
16
|
+
export function getDefaultLogEntriesFilter(operation: FilterLogEntriesArgs['operation']): FilterLogEntriesArgs {
|
|
17
|
+
return {
|
|
18
|
+
operation,
|
|
19
|
+
type: null,
|
|
20
|
+
startDate: null,
|
|
21
|
+
endDate: null,
|
|
22
|
+
query: ''
|
|
23
|
+
};
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
/**
|
|
27
|
+
* Fetch log entries
|
|
28
|
+
*/
|
|
29
|
+
|
|
30
|
+
interface LogEntriesArgs extends PaginationArgs {
|
|
31
|
+
organizationId: string;
|
|
32
|
+
accountId?: string;
|
|
33
|
+
timeZone: string | null;
|
|
34
|
+
filter: FilterLogEntriesArgs;
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
export function useLogEntries(variables: LogEntriesArgs, params: UseQueryParams = {}) {
|
|
38
|
+
|
|
39
|
+
const { data, ...other } = useQuery(logEntriesQry, {
|
|
40
|
+
variables: {
|
|
41
|
+
...variables,
|
|
42
|
+
cursor: null,
|
|
43
|
+
after: true,
|
|
44
|
+
limit: LOG_ENTRIES_LIMIT
|
|
45
|
+
},
|
|
46
|
+
// If this query is used for virtualized list pagination, set {params.skip=true}
|
|
47
|
+
skip: !variables.organizationId || !variables.filter?.operation,
|
|
48
|
+
...params,
|
|
49
|
+
});
|
|
50
|
+
|
|
51
|
+
return {
|
|
52
|
+
logEntries: data?.logEntries,
|
|
53
|
+
...other
|
|
54
|
+
};
|
|
55
|
+
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@jsb188/graphql",
|
|
3
|
-
"version": "1.1.
|
|
3
|
+
"version": "1.1.4",
|
|
4
4
|
"description": "GraphQL client for react, using recoil",
|
|
5
5
|
"license": "ISC",
|
|
6
6
|
"author": "jsb188",
|
|
@@ -13,7 +13,7 @@
|
|
|
13
13
|
"./fragments/billing": "./gql/fragments/billingFragments.ts",
|
|
14
14
|
"./fragments/card": "./gql/fragments/cardFragments.ts",
|
|
15
15
|
"./fragments/chat": "./gql/fragments/chatFragments.ts",
|
|
16
|
-
"./fragments/
|
|
16
|
+
"./fragments/log": "./gql/fragments/logFragments.ts",
|
|
17
17
|
"./fragments/organization": "./gql/fragments/organizationFragments.ts",
|
|
18
18
|
"./fragments/other": "./gql/fragments/otherFragments.ts",
|
|
19
19
|
"./fragments/user": "./gql/fragments/userFragments.ts",
|
|
@@ -21,14 +21,14 @@
|
|
|
21
21
|
"./hooks": "./hooks/",
|
|
22
22
|
"./hooks/use-aiChat-qry": "./hooks/use-aiChat-qry.ts",
|
|
23
23
|
"./hooks/use-app-qry": "./hooks/use-app-qry.ts",
|
|
24
|
-
"./hooks/use-
|
|
24
|
+
"./hooks/use-log-qry": "./hooks/use-log-qry.ts",
|
|
25
25
|
"./hooks/use-organization-qry": "./hooks/use-organization-qry.ts",
|
|
26
26
|
"./hooks/use-auth-mtn": "./hooks/use-auth-mtn.ts",
|
|
27
|
-
"./mutations/accountAuth": "./gql/mutations/accountAuthMutations.ts",
|
|
28
27
|
"./mutations/aiChat": "./gql/mutations/aiChatMutations.ts",
|
|
28
|
+
"./mutations/auth": "./gql/mutations/authMutations.ts",
|
|
29
29
|
"./mutations/billing": "./gql/mutations/billingMutations.ts",
|
|
30
30
|
"./mutations/chat": "./gql/mutations/chatMutations.ts",
|
|
31
|
-
"./mutations/
|
|
31
|
+
"./mutations/log": "./gql/mutations/logMutations.ts",
|
|
32
32
|
"./mutations/other": "./gql/mutations/otherMutations.ts",
|
|
33
33
|
"./mutations/user": "./gql/mutations/userMutations.ts",
|
|
34
34
|
"./mutations/userAuth": "./gql/mutations/userAuthMutations.ts",
|
|
@@ -37,7 +37,7 @@
|
|
|
37
37
|
"./queries/billing": "./gql/queries/billingQueries.ts",
|
|
38
38
|
"./queries/card": "./gql/queries/cardQueries.ts",
|
|
39
39
|
"./queries/chat": "./gql/queries/chatQueries.ts",
|
|
40
|
-
"./queries/
|
|
40
|
+
"./queries/log": "./gql/queries/logQueries.ts",
|
|
41
41
|
"./queries/organization": "./gql/queries/organizationQueries.ts",
|
|
42
42
|
"./queries/other": "./gql/queries/otherQueries.ts",
|
|
43
43
|
"./queries/user": "./gql/queries/userQueries.ts",
|
|
@@ -55,7 +55,7 @@
|
|
|
55
55
|
"graphql-tag": "^2.12.6"
|
|
56
56
|
},
|
|
57
57
|
"peerDependencies": {
|
|
58
|
-
"@jsb188/app": "1.1.
|
|
59
|
-
"@jsb188/react": "1.1.
|
|
58
|
+
"@jsb188/app": "1.1.4",
|
|
59
|
+
"@jsb188/react": "1.1.4"
|
|
60
60
|
}
|
|
61
61
|
}
|
|
@@ -1,28 +0,0 @@
|
|
|
1
|
-
import { gql } from 'graphql-tag';
|
|
2
|
-
import { accountFragment } from '../fragments/accountFragments';
|
|
3
|
-
import { journalEntryFragment } from '../fragments/journalFragments';
|
|
4
|
-
|
|
5
|
-
export const journalEntriesQry = gql`
|
|
6
|
-
query journalEntries (
|
|
7
|
-
$organizationId: GenericID!
|
|
8
|
-
$cursor: Cursor
|
|
9
|
-
$after: Boolean!
|
|
10
|
-
$limit: Int!
|
|
11
|
-
) {
|
|
12
|
-
journalEntries (
|
|
13
|
-
organizationId: $organizationId
|
|
14
|
-
cursor: $cursor
|
|
15
|
-
after: $after
|
|
16
|
-
limit: $limit
|
|
17
|
-
) {
|
|
18
|
-
...journalEntryFragment
|
|
19
|
-
|
|
20
|
-
account {
|
|
21
|
-
...accountFragment
|
|
22
|
-
}
|
|
23
|
-
}
|
|
24
|
-
}
|
|
25
|
-
|
|
26
|
-
${accountFragment}
|
|
27
|
-
${journalEntryFragment}
|
|
28
|
-
`;
|
package/hooks/use-journal-qry.ts
DELETED
|
@@ -1,50 +0,0 @@
|
|
|
1
|
-
import type { PaginationArgs, UseQueryParams } from '../types.d';
|
|
2
|
-
import { useQuery } from '../client';
|
|
3
|
-
import { journalEntriesQry } from '../gql/queries/journalQueries';
|
|
4
|
-
import type { FilterJournalEntriesArgs } from '@jsb188/app/types/journal.d';
|
|
5
|
-
|
|
6
|
-
/**
|
|
7
|
-
* Constants
|
|
8
|
-
*/
|
|
9
|
-
|
|
10
|
-
const JOURNAL_ENTRIES_LIMIT = 50;
|
|
11
|
-
|
|
12
|
-
/**
|
|
13
|
-
* Types
|
|
14
|
-
*/
|
|
15
|
-
|
|
16
|
-
interface JournalEntriesVariables {
|
|
17
|
-
organizationId?: string;
|
|
18
|
-
accountId?: string;
|
|
19
|
-
}
|
|
20
|
-
|
|
21
|
-
interface JournalEntriesArgs extends PaginationArgs {
|
|
22
|
-
organizationId: string;
|
|
23
|
-
accountId?: string;
|
|
24
|
-
timeZone: string | null;
|
|
25
|
-
filter: FilterJournalEntriesArgs;
|
|
26
|
-
}
|
|
27
|
-
|
|
28
|
-
/**
|
|
29
|
-
* Fetch journal entries
|
|
30
|
-
*/
|
|
31
|
-
|
|
32
|
-
export function useJournalEntries(variables: JournalEntriesArgs, params: UseQueryParams = {}) {
|
|
33
|
-
|
|
34
|
-
const { data, ...other } = useQuery(journalEntriesQry, {
|
|
35
|
-
variables: {
|
|
36
|
-
...variables,
|
|
37
|
-
cursor: null,
|
|
38
|
-
after: true,
|
|
39
|
-
limit: JOURNAL_ENTRIES_LIMIT
|
|
40
|
-
},
|
|
41
|
-
// If this query is used for virtualized list pagination, set {params.skip=true}
|
|
42
|
-
skip: !variables.organizationId,
|
|
43
|
-
...params,
|
|
44
|
-
});
|
|
45
|
-
|
|
46
|
-
return {
|
|
47
|
-
journalEntries: data?.journalEntries,
|
|
48
|
-
...other
|
|
49
|
-
};
|
|
50
|
-
}
|
|
File without changes
|