@go-avro/avro-js 0.0.2-beta.153 → 0.0.2-beta.154

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.
@@ -310,7 +310,7 @@ declare module '../client/QueryClient' {
310
310
  useCreateUserCompany(): ReturnType<typeof useMutation<{
311
311
  id: string;
312
312
  }, StandardError, {
313
- userCompanyData: Partial<UserCompanyAssociation>;
313
+ user_id: string;
314
314
  }>>;
315
315
  useRemoveUserCompany(): ReturnType<typeof useMutation<{
316
316
  msg: string;
@@ -95,40 +95,32 @@ AvroQueryClient.prototype.useUpdateCompany = function () {
95
95
  AvroQueryClient.prototype.useCreateUserCompany = function () {
96
96
  const queryClient = this.getQueryClient();
97
97
  return useMutation({
98
- mutationFn: async ({ userCompanyData }) => {
99
- const userId = userCompanyData.user?.id;
100
- const companyId = userCompanyData.company;
101
- if (!userId || !companyId) {
98
+ mutationFn: async ({ user_id }) => {
99
+ if (!user_id) {
102
100
  throw new Error("Both userId and companyId are required");
103
101
  }
104
- return this.post(`/company/${companyId}/user/${userId}`, JSON.stringify({ user_id: userId }), undefined, { "Content-Type": "application/json" });
102
+ return this.post(`/company/${this.companyId}/user/${user_id}`, JSON.stringify({ user_id: user_id }), undefined, { "Content-Type": "application/json" });
105
103
  },
106
- onMutate: async ({ userCompanyData }) => {
107
- const userId = userCompanyData.user?.id;
108
- const companyId = userCompanyData.company;
109
- await queryClient.cancelQueries({ queryKey: ['company', companyId] });
110
- const previousCompany = queryClient.getQueryData(['company', companyId]);
111
- queryClient.setQueryData(['company', companyId], (oldData) => {
104
+ onMutate: async ({ user_id }) => {
105
+ await queryClient.cancelQueries({ queryKey: ['company', this.companyId] });
106
+ const previousCompany = queryClient.getQueryData(['company', this.companyId]);
107
+ queryClient.setQueryData(['company', this.companyId], (oldData) => {
112
108
  if (!oldData)
113
109
  return oldData;
114
110
  return {
115
111
  ...oldData,
116
- users: [...(oldData.users || []), { id: userId }],
112
+ users: [...(oldData.users || []), { id: user_id }],
117
113
  };
118
114
  });
119
115
  return { previousCompany };
120
116
  },
121
117
  onError: (err, variables, context) => {
122
- const { userCompanyData } = variables;
123
- const { company } = userCompanyData;
124
118
  if (context?.previousCompany) {
125
- queryClient.setQueryData(['company', company], context.previousCompany);
119
+ queryClient.setQueryData(['company', this.companyId], context.previousCompany);
126
120
  }
127
121
  },
128
122
  onSettled: (_data, _error, variables) => {
129
- const { userCompanyData } = variables;
130
- const { company } = userCompanyData;
131
- queryClient.invalidateQueries({ queryKey: ['company', company] });
123
+ queryClient.invalidateQueries({ queryKey: ['company', this.companyId] });
132
124
  queryClient.invalidateQueries({ queryKey: ['/company/list'] });
133
125
  },
134
126
  });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@go-avro/avro-js",
3
- "version": "0.0.2-beta.153",
3
+ "version": "0.0.2-beta.154",
4
4
  "description": "JS client for Avro backend integration.",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",