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:
parent
0a00c04b54
commit
eded0187a0
|
|
@ -4,7 +4,7 @@ import { useState } from 'react';
|
||||||
import { Card } from '@/components/ui/Card';
|
import { Card } from '@/components/ui/Card';
|
||||||
import { EmptyState } from '@/components/ui/EmptyState';
|
import { EmptyState } from '@/components/ui/EmptyState';
|
||||||
import Button from '@/components/Button';
|
import Button from '@/components/Button';
|
||||||
import { apiFetch } from '@/hooks/useApi';
|
import { api } from '@/hooks/useApi';
|
||||||
import toast from 'react-hot-toast';
|
import toast from 'react-hot-toast';
|
||||||
import {
|
import {
|
||||||
Search,
|
Search,
|
||||||
|
|
@ -65,7 +65,7 @@ export default function GainsClientPage() {
|
||||||
setLoading(true);
|
setLoading(true);
|
||||||
try {
|
try {
|
||||||
const queryParam = searchType === 'email' ? `email=${encodeURIComponent(searchValue)}` : `phone=${encodeURIComponent(searchValue)}`;
|
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);
|
setClientData(data.data);
|
||||||
toast.success(`Client trouvé: ${data.data.client.firstName} ${data.data.client.lastName}`);
|
toast.success(`Client trouvé: ${data.data.client.firstName} ${data.data.client.lastName}`);
|
||||||
} catch (error: any) {
|
} catch (error: any) {
|
||||||
|
|
@ -84,10 +84,7 @@ export default function GainsClientPage() {
|
||||||
|
|
||||||
setValidatingTicketId(ticketId);
|
setValidatingTicketId(ticketId);
|
||||||
try {
|
try {
|
||||||
await apiFetch('/employee/validate-ticket', {
|
await api.post('/employee/validate-ticket', { ticketId, action: 'APPROVE' });
|
||||||
method: 'POST',
|
|
||||||
body: JSON.stringify({ ticketId, action: 'APPROVE' }),
|
|
||||||
});
|
|
||||||
toast.success('Lot marqué comme remis!');
|
toast.success('Lot marqué comme remis!');
|
||||||
handleSearch();
|
handleSearch();
|
||||||
} catch (error: any) {
|
} catch (error: any) {
|
||||||
|
|
|
||||||
|
|
@ -4,7 +4,7 @@ import { useState, useEffect } from 'react';
|
||||||
import { useAuth } from '@/hooks';
|
import { useAuth } from '@/hooks';
|
||||||
import { Card, EmptyState } from '@/components/ui';
|
import { Card, EmptyState } from '@/components/ui';
|
||||||
import { Loading } from '@/components/ui/Loading';
|
import { Loading } from '@/components/ui/Loading';
|
||||||
import { apiFetch } from '@/hooks/useApi';
|
import { api } from '@/hooks/useApi';
|
||||||
import toast from 'react-hot-toast';
|
import toast from 'react-hot-toast';
|
||||||
import {
|
import {
|
||||||
CheckCircle,
|
CheckCircle,
|
||||||
|
|
@ -45,7 +45,7 @@ export default function EmployeeHistoryPage() {
|
||||||
const loadHistory = async () => {
|
const loadHistory = async () => {
|
||||||
try {
|
try {
|
||||||
setLoading(true);
|
setLoading(true);
|
||||||
const data = await apiFetch<{ data: HistoryTicket[] }>('/employee/history');
|
const data = await api.get<{ data: HistoryTicket[] }>('/employee/history');
|
||||||
setHistory(data.data || []);
|
setHistory(data.data || []);
|
||||||
} catch (error: any) {
|
} catch (error: any) {
|
||||||
console.error('Error loading history:', error);
|
console.error('Error loading history:', error);
|
||||||
|
|
|
||||||
|
|
@ -2,4 +2,4 @@ export { useAuth } from '@/contexts/AuthContext';
|
||||||
export { useForm } from './useForm';
|
export { useForm } from './useForm';
|
||||||
export { useToast } from './useToast';
|
export { useToast } from './useToast';
|
||||||
export { useGame } from './useGame';
|
export { useGame } from './useGame';
|
||||||
export { useApi, useFetchData, apiFetch, getAuthToken } from './useApi';
|
export { useApi, useFetchData, api, ApiError } from './useApi';
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue
Block a user