[MVPTN-62] feat(CRUD): Integração do crud com os endpoints
This commit is contained in:
parent
7ecf79e8a3
commit
b7c5f670df
11 changed files with 35 additions and 64 deletions
|
|
@ -83,7 +83,7 @@ export default function GTBProfissaoForm({ isOpen, data, onClose, onSave }: Prop
|
|||
<FormItem>
|
||||
<FormLabel>Descrição</FormLabel>
|
||||
<FormControl>
|
||||
<Input {...field} placeholder="Digite a descrição" />
|
||||
<Input type="text" {...field} placeholder="Digite a descrição" />
|
||||
</FormControl>
|
||||
<FormMessage />
|
||||
</FormItem>
|
||||
|
|
@ -98,7 +98,7 @@ export default function GTBProfissaoForm({ isOpen, data, onClose, onSave }: Prop
|
|||
<FormItem>
|
||||
<FormLabel>CBO</FormLabel>
|
||||
<FormControl>
|
||||
<Input {...field} placeholder="Digite o código" />
|
||||
<Input type="nubmer" {...field} placeholder="Digite o código" />
|
||||
</FormControl>
|
||||
<FormMessage />
|
||||
</FormItem>
|
||||
|
|
|
|||
|
|
@ -1,49 +1,12 @@
|
|||
import API from "@/services/api/Api";
|
||||
import { Methods } from "@/services/api/enums/ApiMethodEnum";
|
||||
|
||||
export default async function GTBProfissoesIndexData() {
|
||||
|
||||
return Promise.resolve([
|
||||
{ "tb_profissao_id": 2, "descricao": "gestora comercial", "situacao": "A", "cod_cbo": "" },
|
||||
{ "tb_profissao_id": 3, "descricao": "OPERADOR DE SUBSTAÇÃO", "situacao": "A", "cod_cbo": "123456" },
|
||||
{ "tb_profissao_id": 4, "descricao": "funcionária pública federal", "situacao": "A", "cod_cbo": "-2" },
|
||||
{ "tb_profissao_id": 5, "descricao": "Estudante", "situacao": "A", "cod_cbo": "-2" },
|
||||
{ "tb_profissao_id": 6, "descricao": "Fazendeiro", "situacao": "A", "cod_cbo": "-2" },
|
||||
{ "tb_profissao_id": 7, "descricao": "Gerente de Fazenda", "situacao": "A", "cod_cbo": null },
|
||||
{ "tb_profissao_id": 8, "descricao": "Lavrador", "situacao": "A", "cod_cbo": "-2" },
|
||||
{ "tb_profissao_id": 9, "descricao": "motorista", "situacao": "A", "cod_cbo": "-2" },
|
||||
{ "tb_profissao_id": 11, "descricao": "2º Tenente", "situacao": "A", "cod_cbo": null },
|
||||
{ "tb_profissao_id": 12, "descricao": "agricultor", "situacao": "A", "cod_cbo": "-2" },
|
||||
{ "tb_profissao_id": 13, "descricao": "Aposentada", "situacao": "A", "cod_cbo": "-2" },
|
||||
{ "tb_profissao_id": 14, "descricao": "Arquiteto", "situacao": "A", "cod_cbo": "-2" },
|
||||
{ "tb_profissao_id": 15, "descricao": "Artesã", "situacao": "A", "cod_cbo": null },
|
||||
{ "tb_profissao_id": 16, "descricao": "Autônomo", "situacao": "A", "cod_cbo": "-2" },
|
||||
{ "tb_profissao_id": 17, "descricao": "Auxiliar de Escritório", "situacao": "A", "cod_cbo": null },
|
||||
{ "tb_profissao_id": 19, "descricao": "Administrador Rural", "situacao": "A", "cod_cbo": null },
|
||||
{ "tb_profissao_id": 20, "descricao": "Administrador de fazenda", "situacao": "A", "cod_cbo": null },
|
||||
{ "tb_profissao_id": 21, "descricao": "Advogada", "situacao": "A", "cod_cbo": "-2" },
|
||||
{ "tb_profissao_id": 22, "descricao": "Designer de Sobrancelhas", "situacao": "A", "cod_cbo": null },
|
||||
{ "tb_profissao_id": 23, "descricao": "Agente Administrativo Educacional", "situacao": "A", "cod_cbo": null },
|
||||
{ "tb_profissao_id": 24, "descricao": "Agricultora", "situacao": "A", "cod_cbo": "-2" },
|
||||
{ "tb_profissao_id": 25, "descricao": "Agrimensor", "situacao": "A", "cod_cbo": null },
|
||||
{ "tb_profissao_id": 26, "descricao": "Agropecuarista", "situacao": "A", "cod_cbo": "-2" },
|
||||
{ "tb_profissao_id": 27, "descricao": "Agrônoma", "situacao": "A", "cod_cbo": null },
|
||||
{ "tb_profissao_id": 28, "descricao": "Ambulante", "situacao": "A", "cod_cbo": null },
|
||||
{ "tb_profissao_id": 29, "descricao": "Analista de Sistemas", "situacao": "A", "cod_cbo": null },
|
||||
{ "tb_profissao_id": 30, "descricao": "Arquiteta", "situacao": "A", "cod_cbo": null },
|
||||
{ "tb_profissao_id": 31, "descricao": "Artesão", "situacao": "A", "cod_cbo": null },
|
||||
{ "tb_profissao_id": 32, "descricao": "Assessora Parlamentar", "situacao": "A", "cod_cbo": null },
|
||||
{ "tb_profissao_id": 33, "descricao": "Assistente de Gestão", "situacao": "A", "cod_cbo": null },
|
||||
{ "tb_profissao_id": 34, "descricao": "Auxiliar Técnico", "situacao": "A", "cod_cbo": null },
|
||||
{ "tb_profissao_id": 35, "descricao": "Auxiliar Administrativo", "situacao": "A", "cod_cbo": "-2" },
|
||||
{ "tb_profissao_id": 36, "descricao": "Auxiliar de Cartório", "situacao": "A", "cod_cbo": null },
|
||||
{ "tb_profissao_id": 37, "descricao": "Auxiliar de Enfermagem", "situacao": "A", "cod_cbo": null },
|
||||
{ "tb_profissao_id": 38, "descricao": "Auxiliar de Limpeza", "situacao": "A", "cod_cbo": null },
|
||||
{ "tb_profissao_id": 39, "descricao": "Auxiliar de Produção II", "situacao": "A", "cod_cbo": null },
|
||||
{ "tb_profissao_id": 40, "descricao": "Auxiliar de Serviços gerais", "situacao": "A", "cod_cbo": null },
|
||||
{ "tb_profissao_id": 41, "descricao": "Auxiliar de Sondagem", "situacao": "A", "cod_cbo": null },
|
||||
{ "tb_profissao_id": 42, "descricao": "Balconista", "situacao": "A", "cod_cbo": "-2" },
|
||||
{ "tb_profissao_id": 43, "descricao": "Bancário Aposentado", "situacao": "A", "cod_cbo": null },
|
||||
{ "tb_profissao_id": 44, "descricao": "Bioquímico", "situacao": "A", "cod_cbo": "-2" }
|
||||
]
|
||||
);
|
||||
const api = new API();
|
||||
|
||||
return await api.send({
|
||||
method: Methods.GET,
|
||||
endpoint: `administrativo/g_tb_profissao/`
|
||||
});
|
||||
}
|
||||
|
|
@ -1,11 +1,14 @@
|
|||
import API from "@/services/api/Api";
|
||||
import GTBProfissaoInterface from "../../_interfaces/GTBProfissaoInterface";
|
||||
import { Methods } from "@/services/api/enums/ApiMethodEnum";
|
||||
|
||||
export default async function GTBProfissaoRemoveData(data: GTBProfissaoInterface) {
|
||||
|
||||
console.log(data)
|
||||
const api = new API();
|
||||
|
||||
return Promise.resolve({
|
||||
message: 'Dados removidos com sucesso'
|
||||
return await api.send({
|
||||
method: Methods.DELETE,
|
||||
endpoint: `administrativo/g_tb_profissao/${data.tb_profissao_id}`
|
||||
});
|
||||
|
||||
}
|
||||
|
|
@ -1,10 +1,17 @@
|
|||
import API from "@/services/api/Api";
|
||||
import GTBProfissaoInterface from "../../_interfaces/GTBProfissaoInterface";
|
||||
import { Methods } from "@/services/api/enums/ApiMethodEnum";
|
||||
|
||||
export default async function GTBProfissaoSaveData(data: GTBProfissaoInterface) {
|
||||
|
||||
return Promise.resolve({
|
||||
message: 'Profissao salva com sucesso',
|
||||
data: { "tb_profissao_id": 2, "descricao": "gestora comercial", "situacao": "A", "cod_cbo": "" },
|
||||
const isUpdate = Boolean(data.tb_profissao_id);
|
||||
|
||||
const api = new API();
|
||||
|
||||
return await api.send({
|
||||
method: isUpdate ? Methods.PUT : Methods.POST,
|
||||
endpoint: `administrativo/g_tb_profissao/${data.tb_profissao_id || ''}`,
|
||||
body: data
|
||||
});
|
||||
|
||||
}
|
||||
|
|
@ -12,7 +12,7 @@ export const useGTBProfissaoReadHook = () => {
|
|||
|
||||
const response = await GTBProfissaoIndexService();
|
||||
|
||||
setGTBProfissao(response);
|
||||
setGTBProfissao(response.data);
|
||||
|
||||
setResponse(response);
|
||||
|
||||
|
|
|
|||
|
|
@ -12,7 +12,7 @@ export const useGTBProfissaoSaveHook = () => {
|
|||
|
||||
const response = await GTBProfissaoSaveService(data);
|
||||
|
||||
setGTBProfissao(response);
|
||||
setGTBProfissao(response.data);
|
||||
|
||||
setResponse(response);
|
||||
|
||||
|
|
|
|||
|
|
@ -4,6 +4,6 @@ export default interface GTBProfissaoInterface {
|
|||
tb_profissao_id?: number,
|
||||
descricao: string,
|
||||
situacao: string,
|
||||
cod_cbo: string
|
||||
cod_cbo?: string
|
||||
|
||||
}
|
||||
|
|
@ -1,8 +1,8 @@
|
|||
import z from "zod";
|
||||
import { z } from "zod";
|
||||
|
||||
export const GTBProfissaoSchema = z.object({
|
||||
tb_profissao_id: z.number().optional,
|
||||
descricao: z.string().optional,
|
||||
situacao: z.string().optional,
|
||||
cod_cbo: z.string().optional
|
||||
tb_profissao_id: z.number().optional(),
|
||||
descricao: z.string(),
|
||||
situacao: z.string(),
|
||||
cod_cbo: z.string().optional()
|
||||
});
|
||||
|
|
@ -3,8 +3,6 @@ import GTBProfissaoInterface from "../../_interfaces/GTBProfissaoInterface";
|
|||
|
||||
export default async function GTBProfissaoRemoveService(data: GTBProfissaoInterface) {
|
||||
|
||||
console.log(data);
|
||||
|
||||
const response = await GTBProfissaoRemoveData(data);
|
||||
|
||||
return response;
|
||||
|
|
|
|||
|
|
@ -1,8 +1,8 @@
|
|||
{
|
||||
"state": "go",
|
||||
"api": {
|
||||
"url": "http://api-saas-api-homologacao:8000/",
|
||||
"prefix": "api/v1",
|
||||
"url": "http://localhost:8000/",
|
||||
"prefix": "api/v1/",
|
||||
"content_type": "application/json"
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Reference in a new issue