@go-avro/avro-js 0.0.2-beta.92 → 0.0.2-beta.94
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.
|
@@ -42,6 +42,10 @@ declare module '../client/QueryClient' {
|
|
|
42
42
|
paid?: boolean;
|
|
43
43
|
jobId?: string;
|
|
44
44
|
}): UseInfiniteQueryResult<InfiniteData<_Event[], unknown>, StandardError>;
|
|
45
|
+
useGetSessions(companyGuid: string, body: {
|
|
46
|
+
amt?: number;
|
|
47
|
+
query?: string;
|
|
48
|
+
}): UseInfiniteQueryResult<InfiniteData<Session[], unknown>, StandardError>;
|
|
45
49
|
useGetChats(companyGuid: string, body: {
|
|
46
50
|
amt?: number;
|
|
47
51
|
known_ids?: string[];
|
|
@@ -116,6 +120,13 @@ declare module '../client/QueryClient' {
|
|
|
116
120
|
custom_emails: [string, string][];
|
|
117
121
|
};
|
|
118
122
|
}>>;
|
|
123
|
+
useCreateCompany(): ReturnType<typeof useMutation<{
|
|
124
|
+
id: string;
|
|
125
|
+
}, StandardError, {
|
|
126
|
+
companyData: Partial<Company | {
|
|
127
|
+
logo: File | null;
|
|
128
|
+
}>;
|
|
129
|
+
}>>;
|
|
119
130
|
useCreateJob(): ReturnType<typeof useMutation<{
|
|
120
131
|
id: string;
|
|
121
132
|
}, StandardError, {
|
|
@@ -352,6 +363,11 @@ export declare class AvroQueryClient {
|
|
|
352
363
|
query?: string;
|
|
353
364
|
offset?: number;
|
|
354
365
|
}, cancelToken?: CancelToken, headers?: Record<string, string>): Promise<any>;
|
|
366
|
+
fetchSessions(companyGuid: string, body?: {
|
|
367
|
+
amt?: number;
|
|
368
|
+
query?: string;
|
|
369
|
+
offset?: number;
|
|
370
|
+
}, cancelToken?: CancelToken, headers?: Record<string, string>): Promise<any>;
|
|
355
371
|
sendEmail(emailId: string, formData: FormData, progressUpdateCallback?: (loaded: number, total: number) => void): Promise<void>;
|
|
356
372
|
createBill(companyGuid: string, data: {
|
|
357
373
|
line_items: LineItem[];
|
|
@@ -342,6 +342,25 @@ export class AvroQueryClient {
|
|
|
342
342
|
throw new StandardError(500, 'Failed to fetch teams');
|
|
343
343
|
});
|
|
344
344
|
}
|
|
345
|
+
fetchSessions(companyGuid, body = {}, cancelToken, headers = {}) {
|
|
346
|
+
if (!companyGuid || companyGuid.trim() === '') {
|
|
347
|
+
return Promise.reject(new StandardError(400, 'Company GUID is required'));
|
|
348
|
+
}
|
|
349
|
+
return this._fetch('POST', `/company/${companyGuid}/sessions`, JSON.stringify(body), cancelToken, {
|
|
350
|
+
...headers,
|
|
351
|
+
'Content-Type': 'application/json',
|
|
352
|
+
})
|
|
353
|
+
.then(response => {
|
|
354
|
+
if (!response || !Array.isArray(response)) {
|
|
355
|
+
throw new StandardError(400, 'Invalid sessions response');
|
|
356
|
+
}
|
|
357
|
+
return response;
|
|
358
|
+
})
|
|
359
|
+
.catch(err => {
|
|
360
|
+
console.error('Failed to fetch sessions:', err);
|
|
361
|
+
throw new StandardError(500, 'Failed to fetch sessions');
|
|
362
|
+
});
|
|
363
|
+
}
|
|
345
364
|
sendEmail(emailId, formData, progressUpdateCallback) {
|
|
346
365
|
try {
|
|
347
366
|
return this.post(`/email/${emailId}`, formData, undefined, {}, progressUpdateCallback);
|
|
@@ -14,6 +14,17 @@ AvroQueryClient.prototype.useGetCompany = function (companyId) {
|
|
|
14
14
|
enabled: Boolean(companyId),
|
|
15
15
|
});
|
|
16
16
|
};
|
|
17
|
+
AvroQueryClient.prototype.useCreateCompany = function () {
|
|
18
|
+
const queryClient = useQueryClient();
|
|
19
|
+
return useMutation({
|
|
20
|
+
mutationFn: async ({ companyData }) => {
|
|
21
|
+
return this.post(`/company`, JSON.stringify(companyData), undefined, { "Content-Type": "application/json" });
|
|
22
|
+
},
|
|
23
|
+
onSettled: () => {
|
|
24
|
+
queryClient.invalidateQueries({ queryKey: ['/company/list'] });
|
|
25
|
+
},
|
|
26
|
+
});
|
|
27
|
+
};
|
|
17
28
|
AvroQueryClient.prototype.useUpdateCompany = function () {
|
|
18
29
|
const queryClient = useQueryClient();
|
|
19
30
|
return useMutation({
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { useMutation, useQuery, useQueryClient } from "@tanstack/react-query";
|
|
1
|
+
import { useMutation, useQuery, useQueryClient, useInfiniteQuery } from "@tanstack/react-query";
|
|
2
2
|
import { AvroQueryClient } from "../../client/QueryClient";
|
|
3
3
|
AvroQueryClient.prototype.useGetUserSessions = function () {
|
|
4
4
|
return useQuery({
|
|
@@ -152,3 +152,25 @@ AvroQueryClient.prototype.useUpdateSessionBreak = function () {
|
|
|
152
152
|
},
|
|
153
153
|
});
|
|
154
154
|
};
|
|
155
|
+
AvroQueryClient.prototype.useGetSessions = function (companyGuid, body) {
|
|
156
|
+
const queryClient = useQueryClient();
|
|
157
|
+
const result = useInfiniteQuery({
|
|
158
|
+
queryKey: ['sessions', companyGuid, body.amt ?? 50, body.query ?? ""],
|
|
159
|
+
initialPageParam: 0,
|
|
160
|
+
getNextPageParam: (lastPage, allPages) => {
|
|
161
|
+
if (lastPage.length < (body.amt ?? 50))
|
|
162
|
+
return undefined;
|
|
163
|
+
return allPages.flat().length; // next offset
|
|
164
|
+
},
|
|
165
|
+
queryFn: ({ pageParam = 0 }) => this.fetchSessions(companyGuid, { ...body, offset: pageParam }),
|
|
166
|
+
enabled: Boolean(companyGuid) && companyGuid.length > 0,
|
|
167
|
+
});
|
|
168
|
+
if (result.data) {
|
|
169
|
+
result.data.pages.forEach((data_page) => {
|
|
170
|
+
data_page.forEach((session) => {
|
|
171
|
+
queryClient.setQueryData(['session', session.id], session);
|
|
172
|
+
});
|
|
173
|
+
});
|
|
174
|
+
}
|
|
175
|
+
return result;
|
|
176
|
+
};
|