diff --git a/src/locale/he.json b/src/locale/he.json index 3444b7da..54b79e85 100644 --- a/src/locale/he.json +++ b/src/locale/he.json @@ -85,14 +85,15 @@ "bug_attachments": "קבצים מצורפים/ צילומי מסך", "bug_attachments_upload_button": "לחץ להעלאה", "bug_submit": "שלח את הדוח", - "bug_contact_name":"שם מלא", - "bug_contact_name_message":"אנא הזן את שמך!", - "bug_contact_email":"אי-מייל", - "bug_contact_email_message":"אנא הזן כתובת אי-מייל!", - "bug_form_description":"טופס זה נועד על מנת שנוכל לקבל פידבק ולשפר את האפליקציה.", - "bug_type":"סוג הבקשה", - "bug_type_message":"אנא הזן סוג בקשה!", - "bug_type_bug":"באג", - "bug_type_feature":"בקשה לפיתוח", - "funding_paragraph": "דאטאבוס פותח בסדנא לידע ציבורי, בעבודת מתנדבים, ומבוסס על" + "bug_contact_name": "שם מלא", + "bug_contact_name_message": "אנא הזן את שמך!", + "bug_contact_email": "אי-מייל", + "bug_contact_email_message": "אנא הזן כתובת אי-מייל!", + "bug_form_description": "טופס זה נועד על מנת שנוכל לקבל פידבק ולשפר את האפליקציה.", + "bug_type": "סוג הבקשה", + "bug_type_message": "אנא הזן סוג בקשה!", + "bug_type_bug": "באג", + "bug_type_feature": "בקשה לפיתוח", + "funding_paragraph": "דאטאבוס פותח בסדנא לידע ציבורי, בעבודת מתנדבים, ומבוסס על", + "halufa_ride": "נסיעה חלופית מס" } diff --git a/src/model/busRoute.ts b/src/model/busRoute.ts index e06711db..05ff2871 100644 --- a/src/model/busRoute.ts +++ b/src/model/busRoute.ts @@ -11,6 +11,7 @@ export type BusRoute = { direction: string routeIds: number[] lineRef: number + routeAlternative: string } export function fromGtfsRoute(gtfsRoute: GtfsRoutePydanticModel): BusRoute { @@ -26,5 +27,6 @@ export function fromGtfsRoute(gtfsRoute: GtfsRoutePydanticModel): BusRoute { direction: gtfsRoute.routeDirection!, routeIds: [gtfsRoute.id], lineRef: gtfsRoute.lineRef, + routeAlternative: gtfsRoute.routeAlternative!, } } diff --git a/src/pages/components/RouteSelector.tsx b/src/pages/components/RouteSelector.tsx index 48d1ca58..612b476e 100644 --- a/src/pages/components/RouteSelector.tsx +++ b/src/pages/components/RouteSelector.tsx @@ -1,6 +1,9 @@ import { formatted, TEXTS } from 'src/resources/texts' import { BusRoute } from 'src/model/busRoute' import { Autocomplete, TextField } from '@mui/material' +import { useEffect } from 'react' +import { useTranslation } from 'react-i18next' +import { TFunction } from 'i18next' type RouteSelectorProps = { routes: BusRoute[] @@ -8,13 +11,30 @@ type RouteSelectorProps = { setRouteKey: (routeKey: string) => void } -const getRouteTitle = (route: BusRoute) => - `${route.fromName} ${TEXTS.direction_arrow} ${route.toName}` +const getRouteTitle = (route: BusRoute, t: TFunction<'translation', undefined>) => + `${route.fromName} ${TEXTS.direction_arrow} ${route.toName} ${ + route.routeAlternative === '#' || route.routeAlternative === '0' + ? '' + : `(${t('halufa_ride')} ${route.routeAlternative})` + }` const RouteSelector = ({ routes, routeKey, setRouteKey }: RouteSelectorProps) => { const valueFinned = routes.find((route) => route.key === routeKey) const value = valueFinned ? valueFinned : null - + const { t } = useTranslation() + useEffect(() => { + routes.sort((a, b) => { + if ( + a.fromName === b.fromName && + a.routeAlternative !== '#' && + a.routeAlternative !== '0' && + a.routeAlternative > b.routeAlternative + ) { + return 1 + } + return a.fromName > b.fromName ? 1 : -1 + }) + }, [routes]) return ( renderInput={(params) => ( )} - getOptionLabel={(route) => getRouteTitle(route)} + getOptionLabel={(route) => getRouteTitle(route, t)} /> ) }