@jsb188/graphql 1.1.10 → 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 +64 -50
- package/cache/index.test.ts +671 -109
- package/cache/index.ts +1700 -1240
- 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 +2 -0
- 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 +954 -163
- package/client/sse-ticket.test.ts +26 -0
- package/deno.lock +170 -0
- package/deno.test.json +8 -4
- 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 +0 -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 +16 -0
- package/gql/fragments/billingFragments.ts +0 -11
- package/gql/fragments/campaignFragments.ts +277 -0
- package/gql/fragments/dataTableFragments.ts +18 -128
- package/gql/fragments/emailFragments.ts +19 -9
- package/gql/fragments/fieldDocFragments.ts +82 -0
- package/gql/fragments/logFragments.ts +20 -79
- package/gql/fragments/organizationFragments.ts +43 -5
- package/gql/fragments/scheduleFragments.ts +155 -0
- package/gql/fragments/sheetFragments.ts +552 -22
- package/gql/fragments/storageFragments.ts +21 -0
- package/gql/fragments/workflowFragments.ts +28 -4
- package/gql/mutations/accountMutations.ts +0 -2
- package/gql/mutations/agentDocMutations.ts +177 -0
- package/gql/mutations/agentMemoryMutations.ts +36 -0
- package/gql/mutations/aiChatMutations.ts +17 -4
- package/gql/mutations/authMutations.ts +158 -17
- package/gql/mutations/campaignMutations.ts +215 -0
- package/gql/mutations/dataTableMutations.ts +48 -26
- package/gql/mutations/fieldDocMutations.ts +24 -0
- package/gql/mutations/index.ts +6 -1
- package/gql/mutations/logMutations.ts +6 -29
- package/gql/mutations/organizationMutations.ts +13 -4
- package/gql/mutations/scheduleMutations.ts +423 -0
- package/gql/mutations/sheetMutations.ts +273 -56
- package/gql/mutations/storageMutations.ts +20 -0
- 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 +23 -0
- package/gql/queries/campaignQueries.ts +127 -0
- package/gql/queries/dataTableQueries.ts +100 -11
- package/gql/queries/emailQueries.ts +55 -3
- package/gql/queries/fieldDocQueries.ts +158 -0
- package/gql/queries/index.ts +8 -2
- package/gql/queries/logQueries.ts +11 -28
- package/gql/queries/organizationQueries.ts +52 -1
- package/gql/queries/scheduleQueries.ts +315 -0
- package/gql/queries/sheetQueries.ts +336 -25
- package/gql/queries/storageQueries.ts +38 -0
- package/gql/queries/workflowQueries.ts +72 -3
- package/hooks/index.ts +2065 -971
- package/hooks/use-account-mtn.ts +76 -81
- 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 +232 -137
- package/hooks/use-aiChat-qry.ts +480 -222
- package/hooks/use-app-qry.ts +12 -9
- package/hooks/use-auth-mtn.ts +406 -252
- 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 +116 -33
- package/hooks/use-dataTable-qry.ts +859 -35
- package/hooks/use-email-qry.ts +194 -79
- package/hooks/use-fieldDoc-mtn.ts +50 -0
- package/hooks/use-fieldDoc-qry.ts +180 -0
- package/hooks/use-inboundContact-mtn.ts +19 -16
- package/hooks/use-inboundContact-qry.ts +63 -55
- package/hooks/use-integration-mtn.ts +56 -38
- package/hooks/use-integration-qry.ts +24 -9
- package/hooks/use-log-mtn.ts +72 -56
- package/hooks/use-log-qry.ts +93 -69
- package/hooks/use-organization-mtn.ts +334 -277
- package/hooks/use-organization-qry.ts +199 -129
- package/hooks/use-schedule-mtn.ts +416 -0
- package/hooks/use-schedule-qry.ts +157 -0
- package/hooks/use-sheet-mtn.ts +233 -47
- package/hooks/use-sheet-qry.ts +353 -70
- package/hooks/use-storage-mtn.ts +81 -41
- package/hooks/use-storage-qry.ts +104 -13
- package/hooks/use-workflow-mtn.ts +55 -0
- package/hooks/use-workflow-qry.ts +206 -48
- package/loaders/campaign.ts +137 -0
- package/package.json +94 -71
- package/sse.ts +157 -104
- package/tsconfig.json +11 -10
- package/types.d.ts +60 -30
- package/utils.ts +78 -49
- package/gql/fragments/productFragments.ts +0 -39
- package/gql/fragments/reportFragments.ts +0 -90
- package/gql/mutations/billingMutations.ts +0 -34
- package/gql/queries/productQueries.ts +0 -31
- package/gql/queries/reportQueries.ts +0 -134
- package/hooks/use-product-qry.ts +0 -67
- package/hooks/use-report-qry.ts +0 -153
package/hooks/use-email-qry.ts
CHANGED
|
@@ -1,32 +1,69 @@
|
|
|
1
1
|
import { useQuery, useReactiveFragment } from '@jsb188/graphql/client';
|
|
2
|
-
import type {
|
|
3
|
-
|
|
4
|
-
|
|
2
|
+
import type {
|
|
3
|
+
InboundEmailGQL,
|
|
4
|
+
InboundEmailsSortEnum,
|
|
5
|
+
OutboundEmailGQL,
|
|
6
|
+
OutboundEmailsSortEnum,
|
|
7
|
+
} from '@jsb188/mday/types/email.d.ts';
|
|
8
|
+
import {
|
|
9
|
+
inboundEmailQry,
|
|
10
|
+
inboundEmailsQry,
|
|
11
|
+
outboundEmailQry,
|
|
12
|
+
outboundEmailsQry,
|
|
13
|
+
} from '../gql/queries/emailQueries.ts';
|
|
5
14
|
import type { PaginationArgs, UseQueryParams } from '../types.d.ts';
|
|
6
15
|
|
|
7
16
|
/**
|
|
8
17
|
* Constants
|
|
9
18
|
*/
|
|
10
19
|
|
|
11
|
-
const
|
|
20
|
+
const EMAILS_LIST_LIMIT = 250;
|
|
21
|
+
|
|
22
|
+
type EmailListFilter =
|
|
23
|
+
| {
|
|
24
|
+
startDate?: string | null;
|
|
25
|
+
endDate?: string | null;
|
|
26
|
+
query?: string | null;
|
|
27
|
+
statuses?: string[] | null;
|
|
28
|
+
}
|
|
29
|
+
| null
|
|
30
|
+
| undefined;
|
|
12
31
|
|
|
13
32
|
/**
|
|
14
|
-
* Keep
|
|
33
|
+
* Keep email list filters aligned with the GraphQL input shape.
|
|
15
34
|
*/
|
|
16
|
-
function
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
35
|
+
function normalizeEmailsFilter(filter?: EmailListFilter) {
|
|
36
|
+
return filter
|
|
37
|
+
? {
|
|
38
|
+
startDate: filter.startDate || null,
|
|
39
|
+
endDate: filter.endDate || null,
|
|
40
|
+
query: filter.query || null,
|
|
41
|
+
statuses: filter.statuses || null,
|
|
42
|
+
}
|
|
43
|
+
: null;
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
/**
|
|
47
|
+
* Return true when one email record should be fetched from the server.
|
|
48
|
+
*/
|
|
49
|
+
function shouldFetchEmailRecord(
|
|
50
|
+
variables: {
|
|
51
|
+
organizationId?: string | null;
|
|
52
|
+
},
|
|
53
|
+
emailId?: string | null,
|
|
54
|
+
cachedEmail?: InboundEmailGQL | OutboundEmailGQL | null,
|
|
55
|
+
params: UseQueryParams = {},
|
|
56
|
+
) {
|
|
57
|
+
return (
|
|
58
|
+
!!variables.organizationId && !!emailId && !cachedEmail && !params.skip
|
|
59
|
+
);
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
/**
|
|
63
|
+
* Return one email fragment cache key.
|
|
64
|
+
*/
|
|
65
|
+
function getEmailFragmentKey(fragmentName: string, emailId: string) {
|
|
66
|
+
return `$${fragmentName}:${emailId}`;
|
|
30
67
|
}
|
|
31
68
|
|
|
32
69
|
/*
|
|
@@ -34,32 +71,33 @@ function normalizeInboundEmailsFilter(filter?: {
|
|
|
34
71
|
*/
|
|
35
72
|
|
|
36
73
|
export function useInboundEmail(
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
74
|
+
variables: {
|
|
75
|
+
organizationId?: string | null;
|
|
76
|
+
inboundEmailId?: string | null;
|
|
77
|
+
},
|
|
78
|
+
params: UseQueryParams = {},
|
|
42
79
|
) {
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
80
|
+
const cachedInboundEmail = useReactiveInboundEmailFragment(
|
|
81
|
+
variables.inboundEmailId || '',
|
|
82
|
+
null,
|
|
83
|
+
);
|
|
84
|
+
const shouldFetchInboundEmail = shouldFetchEmailRecord(
|
|
85
|
+
variables,
|
|
86
|
+
variables.inboundEmailId,
|
|
87
|
+
cachedInboundEmail,
|
|
88
|
+
params,
|
|
89
|
+
);
|
|
90
|
+
const { data, ...rest } = useQuery(inboundEmailQry, {
|
|
91
|
+
...params,
|
|
92
|
+
variables,
|
|
93
|
+
skip: !shouldFetchInboundEmail,
|
|
94
|
+
});
|
|
95
|
+
|
|
96
|
+
return {
|
|
97
|
+
inboundEmail: cachedInboundEmail || data?.inboundEmail,
|
|
98
|
+
initialLoading: shouldFetchInboundEmail && !data,
|
|
99
|
+
...rest,
|
|
100
|
+
};
|
|
63
101
|
}
|
|
64
102
|
|
|
65
103
|
/**
|
|
@@ -67,46 +105,123 @@ export function useInboundEmail(
|
|
|
67
105
|
*/
|
|
68
106
|
|
|
69
107
|
export function useInboundEmails(
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
statuses?: string[] | null;
|
|
77
|
-
} | null;
|
|
78
|
-
sort?: InboundEmailsSortEnum | null;
|
|
79
|
-
},
|
|
80
|
-
params: UseQueryParams = {},
|
|
108
|
+
variables: PaginationArgs & {
|
|
109
|
+
organizationId?: string | null;
|
|
110
|
+
filter?: EmailListFilter;
|
|
111
|
+
sort?: InboundEmailsSortEnum | null;
|
|
112
|
+
},
|
|
113
|
+
params: UseQueryParams = {},
|
|
81
114
|
) {
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
115
|
+
const { data, ...rest } = useQuery(inboundEmailsQry, {
|
|
116
|
+
...params,
|
|
117
|
+
variables: {
|
|
118
|
+
...variables,
|
|
119
|
+
filter: normalizeEmailsFilter(variables.filter),
|
|
120
|
+
cursor: null,
|
|
121
|
+
after: true,
|
|
122
|
+
limit: EMAILS_LIST_LIMIT,
|
|
123
|
+
},
|
|
124
|
+
skip: !variables.organizationId || params.skip,
|
|
125
|
+
});
|
|
126
|
+
|
|
127
|
+
return {
|
|
128
|
+
inboundEmails: data?.inboundEmails,
|
|
129
|
+
...rest,
|
|
130
|
+
};
|
|
131
|
+
}
|
|
132
|
+
|
|
133
|
+
/*
|
|
134
|
+
* Fetch one outbound email.
|
|
135
|
+
*/
|
|
136
|
+
|
|
137
|
+
export function useOutboundEmail(
|
|
138
|
+
variables: {
|
|
139
|
+
organizationId?: string | null;
|
|
140
|
+
outboundEmailId?: string | null;
|
|
141
|
+
},
|
|
142
|
+
params: UseQueryParams = {},
|
|
143
|
+
) {
|
|
144
|
+
const cachedOutboundEmail = useReactiveOutboundEmailFragment(
|
|
145
|
+
variables.outboundEmailId || '',
|
|
146
|
+
null,
|
|
147
|
+
);
|
|
148
|
+
const shouldFetchOutboundEmail = shouldFetchEmailRecord(
|
|
149
|
+
variables,
|
|
150
|
+
variables.outboundEmailId,
|
|
151
|
+
cachedOutboundEmail,
|
|
152
|
+
params,
|
|
153
|
+
);
|
|
154
|
+
const { data, ...rest } = useQuery(outboundEmailQry, {
|
|
155
|
+
...params,
|
|
156
|
+
variables,
|
|
157
|
+
skip: !shouldFetchOutboundEmail,
|
|
158
|
+
});
|
|
159
|
+
|
|
160
|
+
return {
|
|
161
|
+
outboundEmail: cachedOutboundEmail || data?.outboundEmail,
|
|
162
|
+
initialLoading: shouldFetchOutboundEmail && !data,
|
|
163
|
+
...rest,
|
|
164
|
+
};
|
|
165
|
+
}
|
|
166
|
+
|
|
167
|
+
/**
|
|
168
|
+
* Fetch outbound emails.
|
|
169
|
+
*/
|
|
170
|
+
|
|
171
|
+
export function useOutboundEmails(
|
|
172
|
+
variables: PaginationArgs & {
|
|
173
|
+
organizationId?: string | null;
|
|
174
|
+
filter?: EmailListFilter;
|
|
175
|
+
sort?: OutboundEmailsSortEnum | null;
|
|
176
|
+
},
|
|
177
|
+
params: UseQueryParams = {},
|
|
178
|
+
) {
|
|
179
|
+
const { data, ...rest } = useQuery(outboundEmailsQry, {
|
|
180
|
+
...params,
|
|
181
|
+
variables: {
|
|
182
|
+
...variables,
|
|
183
|
+
filter: normalizeEmailsFilter(variables.filter),
|
|
184
|
+
cursor: null,
|
|
185
|
+
after: true,
|
|
186
|
+
limit: EMAILS_LIST_LIMIT,
|
|
187
|
+
},
|
|
188
|
+
skip: !variables.organizationId || params.skip,
|
|
189
|
+
});
|
|
190
|
+
|
|
191
|
+
return {
|
|
192
|
+
outboundEmails: data?.outboundEmails,
|
|
193
|
+
...rest,
|
|
194
|
+
};
|
|
98
195
|
}
|
|
99
196
|
|
|
100
197
|
/**
|
|
101
198
|
* Get reactive inbound email fragment.
|
|
102
199
|
*/
|
|
103
200
|
|
|
104
|
-
export function useReactiveInboundEmailFragment(
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
201
|
+
export function useReactiveInboundEmailFragment(
|
|
202
|
+
inboundEmailId: string,
|
|
203
|
+
currentData?: any,
|
|
204
|
+
queryCount?: number,
|
|
205
|
+
) {
|
|
206
|
+
return useReactiveFragment(
|
|
207
|
+
currentData,
|
|
208
|
+
[getEmailFragmentKey('inboundEmailFragment', inboundEmailId)],
|
|
209
|
+
queryCount,
|
|
210
|
+
);
|
|
211
|
+
}
|
|
212
|
+
|
|
213
|
+
/**
|
|
214
|
+
* Get reactive outbound email fragment.
|
|
215
|
+
*/
|
|
216
|
+
|
|
217
|
+
export function useReactiveOutboundEmailFragment(
|
|
218
|
+
outboundEmailId: string,
|
|
219
|
+
currentData?: any,
|
|
220
|
+
queryCount?: number,
|
|
221
|
+
) {
|
|
222
|
+
return useReactiveFragment(
|
|
223
|
+
currentData,
|
|
224
|
+
[getEmailFragmentKey('outboundEmailFragment', outboundEmailId)],
|
|
225
|
+
queryCount,
|
|
226
|
+
);
|
|
112
227
|
}
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
import type { UseMutationParams } from '@jsb188/graphql/types.d';
|
|
2
|
+
import type { OpenModalPopUpFn } from '@jsb188/react/states';
|
|
3
|
+
import {
|
|
4
|
+
FRAGMENT_NAMES,
|
|
5
|
+
makeFragmentKey,
|
|
6
|
+
} from '@jsb188/mday/constants/graphqlReactivity.ts';
|
|
7
|
+
import { updateFragment } from '../cache/index.ts';
|
|
8
|
+
import { editFieldDocAgentHintMtn } from '../gql/mutations/fieldDocMutations.ts';
|
|
9
|
+
import { useMutation } from './index.ts';
|
|
10
|
+
|
|
11
|
+
/*
|
|
12
|
+
* Edit one fieldDoc's agent-only matching hint.
|
|
13
|
+
*/
|
|
14
|
+
|
|
15
|
+
export function useEditFieldDocAgentHint(
|
|
16
|
+
params: UseMutationParams = {},
|
|
17
|
+
openModalPopUp?: OpenModalPopUpFn,
|
|
18
|
+
) {
|
|
19
|
+
const { onCompleted, ...rest } = params;
|
|
20
|
+
|
|
21
|
+
const [editFieldDocAgentHint, mtnValues, mtnHandlers, updateObservers] =
|
|
22
|
+
useMutation(editFieldDocAgentHintMtn, {
|
|
23
|
+
openModalPopUp,
|
|
24
|
+
onCompleted: (data, error, variables) => {
|
|
25
|
+
const updatedFieldDoc = data?.editFieldDocAgentHint;
|
|
26
|
+
|
|
27
|
+
if (updatedFieldDoc?.id) {
|
|
28
|
+
// The reset-only realtime emit reaches every socket, but the issuer
|
|
29
|
+
// refreshes its own cached fragment here for an instant update
|
|
30
|
+
updateFragment(
|
|
31
|
+
makeFragmentKey(FRAGMENT_NAMES.fieldDoc, updatedFieldDoc.id),
|
|
32
|
+
updatedFieldDoc,
|
|
33
|
+
null,
|
|
34
|
+
false,
|
|
35
|
+
updateObservers,
|
|
36
|
+
);
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
onCompleted?.(updatedFieldDoc, error, variables);
|
|
40
|
+
},
|
|
41
|
+
...rest,
|
|
42
|
+
});
|
|
43
|
+
|
|
44
|
+
return {
|
|
45
|
+
editFieldDocAgentHint,
|
|
46
|
+
updateObservers,
|
|
47
|
+
...mtnValues,
|
|
48
|
+
...mtnHandlers,
|
|
49
|
+
};
|
|
50
|
+
}
|
|
@@ -0,0 +1,180 @@
|
|
|
1
|
+
import type {
|
|
2
|
+
FieldDocsFilterArgs,
|
|
3
|
+
FieldDocsSortEnum,
|
|
4
|
+
} from '@jsb188/mday/types/fieldDoc.d.ts';
|
|
5
|
+
import {
|
|
6
|
+
FRAGMENT_NAMES,
|
|
7
|
+
getFragmentBaseName,
|
|
8
|
+
makeFragmentKey,
|
|
9
|
+
} from '@jsb188/mday/constants/graphqlReactivity.ts';
|
|
10
|
+
import {
|
|
11
|
+
useQuery,
|
|
12
|
+
useReactiveFragment,
|
|
13
|
+
useReactiveFragmentMap,
|
|
14
|
+
} from '../client/index.ts';
|
|
15
|
+
import {
|
|
16
|
+
fieldDocGroupsQry,
|
|
17
|
+
fieldDocQry,
|
|
18
|
+
fieldDocsQry,
|
|
19
|
+
fieldDocSubmissionsQry,
|
|
20
|
+
} from '../gql/queries/fieldDocQueries.ts';
|
|
21
|
+
import type { UseQueryParams } from '../types.d.ts';
|
|
22
|
+
|
|
23
|
+
/**
|
|
24
|
+
* Get reactive fieldDoc fragment
|
|
25
|
+
*/
|
|
26
|
+
|
|
27
|
+
export function useReactiveFieldDocFragment(
|
|
28
|
+
fieldDocId: string,
|
|
29
|
+
currentData?: any,
|
|
30
|
+
queryCount?: number,
|
|
31
|
+
) {
|
|
32
|
+
return useReactiveFragment(
|
|
33
|
+
currentData,
|
|
34
|
+
[makeFragmentKey(FRAGMENT_NAMES.fieldDoc, fieldDocId)],
|
|
35
|
+
queryCount,
|
|
36
|
+
);
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
/**
|
|
40
|
+
* Get reactive fieldDoc submission fragment
|
|
41
|
+
*/
|
|
42
|
+
|
|
43
|
+
export function useReactiveFieldDocSubmissionFragment(
|
|
44
|
+
fieldDocSubmissionId: string,
|
|
45
|
+
currentData?: any,
|
|
46
|
+
queryCount?: number,
|
|
47
|
+
) {
|
|
48
|
+
return useReactiveFragment(
|
|
49
|
+
currentData,
|
|
50
|
+
[makeFragmentKey(FRAGMENT_NAMES.fieldDocSubmission, fieldDocSubmissionId)],
|
|
51
|
+
queryCount,
|
|
52
|
+
);
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
/**
|
|
56
|
+
* Get reactive fieldDoc element fragments for a list of fieldDoc elements.
|
|
57
|
+
*/
|
|
58
|
+
|
|
59
|
+
export function useReactiveFieldDocElementFragmentMap(
|
|
60
|
+
currentData?: any[] | null,
|
|
61
|
+
) {
|
|
62
|
+
return useReactiveFragmentMap(
|
|
63
|
+
currentData || null,
|
|
64
|
+
getFragmentBaseName(FRAGMENT_NAMES.fieldDocElementData),
|
|
65
|
+
);
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
/**
|
|
69
|
+
* Fetch list of fieldDocs by type and period
|
|
70
|
+
*/
|
|
71
|
+
|
|
72
|
+
export function useFieldDocs(
|
|
73
|
+
variables: {
|
|
74
|
+
organizationId: string;
|
|
75
|
+
filter: FieldDocsFilterArgs;
|
|
76
|
+
sort?: FieldDocsSortEnum;
|
|
77
|
+
},
|
|
78
|
+
params: UseQueryParams = {},
|
|
79
|
+
) {
|
|
80
|
+
const { organizationId, filter } = variables;
|
|
81
|
+
const { skip, ...restParams } = params;
|
|
82
|
+
const { data, ...rest } = useQuery(fieldDocsQry, {
|
|
83
|
+
variables,
|
|
84
|
+
skip:
|
|
85
|
+
skip ||
|
|
86
|
+
!organizationId ||
|
|
87
|
+
!filter?.fieldDocGroupId ||
|
|
88
|
+
!(filter?.startPeriod || filter?.endPeriod),
|
|
89
|
+
...restParams,
|
|
90
|
+
});
|
|
91
|
+
|
|
92
|
+
return {
|
|
93
|
+
fieldDocs: data?.fieldDocs,
|
|
94
|
+
...rest,
|
|
95
|
+
};
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
/**
|
|
99
|
+
* Fetch one fieldDoc by fieldDoc source id
|
|
100
|
+
*/
|
|
101
|
+
|
|
102
|
+
export function useFieldDoc(
|
|
103
|
+
organizationId: string | null,
|
|
104
|
+
fieldDocSourceId: string | null,
|
|
105
|
+
params: UseQueryParams = {},
|
|
106
|
+
) {
|
|
107
|
+
const { skip, ...restParams } = params;
|
|
108
|
+
const { data, ...rest } = useQuery(fieldDocQry, {
|
|
109
|
+
variables: {
|
|
110
|
+
organizationId,
|
|
111
|
+
fieldDocSourceId,
|
|
112
|
+
},
|
|
113
|
+
skip: skip || !organizationId || !fieldDocSourceId,
|
|
114
|
+
...restParams,
|
|
115
|
+
});
|
|
116
|
+
|
|
117
|
+
return {
|
|
118
|
+
fieldDoc: data?.fieldDoc,
|
|
119
|
+
...rest,
|
|
120
|
+
};
|
|
121
|
+
}
|
|
122
|
+
|
|
123
|
+
/**
|
|
124
|
+
* Fetch list of fieldDoc groups for organization
|
|
125
|
+
*/
|
|
126
|
+
|
|
127
|
+
export function useFieldDocGroups(
|
|
128
|
+
organizationId: string | null,
|
|
129
|
+
params: UseQueryParams = {},
|
|
130
|
+
) {
|
|
131
|
+
const { skip, ...restParams } = params;
|
|
132
|
+
const { data, ...rest } = useQuery(fieldDocGroupsQry, {
|
|
133
|
+
variables: {
|
|
134
|
+
organizationId,
|
|
135
|
+
},
|
|
136
|
+
skip: skip || !organizationId,
|
|
137
|
+
...restParams,
|
|
138
|
+
});
|
|
139
|
+
|
|
140
|
+
return {
|
|
141
|
+
fieldDocGroups: data?.fieldDocGroups,
|
|
142
|
+
...rest,
|
|
143
|
+
};
|
|
144
|
+
}
|
|
145
|
+
|
|
146
|
+
/**
|
|
147
|
+
* Fetch list of fieldDoc submissions for organization
|
|
148
|
+
*/
|
|
149
|
+
|
|
150
|
+
export function useFieldDocSubmissions(
|
|
151
|
+
variables: {
|
|
152
|
+
organizationId: string | null;
|
|
153
|
+
filter: FieldDocsFilterArgs;
|
|
154
|
+
sort?: FieldDocsSortEnum;
|
|
155
|
+
limit?: number;
|
|
156
|
+
},
|
|
157
|
+
params: UseQueryParams = {},
|
|
158
|
+
) {
|
|
159
|
+
const {
|
|
160
|
+
organizationId,
|
|
161
|
+
filter,
|
|
162
|
+
sort = 'PERIOD_DESC',
|
|
163
|
+
limit = 100,
|
|
164
|
+
} = variables;
|
|
165
|
+
const { skip, ...restParams } = params;
|
|
166
|
+
const { data, ...rest } = useQuery(fieldDocSubmissionsQry, {
|
|
167
|
+
variables: {
|
|
168
|
+
...variables,
|
|
169
|
+
sort,
|
|
170
|
+
limit,
|
|
171
|
+
},
|
|
172
|
+
skip: skip || !organizationId || !filter,
|
|
173
|
+
...restParams,
|
|
174
|
+
});
|
|
175
|
+
|
|
176
|
+
return {
|
|
177
|
+
fieldDocSubmissions: data?.fieldDocSubmissions,
|
|
178
|
+
...rest,
|
|
179
|
+
};
|
|
180
|
+
}
|
|
@@ -8,24 +8,27 @@ import { useMutation } from './index.ts';
|
|
|
8
8
|
*/
|
|
9
9
|
|
|
10
10
|
export function useEditInboundContact(
|
|
11
|
-
|
|
12
|
-
|
|
11
|
+
params: UseMutationParams = {},
|
|
12
|
+
openModalPopUp?: OpenModalPopUpFn,
|
|
13
13
|
) {
|
|
14
|
-
|
|
14
|
+
const { onCompleted, ...rest } = params;
|
|
15
15
|
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
16
|
+
const [editInboundContact, mtnValues, mtnHandlers] = useMutation(
|
|
17
|
+
editInboundContactMtn,
|
|
18
|
+
{
|
|
19
|
+
openModalPopUp,
|
|
20
|
+
onCompleted: (data, error, variables) => {
|
|
21
|
+
const updatedInboundContact = data?.editInboundContact;
|
|
20
22
|
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
23
|
+
onCompleted?.(updatedInboundContact, error, variables);
|
|
24
|
+
},
|
|
25
|
+
...rest,
|
|
26
|
+
},
|
|
27
|
+
);
|
|
25
28
|
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
29
|
+
return {
|
|
30
|
+
editInboundContact,
|
|
31
|
+
...mtnValues,
|
|
32
|
+
...mtnHandlers,
|
|
33
|
+
};
|
|
31
34
|
}
|