@go-avro/avro-js 0.1.1 → 0.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.
|
@@ -576,6 +576,19 @@ declare module '../client/QueryClient' {
|
|
|
576
576
|
breakId: string;
|
|
577
577
|
updates: Partial<Break>;
|
|
578
578
|
}>>;
|
|
579
|
+
useUpdateCompanySession(): ReturnType<typeof useMutation<{
|
|
580
|
+
msg: string;
|
|
581
|
+
}, StandardError, {
|
|
582
|
+
sessionId: string;
|
|
583
|
+
updates: Partial<Session>;
|
|
584
|
+
companyId?: string;
|
|
585
|
+
}>>;
|
|
586
|
+
useDeleteCompanySession(): ReturnType<typeof useMutation<{
|
|
587
|
+
msg: string;
|
|
588
|
+
}, StandardError, {
|
|
589
|
+
sessionId: string;
|
|
590
|
+
companyId?: string;
|
|
591
|
+
}>>;
|
|
579
592
|
useUpdateUser(userId: string): ReturnType<typeof useMutation<{
|
|
580
593
|
msg: string;
|
|
581
594
|
}, StandardError, Partial<User>>>;
|
|
@@ -7,7 +7,7 @@ AvroQueryClient.prototype.getJobsFromCache = function (queryClient) {
|
|
|
7
7
|
if (!client) {
|
|
8
8
|
return [];
|
|
9
9
|
}
|
|
10
|
-
return client.getQueryData(
|
|
10
|
+
return (client.getQueryData(keys.list('jobs', this.companyId, { numJobs: this.company?.num_jobs ?? 0 })) ?? []);
|
|
11
11
|
};
|
|
12
12
|
AvroQueryClient.prototype.useGetJobs = function (params) {
|
|
13
13
|
const queryClient = this.getQueryClient();
|
|
@@ -231,3 +231,55 @@ AvroQueryClient.prototype.useUpdateSessionBreak = function () {
|
|
|
231
231
|
},
|
|
232
232
|
});
|
|
233
233
|
};
|
|
234
|
+
/** Edit another member's session (requires can_write_others_sessions). */
|
|
235
|
+
AvroQueryClient.prototype.useUpdateCompanySession = function () {
|
|
236
|
+
const queryClient = this.getQueryClient();
|
|
237
|
+
return useMutation({
|
|
238
|
+
mutationFn: ({ sessionId, updates, companyId, }) => {
|
|
239
|
+
return this.put({
|
|
240
|
+
path: `/company/${companyId ?? this.companyId}/session/${sessionId}`,
|
|
241
|
+
data: JSON.stringify(updates),
|
|
242
|
+
headers: { 'Content-Type': 'application/json' },
|
|
243
|
+
});
|
|
244
|
+
},
|
|
245
|
+
onMutate: async ({ sessionId, updates }) => {
|
|
246
|
+
await queryClient.cancelQueries({ queryKey: [NS] });
|
|
247
|
+
const previous = snapshotSessionLists(queryClient);
|
|
248
|
+
patchSessionLists(queryClient, (items) => items.map((session) => session.id === sessionId ? new Session({ ...session, ...updates }) : session));
|
|
249
|
+
queryClient.setQueryData(keys.detail(NS, sessionId), (old) => old ? new Session({ ...old, ...updates }) : old);
|
|
250
|
+
return { previous };
|
|
251
|
+
},
|
|
252
|
+
onError: (_err, _vars, context) => {
|
|
253
|
+
if (context?.previous)
|
|
254
|
+
restoreSessionLists(queryClient, context.previous);
|
|
255
|
+
},
|
|
256
|
+
onSettled: () => {
|
|
257
|
+
this.syncAfterMutation('session', 'timecard');
|
|
258
|
+
},
|
|
259
|
+
});
|
|
260
|
+
};
|
|
261
|
+
/** Delete another member's session (requires can_write_others_sessions). */
|
|
262
|
+
AvroQueryClient.prototype.useDeleteCompanySession = function () {
|
|
263
|
+
const queryClient = this.getQueryClient();
|
|
264
|
+
return useMutation({
|
|
265
|
+
mutationFn: ({ sessionId, companyId }) => {
|
|
266
|
+
return this.delete({
|
|
267
|
+
path: `/company/${companyId ?? this.companyId}/session/${sessionId}`,
|
|
268
|
+
});
|
|
269
|
+
},
|
|
270
|
+
onMutate: async ({ sessionId }) => {
|
|
271
|
+
await queryClient.cancelQueries({ queryKey: [NS] });
|
|
272
|
+
const previous = snapshotSessionLists(queryClient);
|
|
273
|
+
patchSessionLists(queryClient, (items) => items.filter((s) => s.id !== sessionId));
|
|
274
|
+
queryClient.removeQueries({ queryKey: keys.detail(NS, sessionId), exact: true });
|
|
275
|
+
return { previous };
|
|
276
|
+
},
|
|
277
|
+
onError: (_err, _vars, context) => {
|
|
278
|
+
if (context?.previous)
|
|
279
|
+
restoreSessionLists(queryClient, context.previous);
|
|
280
|
+
},
|
|
281
|
+
onSettled: () => {
|
|
282
|
+
this.syncAfterMutation('session', 'timecard');
|
|
283
|
+
},
|
|
284
|
+
});
|
|
285
|
+
};
|
|
@@ -43,7 +43,6 @@ AvroQueryClient.prototype.useGetTimecard = function (timecardId, enabled = true)
|
|
|
43
43
|
});
|
|
44
44
|
};
|
|
45
45
|
AvroQueryClient.prototype.useCreateTimecard = function () {
|
|
46
|
-
const queryClient = this.getQueryClient();
|
|
47
46
|
return useMutation({
|
|
48
47
|
mutationFn: ({ companyId, data, }) => {
|
|
49
48
|
const targetCompanyId = companyId ?? this.companyId;
|
|
@@ -53,13 +52,12 @@ AvroQueryClient.prototype.useCreateTimecard = function () {
|
|
|
53
52
|
headers: { 'Content-Type': 'application/json' },
|
|
54
53
|
});
|
|
55
54
|
},
|
|
56
|
-
|
|
57
|
-
|
|
55
|
+
onSettled: () => {
|
|
56
|
+
this.syncAfterMutation('timecard');
|
|
58
57
|
},
|
|
59
58
|
});
|
|
60
59
|
};
|
|
61
60
|
AvroQueryClient.prototype.useUpdateTimecard = function () {
|
|
62
|
-
const queryClient = this.getQueryClient();
|
|
63
61
|
return useMutation({
|
|
64
62
|
mutationFn: ({ timecardId, updates, }) => {
|
|
65
63
|
return this.put({
|
|
@@ -68,8 +66,8 @@ AvroQueryClient.prototype.useUpdateTimecard = function () {
|
|
|
68
66
|
headers: { 'Content-Type': 'application/json' },
|
|
69
67
|
});
|
|
70
68
|
},
|
|
71
|
-
|
|
72
|
-
|
|
69
|
+
onSettled: () => {
|
|
70
|
+
this.syncAfterMutation('timecard');
|
|
73
71
|
},
|
|
74
72
|
});
|
|
75
73
|
};
|
package/dist/version.d.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export declare const AVRO_JS_VERSION = "0.1.
|
|
1
|
+
export declare const AVRO_JS_VERSION = "0.1.3";
|
package/dist/version.js
CHANGED