[MVPTN-37] feat(Balcão): Ajusta a tela de balcão para trabalhar com itens de pedido
This commit is contained in:
parent
790c79ede6
commit
88cb6f67c8
15 changed files with 262 additions and 204 deletions
|
|
@ -0,0 +1,16 @@
|
|||
'use client'
|
||||
|
||||
import { useParams } from "next/navigation";
|
||||
|
||||
import TServicoPedidoForm from "@/packages/servicos/components/TServicoPedido/TServicoPedidoForm";
|
||||
|
||||
export default function TServicoPedidoPage() {
|
||||
|
||||
const params = useParams();
|
||||
|
||||
return (
|
||||
<TServicoPedidoForm
|
||||
servico_pedido_id={Number(params.servicoPedidoId)}
|
||||
/>
|
||||
)
|
||||
}
|
||||
|
|
@ -3,177 +3,112 @@
|
|||
|
||||
@custom-variant dark (&:is(.dark *));
|
||||
|
||||
@theme inline {
|
||||
--color-background: var(--background);
|
||||
--color-foreground: var(--foreground);
|
||||
--font-sans: Inter, sans-serif;
|
||||
--font-mono: JetBrains Mono, monospace;
|
||||
--color-sidebar-ring: var(--sidebar-ring);
|
||||
--color-sidebar-border: var(--sidebar-border);
|
||||
--color-sidebar-accent-foreground: var(--sidebar-accent-foreground);
|
||||
--color-sidebar-accent: var(--sidebar-accent);
|
||||
--color-sidebar-primary-foreground: var(--sidebar-primary-foreground);
|
||||
--color-sidebar-primary: var(--sidebar-primary);
|
||||
--color-sidebar-foreground: var(--sidebar-foreground);
|
||||
--color-sidebar: var(--sidebar);
|
||||
--color-chart-5: var(--chart-5);
|
||||
--color-chart-4: var(--chart-4);
|
||||
--color-chart-3: var(--chart-3);
|
||||
--color-chart-2: var(--chart-2);
|
||||
--color-chart-1: var(--chart-1);
|
||||
--color-ring: var(--ring);
|
||||
--color-input: var(--input);
|
||||
--color-border: var(--border);
|
||||
--color-destructive: var(--destructive);
|
||||
--color-accent-foreground: var(--accent-foreground);
|
||||
--color-accent: var(--accent);
|
||||
--color-muted-foreground: var(--muted-foreground);
|
||||
--color-muted: var(--muted);
|
||||
--color-secondary-foreground: var(--secondary-foreground);
|
||||
--color-secondary: var(--secondary);
|
||||
--color-primary-foreground: var(--primary-foreground);
|
||||
--color-primary: var(--primary);
|
||||
--color-popover-foreground: var(--popover-foreground);
|
||||
--color-popover: var(--popover);
|
||||
--color-card-foreground: var(--card-foreground);
|
||||
--color-card: var(--card);
|
||||
--radius-sm: calc(var(--radius) - 4px);
|
||||
--radius-md: calc(var(--radius) - 2px);
|
||||
--radius-lg: var(--radius);
|
||||
--radius-xl: calc(var(--radius) + 4px);
|
||||
--font-serif: Source Serif 4, serif;
|
||||
--radius: 0.375rem;
|
||||
--tracking-tighter: calc(var(--tracking-normal) - 0.05em);
|
||||
--tracking-tight: calc(var(--tracking-normal) - 0.025em);
|
||||
--tracking-wide: calc(var(--tracking-normal) + 0.025em);
|
||||
--tracking-wider: calc(var(--tracking-normal) + 0.05em);
|
||||
--tracking-widest: calc(var(--tracking-normal) + 0.1em);
|
||||
--tracking-normal: var(--tracking-normal);
|
||||
--shadow-2xl: var(--shadow-2xl);
|
||||
--shadow-xl: var(--shadow-xl);
|
||||
--shadow-lg: var(--shadow-lg);
|
||||
--shadow-md: var(--shadow-md);
|
||||
--shadow: var(--shadow);
|
||||
--shadow-sm: var(--shadow-sm);
|
||||
--shadow-xs: var(--shadow-xs);
|
||||
--shadow-2xs: var(--shadow-2xs);
|
||||
--spacing: var(--spacing);
|
||||
--letter-spacing: var(--letter-spacing);
|
||||
--shadow-offset-y: var(--shadow-offset-y);
|
||||
--shadow-offset-x: var(--shadow-offset-x);
|
||||
--shadow-spread: var(--shadow-spread);
|
||||
--shadow-blur: var(--shadow-blur);
|
||||
--shadow-opacity: var(--shadow-opacity);
|
||||
--color-shadow-color: var(--shadow-color);
|
||||
--color-destructive-foreground: var(--destructive-foreground);
|
||||
}
|
||||
|
||||
:root {
|
||||
--background: #f8fafc;
|
||||
--foreground: #1e293b;
|
||||
--card: #ffffff;
|
||||
--card-foreground: #1e293b;
|
||||
--popover: #ffffff;
|
||||
--popover-foreground: #1e293b;
|
||||
--primary: #1a292f;
|
||||
--primary-foreground: #ffffff;
|
||||
--secondary: #e5e7eb;
|
||||
--secondary-foreground: #162227;
|
||||
--muted: #f3f4f6;
|
||||
--muted-foreground: #6b7280;
|
||||
--accent: #e0e7ff;
|
||||
--accent-foreground: #2b454f;
|
||||
--destructive: #ef4444;
|
||||
--destructive-foreground: #ffffff;
|
||||
--border: #d1d5db;
|
||||
--input: #d1d5db;
|
||||
--ring: #2b454f;
|
||||
--chart-1: #f26f28;
|
||||
--chart-2: #f26418;
|
||||
--chart-3: #e75a0d;
|
||||
--chart-4: #c14b0b;
|
||||
--chart-5: #9a3c09;
|
||||
--sidebar: #f3f4f6;
|
||||
--sidebar-foreground: #1e293b;
|
||||
--sidebar-primary: #2b454f;
|
||||
--sidebar-primary-foreground: #ffffff;
|
||||
--sidebar-accent: #1a292f;
|
||||
--sidebar-accent-foreground: #374151;
|
||||
--sidebar-border: #ffffff;
|
||||
--sidebar-ring: #2b454f;
|
||||
--font-sans: Inter, sans-serif;
|
||||
--font-serif: Merriweather, serif;
|
||||
--font-mono: JetBrains Mono, monospace;
|
||||
--radius: 0.5rem;
|
||||
--shadow-x: 0px;
|
||||
--shadow-y: 4px;
|
||||
--shadow-blur: 8px;
|
||||
--shadow-spread: -1px;
|
||||
--background: oklch(1 0 0);
|
||||
--foreground: oklch(0.1450 0 0);
|
||||
--card: oklch(1 0 0);
|
||||
--card-foreground: oklch(0.1450 0 0);
|
||||
--popover: oklch(1 0 0);
|
||||
--popover-foreground: oklch(0.1450 0 0);
|
||||
--primary: oklch(0.2050 0 0);
|
||||
--primary-foreground: oklch(0.9850 0 0);
|
||||
--secondary: oklch(0.9700 0 0);
|
||||
--secondary-foreground: oklch(0.2050 0 0);
|
||||
--muted: oklch(0.9700 0 0);
|
||||
--muted-foreground: oklch(0.5560 0 0);
|
||||
--accent: oklch(0.9700 0 0);
|
||||
--accent-foreground: oklch(0.2050 0 0);
|
||||
--destructive: oklch(0.5770 0.2450 27.3250);
|
||||
--destructive-foreground: oklch(1 0 0);
|
||||
--border: oklch(0.9220 0 0);
|
||||
--input: oklch(0.9220 0 0);
|
||||
--ring: oklch(0.7080 0 0);
|
||||
--chart-1: oklch(0.8100 0.1000 252);
|
||||
--chart-2: oklch(0.6200 0.1900 260);
|
||||
--chart-3: oklch(0.5500 0.2200 263);
|
||||
--chart-4: oklch(0.4900 0.2200 264);
|
||||
--chart-5: oklch(0.4200 0.1800 266);
|
||||
--sidebar: oklch(0.9850 0 0);
|
||||
--sidebar-foreground: oklch(0.1450 0 0);
|
||||
--sidebar-primary: oklch(0.2050 0 0);
|
||||
--sidebar-primary-foreground: oklch(0.9850 0 0);
|
||||
--sidebar-accent: oklch(0.9700 0 0);
|
||||
--sidebar-accent-foreground: oklch(0.2050 0 0);
|
||||
--sidebar-border: oklch(0.9220 0 0);
|
||||
--sidebar-ring: oklch(0.7080 0 0);
|
||||
--font-sans: ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, 'Noto Sans', sans-serif, 'Apple Color Emoji', 'Segoe UI Emoji', 'Segoe UI Symbol', 'Noto Color Emoji';
|
||||
--font-serif: ui-serif, Georgia, Cambria, "Times New Roman", Times, serif;
|
||||
--font-mono: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace;
|
||||
--radius: 0.625rem;
|
||||
--shadow-x: 0;
|
||||
--shadow-y: 1px;
|
||||
--shadow-blur: 3px;
|
||||
--shadow-spread: 0px;
|
||||
--shadow-opacity: 0.1;
|
||||
--shadow-color: hsl(0 0% 0%);
|
||||
--shadow-2xs: 0px 4px 8px -1px hsl(0 0% 0% / 0.05);
|
||||
--shadow-xs: 0px 4px 8px -1px hsl(0 0% 0% / 0.05);
|
||||
--shadow-sm: 0px 4px 8px -1px hsl(0 0% 0% / 0.10), 0px 1px 2px -2px hsl(0 0% 0% / 0.10);
|
||||
--shadow: 0px 4px 8px -1px hsl(0 0% 0% / 0.10), 0px 1px 2px -2px hsl(0 0% 0% / 0.10);
|
||||
--shadow-md: 0px 4px 8px -1px hsl(0 0% 0% / 0.10), 0px 2px 4px -2px hsl(0 0% 0% / 0.10);
|
||||
--shadow-lg: 0px 4px 8px -1px hsl(0 0% 0% / 0.10), 0px 4px 6px -2px hsl(0 0% 0% / 0.10);
|
||||
--shadow-xl: 0px 4px 8px -1px hsl(0 0% 0% / 0.10), 0px 8px 10px -2px hsl(0 0% 0% / 0.10);
|
||||
--shadow-2xl: 0px 4px 8px -1px hsl(0 0% 0% / 0.25);
|
||||
--shadow-color: oklch(0 0 0);
|
||||
--shadow-2xs: 0 1px 3px 0px hsl(0 0% 0% / 0.05);
|
||||
--shadow-xs: 0 1px 3px 0px hsl(0 0% 0% / 0.05);
|
||||
--shadow-sm: 0 1px 3px 0px hsl(0 0% 0% / 0.10), 0 1px 2px -1px hsl(0 0% 0% / 0.10);
|
||||
--shadow: 0 1px 3px 0px hsl(0 0% 0% / 0.10), 0 1px 2px -1px hsl(0 0% 0% / 0.10);
|
||||
--shadow-md: 0 1px 3px 0px hsl(0 0% 0% / 0.10), 0 2px 4px -1px hsl(0 0% 0% / 0.10);
|
||||
--shadow-lg: 0 1px 3px 0px hsl(0 0% 0% / 0.10), 0 4px 6px -1px hsl(0 0% 0% / 0.10);
|
||||
--shadow-xl: 0 1px 3px 0px hsl(0 0% 0% / 0.10), 0 8px 10px -1px hsl(0 0% 0% / 0.10);
|
||||
--shadow-2xl: 0 1px 3px 0px hsl(0 0% 0% / 0.25);
|
||||
--tracking-normal: 0em;
|
||||
--spacing: 0.25rem;
|
||||
}
|
||||
|
||||
.dark {
|
||||
--background: #0f172a;
|
||||
--foreground: #e2e8f0;
|
||||
--card: #1e293b;
|
||||
--card-foreground: #e2e8f0;
|
||||
--popover: #1e293b;
|
||||
--popover-foreground: #e2e8f0;
|
||||
--primary: #818cf8;
|
||||
--primary-foreground: #0f172a;
|
||||
--secondary: #2d3748;
|
||||
--secondary-foreground: #d1d5db;
|
||||
--muted: #152032;
|
||||
--muted-foreground: #9ca3af;
|
||||
--accent: #374151;
|
||||
--accent-foreground: #d1d5db;
|
||||
--destructive: #ef4444;
|
||||
--destructive-foreground: #0f172a;
|
||||
--border: #4b5563;
|
||||
--input: #4b5563;
|
||||
--ring: #818cf8;
|
||||
--chart-1: #818cf8;
|
||||
--chart-2: #6366f1;
|
||||
--chart-3: #4f46e5;
|
||||
--chart-4: #4338ca;
|
||||
--chart-5: #3730a3;
|
||||
--sidebar: #1e293b;
|
||||
--sidebar-foreground: #e2e8f0;
|
||||
--sidebar-primary: #818cf8;
|
||||
--sidebar-primary-foreground: #0f172a;
|
||||
--sidebar-accent: #374151;
|
||||
--sidebar-accent-foreground: #d1d5db;
|
||||
--sidebar-border: #4b5563;
|
||||
--sidebar-ring: #818cf8;
|
||||
--font-sans: Inter, sans-serif;
|
||||
--font-serif: Merriweather, serif;
|
||||
--font-mono: JetBrains Mono, monospace;
|
||||
--radius: 0.5rem;
|
||||
--shadow-x: 0px;
|
||||
--shadow-y: 4px;
|
||||
--shadow-blur: 8px;
|
||||
--shadow-spread: -1px;
|
||||
--background: oklch(0.1450 0 0);
|
||||
--foreground: oklch(0.9850 0 0);
|
||||
--card: oklch(0.2050 0 0);
|
||||
--card-foreground: oklch(0.9850 0 0);
|
||||
--popover: oklch(0.2690 0 0);
|
||||
--popover-foreground: oklch(0.9850 0 0);
|
||||
--primary: oklch(0.9220 0 0);
|
||||
--primary-foreground: oklch(0.2050 0 0);
|
||||
--secondary: oklch(0.2690 0 0);
|
||||
--secondary-foreground: oklch(0.9850 0 0);
|
||||
--muted: oklch(0.2690 0 0);
|
||||
--muted-foreground: oklch(0.7080 0 0);
|
||||
--accent: oklch(0.3710 0 0);
|
||||
--accent-foreground: oklch(0.9850 0 0);
|
||||
--destructive: oklch(0.7040 0.1910 22.2160);
|
||||
--destructive-foreground: oklch(0.9850 0 0);
|
||||
--border: oklch(0.2750 0 0);
|
||||
--input: oklch(0.3250 0 0);
|
||||
--ring: oklch(0.5560 0 0);
|
||||
--chart-1: oklch(0.8100 0.1000 252);
|
||||
--chart-2: oklch(0.6200 0.1900 260);
|
||||
--chart-3: oklch(0.5500 0.2200 263);
|
||||
--chart-4: oklch(0.4900 0.2200 264);
|
||||
--chart-5: oklch(0.4200 0.1800 266);
|
||||
--sidebar: oklch(0.2050 0 0);
|
||||
--sidebar-foreground: oklch(0.9850 0 0);
|
||||
--sidebar-primary: oklch(0.4880 0.2430 264.3760);
|
||||
--sidebar-primary-foreground: oklch(0.9850 0 0);
|
||||
--sidebar-accent: oklch(0.2690 0 0);
|
||||
--sidebar-accent-foreground: oklch(0.9850 0 0);
|
||||
--sidebar-border: oklch(0.2750 0 0);
|
||||
--sidebar-ring: oklch(0.4390 0 0);
|
||||
--font-sans: ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, 'Noto Sans', sans-serif, 'Apple Color Emoji', 'Segoe UI Emoji', 'Segoe UI Symbol', 'Noto Color Emoji';
|
||||
--font-serif: ui-serif, Georgia, Cambria, "Times New Roman", Times, serif;
|
||||
--font-mono: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace;
|
||||
--radius: 0.625rem;
|
||||
--shadow-x: 0;
|
||||
--shadow-y: 1px;
|
||||
--shadow-blur: 3px;
|
||||
--shadow-spread: 0px;
|
||||
--shadow-opacity: 0.1;
|
||||
--shadow-color: hsl(0 0% 0%);
|
||||
--shadow-2xs: 0px 4px 8px -1px hsl(0 0% 0% / 0.05);
|
||||
--shadow-xs: 0px 4px 8px -1px hsl(0 0% 0% / 0.05);
|
||||
--shadow-sm: 0px 4px 8px -1px hsl(0 0% 0% / 0.10), 0px 1px 2px -2px hsl(0 0% 0% / 0.10);
|
||||
--shadow: 0px 4px 8px -1px hsl(0 0% 0% / 0.10), 0px 1px 2px -2px hsl(0 0% 0% / 0.10);
|
||||
--shadow-md: 0px 4px 8px -1px hsl(0 0% 0% / 0.10), 0px 2px 4px -2px hsl(0 0% 0% / 0.10);
|
||||
--shadow-lg: 0px 4px 8px -1px hsl(0 0% 0% / 0.10), 0px 4px 6px -2px hsl(0 0% 0% / 0.10);
|
||||
--shadow-xl: 0px 4px 8px -1px hsl(0 0% 0% / 0.10), 0px 8px 10px -2px hsl(0 0% 0% / 0.10);
|
||||
--shadow-2xl: 0px 4px 8px -1px hsl(0 0% 0% / 0.25);
|
||||
--shadow-color: oklch(0 0 0);
|
||||
--shadow-2xs: 0 1px 3px 0px hsl(0 0% 0% / 0.05);
|
||||
--shadow-xs: 0 1px 3px 0px hsl(0 0% 0% / 0.05);
|
||||
--shadow-sm: 0 1px 3px 0px hsl(0 0% 0% / 0.10), 0 1px 2px -1px hsl(0 0% 0% / 0.10);
|
||||
--shadow: 0 1px 3px 0px hsl(0 0% 0% / 0.10), 0 1px 2px -1px hsl(0 0% 0% / 0.10);
|
||||
--shadow-md: 0 1px 3px 0px hsl(0 0% 0% / 0.10), 0 2px 4px -1px hsl(0 0% 0% / 0.10);
|
||||
--shadow-lg: 0 1px 3px 0px hsl(0 0% 0% / 0.10), 0 4px 6px -1px hsl(0 0% 0% / 0.10);
|
||||
--shadow-xl: 0 1px 3px 0px hsl(0 0% 0% / 0.10), 0 8px 10px -1px hsl(0 0% 0% / 0.10);
|
||||
--shadow-2xl: 0 1px 3px 0px hsl(0 0% 0% / 0.25);
|
||||
}
|
||||
|
||||
@theme inline {
|
||||
|
|
|
|||
|
|
@ -59,6 +59,7 @@ export default function TServicoTipoSelect({ field }: TServicoTipoSelectInterfac
|
|||
const selectedValue = {
|
||||
servico_tipo_id: Number(item.servico_tipo_id),
|
||||
descricao: item.descricao,
|
||||
tipo_item: item.tipo_item,
|
||||
};
|
||||
|
||||
field.onChange(selectedValue);
|
||||
|
|
|
|||
|
|
@ -11,10 +11,7 @@ type TableMeta = {
|
|||
updateData?: (rowIndex: number, columnId: string, value: unknown) => void;
|
||||
};
|
||||
|
||||
export default function TServicoItemPedidoFormColumns(
|
||||
onEdit: (item: TServicoItemPedidoInterface, isEditingFormStatus: boolean) => void,
|
||||
onDelete: (item: TServicoItemPedidoInterface, isEditingFormStatus: boolean) => void,
|
||||
): ColumnDef<TServicoItemPedidoInterface>[] {
|
||||
export default function TServicoItemPedidoFormColumns(): ColumnDef<TServicoItemPedidoInterface>[] {
|
||||
return [
|
||||
// servico
|
||||
{
|
||||
|
|
|
|||
|
|
@ -9,8 +9,8 @@ import TServicoItemPedidoFormColumns from './TServicoItemPedidoFormColumns';
|
|||
/**
|
||||
* Componente principal da tabela de Naturezas
|
||||
*/
|
||||
export default function TServicoItemPedidoFormTable({ data, onEdit, onDelete }: TServicoItemPedidoTableInterface) {
|
||||
const columns = TServicoItemPedidoFormColumns(onEdit, onDelete);
|
||||
export default function TServicoItemPedidoFormTable({ data }: TServicoItemPedidoTableInterface) {
|
||||
const columns = TServicoItemPedidoFormColumns();
|
||||
return (
|
||||
<div>
|
||||
<DataTable
|
||||
|
|
|
|||
|
|
@ -121,9 +121,11 @@ export default function TServicoPedidoColumns(
|
|||
</Link>
|
||||
</DropdownMenuItem>
|
||||
<DropdownMenuSeparator />
|
||||
<DropdownMenuItem onSelect={() => onEdit(servicoPedido, true)}>
|
||||
<PencilIcon className="mr-2 h-4 w-4" />
|
||||
Editar
|
||||
<DropdownMenuItem asChild>
|
||||
<Link href={`/servicos/balcao/pedido/${row.getValue('servico_pedido_id')}`}>
|
||||
<PencilIcon className="mr-2 h-4 w-4" />
|
||||
Editar
|
||||
</Link>
|
||||
</DropdownMenuItem>
|
||||
<DropdownMenuSeparator />
|
||||
<DropdownMenuItem onSelect={() => onDelete(servicoPedido, true)}>
|
||||
|
|
|
|||
|
|
@ -21,35 +21,90 @@ import GUsuarioSelect from '@/packages/administrativo/components/GUsuario/GUsuar
|
|||
import TServicoTipoSelect from '@/packages/administrativo/components/TServicoTipo/TServicoTipoSelect';
|
||||
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 { useTServicoPedidoFormHook } from '@/packages/servicos/hooks/TServicoPedido/useTServicoPedidoFormHook';
|
||||
import { useTServicoPedidoSaveHook } from '@/packages/servicos/hooks/TServicoPedido/useTServicoPedidoSaveHook';
|
||||
import { useTServicoPedidoShowHook } from '@/packages/servicos/hooks/TServicoPedido/useTServicoPedidoShowHook';
|
||||
import { TServicoPedidoFormInterface } from '@/packages/servicos/interfaces/TServicoPedido/TServicoPedidoFormInterface';
|
||||
import TServicoPedidoInterface from '@/packages/servicos/interfaces/TServicoPedido/TServicoPedidoInterface';
|
||||
import { parseNumberInput } from '@/shared/actions/form/parseNumberInput';
|
||||
import LoadingButton from '@/shared/components/loadingButton/LoadingButton';
|
||||
import { StepNavigator, StepNavigatorRef, StepSection } from '@/shared/components/step/stepNavigator';
|
||||
import TipoPagamentoSelect from '@/shared/components/tipoPagamento/TipoPagamentoSelect';
|
||||
|
||||
import { useTServicoItemPedidoLocalAddHook } from '../../hooks/TServicoItemPedido/useTServicoItemPedidoLocalAddHook';
|
||||
|
||||
|
||||
|
||||
export default function TServicoPedidoForm() {
|
||||
export default function TServicoPedidoForm({ servico_pedido_id }: TServicoPedidoFormInterface) {
|
||||
|
||||
// Controle de rotas
|
||||
const router = useRouter();
|
||||
|
||||
const form = useTServicoPedidoFormHook({});
|
||||
|
||||
const { setValue, handleSubmit, watch } = form;
|
||||
const { setValue, handleSubmit, reset, watch } = form;
|
||||
|
||||
// Controle de estado do botão
|
||||
const [buttonIsLoading, setButtonIsLoading] = useState(false);
|
||||
const { TServicoPedido, saveTServicoPedido } = useTServicoPedidoSaveHook()
|
||||
const { TServicoItemPedido, addTServicoItemPedido } = useTServicoItemPedidoAddHook(setValue)
|
||||
const { TServicoPedido, saveTServicoPedido } = useTServicoPedidoSaveHook();
|
||||
const { TServicoItemPedidoLocal, localAddTServicoItemPedido, setLocalTServicoItemPedido } = useTServicoItemPedidoLocalAddHook(setValue);
|
||||
const { TServicoItemPedido, addTServicoItemPedido, setTServicoItemPedido } = useTServicoItemPedidoAddHook(setValue);
|
||||
const { TServicoItemPedido: itemPedidoShow, indexTServicoItemPedido } = useTServicoItemPedidoIndexHook()
|
||||
const { TServicoPedido: pedidoShow, showTServicoPedido } = useTServicoPedidoShowHook();
|
||||
|
||||
// Campos para serem monitorados
|
||||
const servicoAtual = watch('servico_tipo_id');
|
||||
const emolumentoAtual = watch('emolumento_id');
|
||||
|
||||
const handleAddItem = () => {
|
||||
// BUsca o o pedido desejado
|
||||
const TServicoPedidoShowData = async () => {
|
||||
|
||||
// Criar um objeto de envio
|
||||
const servicoPedido: TServicoPedidoInterface = {
|
||||
|
||||
servico_pedido_id: servico_pedido_id
|
||||
|
||||
}
|
||||
|
||||
// Busca os dados desejado
|
||||
const response = await showTServicoPedido(servicoPedido)
|
||||
|
||||
// Verifica se foi localizado os dados
|
||||
if (response.servico_pedido_id) {
|
||||
|
||||
// Atualiza os valores do pedido
|
||||
reset(response)
|
||||
|
||||
// Busca os itens do pedido
|
||||
TServicoPedidoItemIndexData(response.servico_pedido_id)
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
// Busca os itens do pedido
|
||||
const TServicoPedidoItemIndexData = async (servico_pedido_id: number) => {
|
||||
|
||||
// Cria objeto de envio
|
||||
const servicoPedido: TServicoPedidoInterface = {
|
||||
|
||||
servico_pedido_id: servico_pedido_id
|
||||
|
||||
}
|
||||
|
||||
// Busca os itens
|
||||
const response = await indexTServicoItemPedido(servicoPedido)
|
||||
|
||||
// Percorre todos os itens localizados
|
||||
for (const item of response.data) {
|
||||
|
||||
// Adiciona os itens locais
|
||||
localAddTServicoItemPedido(item)
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
const handleAddItem = async () => {
|
||||
|
||||
if (servicoAtual && emolumentoAtual) {
|
||||
|
||||
|
|
@ -59,8 +114,7 @@ export default function TServicoPedidoForm() {
|
|||
emolumento: emolumentoAtual
|
||||
}
|
||||
|
||||
// Adiciona o item calculado na tabel
|
||||
addTServicoItemPedido(servicoEEmolumento)
|
||||
await addTServicoItemPedido(servicoEEmolumento);
|
||||
|
||||
}
|
||||
};
|
||||
|
|
@ -103,8 +157,16 @@ export default function TServicoPedidoForm() {
|
|||
}
|
||||
|
||||
React.useEffect(() => {
|
||||
console.log(JSON.stringify(TServicoItemPedido))
|
||||
}, [TServicoItemPedido])
|
||||
|
||||
// Verifica se existe pedido para buscar
|
||||
if (servico_pedido_id) {
|
||||
|
||||
// Busca o pedido desejado
|
||||
TServicoPedidoShowData()
|
||||
|
||||
}
|
||||
|
||||
}, [])
|
||||
|
||||
|
||||
return (
|
||||
|
|
@ -279,10 +341,7 @@ export default function TServicoPedidoForm() {
|
|||
</div>
|
||||
<div className="col-span-12 sm:col-span-12 md:col-span-12">
|
||||
<TServicoItemPedidoFormTable
|
||||
data={TServicoItemPedido}
|
||||
setValue={setValue}
|
||||
onEdit={() => { }}
|
||||
onDelete={() => { }}
|
||||
data={TServicoItemPedidoLocal}
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
|
|
|
|||
|
|
@ -122,7 +122,10 @@ export default function TServicoPedidoIndex() {
|
|||
href='/servicos/balcao/pedido'
|
||||
/>
|
||||
{/* Tabela de andamentos */}
|
||||
<TServicoPedidoTable data={TServicoPedido} onEdit={handleOpenForm} onDelete={handleConfirmDelete} />
|
||||
<TServicoPedidoTable
|
||||
data={TServicoPedido}
|
||||
onEdit={handleOpenForm}
|
||||
onDelete={handleConfirmDelete} />
|
||||
{/* Modal de confirmação */}
|
||||
{isConfirmOpen && (
|
||||
<ConfirmDialog
|
||||
|
|
|
|||
|
|
@ -7,16 +7,17 @@ import { GCalculoServicoService } from '@/packages/administrativo/services/GCalc
|
|||
import TServicoItemPedidoAddInterface from '@/packages/servicos/interfaces/TServicoItemPedido/TServicoItemPedidoAddInterface';
|
||||
import TServicoItemPedidoIndexResponseInterface from '@/packages/servicos/interfaces/TServicoItemPedido/TServicoItemPedidoIndexResponseInterface';
|
||||
|
||||
import { useTServicoItemPedidoLocalAddHook } from './useTServicoItemPedidoLocalAddHook';
|
||||
|
||||
|
||||
|
||||
export const useTServicoItemPedidoAddHook = (setValue: UseFormSetValue<TServicoItemPedidoAddInterface>) => {
|
||||
|
||||
const [TServicoItemPedido, setTServicoItemPedido] = useState<TServicoItemPedidoIndexResponseInterface[]>([]);
|
||||
const { TServicoItemPedidoLocal, localAddTServicoItemPedido } = useTServicoItemPedidoLocalAddHook(setValue)
|
||||
|
||||
const addTServicoItemPedido = async (data: TServicoItemPedidoAddInterface) => {
|
||||
|
||||
console.log(data.emolumento)
|
||||
|
||||
data.sistema_id = 2
|
||||
data.valor_documento = 0
|
||||
data.quantidade = 1
|
||||
|
|
@ -26,8 +27,9 @@ export const useTServicoItemPedidoAddHook = (setValue: UseFormSetValue<TServicoI
|
|||
|
||||
const item = {
|
||||
emolumento_id: data.emolumento.emolumento_id,
|
||||
emolumento_item_id: data.emolumento.emolumento_item_id,
|
||||
emolumento_item_id: response.data.emolumento_item_id,
|
||||
servico_tipo_id: data.servico_tipo.servico_tipo_id,
|
||||
tipo_item: data.servico_tipo.tipo_item,
|
||||
descricao: data.servico_tipo.descricao,
|
||||
tabela: data.emolumento.descricao,
|
||||
situacao: 'F',
|
||||
|
|
@ -45,10 +47,13 @@ export const useTServicoItemPedidoAddHook = (setValue: UseFormSetValue<TServicoI
|
|||
return novoItem
|
||||
});
|
||||
|
||||
localAddTServicoItemPedido(item)
|
||||
|
||||
};
|
||||
|
||||
return {
|
||||
TServicoItemPedido,
|
||||
setTServicoItemPedido,
|
||||
addTServicoItemPedido,
|
||||
};
|
||||
};
|
||||
|
|
|
|||
|
|
@ -0,0 +1,44 @@
|
|||
'use client';
|
||||
|
||||
import { useState } from 'react';
|
||||
import { UseFormSetValue } from 'react-hook-form';
|
||||
|
||||
import TServicoItemPedidoAddInterface from '@/packages/servicos/interfaces/TServicoItemPedido/TServicoItemPedidoAddInterface';
|
||||
import TServicoItemPedidoIndexResponseInterface from '@/packages/servicos/interfaces/TServicoItemPedido/TServicoItemPedidoIndexResponseInterface';
|
||||
|
||||
export const useTServicoItemPedidoLocalAddHook = (setValue: UseFormSetValue<TServicoItemPedidoAddInterface>) => {
|
||||
|
||||
const [TServicoItemPedidoLocal, setLocalTServicoItemPedido] = useState<TServicoItemPedidoIndexResponseInterface[]>([]);
|
||||
|
||||
const localAddTServicoItemPedido = async (data: TServicoItemPedidoAddInterface) => {
|
||||
|
||||
const item = {
|
||||
emolumento_id: data.emolumento_id,
|
||||
emolumento_item_id: data.emolumento_item_id,
|
||||
servico_tipo_id: data.servico_tipo_id,
|
||||
tipo_item: data.tipo_item,
|
||||
descricao: data.descricao,
|
||||
tabela: data.descricao,
|
||||
situacao: data.situacao,
|
||||
qtd: data.qtd,
|
||||
valor: data.valor,
|
||||
emolumento: data.emolumento,
|
||||
fundesp: data.fundesp,
|
||||
taxa_judiciaria: data.taxa_judiciaria,
|
||||
valor_iss: data.valor_iss,
|
||||
}
|
||||
|
||||
setLocalTServicoItemPedido((prev) => {
|
||||
const novoItem = [...prev, item]
|
||||
if (setValue) setValue('itens', novoItem)
|
||||
return novoItem
|
||||
});
|
||||
|
||||
};
|
||||
|
||||
return {
|
||||
TServicoItemPedidoLocal,
|
||||
setLocalTServicoItemPedido,
|
||||
localAddTServicoItemPedido,
|
||||
};
|
||||
};
|
||||
|
|
@ -1,7 +1,7 @@
|
|||
import { zodResolver } from '@hookform/resolvers/zod';
|
||||
import { useForm } from 'react-hook-form';
|
||||
|
||||
import { TServicoPedidoFormValues, TServicoPedidoSchema } from '../../schemas/TServicoPedido/TServicoPedidoSchema';
|
||||
import { TServicoPedidoFormValues, TServicoPedidoSchema } from '@/packages/servicos/schemas/TServicoPedido/TServicoPedidoSchema';
|
||||
|
||||
export function useTServicoPedidoFormHook(defaults?: Partial<TServicoPedidoFormValues>) {
|
||||
return useForm<TServicoPedidoFormValues>({
|
||||
|
|
@ -21,6 +21,8 @@ export function useTServicoPedidoFormHook(defaults?: Partial<TServicoPedidoFormV
|
|||
selo_pessoa_cpfcnpj: "",
|
||||
login: "",
|
||||
funcao: "",
|
||||
mensalista_livrocaixa_id: 0,
|
||||
nfse_id: 0,
|
||||
itens: [],
|
||||
...defaults,
|
||||
},
|
||||
|
|
|
|||
|
|
@ -1,5 +1,4 @@
|
|||
export default interface TServicoInterface {
|
||||
servico_pedido_id: number;
|
||||
escrevente_id: number;
|
||||
apre
|
||||
}
|
||||
|
|
@ -2,6 +2,4 @@ import TServicoItemPedidoInterface from "./TServicoItemPedidoIntefarce";
|
|||
|
||||
export default interface TServicoItemPedidoTableInterface {
|
||||
data?: TServicoItemPedidoInterface[];
|
||||
onEdit: (item: TServicoItemPedidoInterface, isEditingFormStatus: boolean) => void;
|
||||
onDelete: (item: TServicoItemPedidoInterface, isEditingFormStatus: boolean) => void;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,7 +1,4 @@
|
|||
import { TServicoPedidoFormValues } from '@/packages/servicos/schemas/TServicoPedido/TServicoPedidoSchema';
|
||||
|
||||
export interface TServicoPedidoFormInterface {
|
||||
data: TServicoPedidoFormValues | null;
|
||||
onSave: (data: TServicoPedidoFormValues) => void;
|
||||
buttonIsLoading: boolean;
|
||||
servico_pedido_id?: number
|
||||
}
|
||||
|
|
|
|||
|
|
@ -9,12 +9,12 @@ export const TServicoPedidoSchema = z.object({
|
|||
valor_pago: z.number().optional(),
|
||||
usuario_id: z.number().optional(),
|
||||
data_pedido: z.string().optional(),
|
||||
mensalista_livrocaixa_id: z.number().optional(),
|
||||
observacao: z.string().optional(),
|
||||
mensalista_livrocaixa_id: z.union([z.number(), z.null()]),
|
||||
observacao: z.union([z.string(), z.null()]),
|
||||
escrevente_id: z.number(),
|
||||
situacao: z.string().optional(),
|
||||
estornado: z.string().optional(),
|
||||
nfse_id: z.number().optional(),
|
||||
nfse_id: z.union([z.number(), z.null()]),
|
||||
apresentante: z.string().optional(),
|
||||
cpfcnpj_apresentante: z.string().optional(),
|
||||
selo_pessoa_nome: z.string().optional(),
|
||||
|
|
@ -22,8 +22,8 @@ export const TServicoPedidoSchema = z.object({
|
|||
login: z.string().optional(),
|
||||
funcao: z.string().optional(),
|
||||
itens: z.array(TServicoItemPedidoSchema).default([]),
|
||||
servico_tipo_id: z.object(),
|
||||
emolumento_id: z.object(),
|
||||
servico_tipo_id: z.object().optional(),
|
||||
emolumento_id: z.object().optional(),
|
||||
});
|
||||
|
||||
export type TServicoPedidoFormValues = z.infer<typeof TServicoPedidoSchema>;
|
||||
Loading…
Add table
Reference in a new issue