Mobile App design
This commit is contained in:
+20
-1
@@ -512,7 +512,8 @@ app.get('/api/medicines/:medicineId/pharmacies', async (req, res) => {
|
||||
try {
|
||||
const nregistro = req.params.medicineId; // Ahora es el nregistro de CIMA
|
||||
|
||||
const pharmacies = await userDbAll(`
|
||||
// First try to get pharmacies with specific medicine data
|
||||
let pharmacies = await userDbAll(`
|
||||
SELECT
|
||||
p.id,
|
||||
p.name,
|
||||
@@ -529,6 +530,24 @@ app.get('/api/medicines/:medicineId/pharmacies', async (req, res) => {
|
||||
ORDER BY p.name
|
||||
`, [nregistro]);
|
||||
|
||||
// If no specific links exist, return all pharmacies as potential sellers
|
||||
if (pharmacies.length === 0) {
|
||||
pharmacies = await userDbAll(`
|
||||
SELECT
|
||||
p.id,
|
||||
p.name,
|
||||
p.address,
|
||||
p.phone,
|
||||
p.latitude,
|
||||
p.longitude,
|
||||
p.opening_hours,
|
||||
NULL as price,
|
||||
0 as stock
|
||||
FROM pharmacies p
|
||||
ORDER BY p.name
|
||||
`);
|
||||
}
|
||||
|
||||
res.json(pharmacies);
|
||||
} catch (error) {
|
||||
console.error('Error fetching pharmacies:', error);
|
||||
|
||||
Reference in New Issue
Block a user