ver productos y detalles

This commit is contained in:
2025-07-09 14:56:58 -04:00
parent 365cbd0d7a
commit 3a0b29d3c1
14 changed files with 144 additions and 91 deletions

View File

@@ -5,7 +5,8 @@ import {
InventoryTable,
productMutate,
// editInventory,
productApiResponseSchema
productApiResponseSchema,
getProduct
} from '../schemas/inventory';
import { auth } from '@/lib/auth';
@@ -81,7 +82,7 @@ export const getAllProducts = async (params: {
);
if (error) {
console.error('Error:', error);
console.error('Errorrrrr:', error.details);
throw new Error(error.message);
}
@@ -100,6 +101,21 @@ export const getAllProducts = async (params: {
};
};
export const getProductById = async (id: number) => {
const [error, data] = await safeFetchApi(
getProduct,
`/products/id/${id}`,
'GET',
);
if (error) {
console.error('❌ Error en la API:', error);
throw new Error(error.message);
}
return data;
};
export const createProductAction = async (payload: InventoryTable) => {
const session = await auth()
const userId = session?.user?.id