@go-avro/avro-js 0.0.2-beta.154 → 0.0.2-beta.156
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, QueryClient, UseInfiniteQueryResult, useMutation, UseQueryResult } from '@tanstack/react-query';
|
|
3
3
|
import { AuthManager } from '../auth/AuthManager';
|
|
4
|
-
import { _Event, ApiInfo, Avro, Bill, Break, Chat, Company, FinancialInsightData, Job, EventInsightData, LoginResponse, Message, Plan, Route, ServiceMonth, Session, Team, User, UserCompanyAssociation, Skill, Group, Label } from '../types/api';
|
|
4
|
+
import { _Event, ApiInfo, Avro, Bill, Break, Chat, Company, FinancialInsightData, Job, EventInsightData, LoginResponse, Message, Plan, Route, ServiceMonth, Session, Team, User, UserCompanyAssociation, Skill, Group, Label, RouteScheduleConfig } from '../types/api';
|
|
5
5
|
import { AuthState, Tokens } from '../types/auth';
|
|
6
6
|
import { CancelToken, RetryStrategy } from '../types/client';
|
|
7
7
|
import { StandardError } from '../types/error';
|
|
@@ -193,6 +193,7 @@ declare module '../client/QueryClient' {
|
|
|
193
193
|
}>>;
|
|
194
194
|
useCreateSelf(): ReturnType<typeof useMutation<{
|
|
195
195
|
msg: string;
|
|
196
|
+
id?: string;
|
|
196
197
|
}, StandardError, {
|
|
197
198
|
username: string;
|
|
198
199
|
name: string;
|
|
@@ -208,6 +209,11 @@ declare module '../client/QueryClient' {
|
|
|
208
209
|
sessionId: string;
|
|
209
210
|
breakData: Partial<Break>;
|
|
210
211
|
}>>;
|
|
212
|
+
useScheduleRoutes(): ReturnType<typeof useMutation<{
|
|
213
|
+
msg: string;
|
|
214
|
+
}, StandardError, {
|
|
215
|
+
schedule: RouteScheduleConfig;
|
|
216
|
+
}>>;
|
|
211
217
|
useUpdateEvent(): ReturnType<typeof useMutation<{
|
|
212
218
|
msg: string;
|
|
213
219
|
}, StandardError, {
|
|
@@ -311,6 +317,7 @@ declare module '../client/QueryClient' {
|
|
|
311
317
|
id: string;
|
|
312
318
|
}, StandardError, {
|
|
313
319
|
user_id: string;
|
|
320
|
+
data: Partial<UserCompanyAssociation>;
|
|
314
321
|
}>>;
|
|
315
322
|
useRemoveUserCompany(): ReturnType<typeof useMutation<{
|
|
316
323
|
msg: string;
|
|
@@ -95,11 +95,11 @@ AvroQueryClient.prototype.useUpdateCompany = function () {
|
|
|
95
95
|
AvroQueryClient.prototype.useCreateUserCompany = function () {
|
|
96
96
|
const queryClient = this.getQueryClient();
|
|
97
97
|
return useMutation({
|
|
98
|
-
mutationFn: async ({ user_id }) => {
|
|
98
|
+
mutationFn: async ({ user_id, data }) => {
|
|
99
99
|
if (!user_id) {
|
|
100
100
|
throw new Error("Both userId and companyId are required");
|
|
101
101
|
}
|
|
102
|
-
return this.post(`/company/${this.companyId}/user/${user_id}`, JSON.stringify(
|
|
102
|
+
return this.post(`/company/${this.companyId}/user/${user_id}`, JSON.stringify(data), undefined, { "Content-Type": "application/json" });
|
|
103
103
|
},
|
|
104
104
|
onMutate: async ({ user_id }) => {
|
|
105
105
|
await queryClient.cancelQueries({ queryKey: ['company', this.companyId] });
|
|
@@ -122,6 +122,7 @@ AvroQueryClient.prototype.useCreateUserCompany = function () {
|
|
|
122
122
|
onSettled: (_data, _error, variables) => {
|
|
123
123
|
queryClient.invalidateQueries({ queryKey: ['company', this.companyId] });
|
|
124
124
|
queryClient.invalidateQueries({ queryKey: ['/company/list'] });
|
|
125
|
+
queryClient.invalidateQueries({ queryKey: ['company', 'current'] });
|
|
125
126
|
},
|
|
126
127
|
});
|
|
127
128
|
};
|
|
@@ -75,6 +75,13 @@ AvroQueryClient.prototype.useCreateRoute = function () {
|
|
|
75
75
|
},
|
|
76
76
|
});
|
|
77
77
|
};
|
|
78
|
+
AvroQueryClient.prototype.useScheduleRoutes = function () {
|
|
79
|
+
return useMutation({
|
|
80
|
+
mutationFn: async ({ schedule }) => {
|
|
81
|
+
return this.post(`/company/${this.companyId}/schedule`, JSON.stringify(schedule), undefined, { "Content-Type": "application/json" });
|
|
82
|
+
},
|
|
83
|
+
});
|
|
84
|
+
};
|
|
78
85
|
AvroQueryClient.prototype.useUpdateRoute = function () {
|
|
79
86
|
const queryClient = this.getQueryClient();
|
|
80
87
|
return useMutation({
|
package/dist/types/api.d.ts
CHANGED
|
@@ -57,6 +57,33 @@ export interface PaymentMethod {
|
|
|
57
57
|
} | null;
|
|
58
58
|
} | null;
|
|
59
59
|
}
|
|
60
|
+
export type ScheduleItem = {
|
|
61
|
+
type: "location";
|
|
62
|
+
location: [number, number];
|
|
63
|
+
time_window: [number, number];
|
|
64
|
+
} | {
|
|
65
|
+
type: "break";
|
|
66
|
+
start: [number, number];
|
|
67
|
+
time_window: [number, number];
|
|
68
|
+
} | {
|
|
69
|
+
type: "job";
|
|
70
|
+
job_id: string;
|
|
71
|
+
task_ids: string[];
|
|
72
|
+
location: [number, number];
|
|
73
|
+
time_window: [number, number];
|
|
74
|
+
};
|
|
75
|
+
export type TeamSchedule = {
|
|
76
|
+
team_id: string;
|
|
77
|
+
schedule: ScheduleItem[];
|
|
78
|
+
name: string;
|
|
79
|
+
optimize: boolean;
|
|
80
|
+
};
|
|
81
|
+
export type RouteScheduleConfig = {
|
|
82
|
+
schedules: TeamSchedule[];
|
|
83
|
+
whitelist: string[];
|
|
84
|
+
blacklist: string[];
|
|
85
|
+
tasks: string[];
|
|
86
|
+
};
|
|
60
87
|
export interface Avro {
|
|
61
88
|
id: string;
|
|
62
89
|
name: string;
|