@go-avro/avro-js 0.0.10-beta.2 → 0.0.10-beta.3
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.
- package/dist/client/QueryClient.d.ts +34 -1
- package/dist/client/hooks/timecards.d.ts +1 -0
- package/dist/client/hooks/timecards.js +76 -0
- package/dist/index.d.ts +1 -0
- package/dist/index.js +1 -0
- package/dist/types/api/Company.d.ts +2 -0
- package/dist/types/api/Session.d.ts +17 -11
- package/dist/types/api/Session.js +5 -1
- package/dist/types/api/Timecard.d.ts +20 -0
- package/dist/types/api/Timecard.js +6 -0
- package/dist/types/api/TimecardAction.d.ts +18 -0
- package/dist/types/api/TimecardAction.js +8 -0
- package/dist/types/api/UserCompanyAssociation.d.ts +9 -0
- package/dist/types/api.d.ts +2 -0
- package/dist/types/api.js +2 -0
- package/package.json +1 -1
|
@@ -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, RouteScheduleConfig, CatalogItem, Prepayment } 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, CatalogItem, Prepayment, Timecard, TimecardActionType, TimecardStatus } 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';
|
|
@@ -153,6 +153,14 @@ declare module '../client/QueryClient' {
|
|
|
153
153
|
useGetChat(chatId: string): UseQueryResult<Chat, StandardError>;
|
|
154
154
|
useGetCatalogItem(catalogItemId: string): UseQueryResult<CatalogItem, StandardError>;
|
|
155
155
|
useGetUserSessions(): UseQueryResult<Session[], StandardError>;
|
|
156
|
+
useGetCompanyTimecards(params?: {
|
|
157
|
+
companyId?: string;
|
|
158
|
+
periodStart?: number;
|
|
159
|
+
userCompanyId?: string;
|
|
160
|
+
status?: TimecardStatus;
|
|
161
|
+
enabled?: boolean;
|
|
162
|
+
}): UseQueryResult<Timecard[], StandardError>;
|
|
163
|
+
useGetTimecard(timecardId?: string, enabled?: boolean): UseQueryResult<Timecard, StandardError>;
|
|
156
164
|
useGetAvro(): UseQueryResult<Avro, StandardError>;
|
|
157
165
|
useSearchUsers(searchUsername: string): UseQueryResult<User[], StandardError>;
|
|
158
166
|
useAcceptProposal(proposal_id: string): ReturnType<typeof useMutation<{
|
|
@@ -207,6 +215,18 @@ declare module '../client/QueryClient' {
|
|
|
207
215
|
}, StandardError, {
|
|
208
216
|
sessionData: Partial<Session>;
|
|
209
217
|
}>>;
|
|
218
|
+
useCreateTimecard(): ReturnType<typeof useMutation<{
|
|
219
|
+
msg: string;
|
|
220
|
+
id: string;
|
|
221
|
+
}, StandardError, {
|
|
222
|
+
companyId?: string;
|
|
223
|
+
data: {
|
|
224
|
+
user_company_id?: string;
|
|
225
|
+
period_start?: number;
|
|
226
|
+
status?: TimecardStatus;
|
|
227
|
+
details?: string;
|
|
228
|
+
};
|
|
229
|
+
}>>;
|
|
210
230
|
useCreateBill(): ReturnType<typeof useMutation<{
|
|
211
231
|
id: string;
|
|
212
232
|
invoice_id: number;
|
|
@@ -293,6 +313,19 @@ declare module '../client/QueryClient' {
|
|
|
293
313
|
sessionId: string;
|
|
294
314
|
updates: Partial<Session>;
|
|
295
315
|
}>>;
|
|
316
|
+
useUpdateTimecard(): ReturnType<typeof useMutation<{
|
|
317
|
+
msg: string;
|
|
318
|
+
timecard: Timecard;
|
|
319
|
+
}, StandardError, {
|
|
320
|
+
timecardId: string;
|
|
321
|
+
updates: {
|
|
322
|
+
status?: TimecardStatus;
|
|
323
|
+
start?: number;
|
|
324
|
+
end?: number;
|
|
325
|
+
details?: string;
|
|
326
|
+
action_type?: TimecardActionType;
|
|
327
|
+
};
|
|
328
|
+
}>>;
|
|
296
329
|
useUpdateGroup(): ReturnType<typeof useMutation<{
|
|
297
330
|
msg: string;
|
|
298
331
|
}, StandardError, {
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
import { useMutation, useQuery } from "@tanstack/react-query";
|
|
2
|
+
import { AvroQueryClient } from "../../client/QueryClient";
|
|
3
|
+
AvroQueryClient.prototype.useGetCompanyTimecards = function (params = {}) {
|
|
4
|
+
const companyId = params.companyId ?? this.companyId;
|
|
5
|
+
return useQuery({
|
|
6
|
+
queryKey: [
|
|
7
|
+
"timecards",
|
|
8
|
+
companyId,
|
|
9
|
+
params.periodStart ?? null,
|
|
10
|
+
params.userCompanyId ?? null,
|
|
11
|
+
params.status ?? null,
|
|
12
|
+
],
|
|
13
|
+
queryFn: async () => {
|
|
14
|
+
const search = new URLSearchParams();
|
|
15
|
+
if (typeof params.periodStart === "number") {
|
|
16
|
+
search.set("period_start", String(params.periodStart));
|
|
17
|
+
}
|
|
18
|
+
if (params.userCompanyId) {
|
|
19
|
+
search.set("user_company_id", params.userCompanyId);
|
|
20
|
+
}
|
|
21
|
+
if (params.status) {
|
|
22
|
+
search.set("status", params.status);
|
|
23
|
+
}
|
|
24
|
+
const query = search.toString();
|
|
25
|
+
const rsp = await this.get({
|
|
26
|
+
path: `/company/${companyId}/timecards${query ? `?${query}` : ""}`,
|
|
27
|
+
});
|
|
28
|
+
return rsp.timecards ?? [];
|
|
29
|
+
},
|
|
30
|
+
enabled: Boolean(companyId) && Boolean(params.enabled ?? true),
|
|
31
|
+
});
|
|
32
|
+
};
|
|
33
|
+
AvroQueryClient.prototype.useGetTimecard = function (timecardId, enabled = true) {
|
|
34
|
+
return useQuery({
|
|
35
|
+
queryKey: ["timecard", timecardId],
|
|
36
|
+
queryFn: async () => {
|
|
37
|
+
const rsp = await this.get({
|
|
38
|
+
path: `/timecard/${timecardId}`,
|
|
39
|
+
});
|
|
40
|
+
return rsp.timecard;
|
|
41
|
+
},
|
|
42
|
+
enabled: Boolean(timecardId) && enabled,
|
|
43
|
+
});
|
|
44
|
+
};
|
|
45
|
+
AvroQueryClient.prototype.useCreateTimecard = function () {
|
|
46
|
+
const queryClient = this.getQueryClient();
|
|
47
|
+
return useMutation({
|
|
48
|
+
mutationFn: ({ companyId, data, }) => {
|
|
49
|
+
const targetCompanyId = companyId ?? this.companyId;
|
|
50
|
+
return this.post({
|
|
51
|
+
path: `/company/${targetCompanyId}/timecard`,
|
|
52
|
+
data: JSON.stringify(data),
|
|
53
|
+
headers: { "Content-Type": "application/json" },
|
|
54
|
+
});
|
|
55
|
+
},
|
|
56
|
+
onSettled: async () => {
|
|
57
|
+
await queryClient.invalidateQueries({ queryKey: ["timecards"] });
|
|
58
|
+
},
|
|
59
|
+
});
|
|
60
|
+
};
|
|
61
|
+
AvroQueryClient.prototype.useUpdateTimecard = function () {
|
|
62
|
+
const queryClient = this.getQueryClient();
|
|
63
|
+
return useMutation({
|
|
64
|
+
mutationFn: ({ timecardId, updates, }) => {
|
|
65
|
+
return this.put({
|
|
66
|
+
path: `/timecard/${timecardId}`,
|
|
67
|
+
data: JSON.stringify(updates),
|
|
68
|
+
headers: { "Content-Type": "application/json" },
|
|
69
|
+
});
|
|
70
|
+
},
|
|
71
|
+
onSettled: async (_data, _err, variables) => {
|
|
72
|
+
await queryClient.invalidateQueries({ queryKey: ["timecards"] });
|
|
73
|
+
await queryClient.invalidateQueries({ queryKey: ["timecard", variables.timecardId] });
|
|
74
|
+
},
|
|
75
|
+
});
|
|
76
|
+
};
|
package/dist/index.d.ts
CHANGED
|
@@ -26,6 +26,7 @@ import './client/hooks/labels';
|
|
|
26
26
|
import './client/hooks/groups';
|
|
27
27
|
import './client/hooks/skills';
|
|
28
28
|
import './client/hooks/proposal';
|
|
29
|
+
import './client/hooks/timecards';
|
|
29
30
|
import './client/hooks/waivers';
|
|
30
31
|
export * from './types/api';
|
|
31
32
|
export * from './types/auth';
|
package/dist/index.js
CHANGED
|
@@ -26,6 +26,7 @@ import './client/hooks/labels';
|
|
|
26
26
|
import './client/hooks/groups';
|
|
27
27
|
import './client/hooks/skills';
|
|
28
28
|
import './client/hooks/proposal';
|
|
29
|
+
import './client/hooks/timecards';
|
|
29
30
|
import './client/hooks/waivers';
|
|
30
31
|
export * from './types/api';
|
|
31
32
|
export * from './types/auth';
|
|
@@ -1,13 +1,19 @@
|
|
|
1
1
|
import { Break } from "../../types/api/Break";
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
2
|
+
declare module "../../types/api/Session" {
|
|
3
|
+
interface Session {
|
|
4
|
+
id: string;
|
|
5
|
+
user_id: string;
|
|
6
|
+
company_id: string;
|
|
7
|
+
time_started: number;
|
|
8
|
+
time_ended: number | null;
|
|
9
|
+
break_id: string | null;
|
|
10
|
+
is_paused: boolean;
|
|
11
|
+
team_id: string | null;
|
|
12
|
+
route_id: string | null;
|
|
13
|
+
current_route_id?: string | null;
|
|
14
|
+
breaks: Break[];
|
|
15
|
+
}
|
|
16
|
+
}
|
|
17
|
+
export declare class Session {
|
|
18
|
+
constructor(init?: Partial<Session>);
|
|
13
19
|
}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { TimecardAction } from "../../types/api/TimecardAction";
|
|
2
|
+
export declare const TimecardStatus: {
|
|
3
|
+
readonly OPEN: "open";
|
|
4
|
+
readonly PENDING: "pending";
|
|
5
|
+
readonly APPROVED: "approved";
|
|
6
|
+
readonly REJECTED: "rejected";
|
|
7
|
+
};
|
|
8
|
+
export type TimecardStatus = typeof TimecardStatus[keyof typeof TimecardStatus];
|
|
9
|
+
export interface Timecard {
|
|
10
|
+
id: string;
|
|
11
|
+
user_company_id: string;
|
|
12
|
+
session_ids: string[];
|
|
13
|
+
submitted_at: number | null;
|
|
14
|
+
start: number | null;
|
|
15
|
+
end: number | null;
|
|
16
|
+
status: TimecardStatus;
|
|
17
|
+
actions: TimecardAction[];
|
|
18
|
+
time_created: number | null;
|
|
19
|
+
time_updated: number | null;
|
|
20
|
+
}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
export declare const TimecardActionType: {
|
|
2
|
+
readonly CREATED: "created";
|
|
3
|
+
readonly SUBMITTED: "submitted";
|
|
4
|
+
readonly COMMENTED: "commented";
|
|
5
|
+
readonly APPROVED: "approved";
|
|
6
|
+
readonly REJECTED: "rejected";
|
|
7
|
+
readonly EDITED: "edited";
|
|
8
|
+
};
|
|
9
|
+
export type TimecardActionType = typeof TimecardActionType[keyof typeof TimecardActionType];
|
|
10
|
+
export interface TimecardAction {
|
|
11
|
+
id: string;
|
|
12
|
+
action_type: TimecardActionType;
|
|
13
|
+
first_name: string | null;
|
|
14
|
+
last_name: string | null;
|
|
15
|
+
details: string | null;
|
|
16
|
+
time_created: number | null;
|
|
17
|
+
time_updated: number | null;
|
|
18
|
+
}
|
|
@@ -59,6 +59,15 @@ export interface UserCompanyAssociation {
|
|
|
59
59
|
id: string;
|
|
60
60
|
user: User;
|
|
61
61
|
company: string;
|
|
62
|
+
hourly_rate: number;
|
|
63
|
+
salary_rate: number;
|
|
64
|
+
bill_rate: number;
|
|
65
|
+
pto_rate: number;
|
|
66
|
+
sick_rate: number;
|
|
67
|
+
accrued_pto: number;
|
|
68
|
+
accrued_sick: number;
|
|
69
|
+
pto_accrual_rate: number;
|
|
70
|
+
sick_accrual_rate: number;
|
|
62
71
|
permissions: Permission[];
|
|
63
72
|
effective_permissions: Permission[];
|
|
64
73
|
time_created: number | null;
|
package/dist/types/api.d.ts
CHANGED
|
@@ -32,6 +32,8 @@ export * from "../types/api/Session";
|
|
|
32
32
|
export * from "../types/api/Skill";
|
|
33
33
|
export * from "../types/api/Subscription";
|
|
34
34
|
export * from "../types/api/Task";
|
|
35
|
+
export * from "../types/api/Timecard";
|
|
36
|
+
export * from "../types/api/TimecardAction";
|
|
35
37
|
export * from "../types/api/User";
|
|
36
38
|
export * from "../types/api/UserCompanyAssociation";
|
|
37
39
|
export * from "../types/api/UserEvent";
|
package/dist/types/api.js
CHANGED
|
@@ -31,6 +31,8 @@ export * from "../types/api/Session";
|
|
|
31
31
|
export * from "../types/api/Skill";
|
|
32
32
|
export * from "../types/api/Subscription";
|
|
33
33
|
export * from "../types/api/Task";
|
|
34
|
+
export * from "../types/api/Timecard";
|
|
35
|
+
export * from "../types/api/TimecardAction";
|
|
34
36
|
export * from "../types/api/User";
|
|
35
37
|
export * from "../types/api/UserCompanyAssociation";
|
|
36
38
|
export * from "../types/api/UserEvent";
|