@go-avro/avro-js 0.0.2-beta.107 → 0.0.2-beta.109
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,7 +1,7 @@
|
|
|
1
1
|
import { Socket } from 'socket.io-client';
|
|
2
2
|
import { InfiniteData, UseInfiniteQueryResult, useMutation, UseQueryResult } from '@tanstack/react-query';
|
|
3
3
|
import { AuthManager } from '../auth/AuthManager';
|
|
4
|
-
import { _Event, ApiInfo, Avro, Bill, Break, Chat, Company, Job, LoginResponse, Message, Plan, Route, ServiceMonth, Session, Team, User, UserCompanyAssociation } from '../types/api';
|
|
4
|
+
import { _Event, ApiInfo, Avro, Bill, Break, Chat, Company, FinancialInsightData, Job, EventInsightData, LoginResponse, Message, Plan, Route, ServiceMonth, Session, Team, User, UserCompanyAssociation } from '../types/api';
|
|
5
5
|
import { Tokens } from '../types/auth';
|
|
6
6
|
import { CancelToken, RetryStrategy } from '../types/client';
|
|
7
7
|
import { StandardError } from '../types/error';
|
|
@@ -86,6 +86,13 @@ declare module '../client/QueryClient' {
|
|
|
86
86
|
id: string;
|
|
87
87
|
}[], StandardError>;
|
|
88
88
|
useGetAnalytics(): UseQueryResult<any, StandardError>;
|
|
89
|
+
useFinanceAnalytics({ periods, cumulative }: {
|
|
90
|
+
periods: number[][];
|
|
91
|
+
cumulative: boolean;
|
|
92
|
+
}): UseQueryResult<FinancialInsightData[], StandardError>;
|
|
93
|
+
useEventAnalytics({ periods }: {
|
|
94
|
+
periods: number[][];
|
|
95
|
+
}): UseQueryResult<EventInsightData[], StandardError>;
|
|
89
96
|
useGetCompany(companyId: string): UseQueryResult<Company, StandardError>;
|
|
90
97
|
useGetJob(jobId: string): UseQueryResult<Job, StandardError>;
|
|
91
98
|
useGetEvent(eventId: string): UseQueryResult<_Event, StandardError>;
|
|
@@ -1,10 +1,26 @@
|
|
|
1
|
-
import { useQuery
|
|
1
|
+
import { useQuery } from "@tanstack/react-query";
|
|
2
2
|
import { AvroQueryClient } from "../../client/QueryClient";
|
|
3
3
|
AvroQueryClient.prototype.useGetAnalytics = function () {
|
|
4
|
-
const queryClient = useQueryClient();
|
|
5
4
|
return useQuery({
|
|
6
5
|
queryKey: ['analytics'],
|
|
7
6
|
queryFn: () => this.post('/avro/analytics', null),
|
|
8
7
|
enabled: true,
|
|
9
8
|
});
|
|
10
9
|
};
|
|
10
|
+
AvroQueryClient.prototype.useFinanceAnalytics = function ({ periods, cumulative }) {
|
|
11
|
+
return useQuery({
|
|
12
|
+
queryKey: ['analytics', 'finance', this.companyId, periods],
|
|
13
|
+
queryFn: () => this.post(`/company/${this.companyId}/analytics/finance`, JSON.stringify({ periods, cumulative }), undefined, {
|
|
14
|
+
'Content-Type': 'application/json',
|
|
15
|
+
}),
|
|
16
|
+
});
|
|
17
|
+
};
|
|
18
|
+
AvroQueryClient.prototype.useEventAnalytics = function ({ periods }) {
|
|
19
|
+
return useQuery({
|
|
20
|
+
queryKey: ['analytics', 'events', this.companyId, periods],
|
|
21
|
+
queryFn: () => this.post(`/company/${this.companyId}/analytics/events`, JSON.stringify({ periods }), undefined, {
|
|
22
|
+
'Content-Type': 'application/json',
|
|
23
|
+
}),
|
|
24
|
+
enabled: Boolean(this.companyId),
|
|
25
|
+
});
|
|
26
|
+
};
|
|
@@ -22,12 +22,6 @@ AvroQueryClient.prototype.useGetJobs = function (body, total = 0, onProgress) {
|
|
|
22
22
|
if (result.data) {
|
|
23
23
|
result.data.pages.forEach((data_page) => {
|
|
24
24
|
data_page.forEach((job) => {
|
|
25
|
-
job.current_event = (job.tasks || []).reduce((latest, task) => {
|
|
26
|
-
return task.current_event && (!latest || task.current_event.time_started > (latest.time_started ?? 0)) ? task.current_event : latest;
|
|
27
|
-
}, null);
|
|
28
|
-
job.last_completed_event = (job.tasks || []).reduce((latest, task) => {
|
|
29
|
-
return task.last_completed_event && (!latest || task.last_completed_event.time_started > (latest.time_created ?? 0)) ? task.last_completed_event : latest;
|
|
30
|
-
}, null);
|
|
31
25
|
job.overdue_time = (job.tasks || []).reduce((maxOverdue, task) => {
|
|
32
26
|
return (task.overdue_time && task.overdue_time > maxOverdue) ? task.overdue_time : maxOverdue;
|
|
33
27
|
}, 0);
|