@go-avro/avro-js 0.0.2-beta.91 → 0.0.2-beta.93
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[];
|
|
@@ -352,6 +356,11 @@ export declare class AvroQueryClient {
|
|
|
352
356
|
query?: string;
|
|
353
357
|
offset?: number;
|
|
354
358
|
}, cancelToken?: CancelToken, headers?: Record<string, string>): Promise<any>;
|
|
359
|
+
fetchSessions(companyGuid: string, body?: {
|
|
360
|
+
amt?: number;
|
|
361
|
+
query?: string;
|
|
362
|
+
offset?: number;
|
|
363
|
+
}, cancelToken?: CancelToken, headers?: Record<string, string>): Promise<any>;
|
|
355
364
|
sendEmail(emailId: string, formData: FormData, progressUpdateCallback?: (loaded: number, total: number) => void): Promise<void>;
|
|
356
365
|
createBill(companyGuid: string, data: {
|
|
357
366
|
line_items: LineItem[];
|
|
@@ -120,7 +120,7 @@ export class AvroQueryClient {
|
|
|
120
120
|
const queryClient = useQueryClient();
|
|
121
121
|
return useMutation({
|
|
122
122
|
mutationFn: async ({ username, email, code, newPassword, cancelToken }) => {
|
|
123
|
-
await this.post(
|
|
123
|
+
await this.post(`/user/${username ?? email}/password`, JSON.stringify({ code, password: newPassword }), cancelToken, { 'Content-Type': 'application/json' });
|
|
124
124
|
},
|
|
125
125
|
onSettled: () => {
|
|
126
126
|
queryClient.invalidateQueries();
|
|
@@ -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);
|
|
@@ -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
|
+
};
|