[MVPTN-1] feat(Listagem): implementa a listagem de tipos de reconhecimento, atualmente usando dados 'mockados'
This commit is contained in:
parent
7ec1259ba0
commit
12a2c62af8
6 changed files with 157 additions and 11 deletions
|
|
@ -0,0 +1,91 @@
|
|||
'use client'
|
||||
|
||||
import { Card, CardContent } from "@/components/ui/card";
|
||||
import {
|
||||
Table,
|
||||
TableBody,
|
||||
TableCaption,
|
||||
TableCell,
|
||||
TableHead,
|
||||
TableHeader,
|
||||
TableRow,
|
||||
} from "@/components/ui/table"
|
||||
import { useTTBReconhecimentoTipoReadHooks } from "../../_hooks/useTTBReconhecimentoTipoReadHooks";
|
||||
import { useEffect } from "react";
|
||||
import ITTTBReconhecimentoTipo from '../../_interfaces/ITTTBReconhecimentoTipo'
|
||||
import Loading from "@/app/_components/loading/loading";
|
||||
import { Button } from "@/components/ui/button";
|
||||
import Link from "next/link";
|
||||
|
||||
export default function TTBReconhecimentoTipoPage() {
|
||||
|
||||
const { reconhecimentosTipos, fetchReconhecimentosTipos } = useTTBReconhecimentoTipoReadHooks();
|
||||
|
||||
useEffect(() => {
|
||||
fetchReconhecimentosTipos();
|
||||
}, []);
|
||||
|
||||
if (!reconhecimentosTipos) return <Loading type={2} />
|
||||
|
||||
return (
|
||||
|
||||
<div>
|
||||
|
||||
<div className="flex mb-5">
|
||||
<div className="w-64 flex-1">
|
||||
<div className="text-4xl font-semibold mb-1">
|
||||
Tipos de Reconhecimentos
|
||||
</div>
|
||||
<div className="text-base text-muted-foreground">
|
||||
Gerenciamento de tipos de reconhecimentos
|
||||
</div>
|
||||
</div>
|
||||
<div className="w-64 flex-1 text-end">
|
||||
<Button className="cursor-pointer" asChild>
|
||||
<Link href={`/cadastros/reconhecimentos/formulario`}>
|
||||
+ Tipos
|
||||
</Link>
|
||||
</Button>
|
||||
</div>
|
||||
</div>
|
||||
<Card>
|
||||
<CardContent>
|
||||
<Table>
|
||||
<TableHeader>
|
||||
<TableRow>
|
||||
<TableHead className="w-[100px]">
|
||||
#
|
||||
</TableHead>
|
||||
<TableHead>
|
||||
Descrição
|
||||
</TableHead>
|
||||
<TableHead>
|
||||
Situação
|
||||
</TableHead>
|
||||
<TableHead className="text-right">Amount</TableHead>
|
||||
</TableRow>
|
||||
</TableHeader>
|
||||
<TableBody>
|
||||
{reconhecimentosTipos.map((reconhecimentosTipos: ITTTBReconhecimentoTipo) => (
|
||||
<TableRow key={reconhecimentosTipos.tb_reconhecimentotipo_id} className="cursor-pointer">
|
||||
<TableCell className="font-medium">
|
||||
{reconhecimentosTipos.tb_reconhecimentotipo_id}
|
||||
</TableCell>
|
||||
<TableCell>
|
||||
{reconhecimentosTipos.descricao}
|
||||
</TableCell>
|
||||
<TableCell>
|
||||
{reconhecimentosTipos.tb_reconhecimentotipo_id}
|
||||
</TableCell>
|
||||
<TableCell className="text-right">$250.00</TableCell>
|
||||
</TableRow>
|
||||
))}
|
||||
</TableBody>
|
||||
</Table>
|
||||
</CardContent>
|
||||
</Card>
|
||||
</div>
|
||||
|
||||
);
|
||||
|
||||
}
|
||||
|
|
@ -0,0 +1,25 @@
|
|||
'use server'
|
||||
|
||||
import API from "@/services/api/Api"
|
||||
import { Methods } from "@/services/api/enums/ApiMethodEnum";
|
||||
|
||||
export default async function TTBReconhecimentoTipoIndexData() {
|
||||
|
||||
// const api = new API();
|
||||
|
||||
// const response = await api.send({
|
||||
// 'method': Methods.GET,
|
||||
// 'endpoint': `cadastros/reconhecimentos`
|
||||
// });
|
||||
|
||||
// return response;
|
||||
|
||||
return Promise.resolve({
|
||||
data: [
|
||||
{ tb_reconhecimentotipo_id: 1, descricao: 'SEMELHANÇA', situacao: 'A' },
|
||||
{ tb_reconhecimentotipo_id: 2, descricao: 'VERDADEIRO', situacao: 'A' },
|
||||
{ tb_reconhecimentotipo_id: 3, descricao: 'ABONO', situacao: 'A' }
|
||||
]
|
||||
});
|
||||
|
||||
}
|
||||
|
|
@ -0,0 +1,26 @@
|
|||
'use client'
|
||||
|
||||
import ITTTBReconhecimentoTipo from '../_interfaces/ITTTBReconhecimentoTipo'
|
||||
import { useResponse } from "@/app/_response/ResponseContext"
|
||||
import { useState } from "react";
|
||||
import TTBReconhecimentoTipoIndexData from '../_data/TTBReconhecimentoTipo/TTBReconhecimentoTipoIndexData';
|
||||
|
||||
export const useTTBReconhecimentoTipoReadHooks = () => {
|
||||
|
||||
const { setResponse } = useResponse();
|
||||
|
||||
const [reconhecimentosTipos, setReconhecimenntosTipos] = useState<ITTTBReconhecimentoTipo>();
|
||||
|
||||
const fetchReconhecimentosTipos = async () => {
|
||||
|
||||
const response = await TTBReconhecimentoTipoIndexData();
|
||||
|
||||
setReconhecimenntosTipos(response.data);
|
||||
|
||||
setResponse(response);
|
||||
|
||||
}
|
||||
|
||||
return { reconhecimentosTipos, fetchReconhecimentosTipos }
|
||||
|
||||
}
|
||||
|
|
@ -0,0 +1,5 @@
|
|||
export default interface ITTTBReconhecimentoTipo{
|
||||
tb_reconhecimentotipo_id: number,
|
||||
descricao: string,
|
||||
situacao: string,
|
||||
}
|
||||
|
|
@ -0,0 +1,7 @@
|
|||
import { z } from 'zod';
|
||||
|
||||
export const TTBReconhecimentoTipoSchema = z.object({
|
||||
tb_reconhecimentotipo_id: z.number(),
|
||||
descricao: z.string().min(1),
|
||||
situacao: z.string().min(1),
|
||||
});
|
||||
|
|
@ -64,21 +64,13 @@ const data = {
|
|||
],
|
||||
},
|
||||
{
|
||||
title: "Models",
|
||||
title: "Cadastros",
|
||||
url: "#",
|
||||
icon: Bot,
|
||||
items: [
|
||||
{
|
||||
title: "Genesis",
|
||||
url: "#",
|
||||
},
|
||||
{
|
||||
title: "Explorer",
|
||||
url: "#",
|
||||
},
|
||||
{
|
||||
title: "Quantum",
|
||||
url: "#",
|
||||
title: "Reconhecimentos",
|
||||
url: "/cadastros/reconhecimentos/",
|
||||
},
|
||||
],
|
||||
},
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue