e3da625927
- Backend Laravel 11 (API REST, JWT auth, PostgreSQL) - Frontend Next.js 14 (React, TypeScript, Tailwind CSS) - Docker Compose (PostgreSQL, backend, frontend) - Modules : auth, profil, tracker émotions, informations, admin
25 lines
562 B
TypeScript
25 lines
562 B
TypeScript
import { useQuery } from '@tanstack/react-query';
|
|
import api from '@/lib/api';
|
|
import type { Feed } from '@/types';
|
|
|
|
export function useFeeds() {
|
|
return useQuery<Feed[]>({
|
|
queryKey: ['feeds'],
|
|
queryFn: async () => {
|
|
const response = await api.get('/feeds');
|
|
return response.data;
|
|
},
|
|
});
|
|
}
|
|
|
|
export function useFeed(slug: string) {
|
|
return useQuery<Feed>({
|
|
queryKey: ['feeds', slug],
|
|
queryFn: async () => {
|
|
const response = await api.get(`/feeds/${slug}`);
|
|
return response.data;
|
|
},
|
|
enabled: !!slug,
|
|
});
|
|
}
|