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:
@@ -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;
|
||||||
|
|||||||
@@ -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) {
|
||||||
|
|||||||
Reference in New Issue
Block a user