Rebranding app and naming

This commit is contained in:
Antoni Nuñez Romeu
2026-07-01 15:54:10 +02:00
parent 2e9d6a94dd
commit 1c31362e0b
38 changed files with 272 additions and 261 deletions
@@ -56,10 +56,10 @@ function haversineMeters(lat1, lon1, lat2, lon2) {
}
const REGION_PRESETS = [
{ id: 'custom', label: 'Custom coordinates', lat: '', lon: '', radio: '' },
{ id: 'custom', label: 'Coordenadas personalizadas', lat: '', lon: '', radio: '' },
{
id: 'rubi',
label: 'Example: Rubí area (1.5 km)',
label: 'Ejemplo: Área de Rubí (1.5 km)',
lat: '41.5631',
lon: '2.0038',
radio: '1500',
@@ -76,16 +76,16 @@ async function geocodeErrorMessage(response) {
}
if (typeof body.error === 'string' && body.error.trim()) return body.error;
if (response.status === 401) {
return 'Session expired or not logged in. Sign in again on Admin, then retry.';
return 'Sesn expirada o no has iniciado sesión. Inicia sesión de nuevo en el panel Admin y reintenta.';
}
if (response.status === 404) {
const looksLikeHtml = /<!DOCTYPE|<html[\s>]/i.test(text || '');
if (looksLikeHtml) {
return 'The app could not reach the API (404). Use http://localhost:3000 with both frontend and backend running, or configure your server to proxy /api to the backend.';
return 'La app no pudo conectar con la API (404). Usa http://localhost:3000 con frontend y backend activos.';
}
return 'Geocode service not found. Update the backend and restart it.';
return 'Servicio de geocodificación no encontrado. Actualiza el backend y reinícialo.';
}
return `Lookup failed (HTTP ${response.status}).`;
return `Búsqueda fallida (HTTP ${response.status}).`;
}
function PharmacyManagement() {
@@ -132,7 +132,7 @@ function PharmacyManagement() {
setPharmacies(data);
} catch (error) {
console.error('Error fetching pharmacies:', error);
alert('Error loading pharmacies');
alert('Error al cargar farmacias');
} finally {
setLoading(false);
}
@@ -165,7 +165,7 @@ function PharmacyManagement() {
e?.preventDefault();
const q = cityQuery.trim();
if (!q) {
setCityLookupMessage({ type: 'err', text: 'Enter a city or place name.' });
setCityLookupMessage({ type: 'err', text: 'Introduce una ciudad o lugar.' });
return;
}
setCityLookupLoading(true);
@@ -253,7 +253,7 @@ function PharmacyManagement() {
const lon = parseFloat(regionLon);
const radio = parseFloat(regionRadio);
if (!Number.isFinite(lat) || !Number.isFinite(lon) || !Number.isFinite(radio)) {
throw new Error('Set latitude, longitude and radius (use Find city or a preset).');
throw new Error('Establece latitud, longitud y radio (usa Buscar ciudad o un preset).');
}
const response = await fetch('/api/admin/pharmacies/import-external', {
method: 'POST',
@@ -307,7 +307,7 @@ function PharmacyManagement() {
if (!response.ok) {
const error = await response.json();
throw new Error(error.error || 'Failed to update pharmacy');
throw new Error(error.error || 'Error al actualizar farmacia');
}
} else {
const response = await fetch('/api/admin/pharmacies', {
@@ -319,16 +319,16 @@ function PharmacyManagement() {
if (!response.ok) {
const error = await response.json();
throw new Error(error.error || 'Failed to create pharmacy');
throw new Error(error.error || 'Error al crear farmacia');
}
}
resetForm();
fetchPharmacies();
alert(editingPharmacy ? 'Pharmacy updated successfully!' : 'Pharmacy added successfully!');
alert(editingPharmacy ? '¡Farmacia actualizada!' : '¡Farmacia añadida!');
} catch (error) {
console.error('Error saving pharmacy:', error);
alert(`Error saving pharmacy: ${error.message}`);
alert(`Error al guardar farmacia: ${error.message}`);
} finally {
setSaving(false);
}
@@ -348,7 +348,7 @@ function PharmacyManagement() {
};
const handleDelete = async (id) => {
if (!confirm('Are you sure you want to delete this pharmacy?')) return;
if (!confirm('¿Estás seguro de que quieres eliminar esta farmacia?')) return;
try {
const response = await fetch(`/api/admin/pharmacies/${id}`, {
@@ -356,13 +356,13 @@ function PharmacyManagement() {
credentials: 'include',
});
if (!response.ok) throw new Error('Failed to delete pharmacy');
if (!response.ok) throw new Error('Error al eliminar farmacia');
fetchPharmacies();
alert('Pharmacy deleted successfully!');
alert('¡Farmacia eliminada!');
} catch (error) {
console.error('Error deleting pharmacy:', error);
alert('Error deleting pharmacy');
alert('Error al eliminar farmacia');
}
};
@@ -391,7 +391,7 @@ function PharmacyManagement() {
return (
<div className="admin-section">
<div className="section-header">
<h2>Manage Pharmacies</h2>
<h2>Gestionar Farmacias</h2>
<button
type="button"
className="btn-primary"
@@ -400,16 +400,16 @@ function PharmacyManagement() {
setShowForm(true);
}}
>
+ Add New Pharmacy
+ Añadir Nueva Farmacia
</button>
</div>
<div className="pharmacy-tools-card">
<h3>City, region &amp; import</h3>
<h3>Ciudad, región e importación</h3>
<p className="pharmacy-tools-hint">
<strong>Find city</strong> sets latitude, longitude and radius for the map filter and for imports.
Choose a <strong>data source</strong> below: <strong>OpenStreetMap</strong> is free (no key);{' '}
<strong>Open data URL</strong> loads JSON you host (array or GeoJSON). Geocoding uses{' '}
<strong>Buscar ciudad</strong> establece latitud, longitud y radio para el filtro de mapa y las importaciones.
Elige una <strong>fuente de datos</strong>: <strong>OpenStreetMap</strong> es gratuita (sin clave);{' '}
<strong>URL de datos abiertos</strong> carga JSON alojado por ti. Geocodificación usa{' '}
<a href="https://www.openstreetmap.org/copyright" target="_blank" rel="noreferrer">
OpenStreetMap
</a>{' '}
@@ -418,11 +418,11 @@ function PharmacyManagement() {
<form className="city-lookup-form" onSubmit={handleCityLookup}>
<div className="form-group city-lookup-input-wrap">
<label htmlFor="city-finder">Find city</label>
<label htmlFor="city-finder">Buscar ciudad</label>
<input
id="city-finder"
type="search"
placeholder="e.g. Rubí, Spain — or Madrid, Valencia…"
placeholder="Ej: Rubí, Madrid, Valencia…"
value={cityQuery}
onChange={(e) => {
setCityQuery(e.target.value);
@@ -436,7 +436,7 @@ function PharmacyManagement() {
className="btn-secondary city-lookup-submit"
disabled={cityLookupLoading}
>
{cityLookupLoading ? 'Looking up…' : 'Look up city'}
{cityLookupLoading ? 'Buscando…' : 'Buscar ciudad'}
</button>
</form>
{cityLookupMessage && (
@@ -449,7 +449,7 @@ function PharmacyManagement() {
)}
<div className="region-presets">
<label htmlFor="region-preset">Area preset</label>
<label htmlFor="region-preset">Preset de área</label>
<select
id="region-preset"
value={regionPreset}
@@ -465,7 +465,7 @@ function PharmacyManagement() {
<div className="region-grid">
<div className="form-group">
<label htmlFor="region-lat">Latitude</label>
<label htmlFor="region-lat">Latitud</label>
<input
id="region-lat"
type="text"
@@ -476,7 +476,7 @@ function PharmacyManagement() {
/>
</div>
<div className="form-group">
<label htmlFor="region-lon">Longitude</label>
<label htmlFor="region-lon">Longitud</label>
<input
id="region-lon"
type="text"
@@ -487,7 +487,7 @@ function PharmacyManagement() {
/>
</div>
<div className="form-group">
<label htmlFor="region-radio">Radius (m)</label>
<label htmlFor="region-radio">Radio (m)</label>
<input
id="region-radio"
type="text"
@@ -501,7 +501,7 @@ function PharmacyManagement() {
<div className="import-mode-row">
<div className="form-group import-mode-select-wrap">
<label htmlFor="import-mode">Data source</label>
<label htmlFor="import-mode">Fuente de datos</label>
<select
id="import-mode"
value={importMode}
@@ -510,16 +510,16 @@ function PharmacyManagement() {
setImportFeedback(null);
}}
>
<option value="osm">OpenStreetMap (Overpass, free)</option>
<option value="webhook">n8n webhook (legacy)</option>
<option value="openData">Open data JSON URL</option>
<option value="osm">OpenStreetMap (Overpass, gratuito)</option>
<option value="webhook">n8n webhook (heredado)</option>
<option value="openData">URL de datos abiertos JSON</option>
</select>
</div>
</div>
{importMode === 'openData' && (
<div className="form-group open-data-url-row">
<label htmlFor="open-data-url">JSON URL</label>
<label htmlFor="open-data-url">URL JSON</label>
<input
id="open-data-url"
type="url"
@@ -539,12 +539,12 @@ function PharmacyManagement() {
disabled={importing}
>
{importing
? 'Importing…'
? 'Importando…'
: importMode === 'webhook'
? 'Import from webhook'
? 'Importar desde webhook'
: importMode === 'openData'
? 'Import from URL'
: `Import from ${importMode === 'osm' ? 'Overpass' : 'OpenStreetMap'}`}
? 'Importar desde URL'
: `Importar desde ${importMode === 'osm' ? 'Overpass' : 'OpenStreetMap'}`}
</button>
<label className="filter-region-toggle">
<input
@@ -552,7 +552,7 @@ function PharmacyManagement() {
checked={filterByRegion}
onChange={(e) => setFilterByRegion(e.target.checked)}
/>
Show only pharmacies inside radius
Mostrar solo farmacias dentro del radio
</label>
</div>
@@ -568,10 +568,10 @@ function PharmacyManagement() {
{showForm && (
<form className="admin-form" onSubmit={handleSubmit}>
<h3>{editingPharmacy ? 'Edit Pharmacy' : 'Add New Pharmacy'}</h3>
<h3>{editingPharmacy ? 'Editar Farmacia' : 'Añadir Nueva Farmacia'}</h3>
<div className="form-group">
<label>Name *</label>
<label>Nombre *</label>
<input
type="text"
value={formData.name}
@@ -581,7 +581,7 @@ function PharmacyManagement() {
</div>
<div className="form-group">
<label>Address *</label>
<label>Dirección *</label>
<input
type="text"
value={formData.address}
@@ -591,7 +591,7 @@ function PharmacyManagement() {
</div>
<div className="form-group">
<label>Phone</label>
<label>Teléfono</label>
<input
type="text"
value={formData.phone}
@@ -601,7 +601,7 @@ function PharmacyManagement() {
<div className="form-row">
<div className="form-group">
<label>Latitude</label>
<label>Latitud</label>
<input
type="number"
step="any"
@@ -611,7 +611,7 @@ function PharmacyManagement() {
</div>
<div className="form-group">
<label>Longitude</label>
<label>Longitud</label>
<input
type="number"
step="any"
@@ -622,8 +622,8 @@ function PharmacyManagement() {
</div>
<fieldset className="hours-editor">
<legend>Opening hours</legend>
<p className="hours-editor-hint">Leave a day checked as <em>Closed</em> if the pharmacy doesn't open that day.</p>
<legend>Horario de apertura</legend>
<p className="hours-editor-hint">Marca un día como <em>Cerrado</em> si la farmacia no abre ese día.</p>
{DAY_KEYS.map((day) => {
const d = hoursDraft[day];
return (
@@ -635,14 +635,14 @@ function PharmacyManagement() {
checked={d.closed}
onChange={(e) => updateDay(day, { closed: e.target.checked })}
/>
Closed
Cerrado
</label>
<input
type="time"
value={d.open}
disabled={d.closed}
onChange={(e) => updateDay(day, { open: e.target.value })}
aria-label={`${DAY_LABEL[day]} opens at`}
aria-label={`${DAY_LABEL[day]} abre a las`}
/>
<span className="hours-sep"></span>
<input
@@ -650,7 +650,7 @@ function PharmacyManagement() {
value={d.close}
disabled={d.closed}
onChange={(e) => updateDay(day, { close: e.target.value })}
aria-label={`${DAY_LABEL[day]} closes at`}
aria-label={`${DAY_LABEL[day]} cierra a las`}
/>
</div>
);
@@ -659,28 +659,28 @@ function PharmacyManagement() {
<div className="form-actions">
<button type="submit" className="btn-primary" disabled={saving}>
{saving ? 'Saving...' : editingPharmacy ? 'Update' : 'Add'} Pharmacy
{saving ? 'Guardando...' : editingPharmacy ? 'Actualizar' : 'Añadir'} Farmacia
</button>
<button type="button" className="btn-secondary" onClick={resetForm} disabled={saving}>
Cancel
Cancelar
</button>
</div>
</form>
)}
{loading ? (
<div className="loading">Loading pharmacies...</div>
<div className="loading">Cargando farmacias...</div>
) : (
<div className="admin-list">
<p className="list-meta">
Showing {displayedPharmacies.length} of {pharmacies.length} pharmacies
{filterByRegion && ' (inside radius)'}
Mostrando {displayedPharmacies.length} de {pharmacies.length} farmacias
{filterByRegion && ' (dentro del radio)'}
</p>
{displayedPharmacies.length === 0 ? (
<p className="empty-state">
{pharmacies.length === 0
? 'No pharmacies yet. Import from webhook or add one manually.'
: 'No pharmacies in this radius with coordinates. Widen the radius, look up a different city, or turn off the region filter.'}
? 'Aún no hay farmacias. Importa desde webhook o añade una manualmente.'
: 'No hay farmacias en este radio con coordenadas. Amplía el radio, busca otra ciudad o desactiva el filtro de región.'}
</p>
) : (
displayedPharmacies.map((pharmacy) => (
@@ -697,10 +697,10 @@ function PharmacyManagement() {
</div>
<div className="item-actions">
<button type="button" className="btn-edit" onClick={() => handleEdit(pharmacy)}>
Edit
Editar
</button>
<button type="button" className="btn-delete" onClick={() => handleDelete(pharmacy.id)}>
Delete
Eliminar
</button>
</div>
</div>