ver productos y detalles
This commit is contained in:
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user