diff --git a/package-lock.json b/package-lock.json
index 99710f2..429d49e 100644
--- a/package-lock.json
+++ b/package-lock.json
@@ -1,15 +1,15 @@
{
"name": "dashboard",
- "version": "0.4.0",
+ "version": "1.0.0",
"lockfileVersion": 3,
"requires": true,
"packages": {
"": {
"name": "dashboard",
- "version": "0.4.0",
+ "version": "1.0.0",
"dependencies": {
"@heroicons/react": "^2.2.0",
- "@pharmatech/sdk": "^0.4.21",
+ "@pharmatech/sdk": "^0.4.22",
"@react-google-maps/api": "^2.20.6",
"@react-pdf/renderer": "^4.3.0",
"blob-stream": "^0.1.3",
@@ -1826,9 +1826,9 @@
}
},
"node_modules/@pharmatech/sdk": {
- "version": "0.4.21",
- "resolved": "https://registry.npmjs.org/@pharmatech/sdk/-/sdk-0.4.21.tgz",
- "integrity": "sha512-fxyXlgKN3qLxuGVg6bmRS5DhqfLOLsCYazffax5x0iYFFBIQHQBVRLltm5h84jvOEM0oA7ipD08VVXWMyBj/vQ==",
+ "version": "0.4.22",
+ "resolved": "https://registry.npmjs.org/@pharmatech/sdk/-/sdk-0.4.22.tgz",
+ "integrity": "sha512-m9EpwhdhVSC+9E2Bgwsrc2/bF3p5pFN7lj0TZu4UR639I8Zun66ElZVc0kidNLoq9+F3RsuKf4DEicNgZKVLiw==",
"license": "MIT",
"dependencies": {
"axios": "^1.8.1"
diff --git a/package.json b/package.json
index 0ad9c7c..a8a269a 100644
--- a/package.json
+++ b/package.json
@@ -1,6 +1,6 @@
{
"name": "dashboard",
- "version": "1.0.0",
+ "version": "1.1.0",
"private": true,
"scripts": {
"dev": "next dev",
@@ -17,7 +17,7 @@
},
"dependencies": {
"@heroicons/react": "^2.2.0",
- "@pharmatech/sdk": "^0.4.21",
+ "@pharmatech/sdk": "^0.4.22",
"@react-google-maps/api": "^2.20.6",
"@react-pdf/renderer": "^4.3.0",
"blob-stream": "^0.1.3",
diff --git a/src/app/(dashboard)/coupons/page.tsx b/src/app/(dashboard)/coupons/page.tsx
index 0d9a040..87920ab 100644
--- a/src/app/(dashboard)/coupons/page.tsx
+++ b/src/app/(dashboard)/coupons/page.tsx
@@ -146,8 +146,9 @@ export default function CouponsPage() {
return (
{isActive ? 'Activa' : 'Finalizada'}
diff --git a/src/app/(dashboard)/products/[id]/edit/page.tsx b/src/app/(dashboard)/products/[id]/edit/page.tsx
index ac2bcc1..e15b6c2 100644
--- a/src/app/(dashboard)/products/[id]/edit/page.tsx
+++ b/src/app/(dashboard)/products/[id]/edit/page.tsx
@@ -31,7 +31,6 @@ export default function EditProductPage() {
[],
);
const { token } = useAuth();
- const [manufacturerId, setManufacturerId] = useState('');
const [selectedManufacturer, setSelectedManufacturer] = useState('');
const [categories, setCategories] = useState([]);
const [categoryId, setCategoryId] = useState('');
@@ -99,11 +98,6 @@ export default function EditProductPage() {
fetchProduct();
}, [fetchProduct]);
- useEffect(() => {
- const selected = manufacturers.find((m) => m.name === selectedManufacturer);
- setManufacturerId(selected ? selected.id : '');
- }, [selectedManufacturer, manufacturers]);
-
useEffect(() => {
const selected = categories.find((c) => c.name === selectedCategory);
setCategoryId(selected ? selected.id : '');
@@ -115,7 +109,7 @@ export default function EditProductPage() {
genericName,
description,
priority,
- manufacturerId,
+ manufacturerId: selectedManufacturer,
});
if (!result.success) {
@@ -139,19 +133,19 @@ export default function EditProductPage() {
name,
description,
priority: parseInt(priority),
- manufacturerId,
+ manufacturerId: selectedManufacturer,
};
try {
await api.genericProduct.update(id, payload, token);
for (const url of imageUrls) {
- await api.productImage.create(id, { url });
+ await api.productImage.create(id, { url }, token);
}
console.log('Category ID:', categoryId, categoryId);
if (currentCategory) {
- await api.productCategory.delete(id, currentCategory.id);
+ await api.productCategory.delete(id, currentCategory.id, token);
}
- await api.productCategory.create(id, categoryId);
+ await api.productCategory.create(id, categoryId, token);
toast.success('Producto actualizado con exito');
setTimeout(() => {
router.push('/products');
diff --git a/src/app/(dashboard)/products/[id]/presentations/[presentationId]/edit/page.tsx b/src/app/(dashboard)/products/[id]/presentations/[presentationId]/edit/page.tsx
index 4b6acee..48ccc2d 100644
--- a/src/app/(dashboard)/products/[id]/presentations/[presentationId]/edit/page.tsx
+++ b/src/app/(dashboard)/products/[id]/presentations/[presentationId]/edit/page.tsx
@@ -100,7 +100,12 @@ export default function EditProductPresentationPage() {
// Convert to cents
payload.price = Number((payload.price * 100).toFixed(0));
try {
- await api.productPresentation.update(productId, presentationId, payload);
+ await api.productPresentation.update(
+ productId,
+ presentationId,
+ payload,
+ token,
+ );
toast.success('Presentación actualizada exitosamente');
setTimeout(() => {
router.push(`/products/${productId}`);
diff --git a/src/app/(dashboard)/products/[id]/presentations/[presentationId]/page.tsx b/src/app/(dashboard)/products/[id]/presentations/[presentationId]/page.tsx
index a042f65..dd3ee7d 100644
--- a/src/app/(dashboard)/products/[id]/presentations/[presentationId]/page.tsx
+++ b/src/app/(dashboard)/products/[id]/presentations/[presentationId]/page.tsx
@@ -68,7 +68,7 @@ export default function ViewProductPresentationPage() {
}
try {
- await api.productPresentation.delete(productId, presentationId);
+ await api.productPresentation.delete(productId, presentationId, token);
toast.success('Presentación eliminada exitosamente');
setTimeout(() => {
router.push(`/products/${productId}`);
diff --git a/src/app/(dashboard)/products/[id]/presentations/new/page.tsx b/src/app/(dashboard)/products/[id]/presentations/new/page.tsx
index 6414cf5..9429915 100644
--- a/src/app/(dashboard)/products/[id]/presentations/new/page.tsx
+++ b/src/app/(dashboard)/products/[id]/presentations/new/page.tsx
@@ -75,7 +75,7 @@ export default function AddProductPresentationPage() {
// Convert to cents
payload.price = Number((payload.price * 100).toFixed(0));
try {
- await api.productPresentation.create(productId, payload);
+ await api.productPresentation.create(productId, payload, token);
toast.success('Presentación añadida al producto');
setTimeout(() => {
router.push(`/products/${productId}`);
diff --git a/src/app/(dashboard)/products/new/page.tsx b/src/app/(dashboard)/products/new/page.tsx
index 4c67e01..4d984b3 100644
--- a/src/app/(dashboard)/products/new/page.tsx
+++ b/src/app/(dashboard)/products/new/page.tsx
@@ -16,11 +16,10 @@ export default function NewGenericProductPage() {
const [genericName, setGenericName] = useState('');
const [description, setDescription] = useState('');
const [priority, setPriority] = useState('');
- const [manufacturerId, setManufacturerId] = useState('');
const [manufacturers, setManufacturers] = useState(
[],
);
- const [selectedManufacturer, setSelectedManufacturer] = useState('');
+ const [selectedManufacturer, setSelectedManufacturer] = useState('');
const [errors, setErrors] = useState>({});
useEffect(() => {
@@ -39,20 +38,15 @@ export default function NewGenericProductPage() {
fetchManufacturers();
}, []);
- useEffect(() => {
- const selected = manufacturers.find((m) => m.name === selectedManufacturer);
- setManufacturerId(selected ? selected.id : '');
- }, [selectedManufacturer, manufacturers]);
-
const handleSubmit = async () => {
const result = newGenericProductSchema.safeParse({
name,
genericName,
description,
priority,
- manufacturerId,
+ manufacturerId: selectedManufacturer,
});
-
+ console.log('Validation result:', result);
if (!result.success) {
const { fieldErrors } = result.error.flatten();
setErrors({
@@ -79,7 +73,7 @@ export default function NewGenericProductPage() {
genericName,
description,
priority: parseInt(priority),
- manufacturerId,
+ manufacturerId: selectedManufacturer,
};
await api.genericProduct.create(payload, token);
@@ -89,7 +83,6 @@ export default function NewGenericProductPage() {
setGenericName('');
setDescription('');
setPriority('');
- setManufacturerId('');
setSelectedManufacturer('');
setErrors({});
} catch (error) {
diff --git a/src/app/(dashboard)/promos/page.tsx b/src/app/(dashboard)/promos/page.tsx
index 93548fb..15102fb 100644
--- a/src/app/(dashboard)/promos/page.tsx
+++ b/src/app/(dashboard)/promos/page.tsx
@@ -131,7 +131,7 @@ export default function PromosPage() {
{status}
diff --git a/src/components/Image/ImageUpload.tsx b/src/components/Image/ImageUpload.tsx
index 8975ec0..86aa747 100644
--- a/src/components/Image/ImageUpload.tsx
+++ b/src/components/Image/ImageUpload.tsx
@@ -146,7 +146,7 @@ export default function ImageUpload({
const handleRemoveFile = async (file: FileWithProgress) => {
try {
if (file.fromBackend) {
- await api.productImage.delete(productId, file.id);
+ await api.productImage.delete(productId, file.id, token!);
toast.success('Imagen eliminada del backend');
} else {
if (file.previewUrl) URL.revokeObjectURL(file.previewUrl);