23 lines
749 B
TypeScript
23 lines
749 B
TypeScript
'use client';
|
|
|
|
import { useState } from 'react';
|
|
import { LogGedInterface } from '../../interfaces/Log/LogGedInterface';
|
|
import { LogGedService } from '../../services/Log/LogGedService';
|
|
import { useResponse } from '@/shared/components/response/ResponseContext';
|
|
|
|
export const useLogGedHook = () => {
|
|
const { setResponse } = useResponse();
|
|
const [logGed, setLog] = useState<LogGedInterface | null>(null);
|
|
|
|
const fetchLogGed = async (client_id: number) => {
|
|
try {
|
|
const response = await LogGedService(client_id);
|
|
setLog(response as LogGedInterface);
|
|
setResponse(response);
|
|
} catch (error) {
|
|
console.error("Erro ao buscar informação do banco de dados:", error);
|
|
}
|
|
};
|
|
|
|
return { logGed, fetchLogGed };
|
|
};
|