editar, modificar, ver y crear productos listo
This commit is contained in:
@@ -19,7 +19,7 @@ import {
|
||||
import { Input } from '@repo/shadcn/input';
|
||||
import { useForm } from 'react-hook-form';
|
||||
import { useCreateProduct } from "@/feactures/inventory/hooks/use-mutation";
|
||||
import { editInventory, EditInventory } from '@/feactures/inventory/schemas/inventory';
|
||||
import { createProduct, EditInventory } from '@/feactures/inventory/schemas/inventory';
|
||||
import { Textarea } from '@repo/shadcn/textarea';
|
||||
import { STATUS } from '@/constants/status'
|
||||
import { useState, useEffect } from 'react';
|
||||
@@ -59,7 +59,7 @@ export function CreateForm({
|
||||
};
|
||||
|
||||
const form = useForm<EditInventory>({
|
||||
resolver: zodResolver(editInventory),
|
||||
resolver: zodResolver(createProduct),
|
||||
defaultValues: defaultformValues,
|
||||
mode: 'onChange',
|
||||
});
|
||||
|
||||
@@ -8,14 +8,14 @@ import {
|
||||
DialogTitle,
|
||||
} from '@repo/shadcn/dialog';
|
||||
// import { AccountPlan } from '@/feactures/users/schemas/account-plan.schema';
|
||||
import { EditInventory, editInventory } from '../../schemas/inventory';
|
||||
import { EditInventory, InventoryTable } from '../../schemas/inventory';
|
||||
import { CreateForm } from './create-product-form';
|
||||
import { UpdateForm } from './update-product-form';
|
||||
|
||||
interface ModalProps {
|
||||
open: boolean;
|
||||
onOpenChange: (open: boolean) => void;
|
||||
defaultValues?: Partial<EditInventory>;
|
||||
defaultValues?: Partial<InventoryTable>;
|
||||
}
|
||||
|
||||
export function AccountPlanModal({
|
||||
|
||||
@@ -9,9 +9,10 @@ import {
|
||||
TooltipProvider,
|
||||
TooltipTrigger,
|
||||
} from '@repo/shadcn/tooltip';
|
||||
import { Edit, Trash, User } from 'lucide-react';
|
||||
import { Edit, Trash, Eye } from 'lucide-react';
|
||||
import { InventoryTable } from '@/feactures/inventory/schemas/inventory';
|
||||
import { useDeleteUser } from '@/feactures/users/hooks/use-mutation-users';
|
||||
// import { useDeleteUser } from '@/feactures/users/hooks/use-mutation-users';
|
||||
import { useDeleteProduct } from "@/feactures/inventory/hooks/use-mutation";
|
||||
import { AccountPlanModal } from '../inventory-modal';
|
||||
|
||||
interface CellActionProps {
|
||||
@@ -22,7 +23,7 @@ export const CellAction: React.FC<CellActionProps> = ({ data }) => {
|
||||
const [loading, setLoading] = useState(false);
|
||||
const [open, setOpen] = useState(false);
|
||||
const [edit, setEdit] = useState(false);
|
||||
const { mutate: deleteUser } = useDeleteUser();
|
||||
const { mutate: deleteUser } = useDeleteProduct();
|
||||
const router = useRouter();
|
||||
|
||||
const onConfirm = async () => {
|
||||
@@ -51,6 +52,23 @@ export const CellAction: React.FC<CellActionProps> = ({ data }) => {
|
||||
<AccountPlanModal open={edit} onOpenChange={setEdit} defaultValues={data}/>
|
||||
|
||||
<div className="flex gap-1">
|
||||
<TooltipProvider>
|
||||
<Tooltip>
|
||||
<TooltipTrigger asChild>
|
||||
<Button
|
||||
variant="outline"
|
||||
size="icon"
|
||||
onClick={() => router.push(`/dashboard/productos/${data.id}`)}
|
||||
>
|
||||
<Eye className="h-4 w-4" />
|
||||
</Button>
|
||||
</TooltipTrigger>
|
||||
<TooltipContent>
|
||||
<p>Ver</p>
|
||||
</TooltipContent>
|
||||
</Tooltip>
|
||||
</TooltipProvider>
|
||||
|
||||
<TooltipProvider>
|
||||
<Tooltip>
|
||||
<TooltipTrigger asChild>
|
||||
@@ -80,7 +98,7 @@ export const CellAction: React.FC<CellActionProps> = ({ data }) => {
|
||||
</Button>
|
||||
</TooltipTrigger>
|
||||
<TooltipContent>
|
||||
<p>Deshabilitar</p>
|
||||
<p>Eliminar</p>
|
||||
</TooltipContent>
|
||||
</Tooltip>
|
||||
</TooltipProvider>
|
||||
|
||||
@@ -5,16 +5,12 @@ import { CellAction } from './cell-action';
|
||||
import { InventoryTable } from '../../../schemas/inventory';
|
||||
|
||||
export const columns: ColumnDef<InventoryTable>[] = [
|
||||
{
|
||||
accessorKey: 'userId',
|
||||
header: 'ID',
|
||||
},
|
||||
{
|
||||
accessorKey: 'urlImg',
|
||||
header: 'img',
|
||||
cell: ({ row }) => {
|
||||
return (
|
||||
<img src={`http://localhost:3000/uploads/inventory/${row.original.userId}/${row.original.id}/${row.original.urlImg}`} alt="" width={64} height={64} className="rounded"/>
|
||||
<img src={`/uploads/inventory/${row.original.userId}/${row.original.id}/${row.original.urlImg}`} alt="" width={64} height={64} className="rounded"/>
|
||||
)
|
||||
},
|
||||
},
|
||||
|
||||
@@ -19,7 +19,7 @@ import {
|
||||
import { Input } from '@repo/shadcn/input';
|
||||
import { useForm } from 'react-hook-form';
|
||||
import { useUpdateProduct } from "@/feactures/inventory/hooks/use-mutation";
|
||||
import { editInventory, EditInventory } from '@/feactures/inventory/schemas/inventory'; // Renombrado EditInventory para claridad
|
||||
import { updateInventory, EditInventory, InventoryTable } from '@/feactures/inventory/schemas/inventory'; // Renombrado EditInventory para claridad
|
||||
import { Textarea } from '@repo/shadcn/components/ui/textarea';
|
||||
import {STATUS} from '@/constants/status'
|
||||
import { useState, useEffect } from 'react';
|
||||
@@ -43,7 +43,7 @@ import { z } from 'zod'; // Asegúrate de importar Zod
|
||||
interface UpdateFormProps {
|
||||
onSuccess?: () => void;
|
||||
onCancel?: () => void;
|
||||
defaultValues?: Partial<EditInventory>;
|
||||
defaultValues?: Partial<InventoryTable>;
|
||||
}
|
||||
|
||||
export function UpdateForm({
|
||||
@@ -78,7 +78,7 @@ export function UpdateForm({
|
||||
};
|
||||
|
||||
const form = useForm<EditInventory>({ // Usamos el nuevo tipo aquí
|
||||
resolver: zodResolver(editInventory), // Usamos el esquema extendido
|
||||
resolver: zodResolver(updateInventory), // Usamos el esquema extendido
|
||||
defaultValues: defaultformValues,
|
||||
mode: 'onChange',
|
||||
});
|
||||
|
||||
@@ -13,8 +13,8 @@ export function UsersHeader() {
|
||||
<>
|
||||
<div className="flex items-start justify-between">
|
||||
<Heading
|
||||
title="Administración del inventario"
|
||||
description="Gestione aquí los productos que usted registre en la plataforma"
|
||||
title="Mi inventario"
|
||||
description="Gestione aquí los productos que registre en la plataforma"
|
||||
/>
|
||||
<Button onClick={() => setOpen(true)} size="sm">
|
||||
<Plus className="h-4 w-4" /><span className='hidden md:inline'>Agregar Producto</span>
|
||||
|
||||
Reference in New Issue
Block a user