@go-avro/avro-js 0.0.2-beta.171 → 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({
|
|
@@ -59,7 +60,7 @@ AvroQueryClient.prototype.useCreateEvent = function () {
|
|
|
59
60
|
last_completed_event: (eventData.time_ended ?? -1) > -1 ? eventData : previousJob.last_completed_event,
|
|
60
61
|
};
|
|
61
62
|
updatedJob.tasks = previousJob.tasks.map((task) => {
|
|
62
|
-
if (eventData.tasks?.includes(task.id)) {
|
|
63
|
+
if (eventData.tasks?.includes(task.id ?? "")) {
|
|
63
64
|
return {
|
|
64
65
|
...task,
|
|
65
66
|
current_event: eventData,
|
|
@@ -147,12 +148,12 @@ AvroQueryClient.prototype.useUpdateEvent = function () {
|
|
|
147
148
|
last_completed_event: (updates.time_ended ?? -1) > -1 && previousEvent ? { ...previousEvent, ...updates } : previousJob.last_completed_event,
|
|
148
149
|
};
|
|
149
150
|
updatedJob.tasks = previousJob.tasks.map((task) => {
|
|
150
|
-
if (updates.tasks?.includes(task.id)) {
|
|
151
|
+
if (updates.tasks?.includes(task.id ?? "")) {
|
|
151
152
|
return {
|
|
152
153
|
...task,
|
|
153
154
|
current_event: previousEvent ? { ...previousEvent, ...updates } : task.current_event,
|
|
154
155
|
last_completed_event: (updates.time_ended ?? -1) > -1 ? (previousEvent ? { ...previousEvent, ...updates } : task.last_completed_event) : task.last_completed_event,
|
|
155
|
-
overdue_time: -task.frequency - task.delay,
|
|
156
|
+
overdue_time: -(task.frequency ?? 0) - (task.delay ?? 0),
|
|
156
157
|
};
|
|
157
158
|
}
|
|
158
159
|
return task;
|
|
@@ -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
|
-
|
|
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,
|
|
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,
|
|
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,
|
|
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:
|
|
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,
|
|
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,
|
|
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,
|
|
72
|
+
? { ...month, status: action === "billed" ? LineItemStatus.EXTERNALLY_BILLED : LineItemStatus.EXTERNALLY_PAID }
|
|
73
73
|
: month);
|
|
74
74
|
}
|
|
75
75
|
return oldData;
|
package/dist/types/api.d.ts
CHANGED
|
@@ -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
|
}
|
|
@@ -542,7 +551,7 @@ export interface Job {
|
|
|
542
551
|
internal_notes: string;
|
|
543
552
|
external_notes: string;
|
|
544
553
|
priority: number;
|
|
545
|
-
tasks: Task[];
|
|
554
|
+
tasks: Partial<Task>[];
|
|
546
555
|
time_created: number;
|
|
547
556
|
time_updated: number | null;
|
|
548
557
|
routes: RouteJob[];
|
|
@@ -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;
|
|
@@ -579,7 +588,9 @@ export interface Task {
|
|
|
579
588
|
bill_mode: "MONTH" | "SERVICE" | "NONE";
|
|
580
589
|
price: number;
|
|
581
590
|
services_remaining: number;
|
|
591
|
+
activate_on: number | null;
|
|
582
592
|
expire_on: number | null;
|
|
593
|
+
catalog_item_id: string | null;
|
|
583
594
|
bill_day: number | null;
|
|
584
595
|
services_prepaid: number;
|
|
585
596
|
months_prepaid: number;
|
|
@@ -640,8 +651,6 @@ export interface _Event extends LineItem {
|
|
|
640
651
|
billed_amount: number;
|
|
641
652
|
additional_charges: AdditionalCharge[];
|
|
642
653
|
users: UserEvent[];
|
|
643
|
-
billed: boolean;
|
|
644
|
-
paid: boolean;
|
|
645
654
|
autostart: boolean;
|
|
646
655
|
job_labels: string[];
|
|
647
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,
|