Feat/parapharmacy api #38
@@ -105,10 +105,11 @@ export async function getParapharmacyBrands(): Promise<string[]> {
|
||||
|
||||
export async function getProduct(source: string, id: string): Promise<Product | null> {
|
||||
try {
|
||||
// Use different endpoint for parapharmacy products
|
||||
const endpoint = source === 'parapharmacy'
|
||||
? `/products/parapharmacy/${id}`
|
||||
: `/products/${source}/${id}`;
|
||||
// Use parapharmacy endpoint for all non-CIMA sources
|
||||
const isCima = source === 'cima';
|
||||
const endpoint = isCima
|
||||
? `/products/${source}/${id}`
|
||||
: `/products/parapharmacy/${id}`;
|
||||
|
||||
const { data } = await api.get<Product>(endpoint);
|
||||
return data;
|
||||
|
||||
@@ -17,10 +17,11 @@ export default function ProductView({ source, id, onBack }) {
|
||||
setError(null);
|
||||
setPharmacies([]);
|
||||
try {
|
||||
// Use different endpoint for parapharmacy products
|
||||
const apiUrl = source === 'parapharmacy'
|
||||
? `/api/products/parapharmacy/${id}`
|
||||
: `/api/products/${source}/${id}`;
|
||||
// Use parapharmacy endpoint for all non-CIMA sources
|
||||
const isCima = source === 'cima';
|
||||
const apiUrl = isCima
|
||||
? `/api/products/${source}/${id}`
|
||||
: `/api/products/parapharmacy/${id}`;
|
||||
|
||||
const response = await fetch(apiUrl);
|
||||
if (!response.ok) {
|
||||
|
||||
Reference in New Issue
Block a user