[MVPTN-37] feat(Pesquisa): Adiciona query params nas urls
This commit is contained in:
parent
fdd4cf7cfc
commit
2d37d4d421
25 changed files with 195 additions and 52 deletions
|
|
@ -11,16 +11,14 @@ import { GEmolumentoReadInterface } from '../../_interfaces/GEmolumentoReadInter
|
|||
|
||||
// Função assíncrona responsável por executar a requisição para listar os tipos de marcação
|
||||
async function executeGEmolumentoIndexData(data: GEmolumentoReadInterface) {
|
||||
|
||||
// Cria uma nova instância da classe API para enviar a requisição
|
||||
const api = new API();
|
||||
|
||||
// Concatena o endpoint com a query string (caso existam parâmetros)
|
||||
const endpoint = `administrativo/g_emolumento/sistema/${data.sistema_id}`;
|
||||
|
||||
// Envia uma requisição GET para o endpoint 'administrativo/g_marcacao_tipo/'
|
||||
return await api.send({
|
||||
method: Methods.GET,
|
||||
endpoint: endpoint,
|
||||
endpoint: `administrativo/g_emolumento/sistema/${data.sistema_id}?${new URLSearchParams(data.urlParams).toString()}`,
|
||||
});
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -1,3 +1,4 @@
|
|||
export interface GEmolumentoReadInterface {
|
||||
sistema_id?: number;
|
||||
urlParams?: object
|
||||
}
|
||||
|
|
|
|||
|
|
@ -7,6 +7,7 @@ import { GEmolumentoReadInterface } from '../../_interfaces/GEmolumentoReadInter
|
|||
|
||||
// Função assíncrona responsável por executar o serviço de listagem de tipos de marcação
|
||||
async function executeGEmolumentoIndexService(data: GEmolumentoReadInterface) {
|
||||
|
||||
// Chama a função que realiza a requisição à API e aguarda a resposta
|
||||
const response = await GEmolumentoIndexData(data);
|
||||
|
||||
|
|
|
|||
|
|
@ -37,7 +37,8 @@ export default function GEmolumentoServicoSelect({
|
|||
const [open, setOpen] = useState(false);
|
||||
const [isLoading, setIsLoading] = useState(false);
|
||||
|
||||
const gEmolumentoReadParams: GEmolumentoReadInterface = { sistema_id };
|
||||
// Define parâmetros de leitura para o hook que busca os emolumentos
|
||||
const gEmolumentoReadParams: GEmolumentoReadInterface = { sistema_id, urlParams: { situacao: 'A' } };
|
||||
const { gEmolumento = [], fetchGEmolumento } = useGEmolumentoReadHook();
|
||||
|
||||
/**
|
||||
|
|
|
|||
|
|
@ -19,6 +19,7 @@ import { useGUsuarioIndexHook } from '@/packages/administrativo/hooks/GUsuario/u
|
|||
import GUsuarioSelectInterface from '@/packages/administrativo/interfaces/GUsuario/GUsuarioSelectInterface';
|
||||
import GetCapitalize from '@/shared/actions/text/GetCapitalize';
|
||||
|
||||
import GUsuarioIndexInterface from '../../interfaces/GUsuario/GusuarioIndexInterface';
|
||||
|
||||
export default function GUsuarioSelect({ field }: GUsuarioSelectInterface) {
|
||||
const [open, setOpen] = useState(false);
|
||||
|
|
@ -30,9 +31,19 @@ export default function GUsuarioSelect({ field }: GUsuarioSelectInterface) {
|
|||
* useCallback evita recriação desnecessária da função.
|
||||
*/
|
||||
const loadData = useCallback(async () => {
|
||||
|
||||
const urlParams = {
|
||||
assina: 'S',
|
||||
situacao: 'A'
|
||||
}
|
||||
|
||||
const GUsuarioIndex: GUsuarioIndexInterface = {
|
||||
urlParams: urlParams
|
||||
}
|
||||
|
||||
if (usuarios?.length) return;
|
||||
setIsLoading(true);
|
||||
await fetchUsuarios();
|
||||
await fetchUsuarios(GUsuarioIndex);
|
||||
setIsLoading(false);
|
||||
}, [usuarios?.length, fetchUsuarios]);
|
||||
|
||||
|
|
|
|||
|
|
@ -19,7 +19,7 @@ import {
|
|||
import TPessoaCartaoForm from '@/packages/servicos/components/TPessoaCartao/TPessoaCartaoForm';
|
||||
import GetNameInitials from '@/shared/actions/text/GetNameInitials';
|
||||
import WebCamDialog from '@/shared/components/webcam/WebCamDialog';
|
||||
import { useFingerTechIndexHook } from '@/shared/hooks/FingerTech/useFingerTechIndexHook';
|
||||
import { useFingerTechCaptureHook } from '@/shared/hooks/FingerTech/useFingerTechCaptureHook';
|
||||
|
||||
import TPessoaTableFormSubviewInterface from '../../interfaces/TPessoa/TPessoaTableFormSubviewInterface';
|
||||
|
||||
|
|
@ -31,7 +31,7 @@ function TPessoaTableFormSubview({
|
|||
}: TPessoaTableFormSubviewInterface) {
|
||||
|
||||
const [isWebCamOpenDialog, setIsWebCamOpenDialog] = useState(false)
|
||||
const { base64, captureFingerTech } = useFingerTechIndexHook();
|
||||
const { base64, captureFingerTech } = useFingerTechCaptureHook();
|
||||
|
||||
// Chama o leitor biométrico
|
||||
const handleBiometria = useCallback(() => {
|
||||
|
|
|
|||
|
|
@ -19,6 +19,8 @@ import { useTServicoTipoReadHook } from '@/packages/administrativo/hooks/TServic
|
|||
import TServicoTipoSelectInterface from '@/packages/administrativo/interfaces/TServicoTipo/TServicoTipoSelectInterface';
|
||||
import GetCapitalize from '@/shared/actions/text/GetCapitalize';
|
||||
|
||||
import TServicoTipoIndexInteface from '../../interfaces/TServicoTipo/TServicoTipoIndexInteface';
|
||||
|
||||
export default function TServicoTipoSelect({ field }: TServicoTipoSelectInterface) {
|
||||
const [open, setOpen] = useState(false);
|
||||
const [isLoading, setIsLoading] = useState(false);
|
||||
|
|
@ -28,9 +30,16 @@ export default function TServicoTipoSelect({ field }: TServicoTipoSelectInterfac
|
|||
* Efeito para buscar os dados apenas uma vez.
|
||||
*/
|
||||
const loadData = useCallback(async () => {
|
||||
|
||||
const TServicoTipoIndex: TServicoTipoIndexInteface = {
|
||||
urlParams: {
|
||||
situacao: 'A'
|
||||
}
|
||||
}
|
||||
|
||||
if (tServicoTipo.length) return;
|
||||
setIsLoading(true);
|
||||
await fetchTServicoTipo();
|
||||
await fetchTServicoTipo(TServicoTipoIndex);
|
||||
setIsLoading(false);
|
||||
}, [tServicoTipo.length, fetchTServicoTipo]);
|
||||
|
||||
|
|
|
|||
|
|
@ -3,13 +3,17 @@
|
|||
import API from '@/shared/services/api/Api';
|
||||
import { Methods } from '@/shared/services/api/enums/ApiMethodEnum';
|
||||
|
||||
export default async function GUsuarioIndexData() {
|
||||
import GUsuarioIndexInterface from '../../interfaces/GUsuario/GusuarioIndexInterface';
|
||||
|
||||
export default async function GUsuarioIndexData(data: GUsuarioIndexInterface) {
|
||||
const api = new API();
|
||||
|
||||
const response = await api.send({
|
||||
method: Methods.GET,
|
||||
endpoint: `administrativo/g_usuario/`,
|
||||
endpoint: `administrativo/g_usuario?${new URLSearchParams(data.urlParams).toString()}`,
|
||||
});
|
||||
|
||||
console.log(response)
|
||||
|
||||
return response;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,21 +1,23 @@
|
|||
// Importa o serviço de API que será utilizado para realizar requisições HTTP
|
||||
import API from '@/shared/services/api/Api'; //
|
||||
import { withClientErrorHandler } from '@/shared/actions/withClientErrorHandler/withClientErrorHandler';
|
||||
import API from '@/shared/services/api/Api';
|
||||
|
||||
// Importa o enum que contém os métodos HTTP disponíveis (GET, POST, PUT, DELETE)
|
||||
import { Methods } from '@/shared/services/api/enums/ApiMethodEnum'; //
|
||||
|
||||
import TServicoTipoIndexInteface from '../../interfaces/TServicoTipo/TServicoTipoIndexInteface';
|
||||
|
||||
// Importa função que encapsula chamadas assíncronas e trata erros automaticamente
|
||||
import { withClientErrorHandler } from '@/shared/actions/withClientErrorHandler/withClientErrorHandler'; //
|
||||
|
||||
// Função assíncrona que implementa a lógica de buscar todos os tipos de serviço (GET)
|
||||
async function executeTServicoTipoIndexData() {
|
||||
async function executeTServicoTipoIndexData(data: TServicoTipoIndexInteface) {
|
||||
// Instancia o cliente da API para enviar a requisição
|
||||
const api = new API(); //
|
||||
|
||||
// Executa a requisição para a API com o método apropriado e o endpoint da tabela t_servico_tipo
|
||||
return await api.send({
|
||||
method: Methods.GET, // GET listar todos os itens
|
||||
endpoint: `administrativo/t_servico_tipo/`, // Endpoint atualizado
|
||||
endpoint: `administrativo/t_servico_tipo/?${new URLSearchParams(data.urlParams).toString()}`,
|
||||
});
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -2,18 +2,21 @@
|
|||
|
||||
import { useState } from 'react';
|
||||
|
||||
import Usuario from '@/packages/administrativo/interfaces/GUsuario/GUsuarioInterface';
|
||||
import { useResponse } from '@/shared/components/response/ResponseContext';
|
||||
|
||||
import Usuario from '../../interfaces/GUsuario/GUsuarioInterface';
|
||||
import GUsuarioIndexInterface from '../../interfaces/GUsuario/GusuarioIndexInterface';
|
||||
import GUsuarioIndex from '../../services/GUsuario/GUsuarioIndex';
|
||||
|
||||
|
||||
export const useGUsuarioIndexHook = () => {
|
||||
const { setResponse } = useResponse();
|
||||
|
||||
const [usuarios, setUsuarios] = useState<Usuario[] | null>(null);
|
||||
|
||||
const fetchUsuarios = async () => {
|
||||
const response = await GUsuarioIndex();
|
||||
const fetchUsuarios = async (data: GUsuarioIndexInterface) => {
|
||||
|
||||
const response = await GUsuarioIndex(data);
|
||||
|
||||
setUsuarios(response.data);
|
||||
|
||||
|
|
|
|||
|
|
@ -1,14 +1,17 @@
|
|||
import { useResponse } from '@/shared/components/response/ResponseContext'; // Contexto global para gerenciar respostas da API
|
||||
import { useState } from 'react';
|
||||
|
||||
import { useResponse } from '@/shared/components/response/ResponseContext'; // Contexto global para gerenciar respostas da API
|
||||
|
||||
// Serviço que busca a lista de tipos de serviço (TServicoTipoIndexService)
|
||||
import TServicoTipoInterface from '../../../../app/(protected)/(cadastros)/cadastros/_interfaces/TServicoTipoInterface';
|
||||
import TServicoTipoIndexInteface from '../../interfaces/TServicoTipo/TServicoTipoIndexInteface';
|
||||
import { TServicoTipoIndexService } from '../../services/TServicoTipo/TServicoTipoIndexService';
|
||||
|
||||
// Interface tipada do tipo de serviço
|
||||
import TServicoTipoInterface from '../../../../app/(protected)/(cadastros)/cadastros/_interfaces/TServicoTipoInterface';
|
||||
|
||||
// Hook customizado para leitura de dados de tipos de serviço
|
||||
export const useTServicoTipoReadHook = () => {
|
||||
|
||||
// Hook do contexto de resposta para feedback global (alertas, mensagens etc.)
|
||||
const { setResponse } = useResponse();
|
||||
|
||||
|
|
@ -16,9 +19,9 @@ export const useTServicoTipoReadHook = () => {
|
|||
const [tServicoTipo, setTServicoTipo] = useState<TServicoTipoInterface[]>([]);
|
||||
|
||||
// Função assíncrona que busca os dados dos tipos de serviço
|
||||
const fetchTServicoTipo = async () => {
|
||||
const fetchTServicoTipo = async (data: TServicoTipoIndexInteface) => {
|
||||
// Chama o serviço responsável por consultar a API
|
||||
const response = await TServicoTipoIndexService();
|
||||
const response = await TServicoTipoIndexService(data);
|
||||
|
||||
// Atualiza o estado local com os dados retornados
|
||||
setTServicoTipo(response.data);
|
||||
|
|
|
|||
|
|
@ -0,0 +1,3 @@
|
|||
export default interface GUsuarioIndexInterface {
|
||||
urlParams: object
|
||||
}
|
||||
|
|
@ -0,0 +1,3 @@
|
|||
export default interface TServicoTipoIndexInteface {
|
||||
urlParams: object
|
||||
}
|
||||
|
|
@ -1,9 +1,10 @@
|
|||
'use server';
|
||||
|
||||
import GUsuarioIndexData from '../../data/GUsuario/GUsuarioIndexData';
|
||||
import GUsuarioIndexInterface from '../../interfaces/GUsuario/GusuarioIndexInterface';
|
||||
|
||||
export default async function GUsuarioIndex() {
|
||||
const response = await GUsuarioIndexData();
|
||||
export default async function GUsuarioIndex(data: GUsuarioIndexInterface) {
|
||||
const response = await GUsuarioIndexData(data);
|
||||
|
||||
return response;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -2,12 +2,13 @@ import { withClientErrorHandler } from '@/shared/actions/withClientErrorHandler/
|
|||
// Função que envolve qualquer ação assíncrona para capturar e tratar erros do cliente
|
||||
|
||||
import { TServicoTipoIndexData } from '../../data/TServicoTipo/TServicoTipoIndexData';
|
||||
import TServicoTipoIndexInteface from '../../interfaces/TServicoTipo/TServicoTipoIndexInteface';
|
||||
// Função que retorna os dados da lista de tipos de serviço (chamada à API ou mock)
|
||||
|
||||
// Função assíncrona que executa a chamada para buscar os dados dos tipos de serviço
|
||||
async function executeTServicoTipoIndexService() {
|
||||
async function executeTServicoTipoIndexService(data: TServicoTipoIndexInteface) {
|
||||
// Chama a função que retorna os dados dos tipos de serviço
|
||||
const response = await TServicoTipoIndexData();
|
||||
const response = await TServicoTipoIndexData(data);
|
||||
|
||||
// Retorna a resposta para o chamador
|
||||
return response;
|
||||
|
|
|
|||
|
|
@ -78,28 +78,6 @@ export default function TServicoPedidoDetailsPagamento({
|
|||
<span className="font-semibold">{FormatMoney(total)}</span>
|
||||
</div>
|
||||
|
||||
<Separator className="border-cart-border" />
|
||||
|
||||
<div className="flex items-center justify-between">
|
||||
<span className="text-muted-foreground">Emolumento</span>
|
||||
<span className="font-medium">{FormatMoney(emolumento)}</span>
|
||||
</div>
|
||||
|
||||
<div className="flex items-center justify-between">
|
||||
<span className="text-muted-foreground">Tx. Judiciária</span>
|
||||
<span className="font-medium">{FormatMoney(taxa_judiciaria)}</span>
|
||||
</div>
|
||||
|
||||
<div className="flex items-center justify-between">
|
||||
<span className="text-muted-foreground">ISS</span>
|
||||
<span className="font-medium">{FormatMoney(valor_iss)}</span>
|
||||
</div>
|
||||
|
||||
<div className="flex items-center justify-between">
|
||||
<span className="text-muted-foreground">Fundesp</span>
|
||||
<span className="font-medium">{FormatMoney(fundesp)}</span>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
</CardContent>
|
||||
</Card>
|
||||
|
|
|
|||
|
|
@ -181,9 +181,8 @@ export function DataTable<TData extends { subview?: React.ReactNode | (() => Rea
|
|||
table.getRowModel().rows.map((row) => {
|
||||
return (
|
||||
<TableRow
|
||||
className={
|
||||
onRowClick ? 'hover:bg-muted/50 cursor-pointer' : ''
|
||||
}
|
||||
key={row.id}
|
||||
className={onRowClick ? 'hover:bg-muted/50 cursor-pointer' : ''}
|
||||
onClick={() => onRowClick?.(row.original)}
|
||||
>
|
||||
{row.getVisibleCells().map((cell) => (
|
||||
|
|
@ -208,6 +207,7 @@ export function DataTable<TData extends { subview?: React.ReactNode | (() => Rea
|
|||
</TableRow>
|
||||
)}
|
||||
</TableBody>
|
||||
|
||||
</Table>
|
||||
</div>
|
||||
|
||||
|
|
|
|||
|
|
@ -1,5 +1,13 @@
|
|||
import { withClientErrorHandler } from '@/shared/actions/withClientErrorHandler/withClientErrorHandler';
|
||||
|
||||
/*********************************************
|
||||
* Nome: Capture
|
||||
* Descrição: Chama o método "Capture" da aplicação desktop,
|
||||
* responsável por chamar a tela de captura de digital para apenas um único dedo.
|
||||
* Este método é recomendável quando você deseja capturar a impressão digital de um único dedo e
|
||||
* não existe a necessidade de identificar qual dedo da mão esta digital pertence.
|
||||
* Retorno: Template (String) ou Null
|
||||
*********************************************/
|
||||
async function executeFingerTechCaptureData() {
|
||||
|
||||
const response = await fetch(`http://localhost:9000/api/public/v1/captura/Capturar/1`,
|
||||
|
|
|
|||
25
src/shared/data/fingertech/FingerTechEnrollData.ts
Normal file
25
src/shared/data/fingertech/FingerTechEnrollData.ts
Normal file
|
|
@ -0,0 +1,25 @@
|
|||
import { withClientErrorHandler } from '@/shared/actions/withClientErrorHandler/withClientErrorHandler';
|
||||
|
||||
/*********************************************
|
||||
* Nome: Enroll
|
||||
* Descrição: Chama o método "Enroll" da aplicação desktop,
|
||||
* responsável por chamar a tela de captura de impressão digital para mais de um dedo.
|
||||
* Este método é recomendável quando você deseja capturar a impressão digital de mais de um dedo e
|
||||
* quando é necessário identificar a qual dedo esta digital pertence.
|
||||
* Quando houver a captura de mais de uma impressão digital, elas serão armazenadas de maneira
|
||||
* codificada no mesmo "Template" (String), mas durante a comparação qualquer dedo poderá ser
|
||||
* comparado.
|
||||
* Retorno: Template (String) ou "" (Vazio)
|
||||
*********************************************/
|
||||
async function executeFingerTechEnrollData() {
|
||||
|
||||
const response = await fetch(`http://localhost:9000/api/public/v1/captura/Enroll/1`,
|
||||
{
|
||||
method: 'GET'
|
||||
},
|
||||
);
|
||||
|
||||
return await response.text()
|
||||
}
|
||||
|
||||
export const FingerTechEnrollData = withClientErrorHandler(executeFingerTechEnrollData);
|
||||
23
src/shared/data/fingertech/FingerTechMatchData.ts
Normal file
23
src/shared/data/fingertech/FingerTechMatchData.ts
Normal file
|
|
@ -0,0 +1,23 @@
|
|||
import { withClientErrorHandler } from '@/shared/actions/withClientErrorHandler/withClientErrorHandler';
|
||||
|
||||
/*********************************************
|
||||
* Nome: Match
|
||||
* Descrição: Chama o método "VerifyMatch" da aplicação desktop,
|
||||
* responsável por chamar a tela de captura de digital para apenas um único dedo e realizar a
|
||||
* comparação com um outro template (impressão digital) já cadastrada.
|
||||
* Este método é recomendável quando você deseja você comparação de 1:1 (Um para Um).
|
||||
* Retorno: Template (String) ou Null
|
||||
*********************************************/
|
||||
async function executeFingerTechMatchData() {
|
||||
|
||||
// 'http://localhost:9000/api/public/v1/captura/Comparar?Digital=' + digital,
|
||||
const response = await fetch(`http://localhost:9000/api/public/v1/captura/Capturar/1`,
|
||||
{
|
||||
method: 'GET'
|
||||
},
|
||||
);
|
||||
|
||||
return await response.text()
|
||||
}
|
||||
|
||||
export const FingerTechMatchData = withClientErrorHandler(executeFingerTechMatchData);
|
||||
|
|
@ -4,7 +4,7 @@ import { useState } from 'react';
|
|||
|
||||
import { FingerTechCaptureService } from '@/shared/services/FingerTech/FingerTechCaptureService';
|
||||
|
||||
export const useFingerTechIndexHook = () => {
|
||||
export const useFingerTechCaptureHook = () => {
|
||||
|
||||
const [base64, setBase64] = useState<string>('');
|
||||
|
||||
25
src/shared/hooks/FingerTech/useFingerTechEnrollHook.ts
Normal file
25
src/shared/hooks/FingerTech/useFingerTechEnrollHook.ts
Normal file
|
|
@ -0,0 +1,25 @@
|
|||
'use client';
|
||||
|
||||
import { useState } from 'react';
|
||||
|
||||
import { FingerTechEnrollService } from '@/shared/services/FingerTech/FingerTechEnrollService';
|
||||
|
||||
export const useFingerTechEnrollHook = () => {
|
||||
|
||||
const [base64, setBase64] = useState<string>('');
|
||||
|
||||
const enrollFingerTech = async () => {
|
||||
|
||||
const response = await FingerTechEnrollService();
|
||||
|
||||
setBase64(response);
|
||||
|
||||
return response
|
||||
|
||||
};
|
||||
|
||||
return {
|
||||
base64,
|
||||
enrollFingerTech,
|
||||
};
|
||||
};
|
||||
25
src/shared/hooks/FingerTech/useFingerTechMatchHook.ts
Normal file
25
src/shared/hooks/FingerTech/useFingerTechMatchHook.ts
Normal file
|
|
@ -0,0 +1,25 @@
|
|||
'use client';
|
||||
|
||||
import { useState } from 'react';
|
||||
|
||||
import { FingerTechMatchService } from '@/shared/services/FingerTech/FingerTechMatchService';
|
||||
|
||||
export const useFingerTechMatchHook = () => {
|
||||
|
||||
const [base64, setBase64] = useState<string>('');
|
||||
|
||||
const matchFingerTech = async () => {
|
||||
|
||||
const response = await FingerTechMatchService();
|
||||
|
||||
setBase64(response);
|
||||
|
||||
return response
|
||||
|
||||
};
|
||||
|
||||
return {
|
||||
base64,
|
||||
matchFingerTech,
|
||||
};
|
||||
};
|
||||
|
|
@ -0,0 +1,9 @@
|
|||
import { withClientErrorHandler } from '@/shared/actions/withClientErrorHandler/withClientErrorHandler';
|
||||
import { FingerTechEnrollData } from '@/shared/data/fingertech/FingerTechEnrollData';
|
||||
|
||||
export default async function executeFingerTechCEnrollService() {
|
||||
const response = await FingerTechEnrollData();
|
||||
return response;
|
||||
}
|
||||
|
||||
export const FingerTechEnrollService = withClientErrorHandler(executeFingerTechCEnrollService);
|
||||
9
src/shared/services/FingerTech/FingerTechMatchService.ts
Normal file
9
src/shared/services/FingerTech/FingerTechMatchService.ts
Normal file
|
|
@ -0,0 +1,9 @@
|
|||
import { withClientErrorHandler } from '@/shared/actions/withClientErrorHandler/withClientErrorHandler';
|
||||
import { FingerTechMatchData } from '@/shared/data/fingertech/FingerTechMatchData';
|
||||
|
||||
export default async function executeFingerTechMatchService() {
|
||||
const response = await FingerTechMatchData();
|
||||
return response;
|
||||
}
|
||||
|
||||
export const FingerTechMatchService = withClientErrorHandler(executeFingerTechMatchService);
|
||||
Loading…
Add table
Reference in a new issue