@go-avro/avro-js 0.0.2-beta.55 → 0.0.2-beta.57
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.
|
@@ -193,7 +193,7 @@ export declare class AvroQueryClient {
|
|
|
193
193
|
}, cancelToken?: CancelToken): Promise<Boolean>;
|
|
194
194
|
setTokens(tokens: Tokens): Promise<void>;
|
|
195
195
|
clearTokens(): Promise<void>;
|
|
196
|
-
|
|
196
|
+
useLogout(): ReturnType<typeof useMutation<void, StandardError, CancelToken | undefined>>;
|
|
197
197
|
fetchJobs(companyGuid: string, body?: {
|
|
198
198
|
amt?: number;
|
|
199
199
|
known_ids?: string[];
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { useMutation, useQueryClient } from '@tanstack/react-query';
|
|
1
2
|
import { StandardError } from '../types/error';
|
|
2
3
|
export class AvroQueryClient {
|
|
3
4
|
constructor(config) {
|
|
@@ -40,12 +41,19 @@ export class AvroQueryClient {
|
|
|
40
41
|
clearTokens() {
|
|
41
42
|
return this.config.authManager.clearTokens();
|
|
42
43
|
}
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
44
|
+
useLogout() {
|
|
45
|
+
const queryClient = useQueryClient();
|
|
46
|
+
return useMutation({
|
|
47
|
+
mutationFn: (cancelToken) => this._fetch('POST', '/logout', null, cancelToken)
|
|
48
|
+
.then(() => this.config.authManager.clearTokens()),
|
|
49
|
+
onSettled: () => {
|
|
50
|
+
queryClient.invalidateQueries();
|
|
51
|
+
},
|
|
52
|
+
onError: (err) => {
|
|
53
|
+
this.config.authManager.clearTokens();
|
|
54
|
+
console.error('Logout failed:', err);
|
|
55
|
+
throw new StandardError(500, 'Logout failed');
|
|
56
|
+
}
|
|
49
57
|
});
|
|
50
58
|
}
|
|
51
59
|
fetchJobs(companyGuid, body = {}, cancelToken, headers = {}) {
|
|
@@ -18,7 +18,7 @@ AvroQueryClient.prototype.useCreateSelf = function () {
|
|
|
18
18
|
const queryClient = useQueryClient();
|
|
19
19
|
return useMutation({
|
|
20
20
|
mutationFn: async (data) => {
|
|
21
|
-
return this.post('/user', data);
|
|
21
|
+
return this.post('/user', JSON.stringify(data), undefined, { "Content-Type": "application/json" });
|
|
22
22
|
},
|
|
23
23
|
onSettled: () => {
|
|
24
24
|
queryClient.invalidateQueries({ queryKey: ['user'] });
|