diff --git a/package-lock.json b/package-lock.json index 99e913f..901bbba 100644 --- a/package-lock.json +++ b/package-lock.json @@ -23,7 +23,7 @@ "@radix-ui/react-scroll-area": "^1.2.10", "@radix-ui/react-select": "^2.2.6", "@radix-ui/react-separator": "^1.1.8", - "@radix-ui/react-slot": "^1.2.3", + "@radix-ui/react-slot": "^1.2.4", "@radix-ui/react-switch": "^1.2.6", "@radix-ui/react-tabs": "^1.1.13", "@radix-ui/react-tooltip": "^1.2.8", @@ -1436,6 +1436,24 @@ } } }, + "node_modules/@radix-ui/react-alert-dialog/node_modules/@radix-ui/react-slot": { + "version": "1.2.3", + "resolved": "https://registry.npmjs.org/@radix-ui/react-slot/-/react-slot-1.2.3.tgz", + "integrity": "sha512-aeNmHnBxbi2St0au6VBVC7JXFlhLlOnvIIlePNniyUNAClzmtAUEY8/pBiK3iHjufOlwA+c20/8jngo7xcrg8A==", + "license": "MIT", + "dependencies": { + "@radix-ui/react-compose-refs": "1.1.2" + }, + "peerDependencies": { + "@types/react": "*", + "react": "^16.8 || ^17.0 || ^18.0 || ^19.0 || ^19.0.0-rc" + }, + "peerDependenciesMeta": { + "@types/react": { + "optional": true + } + } + }, "node_modules/@radix-ui/react-arrow": { "version": "1.1.7", "resolved": "https://registry.npmjs.org/@radix-ui/react-arrow/-/react-arrow-1.1.7.tgz", @@ -1572,6 +1590,24 @@ } } }, + "node_modules/@radix-ui/react-collection/node_modules/@radix-ui/react-slot": { + "version": "1.2.3", + "resolved": "https://registry.npmjs.org/@radix-ui/react-slot/-/react-slot-1.2.3.tgz", + "integrity": "sha512-aeNmHnBxbi2St0au6VBVC7JXFlhLlOnvIIlePNniyUNAClzmtAUEY8/pBiK3iHjufOlwA+c20/8jngo7xcrg8A==", + "license": "MIT", + "dependencies": { + "@radix-ui/react-compose-refs": "1.1.2" + }, + "peerDependencies": { + "@types/react": "*", + "react": "^16.8 || ^17.0 || ^18.0 || ^19.0 || ^19.0.0-rc" + }, + "peerDependenciesMeta": { + "@types/react": { + "optional": true + } + } + }, "node_modules/@radix-ui/react-compose-refs": { "version": "1.1.2", "resolved": "https://registry.npmjs.org/@radix-ui/react-compose-refs/-/react-compose-refs-1.1.2.tgz", @@ -1638,6 +1674,24 @@ } } }, + "node_modules/@radix-ui/react-dialog/node_modules/@radix-ui/react-slot": { + "version": "1.2.3", + "resolved": "https://registry.npmjs.org/@radix-ui/react-slot/-/react-slot-1.2.3.tgz", + "integrity": "sha512-aeNmHnBxbi2St0au6VBVC7JXFlhLlOnvIIlePNniyUNAClzmtAUEY8/pBiK3iHjufOlwA+c20/8jngo7xcrg8A==", + "license": "MIT", + "dependencies": { + "@radix-ui/react-compose-refs": "1.1.2" + }, + "peerDependencies": { + "@types/react": "*", + "react": "^16.8 || ^17.0 || ^18.0 || ^19.0 || ^19.0.0-rc" + }, + "peerDependenciesMeta": { + "@types/react": { + "optional": true + } + } + }, "node_modules/@radix-ui/react-direction": { "version": "1.1.1", "resolved": "https://registry.npmjs.org/@radix-ui/react-direction/-/react-direction-1.1.1.tgz", @@ -1830,6 +1884,24 @@ } } }, + "node_modules/@radix-ui/react-menu/node_modules/@radix-ui/react-slot": { + "version": "1.2.3", + "resolved": "https://registry.npmjs.org/@radix-ui/react-slot/-/react-slot-1.2.3.tgz", + "integrity": "sha512-aeNmHnBxbi2St0au6VBVC7JXFlhLlOnvIIlePNniyUNAClzmtAUEY8/pBiK3iHjufOlwA+c20/8jngo7xcrg8A==", + "license": "MIT", + "dependencies": { + "@radix-ui/react-compose-refs": "1.1.2" + }, + "peerDependencies": { + "@types/react": "*", + "react": "^16.8 || ^17.0 || ^18.0 || ^19.0 || ^19.0.0-rc" + }, + "peerDependenciesMeta": { + "@types/react": { + "optional": true + } + } + }, "node_modules/@radix-ui/react-popover": { "version": "1.1.15", "resolved": "https://registry.npmjs.org/@radix-ui/react-popover/-/react-popover-1.1.15.tgz", @@ -1867,6 +1939,24 @@ } } }, + "node_modules/@radix-ui/react-popover/node_modules/@radix-ui/react-slot": { + "version": "1.2.3", + "resolved": "https://registry.npmjs.org/@radix-ui/react-slot/-/react-slot-1.2.3.tgz", + "integrity": "sha512-aeNmHnBxbi2St0au6VBVC7JXFlhLlOnvIIlePNniyUNAClzmtAUEY8/pBiK3iHjufOlwA+c20/8jngo7xcrg8A==", + "license": "MIT", + "dependencies": { + "@radix-ui/react-compose-refs": "1.1.2" + }, + "peerDependencies": { + "@types/react": "*", + "react": "^16.8 || ^17.0 || ^18.0 || ^19.0 || ^19.0.0-rc" + }, + "peerDependenciesMeta": { + "@types/react": { + "optional": true + } + } + }, "node_modules/@radix-ui/react-popper": { "version": "1.2.8", "resolved": "https://registry.npmjs.org/@radix-ui/react-popper/-/react-popper-1.2.8.tgz", @@ -1970,6 +2060,24 @@ } } }, + "node_modules/@radix-ui/react-primitive/node_modules/@radix-ui/react-slot": { + "version": "1.2.3", + "resolved": "https://registry.npmjs.org/@radix-ui/react-slot/-/react-slot-1.2.3.tgz", + "integrity": "sha512-aeNmHnBxbi2St0au6VBVC7JXFlhLlOnvIIlePNniyUNAClzmtAUEY8/pBiK3iHjufOlwA+c20/8jngo7xcrg8A==", + "license": "MIT", + "dependencies": { + "@radix-ui/react-compose-refs": "1.1.2" + }, + "peerDependencies": { + "@types/react": "*", + "react": "^16.8 || ^17.0 || ^18.0 || ^19.0 || ^19.0.0-rc" + }, + "peerDependenciesMeta": { + "@types/react": { + "optional": true + } + } + }, "node_modules/@radix-ui/react-progress": { "version": "1.1.7", "resolved": "https://registry.npmjs.org/@radix-ui/react-progress/-/react-progress-1.1.7.tgz", @@ -2131,6 +2239,24 @@ } } }, + "node_modules/@radix-ui/react-select/node_modules/@radix-ui/react-slot": { + "version": "1.2.3", + "resolved": "https://registry.npmjs.org/@radix-ui/react-slot/-/react-slot-1.2.3.tgz", + "integrity": "sha512-aeNmHnBxbi2St0au6VBVC7JXFlhLlOnvIIlePNniyUNAClzmtAUEY8/pBiK3iHjufOlwA+c20/8jngo7xcrg8A==", + "license": "MIT", + "dependencies": { + "@radix-ui/react-compose-refs": "1.1.2" + }, + "peerDependencies": { + "@types/react": "*", + "react": "^16.8 || ^17.0 || ^18.0 || ^19.0 || ^19.0.0-rc" + }, + "peerDependenciesMeta": { + "@types/react": { + "optional": true + } + } + }, "node_modules/@radix-ui/react-separator": { "version": "1.1.8", "resolved": "https://registry.npmjs.org/@radix-ui/react-separator/-/react-separator-1.1.8.tgz", @@ -2177,7 +2303,7 @@ } } }, - "node_modules/@radix-ui/react-separator/node_modules/@radix-ui/react-slot": { + "node_modules/@radix-ui/react-slot": { "version": "1.2.4", "resolved": "https://registry.npmjs.org/@radix-ui/react-slot/-/react-slot-1.2.4.tgz", "integrity": "sha512-Jl+bCv8HxKnlTLVrcDE8zTMJ09R9/ukw4qBs/oZClOfoQk/cOTbDn+NceXfV7j09YPVQUryJPHurafcSg6EVKA==", @@ -2195,24 +2321,6 @@ } } }, - "node_modules/@radix-ui/react-slot": { - "version": "1.2.3", - "resolved": "https://registry.npmjs.org/@radix-ui/react-slot/-/react-slot-1.2.3.tgz", - "integrity": "sha512-aeNmHnBxbi2St0au6VBVC7JXFlhLlOnvIIlePNniyUNAClzmtAUEY8/pBiK3iHjufOlwA+c20/8jngo7xcrg8A==", - "license": "MIT", - "dependencies": { - "@radix-ui/react-compose-refs": "1.1.2" - }, - "peerDependencies": { - "@types/react": "*", - "react": "^16.8 || ^17.0 || ^18.0 || ^19.0 || ^19.0.0-rc" - }, - "peerDependenciesMeta": { - "@types/react": { - "optional": true - } - } - }, "node_modules/@radix-ui/react-switch": { "version": "1.2.6", "resolved": "https://registry.npmjs.org/@radix-ui/react-switch/-/react-switch-1.2.6.tgz", @@ -2306,6 +2414,24 @@ } } }, + "node_modules/@radix-ui/react-tooltip/node_modules/@radix-ui/react-slot": { + "version": "1.2.3", + "resolved": "https://registry.npmjs.org/@radix-ui/react-slot/-/react-slot-1.2.3.tgz", + "integrity": "sha512-aeNmHnBxbi2St0au6VBVC7JXFlhLlOnvIIlePNniyUNAClzmtAUEY8/pBiK3iHjufOlwA+c20/8jngo7xcrg8A==", + "license": "MIT", + "dependencies": { + "@radix-ui/react-compose-refs": "1.1.2" + }, + "peerDependencies": { + "@types/react": "*", + "react": "^16.8 || ^17.0 || ^18.0 || ^19.0 || ^19.0.0-rc" + }, + "peerDependenciesMeta": { + "@types/react": { + "optional": true + } + } + }, "node_modules/@radix-ui/react-use-callback-ref": { "version": "1.1.1", "resolved": "https://registry.npmjs.org/@radix-ui/react-use-callback-ref/-/react-use-callback-ref-1.1.1.tgz", diff --git a/package.json b/package.json index f25f061..b918299 100644 --- a/package.json +++ b/package.json @@ -25,7 +25,7 @@ "@radix-ui/react-scroll-area": "^1.2.10", "@radix-ui/react-select": "^2.2.6", "@radix-ui/react-separator": "^1.1.8", - "@radix-ui/react-slot": "^1.2.3", + "@radix-ui/react-slot": "^1.2.4", "@radix-ui/react-switch": "^1.2.6", "@radix-ui/react-tabs": "^1.1.13", "@radix-ui/react-tooltip": "^1.2.8", diff --git a/public/sounds/success.mp3 b/public/sounds/success.mp3 new file mode 100644 index 0000000..0241778 Binary files /dev/null and b/public/sounds/success.mp3 differ diff --git a/src/components/ui/button-group.tsx b/src/components/ui/button-group.tsx new file mode 100644 index 0000000..8600af0 --- /dev/null +++ b/src/components/ui/button-group.tsx @@ -0,0 +1,83 @@ +import { Slot } from "@radix-ui/react-slot" +import { cva, type VariantProps } from "class-variance-authority" + +import { cn } from "@/lib/utils" +import { Separator } from "@/components/ui/separator" + +const buttonGroupVariants = cva( + "flex w-fit items-stretch [&>*]:focus-visible:z-10 [&>*]:focus-visible:relative [&>[data-slot=select-trigger]:not([class*='w-'])]:w-fit [&>input]:flex-1 has-[select[aria-hidden=true]:last-child]:[&>[data-slot=select-trigger]:last-of-type]:rounded-r-md has-[>[data-slot=button-group]]:gap-2", + { + variants: { + orientation: { + horizontal: + "[&>*:not(:first-child)]:rounded-l-none [&>*:not(:first-child)]:border-l-0 [&>*:not(:last-child)]:rounded-r-none", + vertical: + "flex-col [&>*:not(:first-child)]:rounded-t-none [&>*:not(:first-child)]:border-t-0 [&>*:not(:last-child)]:rounded-b-none", + }, + }, + defaultVariants: { + orientation: "horizontal", + }, + } +) + +function ButtonGroup({ + className, + orientation, + ...props +}: React.ComponentProps<"div"> & VariantProps) { + return ( +
+ ) +} + +function ButtonGroupText({ + className, + asChild = false, + ...props +}: React.ComponentProps<"div"> & { + asChild?: boolean +}) { + const Comp = asChild ? Slot : "div" + + return ( + + ) +} + +function ButtonGroupSeparator({ + className, + orientation = "vertical", + ...props +}: React.ComponentProps) { + return ( + + ) +} + +export { + ButtonGroup, + ButtonGroupSeparator, + ButtonGroupText, + buttonGroupVariants, +} diff --git a/src/packages/administrativo/components/TPessoa/TPessoaTableFormSubview.tsx b/src/packages/administrativo/components/TPessoa/TPessoaTableFormSubview.tsx index 04ad22f..5206aab 100644 --- a/src/packages/administrativo/components/TPessoa/TPessoaTableFormSubview.tsx +++ b/src/packages/administrativo/components/TPessoa/TPessoaTableFormSubview.tsx @@ -1,131 +1,126 @@ +import { FingerprintIcon, WebcamIcon } from 'lucide-react'; +import { + memo, + useCallback, + useMemo, + useState +} from 'react'; +import { Avatar, AvatarFallback, AvatarImage } from '@/components/ui/avatar'; +import { Button } from '@/components/ui/button'; +import { + Item, + ItemActions, + ItemContent, + ItemDescription, + ItemMedia, + ItemTitle +} from '@/components/ui/item'; +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 { FingerprintIcon, WebcamIcon } from "lucide-react"; -import { useCallback, useEffect, useState } from "react"; +function TPessoaTableFormSubview({ + item_index, + data, + params, + form, +}: any) { -import { Avatar, AvatarFallback, AvatarImage } from "@/components/ui/avatar"; -import { Button } from "@/components/ui/button"; -import { Item, ItemActions, ItemContent, ItemDescription, ItemMedia, ItemTitle } from "@/components/ui/item"; -import TPessoaTableFormSubviewInterface from "@/packages/administrativo/interfaces/TPessoa/TPessoaTableFormSubviewInterface"; -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"; + const [isWebCamOpenDialog, setIsWebCamOpenDialog] = useState(false) + const { base64, captureFingerTech } = useFingerTechIndexHook(); + const handleBiometria = useCallback(() => { -export default function TPessoaTableFormSubview({ params, servico, selectedTPessoa, form, index }: TPessoaTableFormSubviewInterface) { + console.log(captureFingerTech()) - const [isOpenWebcamDialog, setIsOpenWebcamDialog] = useState(false) - const [base64, setBase64] = useState('') - const [statusBiometria, setStatusBiometria] = useState(0) - const [classBiometriaButton, setClassBiometriaButton] = useState('') - const { base64: base64Biometria, captureFingerTech } = useFingerTechIndexHook() + }) - const handleCapture = (data: string) => { - setBase64(data) - }; - - const handleCaptureBiometria = useCallback(async () => { - - const response = await captureFingerTech() - - if (response) { - - setStatusBiometria(1) - - } - - }, []) - - const handleBiometriaButton = useCallback(async () => { - switch (statusBiometria) { + // Define a classe do botão de biometria com base no status, sem estado extra + const biometriaButtonClass = useMemo(() => { + switch (1) { case 0: // Amarelo (aviso) - setClassBiometriaButton('bg-amber-100 text-amber-700 border border-amber-300 hover:bg-amber-200 hover:text-amber-800'); - break; - + return 'bg-amber-100 text-amber-700 border border-amber-300 hover:bg-amber-200 hover:text-amber-800'; case 1: // Verde discreto - setClassBiometriaButton('bg-green-100 text-green-700 border border-green-300 hover:bg-green-200 hover:text-green-800'); - break; + return 'bg-green-100 text-green-700 border border-green-300 hover:bg-green-200 hover:text-green-800'; case 2: // Vermelho (erro) - setClassBiometriaButton('bg-red-100 text-red-700 border border-red-300 hover:bg-red-200 hover:text-red-800'); - break; - + return 'bg-red-100 text-red-700 border border-red-300 hover:bg-red-200 hover:text-red-800'; default: - break; + return ''; } - }, [statusBiometria]) - - useEffect(() => { - handleBiometriaButton() - }, [statusBiometria]) + }, []); return ( - -
+
- + - {GetNameInitials(selectedTPessoa.nome)} + {GetNameInitials(data.pessoa?.nome)} - {selectedTPessoa.cpf_cnpj} - {selectedTPessoa.nome} + {data.pessoa?.cpf_cnpj} - {data.pessoa?.nome} - {selectedTPessoa.email ? selectedTPessoa.email : 'Email não informado'} + {data.pessoa?.email || 'Email não informado'} - {/* Verifica se existe formulário de acordo com parâmetros */} - {params.map((param) => ( - // Verifica se dfeve aparecer os dados do cartão - Number(param.valor) == Number(servico.servico_tipo_id) && ( + {params + .filter((param) => Number(param.valor) === data.servico.servico_tipo_id) + .map((param) => ( - ) - ))} + ))} + - {servico.requer_biometria === 'S' && ( + {data.servico.requer_biometria === 'S' && ( )} - {servico.requer_biometria === 'S' && ( + {data.servico.requer_biometria && ( )} - {isOpenWebcamDialog && ( + {isWebCamOpenDialog && ( { setIsOpenWebcamDialog(false) }} - onSave={handleCapture} + isOpen={isWebCamOpenDialog} + onClose={() => { setIsWebCamOpenDialog(false) }} + onSave={() => { }} + key={1} /> )}
); -} \ No newline at end of file +} + +// Memo para evitar re-renderizações desnecessárias da subview +export default memo(TPessoaTableFormSubview); \ No newline at end of file diff --git a/src/packages/administrativo/services/GCalculo/GCalculoServicoService.ts b/src/packages/administrativo/services/GCalculo/GCalculoServicoService.ts index 28879b7..dcba5f4 100644 --- a/src/packages/administrativo/services/GCalculo/GCalculoServicoService.ts +++ b/src/packages/administrativo/services/GCalculo/GCalculoServicoService.ts @@ -6,7 +6,7 @@ import { withClientErrorHandler } from "@/shared/actions/withClientErrorHandler/ async function executeGCalculoServicoService(payload: GCalculoServicoInterface, data) { const response = await GCalculoServico(payload); - const item = PrepareTServicoItemPedidoCalculoResponse(response.data, data) + const item = PrepareTServicoItemPedidoCalculoResponse(response, data) return item; } diff --git a/src/packages/servicos/actions/TServicoPedido/PrepareTServicoItemPedidoResponseItem.ts b/src/packages/servicos/actions/TServicoPedido/PrepareTServicoItemPedidoResponseItem.ts index 985c7ac..6e60e0e 100644 --- a/src/packages/servicos/actions/TServicoPedido/PrepareTServicoItemPedidoResponseItem.ts +++ b/src/packages/servicos/actions/TServicoPedido/PrepareTServicoItemPedidoResponseItem.ts @@ -1,60 +1,37 @@ -import TServicoItemPedidoAddInterface from "../../interfaces/TServicoItemPedido/TServicoItemPedidoAddInterface"; -import TServicoItemPedidoAddResponseInterface from "../../interfaces/TServicoItemPedido/TServicoItemPedidoAddResponseInterface"; +import TServicoItemPedidoAddInterface from "@/packages/servicos/interfaces/TServicoItemPedido/TServicoItemPedidoAddInterface"; +import TServicoItemPedidoAddResponseInterface from "@/packages/servicos/interfaces/TServicoItemPedido/TServicoItemPedidoAddResponseInterface"; export function PrepareTServicoItemPedidoCalculoResponse( result: any, data: TServicoItemPedidoAddInterface ) { - // Valida resposta básica do cálculo de emolumento - if (!result) { + if (result.status == 404 || result.status == 400) { return { - status: 400, - message: "Resposta inválida ao calcular emolumento.", + 'status': result.status, + 'message': result.detail }; } - // Emolumento obrigatório - if (!result.emolumento_id) { - return { - status: 400, - message: "Emolumento não informado na resposta.", - }; - } - - // Valida campos numéricos da resposta (não podem ser NaN) - const numericFields = [ - "valor_total", - "valor_emolumento", - "valor_fundos", - "taxa_judiciaria", - "valor_iss", - ] as const; - - for (const field of numericFields) { - const value = result[field]; - if (value !== null && value !== undefined && isNaN(Number(value))) { - return { - status: 400, - message: `Valor numérico inválido em '${field}'.`, - }; - } - } - const item: TServicoItemPedidoAddResponseInterface = { - emolumento_id: result.emolumento_id, - emolumento_item_id: result.emolumento_item_id ?? null, + emolumento_id: result.data.emolumento_id, + emolumento_item_id: result.data.emolumento_item_id ?? null, servico_tipo_id: data.servico_tipo.servico_tipo_id ?? 0, tipo_item: data.servico_tipo.tipo_item ?? "", descricao: data.servico_tipo.descricao ?? "", tabela: data.servico_tipo?.descricao ?? "", situacao: "F", qtd: 1, - valor: result.valor_total ?? 0, - emolumento: result.valor_emolumento ?? 0, - fundesp: result.valor_fundos ?? 0, - taxa_judiciaria: result.taxa_judiciaria ?? 0, - valor_iss: result.valor_iss ?? 0, + valor: result.data.valor_total ?? 0, + emolumento: result.data.valor_emolumento ?? 0, + fundesp: result.data.valor_fundos ?? 0, + taxa_judiciaria: result.data.taxa_judiciaria ?? 0, + valor_iss: result.data.valor_iss ?? 0, + pessoa_id: data.pessoa.pessoa_id ?? null, + subview: { + servico: data.servico_tipo, + pessoa: data.pessoa, + } }; return item; diff --git a/src/packages/servicos/components/TPessoaCartao/TPessoaCartaoForm.tsx b/src/packages/servicos/components/TPessoaCartao/TPessoaCartaoForm.tsx index 60198ae..a08ca8c 100644 --- a/src/packages/servicos/components/TPessoaCartao/TPessoaCartaoForm.tsx +++ b/src/packages/servicos/components/TPessoaCartao/TPessoaCartaoForm.tsx @@ -53,7 +53,9 @@ export default function TPessoaCartaoForm({ index, form }: TPessoaCartaoFormInte field.onChange(parseNumberInput(e))} /> + onChange={(e) => field.onChange(parseNumberInput(e))} + defaultValue={field.value ?? ""} + /> @@ -69,7 +71,10 @@ export default function TPessoaCartaoForm({ index, form }: TPessoaCartaoFormInte Data de Abertura - + diff --git a/src/packages/servicos/components/TServicoItemPedido/TServicoItemPedidoFormColumns.tsx b/src/packages/servicos/components/TServicoItemPedido/TServicoItemPedidoFormColumns.tsx deleted file mode 100644 index dcbf488..0000000 --- a/src/packages/servicos/components/TServicoItemPedido/TServicoItemPedidoFormColumns.tsx +++ /dev/null @@ -1,122 +0,0 @@ -import { ColumnDef } from '@tanstack/react-table'; -import { Minus, Plus } from 'lucide-react'; - -import { Button } from '@/components/ui/button'; -import { Input } from '@/components/ui/input'; -import TServicoItemPedidoInterface from '@/packages/servicos/interfaces/TServicoItemPedido/TServicoItemPedidoIntefarce'; -import GetCapitalize from '@/shared/actions/text/GetCapitalize'; -import { SortableHeader } from '@/shared/components/dataTable/SortableHeader'; - -/** Permite atualizar a linha externamente, caso o DataTable forneça meta.updateData */ -type TableMeta = { - updateData?: (rowIndex: number, columnId: string, value: unknown) => void; -}; - -export default function TServicoItemPedidoFormColumns(): ColumnDef[] { - return [ - // servico - { - accessorKey: 'servico', - header: ({ column }) => SortableHeader('Serviço / Tabela', column), - cell: ({ row }) => { - const data = row.original; - return ( -
-
-
- {GetCapitalize(data.descricao)} -
-
- {GetCapitalize(data.tabela)} -
-
-
- ); - }, - sortingFn: (a, b) => - (a.original.descricao?.toLowerCase() || '').localeCompare( - b.original.descricao?.toLowerCase() || '', - ), - }, - - // emolumento - { - accessorKey: 'emolumento', - header: ({ column }) => SortableHeader('Emolumento', column), - cell: ({ row }) =>
R$ {row.getValue('emolumento') || '---'}
, - }, - - // taxa_judiciaria - { - accessorKey: 'taxa_judiciaria', - header: ({ column }) => SortableHeader('Tx. Judiciária', column), - cell: ({ row }) =>
R$ {row.getValue('taxa_judiciaria') || '---'}
, - }, - - // fundesp - { - accessorKey: 'fundesp', - header: ({ column }) => SortableHeader('Fundesp 21%', column), - cell: ({ row }) =>
R$ {row.getValue('fundesp') || '---'}
, - }, - - // valor_iss - { - accessorKey: 'valor_iss', - header: ({ column }) => SortableHeader('ISS 5%', column), - cell: ({ row }) =>
R$ {row.getValue('valor_iss') || '---'}
, - }, - - // total - { - accessorKey: 'valor', - header: ({ column }) => SortableHeader('Total', column), - cell: ({ row }) =>
R$ {row.getValue('valor') || '---'}
, - }, - - { - accessorKey: 'quantidade', - header: ({ column }) => SortableHeader('Qtd.', column), - enableSorting: true, - cell: ({ row, table }) => { - return ( -
- {/* Botão diminuir */} - - - {/* Campo de entrada */} -
- -
- - {/* Botão aumentar */} - -
- ); - }, - } - - - ]; -} diff --git a/src/packages/servicos/components/TServicoItemPedido/TServicoItemPedidoFormTable.tsx b/src/packages/servicos/components/TServicoItemPedido/TServicoItemPedidoFormTable.tsx index 9e23bbf..1f5f866 100644 --- a/src/packages/servicos/components/TServicoItemPedido/TServicoItemPedidoFormTable.tsx +++ b/src/packages/servicos/components/TServicoItemPedido/TServicoItemPedidoFormTable.tsx @@ -1,24 +1,128 @@ 'use client'; -import TServicoItemPedidoTableInterface from '@/packages/servicos/interfaces/TServicoItemPedido/TServicoItemPedidoTableInterface'; -import { DataTable } from '@/shared/components/dataTable/DataTable'; +import { Minus, Plus } from 'lucide-react'; +import React, { memo } from 'react'; -import TServicoItemPedidoFormColumns from './TServicoItemPedidoFormColumns'; +import { Button } from '@/components/ui/button'; +import { Input } from '@/components/ui/input'; +import { + Table, + TableBody, + TableCell, + TableHead, + TableHeader, + TableRow +} from '@/components/ui/table'; +import TPessoaTableFormSubview from '@/packages/administrativo/components/TPessoa/TPessoaTableFormSubview'; +import TServicoItemPedidoFormTableInterface from '@/packages/servicos/interfaces/TServicoItemPedido/TServicoItemPedidoFormTableInterface'; +import GetCapitalize from '@/shared/actions/text/GetCapitalize'; - -/** - * Componente principal da tabela de Naturezas - */ -export default function TServicoItemPedidoFormTable({ data }: TServicoItemPedidoTableInterface) { - const columns = TServicoItemPedidoFormColumns(); +function TServicoItemPedidoFormTableComponent({ + data, + form, + params +}: TServicoItemPedidoFormTableInterface) { return ( -
- +
+ + + + + Serviço / Tabela + + + Emolumento + + + Tx. Judiciária + + + Fundesp 21% + + + ISS 5% + + + Total + + Qtd. + + + + {data?.length ? ( + data.map((item, index) => { + return ( + + {/* Linha principal */} + + +
+
+
+ {GetCapitalize(item.descricao)} +
+
+ {GetCapitalize(item.tabela)} +
+
+
+
+ R$ {item.emolumento ?? '---'} + R$ {item.taxa_judiciaria ?? '---'} + R$ {item.fundesp ?? '---'} + R$ {item.valor_iss ?? '---'} + R$ {item.valor ?? '---'} + +
+ + + + + +
+
+
+ {/* SubView */} + {item.subview && ( + + + + + + )} +
+ ); + }) + ) : ( + + + Nenhum item encontrado. + + + )} +
+
); } + +export const TServicoItemPedidoFormTable = memo(TServicoItemPedidoFormTableComponent); \ No newline at end of file diff --git a/src/packages/servicos/components/TServicoItemPedido/TServicoItemPedidoList.tsx b/src/packages/servicos/components/TServicoItemPedido/TServicoItemPedidoList.tsx index 3bd40f8..4a32ea2 100644 --- a/src/packages/servicos/components/TServicoItemPedido/TServicoItemPedidoList.tsx +++ b/src/packages/servicos/components/TServicoItemPedido/TServicoItemPedidoList.tsx @@ -1,61 +1,105 @@ 'use client'; + +import { BookmarkX, IdCardIcon, MoreHorizontalIcon, TicketIcon } from 'lucide-react'; + +import { Button } from '@/components/ui/button'; +import { ButtonGroup } from '@/components/ui/button-group'; import { Card, CardContent, CardHeader, CardTitle } from '@/components/ui/card'; +import { DropdownMenu, DropdownMenuContent, DropdownMenuGroup, DropdownMenuItem, DropdownMenuSeparator, DropdownMenuTrigger } from '@/components/ui/dropdown-menu'; import TServicoItemPedidoListInterface from '@/packages/servicos/interfaces/TServicoItemPedido/TServicoItemPedidoListInterface'; +import FormatMoney from '@/shared/actions/money/FormatMoney'; +import { ServicosPedidosSituacoesBadge } from '@/shared/components/servicosPedidosSituacoes/ServicosPedidosSituacoesBadge'; export default function TServicoItemPedidoList({ items }: TServicoItemPedidoListInterface) { - const money = (v: unknown) => - new Intl.NumberFormat('pt-BR', { style: 'currency', currency: 'BRL' }).format(Number(v || 0)); - return ( - Itens: {items?.length} + + Itens: {items?.length} + {/* Altura máxima + scroll vertical */}
{items?.map((item) => ( -
+
{/* Descrição */} -
+

- {item.descricao} + {item.descricao} de {item.nome} -

# {item.servico_itempedido_id}
+ {/* Valores (grid compacto) */} -
+
+
Emolumento
-
{money(item.emolumento)}
+
{FormatMoney(item.emolumento)}
Tx. Judiciária
-
{money(item.taxa_judiciaria)}
+
{FormatMoney(item.taxa_judiciaria)}
ISS
-
{money(item.valor_iss)}
+
{FormatMoney(item.valor_iss)}
Fundesp
-
{money(item.fundesp)}
+
{FormatMoney(item.fundesp)}
Total
-
{money(item.valor)}
+
{FormatMoney(item.valor)}
+
+ +
+ + + + + + + + + + + + Imprimir Etiqueta + + + + + + Imprimir Cartão + + + + + + Estornar Item + + + + + +
+
))}
diff --git a/src/packages/servicos/components/TServicoItemPedido/TServicoItemPedidoTable.tsx b/src/packages/servicos/components/TServicoItemPedido/TServicoItemPedidoTable.tsx index 3b5fecb..6e87f4d 100644 --- a/src/packages/servicos/components/TServicoItemPedido/TServicoItemPedidoTable.tsx +++ b/src/packages/servicos/components/TServicoItemPedido/TServicoItemPedidoTable.tsx @@ -2,8 +2,8 @@ import { DataTable } from '@/shared/components/dataTable/DataTable'; -import TServicoItemPedidoColumns from './TServicoItemPedidoColumns'; import TServicoItemPedidoTableInterface from '../../interfaces/TServicoItemPedido/TServicoItemPedidoTableInterface'; +import TServicoItemPedidoColumns from './TServicoItemPedidoColumns'; /** * Componente principal da tabela de Naturezas diff --git a/src/packages/servicos/components/TServicoPedido/PessoaSubviewForm.tsx b/src/packages/servicos/components/TServicoPedido/PessoaSubviewForm.tsx new file mode 100644 index 0000000..f713e80 --- /dev/null +++ b/src/packages/servicos/components/TServicoPedido/PessoaSubviewForm.tsx @@ -0,0 +1,28 @@ +import { Input } from "@/components/ui/input"; + +export function PessoaSubviewForm({ form, index, pessoa }) { + return ( +
+ +

+ Dados da Pessoa Selecionada +

+ +
+ +
+ + +
+ +
+ + +
+ +
+ +
+ ); +} diff --git a/src/packages/servicos/components/TServicoPedido/TServicoPedidoDetails.tsx b/src/packages/servicos/components/TServicoPedido/TServicoPedidoDetails.tsx index 30dd726..ac68696 100644 --- a/src/packages/servicos/components/TServicoPedido/TServicoPedidoDetails.tsx +++ b/src/packages/servicos/components/TServicoPedido/TServicoPedidoDetails.tsx @@ -1,8 +1,8 @@ 'use client'; -import { CalendarIcon, ClockIcon, Pencil } from 'lucide-react'; -import { useCallback, useEffect } from 'react'; +import { BookmarkX, CalendarIcon, ReceiptText } from 'lucide-react'; +import { useCallback, useEffect, useState } from 'react'; import { Button } from '@/components/ui/button'; import { Card, CardContent, CardHeader, CardTitle } from '@/components/ui/card'; @@ -16,14 +16,13 @@ import { FormatCPF } from '@/shared/actions/CPF/FormatCPF'; import { FormatDateTime } from '@/shared/actions/dateTime/FormatDateTime'; import GetCapitalize from '@/shared/actions/text/GetCapitalize'; import GetNameInitials from '@/shared/actions/text/GetNameInitials'; - - - +import ConfirmDialog from '@/shared/components/confirmDialog/ConfirmDialog'; export default function TServicoPedidoDetails({ servico_pedido_id }: TServicoPedidoInterface) { const { TServicoItemPedido, indexTServicoItemPedido } = useTServicoItemPedidoIndexHook() const { TServicoPedido, showTServicoPedido } = useTServicoPedidoShowHook() + const [isCancelServicoPedidoDialogOpen, setIsCancelServicoPedidoDialogOpen] = useState(false) const TServicoPedidoShowData = useCallback(async () => { const servicoPedido: TServicoPedidoInterface = { @@ -42,23 +41,19 @@ export default function TServicoPedidoDetails({ servico_pedido_id }: TServicoPed await indexTServicoItemPedido(servicoPedido) }) + const handleCancelServicoPedidoOpenDialog = useCallback((state: boolean) => { + setIsCancelServicoPedidoDialogOpen(state) + }, []) + useEffect(() => { TServicoPedidoShowData() }, []) return (
-
-

- Pedido: #{TServicoPedido?.servico_pedido_id} -

-
- -
-
+

+ Pedido: #{TServicoPedido?.servico_pedido_id} +

{/* Main */}
@@ -99,18 +94,12 @@ export default function TServicoPedidoDetails({ servico_pedido_id }: TServicoPed
-
- +
+ {FormatDateTime(TServicoPedido?.data_pedido)}
-
- - - 14:50:31 - -
@@ -141,17 +130,34 @@ export default function TServicoPedidoDetails({ servico_pedido_id }: TServicoPed - Impressões + Controles - - + +
+ {/* Confirma o cancelamento do pedido */} + {isCancelServicoPedidoDialogOpen && ( + { handleCancelServicoPedidoOpenDialog(false) }} + onCancel={() => { handleCancelServicoPedidoOpenDialog(false) }} + /> + )}
) } \ No newline at end of file diff --git a/src/packages/servicos/components/TServicoPedido/TServicoPedidoDetailsPagamento.tsx b/src/packages/servicos/components/TServicoPedido/TServicoPedidoDetailsPagamento.tsx index 05b8ea2..077e883 100644 --- a/src/packages/servicos/components/TServicoPedido/TServicoPedidoDetailsPagamento.tsx +++ b/src/packages/servicos/components/TServicoPedido/TServicoPedidoDetailsPagamento.tsx @@ -4,6 +4,7 @@ import * as React from 'react'; import { Card, CardContent, CardHeader, CardTitle } from '@/components/ui/card'; import { Separator } from '@/components/ui/separator'; +import FormatMoney from '@/shared/actions/money/FormatMoney'; import { ServicosPedidosSituacoesBadge } from '@/shared/components/servicosPedidosSituacoes/ServicosPedidosSituacoesBadge'; import TServicoPedidoDetailsPagamentoInterface from '../../interfaces/TServicoPedido/TServicoPedidoDetailsPagamentoInterface'; @@ -13,28 +14,29 @@ export default function TServicoPedidoDetailsPagamento({ items, }: TServicoPedidoDetailsPagamentoInterface) { - // Formatação monetária (BRL) - const fmt = React.useMemo( - () => new Intl.NumberFormat('pt-BR', { style: 'currency', currency: 'BRL' }), - [] - ); - - // Helper para evitar NaN/undefined - const safe = (n: number | undefined | null) => - typeof n === 'number' && Number.isFinite(n) ? n : 0; - // Somas por tipo de valor const { emolumento, taxa_judiciaria, valor_iss, fundesp } = React.useMemo(() => { + return (items ?? []).reduce( + (acc, item) => { - acc.emolumento += safe(item.emolumento); - acc.taxa_judiciaria += safe(item.taxa_judiciaria); - acc.valor_iss += safe(item.valor_iss); - acc.fundesp += safe(item.fundesp); + + if (item.situacao === 'F') { + + acc.emolumento += item.emolumento; + acc.taxa_judiciaria += item.taxa_judiciaria; + acc.valor_iss += item.valor_iss; + acc.fundesp += item.fundesp; + + } + return acc; + }, { emolumento: 0, taxa_judiciaria: 0, valor_iss: 0, fundesp: 0 } + ); + }, [items]); // Total exibido = soma dos quatro componentes @@ -47,35 +49,57 @@ export default function TServicoPedidoDetailsPagamento({ Pagamento - -
+
Emolumento - {fmt.format(emolumento)} + {FormatMoney(emolumento)}
Tx. Judiciária - {fmt.format(taxa_judiciaria)} + {FormatMoney(taxa_judiciaria)}
ISS - {fmt.format(valor_iss)} + {FormatMoney(valor_iss)}
Fundesp - {fmt.format(fundesp)} + {FormatMoney(fundesp)} +
+ + + +
+ Total + {FormatMoney(total)}
- Total - {fmt.format(total)} + Emolumento + {FormatMoney(emolumento)}
+ +
+ Tx. Judiciária + {FormatMoney(taxa_judiciaria)} +
+ +
+ ISS + {FormatMoney(valor_iss)} +
+ +
+ Fundesp + {FormatMoney(fundesp)} +
+
diff --git a/src/packages/servicos/components/TServicoPedido/TServicoPedidoForm.tsx b/src/packages/servicos/components/TServicoPedido/TServicoPedidoForm.tsx index ef44577..6af3173 100644 --- a/src/packages/servicos/components/TServicoPedido/TServicoPedidoForm.tsx +++ b/src/packages/servicos/components/TServicoPedido/TServicoPedidoForm.tsx @@ -25,10 +25,9 @@ import { Switch } from '@/components/ui/switch'; import GEmolumentoServicoSelect from '@/packages/administrativo/components/GEmolumento/GEmolumentoServicoSelect'; import GUsuarioSelect from '@/packages/administrativo/components/GUsuario/GUsuarioSelect'; import TPessoaTableFormDialog from '@/packages/administrativo/components/TPessoa/TPessoaTableFormDialog'; -import TPessoaTableFormSubview from '@/packages/administrativo/components/TPessoa/TPessoaTableFormSubview'; import TServicoTipoSelect from '@/packages/administrativo/components/TServicoTipo/TServicoTipoSelect'; +import TPessoaInterface from '@/packages/administrativo/interfaces/TPessoa/TPessoaInterface'; import HandleSelectTServicoTipoAction from '@/packages/servicos/actions/TServicoPedido/HandleSelectTServicoTipoAction'; -import TServicoItemPedidoFormTable from '@/packages/servicos/components/TServicoItemPedido/TServicoItemPedidoFormTable'; import { useTServicoItemPedidoAddHook } from '@/packages/servicos/hooks/TServicoItemPedido/useTServicoItemPedidoAddHook'; import { useTServicoItemPedidoIndexHook } from '@/packages/servicos/hooks/TServicoItemPedido/useTServicoItemPedidoIndexHook'; import { useTServicoItemPedidoLocalAddHook } from '@/packages/servicos/hooks/TServicoItemPedido/useTServicoItemPedidoLocalAddHook'; @@ -51,7 +50,9 @@ import { } from '@/shared/components/step/stepNavigator'; import TipoPagamentoSelect from '@/shared/components/tipoPagamento/TipoPagamentoSelect'; -import TServicoSubviewInterface from '../../interfaces/TServico/TServicoSubviewInterface'; +import TServicoItemPedidoAddInterface from '../../interfaces/TServicoItemPedido/TServicoItemPedidoAddInterface'; +import TServicoItemPedidoAddResponseInterface from '../../interfaces/TServicoItemPedido/TServicoItemPedidoAddResponseInterface'; +import { TServicoItemPedidoFormTable } from '../TServicoItemPedido/TServicoItemPedidoFormTable'; export default function TServicoPedidoForm({ servico_pedido_id }: TServicoPedidoFormInterface) { @@ -76,7 +77,8 @@ export default function TServicoPedidoForm({ servico_pedido_id }: TServicoPedido const handleCloseSaveConfirm = useCallback(() => setIsSaveConfirmOpen(false), []); // Hooks - const { response, setResponse } = useResponse() + // const playSuccess = useSoundHook("/sounds/success.mp3"); + const { setResponse } = useResponse() const { saveTServicoPedido } = useTServicoPedidoSaveHook(); const { showTServicoPedido } = useTServicoPedidoShowHook(); const { TServicoItemPedidoLocal, localAddTServicoItemPedido, setLocalTServicoItemPedido } = useTServicoItemPedidoLocalAddHook(setValue); @@ -107,6 +109,14 @@ export default function TServicoPedidoForm({ servico_pedido_id }: TServicoPedido // Desativa o botão de loading setIsSaving(false); + // Verifica se devo redirecionar a pagina + if (response?.servico_pedido_id > 0) { + + // Toca o som do sistema + // playSuccess() + + } + // Verifica se devo redirecionar a pagina if (response?.servico_pedido_id > 0 && !shouldKeepFormOpen) { @@ -127,8 +137,12 @@ export default function TServicoPedidoForm({ servico_pedido_id }: TServicoPedido // Busca os itens do Pedido const fetchPedidoItens = useCallback(async (id: number) => { + const pedidoItens = { + servico_pedido_id: id + } + // Busca os itens do pedido - const response = await indexTServicoItemPedido({ servico_pedido_id: id }); + const response = await indexTServicoItemPedido(pedidoItens); // Verifica se os dados foram localizados if (response?.data?.length) { @@ -161,14 +175,16 @@ export default function TServicoPedidoForm({ servico_pedido_id }: TServicoPedido }, [servico_pedido_id, showTServicoPedido, reset, fetchPedidoItens]); - const handleAddItemWithPessoa = useCallback(async (selectedTPessoa: any) => { + const handleAddItemWithPessoa = useCallback(async (selectedTPessoa: TPessoaInterface) => { + // Habilita o loading setIsAdding(true) // Constroi um novo item - const newItem: TServicoSubviewInterface = await addTServicoItemPedido({ + const newItem: TServicoItemPedidoAddResponseInterface = await addTServicoItemPedido({ servico_tipo: selectedServicoTipo, - emolumento: selectedEmolumento + emolumento: selectedEmolumento, + pessoa: selectedTPessoa }); // Verifica se existe um novo item @@ -177,19 +193,8 @@ export default function TServicoPedidoForm({ servico_pedido_id }: TServicoPedido // Obtem o indice atual const index = TServicoItemPedidoLocal.length; - // Guarda o ID da pessoa - newItem.pessoa_id = selectedTPessoa.pessoa_id; - - // Cria a subview se necessário - newItem.subview = ( - - ); + // Define a posição do item + newItem.index = index // Atualiza o estado localAddTServicoItemPedido(newItem); @@ -197,6 +202,7 @@ export default function TServicoPedidoForm({ servico_pedido_id }: TServicoPedido // Atualiza os itens do formulário form.setValue(`itens.${index}`, newItem); + // Desabilita o loading setIsAdding(false) }, [ @@ -206,7 +212,6 @@ export default function TServicoPedidoForm({ servico_pedido_id }: TServicoPedido TServicoItemPedidoLocal.length, localAddTServicoItemPedido, form, - TServicoPedidoParams ]); // Controla o formulário de cancelamento de pedido @@ -251,7 +256,7 @@ export default function TServicoPedidoForm({ servico_pedido_id }: TServicoPedido setIsAdding(true) // Prepara e valida os dados de item do pedido - const payload = { + const payload: TServicoItemPedidoAddInterface = { servico_tipo: selectedServicoTipo, emolumento: selectedEmolumento } @@ -303,7 +308,7 @@ export default function TServicoPedidoForm({ servico_pedido_id }: TServicoPedido } const total = TServicoItemPedidoLocal.reduce((acc, item) => { - const valor = Number(item.valor_total ?? item.valor ?? 0); + const valor = Number(item.valor ?? 0); return acc + valor; }, 0); @@ -522,7 +527,10 @@ export default function TServicoPedidoForm({ servico_pedido_id }: TServicoPedido />
- +
diff --git a/src/packages/servicos/hooks/TServicoItemPedido/useTServicoItemPedidoAddHook.ts b/src/packages/servicos/hooks/TServicoItemPedido/useTServicoItemPedidoAddHook.ts index 6a87816..1d4f135 100644 --- a/src/packages/servicos/hooks/TServicoItemPedido/useTServicoItemPedidoAddHook.ts +++ b/src/packages/servicos/hooks/TServicoItemPedido/useTServicoItemPedidoAddHook.ts @@ -1,7 +1,8 @@ 'use client'; import { useState } from 'react'; -import { UseFormSetValue } from 'react-hook-form'; +import { FieldValues, UseFormSetValue } from 'react-hook-form'; + import { GCalculoServicoService } from '@/packages/administrativo/services/GCalculo/GCalculoServicoService'; import PrepareTServicoItemPedidoPayload from '@/packages/servicos/actions/TServicoPedido/PrepareTServicoItemPedidoPayload'; @@ -9,8 +10,7 @@ import TServicoItemPedidoAddInterface from '@/packages/servicos/interfaces/TServ import { default as TServicoItemPedidoIndexResponseInterface } from '@/packages/servicos/interfaces/TServicoItemPedido/TServicoItemPedidoAddResponseInterface'; import { useResponse } from '@/shared/components/response/ResponseContext'; - -export const useTServicoItemPedidoAddHook = (setValue?: UseFormSetValue) => { +export function useTServicoItemPedidoAddHook(setValue?: UseFormSetValue) { const { setResponse } = useResponse(); @@ -25,13 +25,23 @@ export const useTServicoItemPedidoAddHook = (setValue?: UseFormSetValue) => { + +export function useTServicoItemPedidoLocalAddHook(setValue?: UseFormSetValue) { const [TServicoItemPedidoLocal, setLocalTServicoItemPedido] = useState([]); - const localAddTServicoItemPedido = (item: any) => { + const localAddTServicoItemPedido = (item: TServicoItemPedidoAddResponseInterface) => { setLocalTServicoItemPedido((prev) => { diff --git a/src/packages/servicos/hooks/TServicoPedido/useTServicoPedidoFormHook.ts b/src/packages/servicos/hooks/TServicoPedido/useTServicoPedidoFormHook.ts index 94866e0..39edf22 100644 --- a/src/packages/servicos/hooks/TServicoPedido/useTServicoPedidoFormHook.ts +++ b/src/packages/servicos/hooks/TServicoPedido/useTServicoPedidoFormHook.ts @@ -19,6 +19,7 @@ export function useTServicoPedidoFormHook(defaults?: Partial { const { setResponse } = useResponse(); - const [TServicoPedido, setTServicoPedido] = useState(null); + const [TServicoPedido, setTServicoPedido] = useState(); const showTServicoPedido = async (data: TServicoPedidoInterface) => { diff --git a/src/packages/servicos/interfaces/TServico/TServicoItemPedidoSubviewInterface.ts b/src/packages/servicos/interfaces/TServico/TServicoItemPedidoSubviewInterface.ts new file mode 100644 index 0000000..da03c69 --- /dev/null +++ b/src/packages/servicos/interfaces/TServico/TServicoItemPedidoSubviewInterface.ts @@ -0,0 +1,7 @@ +import TServicoTipoInterface from "@/app/(protected)/(cadastros)/cadastros/_interfaces/TServicoTipoInterface"; +import TPessoaInterface from "@/packages/administrativo/interfaces/TPessoa/TPessoaInterface"; + +export default interface TServicoItemPedidoSubviewInterface { + servico: TServicoTipoInterface, + pessoa: TPessoaInterface +} \ No newline at end of file diff --git a/src/packages/servicos/interfaces/TServico/TServicoSubviewInterface.ts b/src/packages/servicos/interfaces/TServico/TServicoSubviewInterface.ts deleted file mode 100644 index 3364882..0000000 --- a/src/packages/servicos/interfaces/TServico/TServicoSubviewInterface.ts +++ /dev/null @@ -1,5 +0,0 @@ - -export default interface TServicoSubviewInterface { - pessoa_id: number; - subview: any; -} \ No newline at end of file diff --git a/src/packages/servicos/interfaces/TServicoItemPedido/TServicoItemPedidoAddInterface.ts b/src/packages/servicos/interfaces/TServicoItemPedido/TServicoItemPedidoAddInterface.ts index 1269f8f..80fa589 100644 --- a/src/packages/servicos/interfaces/TServicoItemPedido/TServicoItemPedidoAddInterface.ts +++ b/src/packages/servicos/interfaces/TServicoItemPedido/TServicoItemPedidoAddInterface.ts @@ -4,7 +4,4 @@ import GEmolumentoInterface from "@/packages/administrativo/interfaces/GEmolumen export default interface TServicoItemPedidoAddInterface { emolumento: GEmolumentoInterface; servico_tipo: TServicoTipoInterface; - sistema_id?: number; - valor_documento?: number; - quantidade?: number; } \ No newline at end of file diff --git a/src/packages/servicos/interfaces/TServicoItemPedido/TServicoItemPedidoAddResponseInterface.ts b/src/packages/servicos/interfaces/TServicoItemPedido/TServicoItemPedidoAddResponseInterface.ts index e451438..e5c0d50 100644 --- a/src/packages/servicos/interfaces/TServicoItemPedido/TServicoItemPedidoAddResponseInterface.ts +++ b/src/packages/servicos/interfaces/TServicoItemPedido/TServicoItemPedidoAddResponseInterface.ts @@ -1,4 +1,7 @@ +import TServicoItemPedidoSubviewInterface from "../TServico/TServicoItemPedidoSubviewInterface"; + export default interface TServicoItemPedidoAddResponseInterface { + index?: number; emolumento_id: number; emolumento_item_id: number; servico_tipo_id: number; @@ -12,4 +15,6 @@ export default interface TServicoItemPedidoAddResponseInterface { fundesp: number; taxa_judiciaria: number; valor_iss: number; + pessoa_id?: number; + subview?: TServicoItemPedidoSubviewInterface; } diff --git a/src/packages/servicos/interfaces/TServicoItemPedido/TServicoItemPedidoFormInterface.ts b/src/packages/servicos/interfaces/TServicoItemPedido/TServicoItemPedidoFormInterface.ts deleted file mode 100644 index e418f33..0000000 --- a/src/packages/servicos/interfaces/TServicoItemPedido/TServicoItemPedidoFormInterface.ts +++ /dev/null @@ -1,9 +0,0 @@ -import { TServicoItemPedidoFormValues } from '../../schemas/TServicoItemPedido/TServicoItemPedidoSchema'; - -export interface TServicoItemPedidoFormInterface { - isOpen: boolean; - data: TServicoItemPedidoFormValues | null; - onClose: (item: null, isFormStatus: boolean) => void; - onSave: (data: TServicoItemPedidoFormValues) => void; - buttonIsLoading: boolean; -} diff --git a/src/packages/servicos/interfaces/TServicoItemPedido/TServicoItemPedidoFormTableInterface.ts b/src/packages/servicos/interfaces/TServicoItemPedido/TServicoItemPedidoFormTableInterface.ts new file mode 100644 index 0000000..a4f2203 --- /dev/null +++ b/src/packages/servicos/interfaces/TServicoItemPedido/TServicoItemPedidoFormTableInterface.ts @@ -0,0 +1,10 @@ +import TServicoItemPedidoAddResponseInterface from "@/packages/servicos/interfaces/TServicoItemPedido/TServicoItemPedidoAddResponseInterface"; +import { TServicoPedidoFormInterface } from "@/packages/servicos/interfaces/TServicoPedido/TServicoPedidoFormInterface"; +import GConfigInterface from "@/shared/interfaces/GConfigInterface"; + + +export default interface TServicoItemPedidoFormTableInterface { + data: TServicoItemPedidoAddResponseInterface; + form: TServicoPedidoFormInterface; + params: GConfigInterface; +} \ No newline at end of file diff --git a/src/packages/servicos/schemas/TServicoPedido/TServicoPedidoFormSchema.ts b/src/packages/servicos/schemas/TServicoPedido/TServicoPedidoFormSchema.ts index e9e92c4..efd2a21 100644 --- a/src/packages/servicos/schemas/TServicoPedido/TServicoPedidoFormSchema.ts +++ b/src/packages/servicos/schemas/TServicoPedido/TServicoPedidoFormSchema.ts @@ -53,6 +53,10 @@ export const TServicoPedidoFormSchema = z.object({ tipo_pagamento: z .any() .refine((v) => !!v, "Selecione a forma de pagamento."), + + situacao: z + .string() + .min(1, "Campo situação deve ser informado"), }); export type TServicoPedidoFormValues = z.infer; \ No newline at end of file diff --git a/src/shared/actions/money/FormatMoney.ts b/src/shared/actions/money/FormatMoney.ts new file mode 100644 index 0000000..9ad7fce --- /dev/null +++ b/src/shared/actions/money/FormatMoney.ts @@ -0,0 +1,5 @@ +export default function FormatMoney(data) { + + return new Intl.NumberFormat('pt-BR', { style: 'currency', currency: 'BRL' }).format(Number(data || 0)); + +} \ No newline at end of file diff --git a/src/shared/components/dataTable/DataTable.tsx b/src/shared/components/dataTable/DataTable.tsx index 498ccbc..4d49119 100644 --- a/src/shared/components/dataTable/DataTable.tsx +++ b/src/shared/components/dataTable/DataTable.tsx @@ -34,6 +34,7 @@ import { } from '@/components/ui/table'; import DataTableInterface from './interfaces/DataTableInterface'; +import DataTableSubview from './interfaces/DataTableSubview'; /** * DataTable genérico com suporte a subvisões dinâmicas (subtabelas ou detalhes). @@ -210,7 +211,7 @@ export function DataTable Rea colSpan={row.getVisibleCells().length} className="p-0" > - {subview} + )} diff --git a/src/shared/components/dataTable/interfaces/DataTableSubview.tsx b/src/shared/components/dataTable/interfaces/DataTableSubview.tsx new file mode 100644 index 0000000..ae2efb4 --- /dev/null +++ b/src/shared/components/dataTable/interfaces/DataTableSubview.tsx @@ -0,0 +1,11 @@ +'use client'; + +export default function DataTableSubview({ subview }) { + if (!subview) return null; + if (!subview.component) return null; + + const Component = subview.component; + const props = subview.props || {}; + + return ; +} diff --git a/src/shared/hooks/FingerTech/useFingerTechIndexHook.ts b/src/shared/hooks/FingerTech/useFingerTechIndexHook.ts index acce843..2674bca 100644 --- a/src/shared/hooks/FingerTech/useFingerTechIndexHook.ts +++ b/src/shared/hooks/FingerTech/useFingerTechIndexHook.ts @@ -4,10 +4,9 @@ import { useState } from 'react'; import { FingerTechCaptureService } from '@/shared/services/FingerTech/FingerTechCaptureService'; - export const useFingerTechIndexHook = () => { - const [base64, setBase64] = useState(''); + const [base64, setBase64] = useState(''); const captureFingerTech = async () => { diff --git a/src/shared/hooks/sound/useSoundHook.ts b/src/shared/hooks/sound/useSoundHook.ts new file mode 100644 index 0000000..45a2c71 --- /dev/null +++ b/src/shared/hooks/sound/useSoundHook.ts @@ -0,0 +1,18 @@ +'use client' + +import { useCallback, useRef } from "react"; + +export function useSoundHook(soundPath: string) { + + const audioRef = useRef(null); + + if (!audioRef.current) { + audioRef.current = new Audio(soundPath); + } + + const play = useCallback(() => { + audioRef.current?.play().catch(() => { }); + }, []); + + return play; +}