fix: use parapharmacy endpoint for all non-CIMA sources

- ProductView now checks if source is 'cima' to decide endpoint
- All other sources (seed, promofarma, docmorris, primor) use parapharmacy endpoint
- Same fix applied to mobile getProduct function

Before: only 'parapharmacy' source used parapharmacy endpoint
After: all non-CIMA sources use parapharmacy endpoint
This commit is contained in:
Antoni Nuñez Romeu
2026-07-16 16:23:57 +02:00
parent 63b25e3f4f
commit dca7e373cd
2 changed files with 10 additions and 8 deletions
+5 -4
View File
@@ -105,10 +105,11 @@ export async function getParapharmacyBrands(): Promise<string[]> {
export async function getProduct(source: string, id: string): Promise<Product | null> { export async function getProduct(source: string, id: string): Promise<Product | null> {
try { try {
// Use different endpoint for parapharmacy products // Use parapharmacy endpoint for all non-CIMA sources
const endpoint = source === 'parapharmacy' const isCima = source === 'cima';
? `/products/parapharmacy/${id}` const endpoint = isCima
: `/products/${source}/${id}`; ? `/products/${source}/${id}`
: `/products/parapharmacy/${id}`;
const { data } = await api.get<Product>(endpoint); const { data } = await api.get<Product>(endpoint);
return data; return data;
+5 -4
View File
@@ -17,10 +17,11 @@ export default function ProductView({ source, id, onBack }) {
setError(null); setError(null);
setPharmacies([]); setPharmacies([]);
try { try {
// Use different endpoint for parapharmacy products // Use parapharmacy endpoint for all non-CIMA sources
const apiUrl = source === 'parapharmacy' const isCima = source === 'cima';
? `/api/products/parapharmacy/${id}` const apiUrl = isCima
: `/api/products/${source}/${id}`; ? `/api/products/${source}/${id}`
: `/api/products/parapharmacy/${id}`;
const response = await fetch(apiUrl); const response = await fetch(apiUrl);
if (!response.ok) { if (!response.ok) {