@go-avro/avro-js 0.0.2-beta.110 → 0.0.2-beta.112

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.
@@ -165,6 +165,11 @@ declare module '../client/QueryClient' {
165
165
  eventId: string;
166
166
  updates: Partial<_Event>;
167
167
  }>>;
168
+ useSyncBillToIntuit(): ReturnType<typeof useMutation<{
169
+ msg: string;
170
+ }, StandardError, {
171
+ billId: string;
172
+ }>>;
168
173
  useUpdateUserSession(): ReturnType<typeof useMutation<{
169
174
  msg: string;
170
175
  }, StandardError, {
@@ -139,3 +139,29 @@ AvroQueryClient.prototype.useDeleteBill = function () {
139
139
  },
140
140
  });
141
141
  };
142
+ AvroQueryClient.prototype.useSyncBillToIntuit = function () {
143
+ const queryClient = useQueryClient();
144
+ return useMutation({
145
+ mutationFn: async ({ billId }) => {
146
+ return this.post(`/company/${this.companyId}/bill/${billId}/intuit/sync`, null);
147
+ },
148
+ onMutate: async ({ billId }) => {
149
+ await queryClient.cancelQueries({ queryKey: ['bill', billId] });
150
+ const previousBill = queryClient.getQueryData(['bill', billId]);
151
+ if (previousBill) {
152
+ previousBill.intuit_id = "syncing";
153
+ }
154
+ return { previousBill };
155
+ },
156
+ onError: (_err, variables, context) => {
157
+ const { billId } = variables;
158
+ if (context?.previousBill) {
159
+ queryClient.setQueryData(['bill', billId], context.previousBill);
160
+ }
161
+ },
162
+ onSettled: (_data, _error, variables) => {
163
+ const { billId } = variables;
164
+ queryClient.invalidateQueries({ queryKey: ['bill', billId] });
165
+ },
166
+ });
167
+ };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@go-avro/avro-js",
3
- "version": "0.0.2-beta.110",
3
+ "version": "0.0.2-beta.112",
4
4
  "description": "JS client for Avro backend integration.",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",