fix: import StandardPageLayout e alinhamento de props em CadastroPecasFiltrado
This commit is contained in:
@@ -10,6 +10,7 @@ import { ComponentesPopup } from '@/components/pecas/ComponentesPopup';
|
|||||||
import { usePecas, Peca } from '@/hooks/usePecas';
|
import { usePecas, Peca } from '@/hooks/usePecas';
|
||||||
import { toast } from 'sonner';
|
import { toast } from 'sonner';
|
||||||
import { usePermissionControl } from '@/hooks/usePermissionControl';
|
import { usePermissionControl } from '@/hooks/usePermissionControl';
|
||||||
|
import { StandardPageLayout } from '@/components/layout/StandardPageLayout';
|
||||||
|
|
||||||
export default function CadastroPecasFiltrado() {
|
export default function CadastroPecasFiltrado() {
|
||||||
const { ofNumber } = useParams<{ ofNumber: string }>();
|
const { ofNumber } = useParams<{ ofNumber: string }>();
|
||||||
@@ -58,12 +59,12 @@ export default function CadastroPecasFiltrado() {
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
const handleUpdate = async (formData: any) => {
|
const handleUpdate = async (id: string, formData: any) => {
|
||||||
if (!canEdit() || !editingPeca) return false;
|
if (!canEdit()) return false;
|
||||||
setSaving(true);
|
setSaving(true);
|
||||||
try {
|
try {
|
||||||
const pecaComOF = { ...formData, of_number: ofSelecionada };
|
const pecaComOF = { ...formData, of_number: ofSelecionada };
|
||||||
const success = await updatePeca(editingPeca.id, pecaComOF);
|
const success = await updatePeca(id, pecaComOF);
|
||||||
if (success) {
|
if (success) {
|
||||||
setEditingPeca(null);
|
setEditingPeca(null);
|
||||||
setShowForm(false);
|
setShowForm(false);
|
||||||
@@ -174,9 +175,10 @@ export default function CadastroPecasFiltrado() {
|
|||||||
|
|
||||||
if (loading) {
|
if (loading) {
|
||||||
return (
|
return (
|
||||||
<div className="min-h-screen bg-background p-6">
|
<div className="min-h-screen bg-background p-6 flex items-center justify-center">
|
||||||
<div className="flex items-center justify-center h-64">
|
<div className="text-center space-y-4">
|
||||||
<div className="text-lg text-foreground">Carregando cadastro de peças...</div>
|
<div className="animate-spin rounded-full h-8 w-8 border-b-2 border-primary mx-auto"></div>
|
||||||
|
<p className="text-muted-foreground">Carregando peças da OF {ofSelecionada}...</p>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
);
|
);
|
||||||
@@ -189,10 +191,8 @@ export default function CadastroPecasFiltrado() {
|
|||||||
return (
|
return (
|
||||||
<StandardPageLayout
|
<StandardPageLayout
|
||||||
title="Cadastro de Peças"
|
title="Cadastro de Peças"
|
||||||
description="Gerencie as peças da OF selecionada"
|
subtitle="Gerencie as peças da OF selecionada"
|
||||||
badges={[
|
badge={{ text: `OF: ${ofSelecionada}`, variant: "secondary" }}
|
||||||
{ label: `OF: ${ofSelecionada}`, variant: "secondary" }
|
|
||||||
]}
|
|
||||||
actions={
|
actions={
|
||||||
<div className="flex gap-2">
|
<div className="flex gap-2">
|
||||||
<Button
|
<Button
|
||||||
@@ -232,7 +232,8 @@ export default function CadastroPecasFiltrado() {
|
|||||||
</CardHeader>
|
</CardHeader>
|
||||||
<CardContent>
|
<CardContent>
|
||||||
<PecaForm
|
<PecaForm
|
||||||
ofNumber={ofSelecionada}
|
ofNumbers={[ofSelecionada]}
|
||||||
|
ofDefault={ofSelecionada}
|
||||||
onSave={handleSave}
|
onSave={handleSave}
|
||||||
onUpdate={handleUpdate}
|
onUpdate={handleUpdate}
|
||||||
onImportCSV={handleImportCSV}
|
onImportCSV={handleImportCSV}
|
||||||
|
|||||||
Reference in New Issue
Block a user