@go-avro/avro-js 0.0.2-beta.67 → 0.0.2-beta.68
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 +8 -1
- package/dist/client/hooks/companies.js +28 -0
- package/dist/client/hooks/plans.d.ts +1 -0
- package/dist/client/hooks/plans.js +9 -0
- package/dist/client/hooks/users.js +11 -0
- package/dist/index.d.ts +1 -0
- package/dist/index.js +1 -0
- package/dist/types/api.d.ts +2 -0
- package/package.json +1 -1
|
@@ -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, Bill, Break, Chat, Company, Job, LineItem, LoginResponse, Message, Route, ServiceMonth, Session, User, UserCompanyAssociation } from '../types/api';
|
|
4
|
+
import { _Event, ApiInfo, Bill, Break, Chat, Company, Job, LineItem, LoginResponse, Message, Plan, Route, ServiceMonth, Session, 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';
|
|
@@ -69,6 +69,7 @@ declare module '../client/QueryClient' {
|
|
|
69
69
|
query?: string;
|
|
70
70
|
paid?: boolean;
|
|
71
71
|
}): UseInfiniteQueryResult<InfiniteData<Bill[], unknown>, StandardError>;
|
|
72
|
+
useGetPlans(code: string): UseQueryResult<Plan[], StandardError>;
|
|
72
73
|
useGetCompanies(options?: {}): UseQueryResult<{
|
|
73
74
|
name: string;
|
|
74
75
|
id: string;
|
|
@@ -82,6 +83,7 @@ declare module '../client/QueryClient' {
|
|
|
82
83
|
useGetRoute(routeId: string): UseQueryResult<Route, StandardError>;
|
|
83
84
|
useGetChat(chatId: string): UseQueryResult<Chat, StandardError>;
|
|
84
85
|
useGetUserSessions(): UseQueryResult<Session[], StandardError>;
|
|
86
|
+
useSearchUsers(searchUsername: string): UseQueryResult<User[], StandardError>;
|
|
85
87
|
useCreateEvent(): ReturnType<typeof useMutation<{
|
|
86
88
|
id: string;
|
|
87
89
|
}, StandardError, {
|
|
@@ -215,6 +217,11 @@ declare module '../client/QueryClient' {
|
|
|
215
217
|
useDeleteSelf(): ReturnType<typeof useMutation<{
|
|
216
218
|
msg: string;
|
|
217
219
|
}, StandardError, void>>;
|
|
220
|
+
useDeleteCompany(): ReturnType<typeof useMutation<{
|
|
221
|
+
msg: string;
|
|
222
|
+
}, StandardError, {
|
|
223
|
+
companyId: string;
|
|
224
|
+
}>>;
|
|
218
225
|
}
|
|
219
226
|
}
|
|
220
227
|
export declare class AvroQueryClient {
|
|
@@ -49,3 +49,31 @@ AvroQueryClient.prototype.useUpdateCompany = function () {
|
|
|
49
49
|
},
|
|
50
50
|
});
|
|
51
51
|
};
|
|
52
|
+
AvroQueryClient.prototype.useDeleteCompany = function () {
|
|
53
|
+
const queryClient = useQueryClient();
|
|
54
|
+
return useMutation({
|
|
55
|
+
mutationFn: async ({ companyId }) => {
|
|
56
|
+
return this.delete(`/company/${companyId}`);
|
|
57
|
+
},
|
|
58
|
+
onMutate: async ({ companyId }) => {
|
|
59
|
+
await queryClient.cancelQueries({ queryKey: ['/company/list'] });
|
|
60
|
+
await queryClient.cancelQueries({ queryKey: ['company', companyId] });
|
|
61
|
+
const previousCompanyList = queryClient.getQueryData(['/company/list']);
|
|
62
|
+
queryClient.setQueryData(['/company/list'], (oldList) => {
|
|
63
|
+
if (!oldList)
|
|
64
|
+
return oldList;
|
|
65
|
+
return oldList.filter((company) => company.id !== companyId);
|
|
66
|
+
});
|
|
67
|
+
return { previousCompanyList };
|
|
68
|
+
},
|
|
69
|
+
onError: (err, companyId, context) => {
|
|
70
|
+
if (context?.previousCompanyList) {
|
|
71
|
+
queryClient.setQueryData(['/company/list'], context.previousCompanyList);
|
|
72
|
+
}
|
|
73
|
+
},
|
|
74
|
+
onSettled: (_data, _error, companyId) => {
|
|
75
|
+
queryClient.invalidateQueries({ queryKey: ['/company/list'] });
|
|
76
|
+
queryClient.invalidateQueries({ queryKey: ['company', companyId] });
|
|
77
|
+
},
|
|
78
|
+
});
|
|
79
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { AvroQueryClient } from "../../client/QueryClient";
|
|
2
|
+
import { useQuery, useQueryClient } from "@tanstack/react-query";
|
|
3
|
+
AvroQueryClient.prototype.useGetPlans = function (code) {
|
|
4
|
+
const queryClient = useQueryClient();
|
|
5
|
+
return useQuery({
|
|
6
|
+
queryKey: ['plans', code],
|
|
7
|
+
queryFn: async () => this.get(`/plans${code ? `?code=${code}` : ''}`),
|
|
8
|
+
});
|
|
9
|
+
};
|
|
@@ -7,6 +7,17 @@ AvroQueryClient.prototype.useGetUser = function (userId) {
|
|
|
7
7
|
enabled: Boolean(userId),
|
|
8
8
|
});
|
|
9
9
|
};
|
|
10
|
+
AvroQueryClient.prototype.useSearchUsers = function (searchUsername) {
|
|
11
|
+
return useQuery({
|
|
12
|
+
queryKey: ['user', 'search', searchUsername],
|
|
13
|
+
queryFn: () => {
|
|
14
|
+
if (!searchUsername)
|
|
15
|
+
return Promise.resolve([]);
|
|
16
|
+
return this.get(`/user/search/${searchUsername}`);
|
|
17
|
+
},
|
|
18
|
+
enabled: Boolean(searchUsername),
|
|
19
|
+
});
|
|
20
|
+
};
|
|
10
21
|
AvroQueryClient.prototype.useGetSelf = function () {
|
|
11
22
|
return useQuery({
|
|
12
23
|
queryKey: ['user'],
|
package/dist/index.d.ts
CHANGED
|
@@ -15,6 +15,7 @@ import './client/hooks/users';
|
|
|
15
15
|
import './client/hooks/sessions';
|
|
16
16
|
import './client/hooks/chats';
|
|
17
17
|
import './client/hooks/messages';
|
|
18
|
+
import './client/hooks/plans';
|
|
18
19
|
export * from './types/api';
|
|
19
20
|
export * from './types/auth';
|
|
20
21
|
export * from './types/error';
|
package/dist/index.js
CHANGED
|
@@ -15,6 +15,7 @@ import './client/hooks/users';
|
|
|
15
15
|
import './client/hooks/sessions';
|
|
16
16
|
import './client/hooks/chats';
|
|
17
17
|
import './client/hooks/messages';
|
|
18
|
+
import './client/hooks/plans';
|
|
18
19
|
export * from './types/api';
|
|
19
20
|
export * from './types/auth';
|
|
20
21
|
export * from './types/error';
|
package/dist/types/api.d.ts
CHANGED