Initial commit
Build / run (push) Has been cancelled

This commit is contained in:
maher
2026-05-14 13:42:10 +02:00
commit 511fad8199
4595 changed files with 385164 additions and 0 deletions
+32
View File
@@ -0,0 +1,32 @@
import {useQuery} from '@tanstack/react-query';
import {BackendResponse} from '../../http/backend-response/backend-response';
import {User} from '../user';
import {apiClient} from '../../http/query-client';
export interface FetchUseUserResponse extends BackendResponse {
user: User;
}
interface Params {
with: string[];
}
type UserId = number | string | 'me';
const queryKey = (id: UserId, params?: Params) => {
const key: any[] = ['users', `${id}`];
if (params) {
key.push(params);
}
return key;
};
export function useUser(id: UserId, params?: Params) {
return useQuery({
queryKey: queryKey(id, params),
queryFn: () => fetchUser(id, params),
});
}
function fetchUser(id: UserId, params?: Params): Promise<FetchUseUserResponse> {
return apiClient.get(`users/${id}`, {params}).then(response => response.data);
}