27 lines
729 B
TypeScript
27 lines
729 B
TypeScript
'use client';
|
|
|
|
import { useResponse } from '@/shared/components/response/ResponseContext';
|
|
import { useState } from 'react';
|
|
import TImovelInterface from '../../interfaces/TImovel/TImovelInterface';
|
|
import { TImovelIndexData } from '../../data/TImovel/TImovelIndexData';
|
|
|
|
export const useTImovelIndexHook = () => {
|
|
const { setResponse } = useResponse();
|
|
|
|
const [tImovel, setTImovel] = useState<TImovelInterface[]>([]);
|
|
|
|
const indexTImovel = async () => {
|
|
const response = await TImovelIndexData();
|
|
|
|
// Armazena os dados consultados
|
|
setTImovel(response.data);
|
|
|
|
// Define os dados do componente de resposta (toast, modal, etc)
|
|
setResponse(response);
|
|
};
|
|
|
|
return {
|
|
tImovel,
|
|
indexTImovel
|
|
};
|
|
};
|