fix: resolve {{count}} interpolation and add notification bell for parapharmacy products
Run Tests on Branches / Detect Changes (push) Successful in 12s
Run Tests on Branches / Backend Tests (push) Has been skipped
Run Tests on Branches / Frontend Tests (push) Successful in 1m44s
Run Tests on Branches / Frontend Mobile Tests (push) Successful in 1m51s
Run Tests on Branches / PIP Platform Tests (push) Has been skipped
Run Tests on Branches / Parapharmacy API Tests (push) Has been skipped
Run Tests on Branches / Detect Changes (push) Successful in 12s
Run Tests on Branches / Backend Tests (push) Has been skipped
Run Tests on Branches / Frontend Tests (push) Successful in 1m44s
Run Tests on Branches / Frontend Mobile Tests (push) Successful in 1m51s
Run Tests on Branches / PIP Platform Tests (push) Has been skipped
Run Tests on Branches / Parapharmacy API Tests (push) Has been skipped
- Add interpolation support to t() function in LanguageContext (web + mobile) - Pass medicine, currentUser, onLoginRequest props to PharmacyList in ProductView - Remove duplicate title in ProductView (PharmacyList already renders one)
This commit is contained in:
@@ -36,8 +36,14 @@ export function LanguageProvider({ children }) {
|
||||
AsyncStorage.setItem(STORAGE_KEY, newLang).catch(() => {});
|
||||
}, []);
|
||||
|
||||
const t = useCallback((key) => {
|
||||
return locales[lang]?.[key] || locales.es[key] || key;
|
||||
const t = useCallback((key, params) => {
|
||||
let str = locales[lang]?.[key] || locales.es[key] || key;
|
||||
if (params && typeof str === 'string') {
|
||||
Object.keys(params).forEach((k) => {
|
||||
str = str.replace(new RegExp(`\\{\\{${k}\\}\\}`, 'g'), params[k]);
|
||||
});
|
||||
}
|
||||
return str;
|
||||
}, [lang]);
|
||||
|
||||
const value = useMemo(() => ({ lang, setLang, t, ready }), [lang, setLang, t, ready]);
|
||||
|
||||
@@ -195,6 +195,8 @@ function App() {
|
||||
source={productScreen?.source}
|
||||
id={productScreen?.id}
|
||||
onBack={() => { setProductScreen(null); setScreen('search'); }}
|
||||
currentUser={currentUser}
|
||||
onLoginRequest={() => setShowLogin(true)}
|
||||
/>
|
||||
);
|
||||
break;
|
||||
|
||||
@@ -26,8 +26,14 @@ export function LanguageProvider({ children }) {
|
||||
} catch {}
|
||||
}, []);
|
||||
|
||||
const t = useCallback((key) => {
|
||||
return locales[lang]?.[key] || locales.es[key] || key;
|
||||
const t = useCallback((key, params) => {
|
||||
let str = locales[lang]?.[key] || locales.es[key] || key;
|
||||
if (params && typeof str === 'string') {
|
||||
Object.keys(params).forEach((k) => {
|
||||
str = str.replace(new RegExp(`\\{\\{${k}\\}\\}`, 'g'), params[k]);
|
||||
});
|
||||
}
|
||||
return str;
|
||||
}, [lang]);
|
||||
|
||||
const value = useMemo(() => ({ lang, setLang, t }), [lang, setLang, t]);
|
||||
|
||||
@@ -5,7 +5,7 @@ import { haversineKm, getUserPosition, hasCachedPosition } from '../utils/geo';
|
||||
import { useTranslation } from '../i18n';
|
||||
import './ProductView.css';
|
||||
|
||||
export default function ProductView({ source, id, onBack }) {
|
||||
export default function ProductView({ source, id, onBack, currentUser, onLoginRequest }) {
|
||||
const { t } = useTranslation();
|
||||
const [product, setProduct] = useState(null);
|
||||
const [loading, setLoading] = useState(true);
|
||||
@@ -196,10 +196,6 @@ export default function ProductView({ source, id, onBack }) {
|
||||
<div className="pharmacies-loading">{t('productView.loadingPharmacies')}</div>
|
||||
) : pharmacies.length > 0 ? (
|
||||
<>
|
||||
<h3 className="pharmacies-title">
|
||||
{t('productView.availableInPharmacies', { count: pharmacies.length })}
|
||||
</h3>
|
||||
|
||||
<div className="pharmacy-controls">
|
||||
<button
|
||||
className={`sort-distance-button ${sortByDistance ? 'active' : ''}`}
|
||||
@@ -231,6 +227,9 @@ export default function ProductView({ source, id, onBack }) {
|
||||
pharmacies={displayedPharmacies}
|
||||
loading={loadingPharmacies}
|
||||
userPosition={sortByDistance ? userPosition : null}
|
||||
medicine={product}
|
||||
currentUser={currentUser}
|
||||
onLoginRequest={onLoginRequest}
|
||||
/>
|
||||
</>
|
||||
) : null}
|
||||
|
||||
Reference in New Issue
Block a user