client: spaces - wip

This commit is contained in:
Philipinho
2024-03-22 20:23:58 +00:00
parent 4657672dfe
commit 6136d30a1f
3 changed files with 28 additions and 0 deletions

View File

@ -0,0 +1,10 @@
import { useQuery, UseQueryResult } from "@tanstack/react-query";
import { ISpace } from "@/features/space/types/space.types";
import { getUserSpaces } from "@/features/space/services/space-service";
export function useUserSpacesQuery(): UseQueryResult<ISpace[], Error> {
return useQuery({
queryKey: ["user-spaces"],
queryFn: () => getUserSpaces(),
});
}

View File

@ -0,0 +1,7 @@
import api from '@/lib/api-client';
import { ISpace } from '@/features/space/types/space.types';
export async function getUserSpaces(): Promise<ISpace[]> {
const req = await api.get<ISpace[]>('/spaces');
return req.data as ISpace[];
}

View File

@ -0,0 +1,11 @@
export interface ISpace {
id: string;
name: string;
description: string;
icon: string;
hostname: string;
creatorId: string;
createdAt: Date;
updatedAt: Date;
}