@go-avro/avro-js 0.0.2-beta.103 → 0.0.2-beta.105
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/dist/client/QueryClient.d.ts +6 -0
- package/dist/client/hooks/companies.js +31 -0
- package/dist/index.d.ts +2 -1
- package/dist/index.js +2 -1
- package/package.json +1 -1
|
@@ -225,6 +225,12 @@ declare module '../client/QueryClient' {
|
|
|
225
225
|
logo: File | null;
|
|
226
226
|
}>;
|
|
227
227
|
}>>;
|
|
228
|
+
useRemoveUserCompany(): ReturnType<typeof useMutation<{
|
|
229
|
+
msg: string;
|
|
230
|
+
}, StandardError, {
|
|
231
|
+
companyId: string;
|
|
232
|
+
userId: string;
|
|
233
|
+
}>>;
|
|
228
234
|
useDeleteEvent(): ReturnType<typeof useMutation<{
|
|
229
235
|
msg: string;
|
|
230
236
|
}, StandardError, {
|
|
@@ -60,6 +60,37 @@ AvroQueryClient.prototype.useUpdateCompany = function () {
|
|
|
60
60
|
},
|
|
61
61
|
});
|
|
62
62
|
};
|
|
63
|
+
AvroQueryClient.prototype.useRemoveUserCompany = function () {
|
|
64
|
+
const queryClient = useQueryClient();
|
|
65
|
+
return useMutation({
|
|
66
|
+
mutationFn: async ({ companyId, userId }) => {
|
|
67
|
+
return this.delete(`/company/${companyId}/user/${userId}`);
|
|
68
|
+
},
|
|
69
|
+
onMutate: async ({ companyId, userId }) => {
|
|
70
|
+
await queryClient.cancelQueries({ queryKey: ['company', companyId] });
|
|
71
|
+
const previousCompany = queryClient.getQueryData(['company', companyId]);
|
|
72
|
+
queryClient.setQueryData(['company', companyId], (oldData) => {
|
|
73
|
+
if (!oldData)
|
|
74
|
+
return oldData;
|
|
75
|
+
return {
|
|
76
|
+
...oldData,
|
|
77
|
+
users: oldData.users.filter((user) => user.id !== userId),
|
|
78
|
+
};
|
|
79
|
+
});
|
|
80
|
+
return { previousCompany };
|
|
81
|
+
},
|
|
82
|
+
onError: (err, variables, context) => {
|
|
83
|
+
const { companyId } = variables;
|
|
84
|
+
if (context?.previousCompany) {
|
|
85
|
+
queryClient.setQueryData(['company', companyId], context.previousCompany);
|
|
86
|
+
}
|
|
87
|
+
},
|
|
88
|
+
onSettled: (_data, _error, variables) => {
|
|
89
|
+
const { companyId } = variables;
|
|
90
|
+
queryClient.invalidateQueries({ queryKey: ['company', companyId] });
|
|
91
|
+
},
|
|
92
|
+
});
|
|
93
|
+
};
|
|
63
94
|
AvroQueryClient.prototype.useDeleteCompany = function () {
|
|
64
95
|
const queryClient = useQueryClient();
|
|
65
96
|
return useMutation({
|
package/dist/index.d.ts
CHANGED
|
@@ -21,5 +21,6 @@ import './client/hooks/avro';
|
|
|
21
21
|
import './client/hooks/teams';
|
|
22
22
|
export * from './types/api';
|
|
23
23
|
export * from './types/auth';
|
|
24
|
-
export * from './types/
|
|
24
|
+
export * from './types/cache';
|
|
25
25
|
export * from './types/client';
|
|
26
|
+
export * from './types/error';
|
package/dist/index.js
CHANGED
|
@@ -21,5 +21,6 @@ import './client/hooks/avro';
|
|
|
21
21
|
import './client/hooks/teams';
|
|
22
22
|
export * from './types/api';
|
|
23
23
|
export * from './types/auth';
|
|
24
|
-
export * from './types/
|
|
24
|
+
export * from './types/cache';
|
|
25
25
|
export * from './types/client';
|
|
26
|
+
export * from './types/error';
|