* feat: Enhance portfolio with SEO meta tags, implement API for experiences and projects, and refactor components for improved structure * fix: address Copilot review comments on PR #2 - Migrate Grid callers to the System Grid size prop (GridWrapper) - Render experience icons from exp.type instead of exp.icon - Show experience date range (dateS-dateE) on desktop and mobile - Select experience description from the active i18n language - Restore technology chips from exp.technologies - Rename uesExperience hook to useExperience - Normalize getProjets response to the { data, count } shape - Return ExperienceFull from getExperience - Type useEditProjet/updateProjet with ProjetEdit - Fetch project details from the API in Projet page (useProjet) - Replace ExperienceType enum with const object (erasableSyntaxOnly) - Sync document lang attribute with the active language
42 lines
1.2 KiB
TypeScript
42 lines
1.2 KiB
TypeScript
import { useMutation, useQuery, useQueryClient } from '@tanstack/react-query';
|
|
|
|
|
|
import { createExperience, deleteExperience, getExperience, getExperiences } from '../api/experience';
|
|
import type { Experiencecreate } from '../types/experience';
|
|
|
|
export function useExperiences() {
|
|
return useQuery({
|
|
queryKey: ['experiences'],
|
|
queryFn: () => getExperiences(),
|
|
})
|
|
}
|
|
|
|
export function useExperience(id: number | undefined) {
|
|
return useQuery({
|
|
queryKey: ['experience', id],
|
|
queryFn: () => getExperience(id!),
|
|
enabled: !!id,
|
|
})
|
|
}
|
|
|
|
export default function useCreateExperience() {
|
|
const queryClient = useQueryClient();
|
|
return useMutation({
|
|
mutationFn: (newExperience: Experiencecreate) => createExperience(newExperience),
|
|
onSuccess: () => {
|
|
queryClient.invalidateQueries({ queryKey: ['experiences'] });
|
|
},
|
|
|
|
})
|
|
}
|
|
|
|
export function useDeleteExperience() {
|
|
const queryClient = useQueryClient();
|
|
return useMutation({
|
|
mutationFn: (id: number) => deleteExperience(id),
|
|
onSuccess: () => {
|
|
queryClient.invalidateQueries({ queryKey: ['experiences'] });
|
|
},
|
|
|
|
})
|
|
} |