diff --git a/app/employe/gains-client/page.tsx b/app/employe/gains-client/page.tsx index 280d790..ba097e5 100644 --- a/app/employe/gains-client/page.tsx +++ b/app/employe/gains-client/page.tsx @@ -4,7 +4,7 @@ import { useState } from 'react'; import { Card } from '@/components/ui/Card'; import { EmptyState } from '@/components/ui/EmptyState'; import Button from '@/components/Button'; -import { apiFetch } from '@/hooks/useApi'; +import { api } from '@/hooks/useApi'; import toast from 'react-hot-toast'; import { Search, @@ -65,7 +65,7 @@ export default function GainsClientPage() { setLoading(true); try { const queryParam = searchType === 'email' ? `email=${encodeURIComponent(searchValue)}` : `phone=${encodeURIComponent(searchValue)}`; - const data = await apiFetch<{ data: ClientData }>(`/employee/client-prizes?${queryParam}`); + const data = await api.get<{ data: ClientData }>(`/employee/client-prizes?${queryParam}`); setClientData(data.data); toast.success(`Client trouvé: ${data.data.client.firstName} ${data.data.client.lastName}`); } catch (error: any) { @@ -84,10 +84,7 @@ export default function GainsClientPage() { setValidatingTicketId(ticketId); try { - await apiFetch('/employee/validate-ticket', { - method: 'POST', - body: JSON.stringify({ ticketId, action: 'APPROVE' }), - }); + await api.post('/employee/validate-ticket', { ticketId, action: 'APPROVE' }); toast.success('Lot marqué comme remis!'); handleSearch(); } catch (error: any) { diff --git a/app/employe/historique/page.tsx b/app/employe/historique/page.tsx index 46b5b8d..67d80f7 100644 --- a/app/employe/historique/page.tsx +++ b/app/employe/historique/page.tsx @@ -4,7 +4,7 @@ import { useState, useEffect } from 'react'; import { useAuth } from '@/hooks'; import { Card, EmptyState } from '@/components/ui'; import { Loading } from '@/components/ui/Loading'; -import { apiFetch } from '@/hooks/useApi'; +import { api } from '@/hooks/useApi'; import toast from 'react-hot-toast'; import { CheckCircle, @@ -45,7 +45,7 @@ export default function EmployeeHistoryPage() { const loadHistory = async () => { try { setLoading(true); - const data = await apiFetch<{ data: HistoryTicket[] }>('/employee/history'); + const data = await api.get<{ data: HistoryTicket[] }>('/employee/history'); setHistory(data.data || []); } catch (error: any) { console.error('Error loading history:', error); diff --git a/hooks/index.ts b/hooks/index.ts index 24204cd..241d6be 100644 --- a/hooks/index.ts +++ b/hooks/index.ts @@ -2,4 +2,4 @@ export { useAuth } from '@/contexts/AuthContext'; export { useForm } from './useForm'; export { useToast } from './useToast'; export { useGame } from './useGame'; -export { useApi, useFetchData, apiFetch, getAuthToken } from './useApi'; +export { useApi, useFetchData, api, ApiError } from './useApi';