@go-avro/avro-js 0.0.2-beta.172 → 0.0.2-beta.173

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.
@@ -1,5 +1,6 @@
1
1
  import { useInfiniteQuery, useQuery, useMutation } from '@tanstack/react-query';
2
2
  import { AvroQueryClient } from '../../client/QueryClient';
3
+ import { LineItemStatus } from '../../types/api';
3
4
  AvroQueryClient.prototype.useGetEvents = function (body) {
4
5
  const queryClient = this.getQueryClient();
5
6
  const result = useInfiniteQuery({
@@ -208,7 +209,7 @@ AvroQueryClient.prototype.useUpdateEvents = function () {
208
209
  return this.put(`/company/${this.companyId}/events`, JSON.stringify({
209
210
  events: eventIds,
210
211
  billed: true,
211
- paid: action === "paid",
212
+ status: action === "billed" ? LineItemStatus.EXTERNALLY_BILLED : LineItemStatus.EXTERNALLY_PAID,
212
213
  }), undefined, {
213
214
  "Content-Type": "application/json",
214
215
  });
@@ -223,7 +224,7 @@ AvroQueryClient.prototype.useUpdateEvents = function () {
223
224
  eventIds.forEach((eventId, idx) => {
224
225
  queryClient.setQueryData(['event', eventId], (oldData) => {
225
226
  return oldData
226
- ? { ...oldData, billed: true, paid: action === "paid" }
227
+ ? { ...oldData, billed: true, status: action === "billed" ? LineItemStatus.EXTERNALLY_BILLED : LineItemStatus.EXTERNALLY_PAID }
227
228
  : oldData;
228
229
  });
229
230
  });
@@ -233,13 +234,13 @@ AvroQueryClient.prototype.useUpdateEvents = function () {
233
234
  return oldData;
234
235
  if (oldData.pages) {
235
236
  const updatedPages = oldData.pages.map((page) => page.map((event) => eventIds.includes(event.id)
236
- ? { ...event, billed: true, paid: action === "paid" }
237
+ ? { ...event, billed: true, status: action === "billed" ? LineItemStatus.EXTERNALLY_BILLED : LineItemStatus.EXTERNALLY_PAID }
237
238
  : event));
238
239
  return { ...oldData, pages: updatedPages };
239
240
  }
240
241
  if (Array.isArray(oldData)) {
241
242
  return oldData.map((event) => eventIds.includes(event.id)
242
- ? { ...event, billed: true, paid: action === "paid" }
243
+ ? { ...event, billed: true, status: action === "billed" ? LineItemStatus.EXTERNALLY_BILLED : LineItemStatus.EXTERNALLY_PAID }
243
244
  : event);
244
245
  }
245
246
  return oldData;
@@ -1,5 +1,6 @@
1
1
  import { useInfiniteQuery, useMutation } from '@tanstack/react-query';
2
2
  import { AvroQueryClient } from '../../client/QueryClient';
3
+ import { LineItemStatus } from '../../types/api';
3
4
  AvroQueryClient.prototype.useGetMonths = function (body) {
4
5
  const queryClient = this.getQueryClient();
5
6
  const result = useInfiniteQuery({
@@ -39,8 +40,7 @@ AvroQueryClient.prototype.useUpdateMonths = function () {
39
40
  const monthIds = months.map(month => month.id);
40
41
  return this.put(`/company/${this.companyId}/months`, JSON.stringify({
41
42
  months: monthIds,
42
- billed: true,
43
- paid: action === "paid",
43
+ status: action === "billed" ? LineItemStatus.EXTERNALLY_BILLED : LineItemStatus.EXTERNALLY_PAID,
44
44
  }), undefined, {
45
45
  "Content-Type": "application/json",
46
46
  });
@@ -54,7 +54,7 @@ AvroQueryClient.prototype.useUpdateMonths = function () {
54
54
  monthIds.forEach((monthId, idx) => {
55
55
  queryClient.setQueryData(['month', monthId], (oldData) => {
56
56
  return oldData
57
- ? { ...oldData, billed: true, paid: action === "paid" }
57
+ ? { ...oldData, status: action === "billed" ? LineItemStatus.EXTERNALLY_BILLED : LineItemStatus.EXTERNALLY_PAID }
58
58
  : oldData;
59
59
  });
60
60
  });
@@ -63,13 +63,13 @@ AvroQueryClient.prototype.useUpdateMonths = function () {
63
63
  return oldData;
64
64
  if (oldData.pages) {
65
65
  const updatedPages = oldData.pages.map((page) => page.map((month) => monthIds.includes(month.id)
66
- ? { ...month, billed: true, paid: action === "paid" }
66
+ ? { ...month, status: action === "billed" ? LineItemStatus.EXTERNALLY_BILLED : LineItemStatus.EXTERNALLY_PAID }
67
67
  : month));
68
68
  return { ...oldData, pages: updatedPages };
69
69
  }
70
70
  if (Array.isArray(oldData)) {
71
71
  return oldData.map((month) => monthIds.includes(month.id)
72
- ? { ...month, billed: true, paid: action === "paid" }
72
+ ? { ...month, status: action === "billed" ? LineItemStatus.EXTERNALLY_BILLED : LineItemStatus.EXTERNALLY_PAID }
73
73
  : month);
74
74
  }
75
75
  return oldData;
@@ -126,6 +126,16 @@ export interface MemberState {
126
126
  friendship: Friendship | null;
127
127
  last_message_read_at: number | null;
128
128
  }
129
+ export declare const LineItemStatus: {
130
+ readonly CREATED: "CREATED";
131
+ readonly EXTERNALLY_BILLED: "EXTERNALLY_BILLED";
132
+ readonly BILLED: "BILLED";
133
+ readonly PROCESSING: "PROCESSING";
134
+ readonly EXTERNALLY_PAID: "EXTERNALLY_PAID";
135
+ readonly PREPAID: "PREPAID";
136
+ readonly PAID: "PAID";
137
+ };
138
+ export type LineItemStatus = typeof LineItemStatus[keyof typeof LineItemStatus];
129
139
  export interface LineItem {
130
140
  id: string;
131
141
  line_item_type: "CUSTOM" | "ADDITIONAL_CHARGE" | "EVENT" | "SERVICE_MONTH";
@@ -133,6 +143,7 @@ export interface LineItem {
133
143
  description: string;
134
144
  cost: number | null;
135
145
  amount: number | null;
146
+ status: LineItemStatus;
136
147
  time_created: number;
137
148
  }
138
149
  export interface CustomLineItem extends LineItem {
@@ -288,8 +299,6 @@ export interface ServiceMonth extends LineItem {
288
299
  job_address: string;
289
300
  job_labels: string[];
290
301
  bill_id: string | null;
291
- billed: boolean;
292
- paid: boolean;
293
302
  tasks: string[];
294
303
  time_updated: number | null;
295
304
  }
@@ -567,7 +576,7 @@ export interface Task {
567
576
  images: string[];
568
577
  time_created: number;
569
578
  time_updated: number | null;
570
- status: "PENDING_CUSTOMER" | "PENDING_COMPANY" | "ACTIVE" | "ARCHIVED" | "DRAFT";
579
+ status: "PENDING_CUSTOMER" | "PENDING_COMPANY" | "ACTIVE" | "ARCHIVED" | "DRAFT" | "PENDING_PAYMENT" | "PENDING_ACTIVATION";
571
580
  created_by: UserCompanyAssociation | null;
572
581
  overdueness: number | null;
573
582
  overdue_time: number;
@@ -642,8 +651,6 @@ export interface _Event extends LineItem {
642
651
  billed_amount: number;
643
652
  additional_charges: AdditionalCharge[];
644
653
  users: UserEvent[];
645
- billed: boolean;
646
- paid: boolean;
647
654
  autostart: boolean;
648
655
  job_labels: string[];
649
656
  }
package/dist/types/api.js CHANGED
@@ -1,3 +1,12 @@
1
+ export const LineItemStatus = {
2
+ CREATED: "CREATED",
3
+ EXTERNALLY_BILLED: "EXTERNALLY_BILLED",
4
+ BILLED: "BILLED",
5
+ PROCESSING: "PROCESSING",
6
+ EXTERNALLY_PAID: "EXTERNALLY_PAID",
7
+ PREPAID: "PREPAID",
8
+ PAID: "PAID",
9
+ };
1
10
  export const NotificationLevel = {
2
11
  IN_APP: 0,
3
12
  EMAIL: 1,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@go-avro/avro-js",
3
- "version": "0.0.2-beta.172",
3
+ "version": "0.0.2-beta.173",
4
4
  "description": "JS client for Avro backend integration.",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",