@jsb188/graphql 1.1.10 → 1.1.12
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/audience.d.ts +343 -0
- package/cache/config.ts +98 -50
- package/cache/index.chat-activity.test.ts +119 -0
- package/cache/index.chat.test.ts +92 -0
- package/cache/index.helpers.ts +96 -0
- package/cache/index.regression.test.ts +149 -0
- package/cache/index.test.ts +1017 -127
- package/cache/index.ts +1256 -1269
- package/cache/optimistic-ui-runtime.ts +46 -0
- package/cache/optimistic-ui.ts +401 -0
- package/cache/persist.ts +800 -0
- package/cache/store.ts +395 -0
- package/cache/value.helpers.ts +17 -0
- package/client/draft-persistence-indexed-db.ts +413 -0
- package/client/draft-persistence.ts +152 -0
- package/client/index.ts +3 -0
- package/client/request.helpers.ts +14 -0
- package/client/request.ts +870 -164
- package/deno.lock +187 -0
- package/deno.test.json +10 -4
- 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/agentMemoryFragments.ts +23 -0
- package/gql/fragments/agentNoteFragments.ts +150 -0
- package/gql/fragments/aiChatFragments.ts +42 -0
- package/gql/fragments/audienceFragments.ts +141 -0
- package/gql/fragments/campaignFragments.ts +566 -0
- package/gql/fragments/dataTableFragments.ts +50 -192
- package/gql/fragments/emailFragments.ts +32 -17
- package/gql/fragments/fieldDocFragments.ts +264 -0
- package/gql/fragments/inboundContactFragments.ts +2 -0
- package/gql/fragments/logFragments.ts +101 -69
- package/gql/fragments/organizationFragments.ts +53 -5
- package/gql/fragments/qrCodeFragments.ts +29 -0
- package/gql/fragments/scheduleFragments.ts +667 -0
- package/gql/fragments/sheetFragments.ts +304 -63
- package/gql/fragments/storageFragments.ts +45 -0
- package/gql/fragments/workflowFragments.ts +41 -5
- package/gql/mutations/accountMutations.ts +0 -2
- package/gql/mutations/agentMemoryMutations.ts +68 -0
- package/gql/mutations/agentNoteMutations.ts +62 -0
- package/gql/mutations/aiChatMutations.ts +49 -4
- package/gql/mutations/audienceMutations.ts +71 -0
- package/gql/mutations/authMutations.ts +203 -18
- package/gql/mutations/billingMutations.ts +17 -27
- package/gql/mutations/campaignMutations.ts +258 -0
- package/gql/mutations/contactMutations.ts +23 -0
- package/gql/mutations/dataTableMutations.ts +19 -54
- package/gql/mutations/fieldDocMutations.ts +173 -0
- package/gql/mutations/index.ts +10 -2
- package/gql/mutations/logMutations.ts +6 -29
- package/gql/mutations/organizationMutations.ts +19 -4
- package/gql/mutations/qrCodeMutations.ts +20 -0
- package/gql/mutations/scheduleMutations.ts +1121 -0
- package/gql/mutations/sheetMutations.ts +221 -60
- package/gql/mutations/storageMutations.ts +19 -0
- package/gql/mutations/workflowMutations.ts +60 -0
- package/gql/queries/agentMemoryQueries.ts +28 -0
- package/gql/queries/agentNoteQueries.ts +89 -0
- package/gql/queries/aiChatQueries.ts +70 -2
- package/gql/queries/audienceQueries.ts +128 -0
- package/gql/queries/authQueries.ts +47 -0
- package/gql/queries/billingQueries.ts +118 -6
- package/gql/queries/campaignQueries.ts +236 -0
- package/gql/queries/dataTableQueries.ts +61 -13
- package/gql/queries/emailQueries.ts +26 -17
- package/gql/queries/emailReplyReportQueries.ts +76 -0
- package/gql/queries/fieldDocQueries.ts +166 -0
- package/gql/queries/inboundContactQueries.ts +4 -0
- package/gql/queries/index.ts +10 -2
- package/gql/queries/logQueries.ts +68 -30
- package/gql/queries/organizationQueries.ts +65 -1
- package/gql/queries/qrCodeQueries.ts +20 -0
- package/gql/queries/scheduleQueries.ts +691 -0
- package/gql/queries/sheetQueries.ts +244 -26
- package/gql/queries/storageQueries.ts +38 -0
- package/gql/queries/workflowQueries.ts +77 -2
- package/hooks/index.helpers.test.ts +50 -0
- package/hooks/index.helpers.ts +52 -0
- package/hooks/index.ts +2254 -982
- package/hooks/use-account-mtn.ts +76 -81
- package/hooks/use-agentMemory-mtn.ts +71 -0
- package/hooks/use-agentMemory-qry.ts +56 -0
- package/hooks/use-agentNote-mtn.ts +82 -0
- package/hooks/use-agentNote-qry.ts +190 -0
- package/hooks/use-agentNote-recovery.helpers.test.ts +68 -0
- package/hooks/use-agentNote-recovery.helpers.ts +58 -0
- package/hooks/use-agentNote-recovery.ts +72 -0
- package/hooks/use-aiChat-mtn.ts +220 -141
- package/hooks/use-aiChat-qry.helpers.test.ts +63 -0
- package/hooks/use-aiChat-qry.helpers.ts +124 -0
- package/hooks/use-aiChat-qry.ts +341 -237
- package/hooks/use-aiChat-stream-mtn.ts +14 -0
- package/hooks/use-app-qry.ts +12 -9
- package/hooks/use-audience-mtn.ts +194 -0
- package/hooks/use-audience-qry.helpers.test.ts +80 -0
- package/hooks/use-audience-qry.helpers.ts +63 -0
- package/hooks/use-audience-qry.ts +330 -0
- package/hooks/use-auth-mtn.ts +435 -252
- package/hooks/use-auth-qry.ts +51 -0
- package/hooks/use-billing-mtn.ts +31 -0
- package/hooks/use-billing-qry.ts +76 -0
- package/hooks/use-campaign-generation-recovery.ts +53 -0
- package/hooks/use-campaign-mtn.ts +436 -0
- package/hooks/use-campaign-qry.helpers.ts +40 -0
- package/hooks/use-campaign-qry.ts +834 -0
- package/hooks/use-dataTable-mtn.ts +37 -46
- package/hooks/use-dataTable-qry.ts +102 -128
- package/hooks/use-email-qry.helpers.ts +37 -0
- package/hooks/use-email-qry.ts +56 -86
- package/hooks/use-emailCampaignReplyReport-qry.ts +27 -0
- package/hooks/use-fieldDoc-mtn.ts +262 -0
- package/hooks/use-fieldDoc-qry.helpers.test.ts +65 -0
- package/hooks/use-fieldDoc-qry.helpers.ts +49 -0
- package/hooks/use-fieldDoc-qry.ts +212 -0
- package/hooks/use-inboundContact-mtn.ts +19 -16
- package/hooks/use-inboundContact-qry.ts +62 -56
- package/hooks/use-integration-mtn.ts +56 -38
- package/hooks/use-integration-qry.ts +24 -9
- package/hooks/use-log-mtn.ts +88 -59
- package/hooks/use-log-qry.ts +150 -73
- package/hooks/use-organization-mtn.ts +334 -277
- package/hooks/use-organization-qry.ts +155 -129
- package/hooks/use-publicFormEmail-mtn.ts +27 -0
- package/hooks/use-qrCode-mtn.ts +40 -0
- package/hooks/use-qrCode-qry.ts +78 -0
- package/hooks/use-schedule-mtn.ts +589 -0
- package/hooks/use-schedule-qry.ts +738 -0
- package/hooks/use-schedule-reactive.ts +486 -0
- package/hooks/use-sheet-mtn.ts +157 -79
- package/hooks/use-sheet-qry.ts +221 -92
- package/hooks/use-storage-mtn.ts +81 -41
- package/hooks/use-storage-qry.ts +128 -14
- package/hooks/use-workflow-mtn.ts +72 -0
- package/hooks/use-workflow-qry.ts +184 -47
- package/libs/ai-chat-outgoing.helpers.ts +153 -0
- package/libs/ai-chat-outgoing.ts +11 -0
- package/libs/ai-chat-outgoing.types.ts +25 -0
- package/libs/ai-chat-run-realtime.ts +20 -0
- package/libs/ai-chat-submission-realtime.ts +150 -0
- package/libs/fragment-realtime-sequence.ts +55 -0
- package/libs/fragment-recovery.test.ts +326 -0
- package/libs/fragment-recovery.ts +325 -0
- package/libs/open-sheet.ts +138 -0
- package/libs/orchestrator-realtime.helpers.test.ts +229 -0
- package/libs/orchestrator-realtime.helpers.ts +317 -0
- package/libs/orchestrator-realtime.ts +433 -0
- package/libs/request-cache-regression.test.ts +122 -0
- package/libs/request-managed-session.test.ts +574 -0
- package/libs/request-no-store.test.ts +419 -0
- package/libs/sheet-command-batch.ts +44 -0
- package/libs/sheet-view-realtime-router.test.ts +214 -0
- package/libs/sheet-view-realtime-router.ts +99 -0
- package/libs/sse-ticket.test.ts +26 -0
- package/loaders/campaign.test.ts +186 -0
- package/loaders/campaign.ts +110 -0
- package/loaders/emailPreference.ts +75 -0
- package/loaders/rest.ts +12 -0
- package/package.json +119 -71
- package/schedule.d.ts +1790 -0
- package/sse.helpers.ts +19 -0
- package/sse.ts +70 -106
- package/tests/agent-note-detail-cache.test.ts +120 -0
- package/tests/agent-note-search.test.ts +444 -0
- package/tsconfig.json +11 -10
- package/types.d.ts +77 -26
- package/utils.ts +78 -49
- package/gql/fragments/billingFragments.ts +0 -25
- package/gql/fragments/productFragments.ts +0 -39
- package/gql/fragments/reportFragments.ts +0 -90
- 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
|
@@ -1,7 +1,13 @@
|
|
|
1
1
|
import { useQuery, useReactiveFragment } from '@jsb188/graphql/client';
|
|
2
|
-
import
|
|
3
|
-
|
|
4
|
-
|
|
2
|
+
import {
|
|
3
|
+
FRAGMENT_NAMES,
|
|
4
|
+
makeFragmentKey,
|
|
5
|
+
} from '@jsb188/mday/constants/graphqlReactivity.ts';
|
|
6
|
+
import type { InboundContactsQueryArgs } from '@jsb188/mday/types/inboundContact.d.ts';
|
|
7
|
+
import {
|
|
8
|
+
inboundContactQry,
|
|
9
|
+
inboundContactsQry,
|
|
10
|
+
} from '../gql/queries/inboundContactQueries.ts';
|
|
5
11
|
import type { PaginationArgs, UseQueryParams } from '../types.d.ts';
|
|
6
12
|
|
|
7
13
|
/**
|
|
@@ -15,32 +21,32 @@ const INBOUND_CONTACTS_LIMIT = 250;
|
|
|
15
21
|
*/
|
|
16
22
|
|
|
17
23
|
export function useInboundContact(
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
24
|
+
variables: {
|
|
25
|
+
organizationId?: string | null;
|
|
26
|
+
inboundContactId?: string | null;
|
|
27
|
+
},
|
|
28
|
+
params: UseQueryParams = {},
|
|
23
29
|
) {
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
30
|
+
const cachedInboundContact = useReactiveInboundContactFragment(
|
|
31
|
+
variables.inboundContactId || '',
|
|
32
|
+
null,
|
|
33
|
+
);
|
|
34
|
+
const shouldFetchInboundContact =
|
|
35
|
+
!!variables.organizationId &&
|
|
36
|
+
!!variables.inboundContactId &&
|
|
37
|
+
!cachedInboundContact &&
|
|
38
|
+
!params.skip;
|
|
39
|
+
const { data, ...rest } = useQuery(inboundContactQry, {
|
|
40
|
+
...params,
|
|
41
|
+
variables,
|
|
42
|
+
skip: !shouldFetchInboundContact,
|
|
43
|
+
});
|
|
38
44
|
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
45
|
+
return {
|
|
46
|
+
inboundContact: cachedInboundContact || data?.inboundContact,
|
|
47
|
+
initialLoading: shouldFetchInboundContact && !data,
|
|
48
|
+
...rest,
|
|
49
|
+
};
|
|
44
50
|
}
|
|
45
51
|
|
|
46
52
|
/**
|
|
@@ -48,41 +54,41 @@ export function useInboundContact(
|
|
|
48
54
|
*/
|
|
49
55
|
|
|
50
56
|
export function useInboundContacts(
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
params: UseQueryParams = {},
|
|
57
|
+
variables: PaginationArgs &
|
|
58
|
+
InboundContactsQueryArgs & {
|
|
59
|
+
organizationId?: string | null;
|
|
60
|
+
},
|
|
61
|
+
params: UseQueryParams = {},
|
|
57
62
|
) {
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
});
|
|
63
|
+
const { data, ...rest } = useQuery(inboundContactsQry, {
|
|
64
|
+
...params,
|
|
65
|
+
variables: {
|
|
66
|
+
...variables,
|
|
67
|
+
cursor: null,
|
|
68
|
+
after: true,
|
|
69
|
+
limit: variables.limit ?? INBOUND_CONTACTS_LIMIT,
|
|
70
|
+
},
|
|
71
|
+
skip: !variables.organizationId || params.skip,
|
|
72
|
+
});
|
|
69
73
|
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
+
return {
|
|
75
|
+
inboundContacts: data?.inboundContacts,
|
|
76
|
+
...rest,
|
|
77
|
+
};
|
|
74
78
|
}
|
|
75
79
|
|
|
76
80
|
/**
|
|
77
81
|
* Get reactive inbound contact fragment.
|
|
78
82
|
*/
|
|
79
83
|
|
|
80
|
-
export function useReactiveInboundContactFragment(
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
84
|
+
export function useReactiveInboundContactFragment(
|
|
85
|
+
inboundContactId: string,
|
|
86
|
+
currentData?: any,
|
|
87
|
+
queryCount?: number,
|
|
88
|
+
) {
|
|
89
|
+
return useReactiveFragment(
|
|
90
|
+
currentData,
|
|
91
|
+
[makeFragmentKey(FRAGMENT_NAMES.inboundContact, inboundContactId)],
|
|
92
|
+
queryCount,
|
|
93
|
+
);
|
|
88
94
|
}
|
|
@@ -1,59 +1,77 @@
|
|
|
1
1
|
import type { UseMutationParams } from '@jsb188/graphql/types.d';
|
|
2
2
|
import type { OpenModalPopUpFn } from '@jsb188/react/states';
|
|
3
|
+
import {
|
|
4
|
+
FRAGMENT_NAMES,
|
|
5
|
+
makeFragmentKey,
|
|
6
|
+
} from '@jsb188/mday/constants/graphqlReactivity.ts';
|
|
3
7
|
import { updateFragment } from '../cache/index.ts';
|
|
4
8
|
import {
|
|
5
|
-
|
|
6
|
-
|
|
9
|
+
createIntegrationAuthorizationUrlMtn,
|
|
10
|
+
disconnectIntegrationMtn,
|
|
7
11
|
} from '../gql/mutations/integrationMutations.ts';
|
|
8
12
|
import { useMutation } from './index.ts';
|
|
9
13
|
|
|
10
14
|
/**
|
|
11
15
|
* Create integration OAuth authorization URL.
|
|
12
16
|
*/
|
|
13
|
-
export function useCreateIntegrationAuthorizationUrl(
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
17
|
+
export function useCreateIntegrationAuthorizationUrl(
|
|
18
|
+
params: UseMutationParams = {},
|
|
19
|
+
openModalPopUp?: OpenModalPopUpFn,
|
|
20
|
+
) {
|
|
21
|
+
const [createIntegrationAuthorizationUrl, mtnValues, mtnHandlers] =
|
|
22
|
+
useMutation(createIntegrationAuthorizationUrlMtn, {
|
|
23
|
+
openModalPopUp,
|
|
24
|
+
...params,
|
|
25
|
+
});
|
|
18
26
|
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
27
|
+
return {
|
|
28
|
+
createIntegrationAuthorizationUrl,
|
|
29
|
+
...mtnValues,
|
|
30
|
+
...mtnHandlers,
|
|
31
|
+
};
|
|
24
32
|
}
|
|
25
33
|
|
|
26
34
|
/**
|
|
27
35
|
* Disconnect an integration.
|
|
28
36
|
*/
|
|
29
|
-
export function useDisconnectIntegration(
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
37
|
+
export function useDisconnectIntegration(
|
|
38
|
+
params: UseMutationParams = {},
|
|
39
|
+
openModalPopUp?: OpenModalPopUpFn,
|
|
40
|
+
) {
|
|
41
|
+
const { onCompleted, ...otherParams } = params;
|
|
42
|
+
const [disconnectIntegration, mtnValues, mtnHandlers, updateObservers] =
|
|
43
|
+
useMutation(disconnectIntegrationMtn, {
|
|
44
|
+
openModalPopUp,
|
|
45
|
+
onCompleted: (data: any, error: any, variables: any) => {
|
|
46
|
+
const disconnectedIntegrationId = data?.disconnectIntegration;
|
|
35
47
|
|
|
36
|
-
|
|
37
|
-
|
|
48
|
+
if (disconnectedIntegrationId) {
|
|
49
|
+
const organizationFragmentKey = makeFragmentKey(
|
|
50
|
+
FRAGMENT_NAMES.organization,
|
|
51
|
+
variables.organizationId,
|
|
52
|
+
);
|
|
38
53
|
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
54
|
+
updateFragment(
|
|
55
|
+
makeFragmentKey(
|
|
56
|
+
FRAGMENT_NAMES.integrationConnection,
|
|
57
|
+
disconnectedIntegrationId,
|
|
58
|
+
),
|
|
59
|
+
{ status: 'DISCONNECTED' },
|
|
60
|
+
null,
|
|
61
|
+
false,
|
|
62
|
+
updateObservers,
|
|
63
|
+
[organizationFragmentKey],
|
|
64
|
+
);
|
|
65
|
+
}
|
|
48
66
|
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
67
|
+
onCompleted?.(disconnectedIntegrationId, error, variables);
|
|
68
|
+
},
|
|
69
|
+
...otherParams,
|
|
70
|
+
});
|
|
53
71
|
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
72
|
+
return {
|
|
73
|
+
disconnectIntegration,
|
|
74
|
+
...mtnValues,
|
|
75
|
+
...mtnHandlers,
|
|
76
|
+
};
|
|
59
77
|
}
|
|
@@ -1,15 +1,30 @@
|
|
|
1
|
+
import {
|
|
2
|
+
FRAGMENT_NAMES,
|
|
3
|
+
makeFragmentKey,
|
|
4
|
+
} from '@jsb188/mday/constants/graphqlReactivity.ts';
|
|
1
5
|
import { useReactiveFragment } from '../client/index.ts';
|
|
2
6
|
|
|
3
7
|
/**
|
|
4
8
|
* Get reactive integration connection fragment.
|
|
5
9
|
*/
|
|
6
|
-
export function useReactiveIntegrationConnection(
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
10
|
+
export function useReactiveIntegrationConnection(
|
|
11
|
+
integrationConnectionId?: string | null,
|
|
12
|
+
currentData?: any,
|
|
13
|
+
queryCount?: number,
|
|
14
|
+
) {
|
|
15
|
+
return useReactiveFragment(
|
|
16
|
+
currentData,
|
|
17
|
+
integrationConnectionId
|
|
18
|
+
? [
|
|
19
|
+
makeFragmentKey(
|
|
20
|
+
FRAGMENT_NAMES.integrationConnection,
|
|
21
|
+
integrationConnectionId,
|
|
22
|
+
),
|
|
23
|
+
]
|
|
24
|
+
: [],
|
|
25
|
+
queryCount,
|
|
26
|
+
undefined,
|
|
27
|
+
undefined,
|
|
28
|
+
true,
|
|
29
|
+
);
|
|
15
30
|
}
|
package/hooks/use-log-mtn.ts
CHANGED
|
@@ -1,58 +1,79 @@
|
|
|
1
|
-
import { checkACLPermission } from '@jsb188/mday/utils/organization.ts';
|
|
2
1
|
import type { UseMutationParams } from '@jsb188/graphql/types.d';
|
|
3
|
-
import {
|
|
2
|
+
import {
|
|
3
|
+
FRAGMENT_NAMES,
|
|
4
|
+
makeFragmentKey,
|
|
5
|
+
} from '@jsb188/mday/constants/graphqlReactivity.ts';
|
|
6
|
+
import { checkACLPermission } from '@jsb188/mday/utils/organization.ts';
|
|
7
|
+
import type { OpenModalPopUpFn } from '@jsb188/react/states';
|
|
4
8
|
import { useMemo } from 'react';
|
|
5
9
|
import { updateFragment } from '../cache/index.ts';
|
|
6
|
-
import {
|
|
10
|
+
import {
|
|
11
|
+
deleteLogEntryMtn,
|
|
12
|
+
editLogEntryMtn,
|
|
13
|
+
} from '../gql/mutations/logMutations.ts';
|
|
7
14
|
import { useMutation } from './index.ts';
|
|
8
15
|
import { useReactiveLogFragment } from './use-log-qry.ts';
|
|
9
16
|
import { useOrgRelFromMyOrganizations } from './use-organization-qry.ts';
|
|
10
17
|
|
|
18
|
+
/**
|
|
19
|
+
* Prepare the shared edit-log mutation command without subscribing to one log row.
|
|
20
|
+
*/
|
|
21
|
+
|
|
22
|
+
export function useEditLogEntryMutation(
|
|
23
|
+
params: UseMutationParams = {},
|
|
24
|
+
openModalPopUp?: OpenModalPopUpFn,
|
|
25
|
+
) {
|
|
26
|
+
const [editLogEntry, mtnValues, mtnHandlers] = useMutation(editLogEntryMtn, {
|
|
27
|
+
openModalPopUp,
|
|
28
|
+
...params,
|
|
29
|
+
});
|
|
30
|
+
|
|
31
|
+
return {
|
|
32
|
+
editLogEntry,
|
|
33
|
+
...mtnValues,
|
|
34
|
+
...mtnHandlers,
|
|
35
|
+
};
|
|
36
|
+
}
|
|
37
|
+
|
|
11
38
|
/**
|
|
12
39
|
* Fetch a single log entry,
|
|
13
40
|
* from cache first; only check server if cache is not found.
|
|
14
41
|
*/
|
|
15
42
|
|
|
16
43
|
export function useEditLogEntry(
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
44
|
+
viewerAccountId: string,
|
|
45
|
+
logEntryId: string,
|
|
46
|
+
organizationId: string,
|
|
47
|
+
params: UseMutationParams = {},
|
|
48
|
+
openModalPopUp?: OpenModalPopUpFn,
|
|
22
49
|
) {
|
|
50
|
+
const { organizationRelationship } =
|
|
51
|
+
useOrgRelFromMyOrganizations(organizationId);
|
|
52
|
+
const notReady = !organizationRelationship;
|
|
53
|
+
const mutation = useEditLogEntryMutation(params, openModalPopUp);
|
|
23
54
|
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
{
|
|
30
|
-
// checkMountedBeforeCallback: true,
|
|
31
|
-
openModalPopUp,
|
|
32
|
-
...params,
|
|
33
|
-
},
|
|
34
|
-
);
|
|
55
|
+
const logEntry = useReactiveLogFragment(
|
|
56
|
+
logEntryId,
|
|
57
|
+
null,
|
|
58
|
+
mutation.mutationCount,
|
|
59
|
+
);
|
|
35
60
|
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
61
|
+
const isMyDocument =
|
|
62
|
+
!!viewerAccountId && logEntry?.accountId === viewerAccountId;
|
|
63
|
+
const allowEdit = useMemo(() => {
|
|
64
|
+
return checkACLPermission(
|
|
65
|
+
organizationRelationship,
|
|
66
|
+
'logs',
|
|
67
|
+
isMyDocument ? 'WRITE' : 'MANAGE',
|
|
68
|
+
);
|
|
69
|
+
}, [organizationRelationship?.acl, organizationRelationship?.role]);
|
|
42
70
|
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
logEntry,
|
|
50
|
-
editLogEntry,
|
|
51
|
-
notReady,
|
|
52
|
-
allowEdit,
|
|
53
|
-
...mtnValues,
|
|
54
|
-
...mtnHandlers,
|
|
55
|
-
};
|
|
71
|
+
return {
|
|
72
|
+
logEntry,
|
|
73
|
+
notReady,
|
|
74
|
+
allowEdit,
|
|
75
|
+
...mutation,
|
|
76
|
+
};
|
|
56
77
|
}
|
|
57
78
|
|
|
58
79
|
/**
|
|
@@ -60,26 +81,34 @@ export function useEditLogEntry(
|
|
|
60
81
|
* NOTE: Don't check ACL and allow server to handle it.
|
|
61
82
|
*/
|
|
62
83
|
|
|
63
|
-
export function useDeleteLogEntry(
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
84
|
+
export function useDeleteLogEntry(
|
|
85
|
+
params: UseMutationParams = {},
|
|
86
|
+
openModalPopUp?: OpenModalPopUpFn,
|
|
87
|
+
) {
|
|
88
|
+
const { onCompleted, ...rest } = params;
|
|
89
|
+
const [deleteLogEntry, mtnValues, mtnHandlers, updateObservers] = useMutation(
|
|
90
|
+
deleteLogEntryMtn,
|
|
91
|
+
{
|
|
92
|
+
openModalPopUp,
|
|
93
|
+
onCompleted: (data, dataMtnValues, variables) => {
|
|
94
|
+
if (data?.deleteLogEntry) {
|
|
95
|
+
updateFragment(
|
|
96
|
+
makeFragmentKey(FRAGMENT_NAMES.logEntry, variables.logEntryId),
|
|
97
|
+
{ __deleted: true },
|
|
98
|
+
null,
|
|
99
|
+
false,
|
|
100
|
+
updateObservers,
|
|
101
|
+
);
|
|
102
|
+
}
|
|
103
|
+
onCompleted?.(data, dataMtnValues, variables);
|
|
104
|
+
},
|
|
105
|
+
...rest,
|
|
106
|
+
},
|
|
107
|
+
);
|
|
79
108
|
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
109
|
+
return {
|
|
110
|
+
deleteLogEntry,
|
|
111
|
+
...mtnValues,
|
|
112
|
+
...mtnHandlers,
|
|
113
|
+
};
|
|
85
114
|
}
|