@go-avro/avro-js 0.0.2-beta.104 → 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.
@@ -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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@go-avro/avro-js",
3
- "version": "0.0.2-beta.104",
3
+ "version": "0.0.2-beta.105",
4
4
  "description": "JS client for Avro backend integration.",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",