fix: replace apiFetch with api service methods

- hooks/index.ts: remove non-existent exports (apiFetch, getAuthToken)
- app/employe/gains-client/page.tsx: use api.get and api.post
- app/employe/historique/page.tsx: use api.get

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
soufiane 2025-12-01 15:38:18 +01:00
parent 0a00c04b54
commit eded0187a0
3 changed files with 6 additions and 9 deletions

View File

@ -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) {

View File

@ -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);

View File

@ -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';