From 4d15efd38b7cf48533e602807b7ee4611a345ecd Mon Sep 17 00:00:00 2001 From: ArkadiK94 Date: Fri, 1 Dec 2023 19:18:52 +0200 Subject: [PATCH 1/3] [Feat] Display Difference in halufot routes Why: the user could see that there is a difference between two routes with same fromRoute and toRoute How: sorting the routes and indicate the halufa number baside the route title --- src/locale/he.json | 21 ++++++++++--------- src/model/busRoute.ts | 2 ++ src/pages/components/RouteSelector.tsx | 28 ++++++++++++++++++++++---- 3 files changed, 37 insertions(+), 14 deletions(-) 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..817d8212 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={(routes) => getRouteTitle(routes, t)} /> ) } From 10cd0783054c0c8317684564b7d2a123a93d1899 Mon Sep 17 00:00:00 2001 From: ArkadiK94 Date: Fri, 1 Dec 2023 19:18:52 +0200 Subject: [PATCH 2/3] [Feat] Display Difference in halufot routes Why: the user could see that there is a difference between two routes with same origin and destination How: sorting the routes and indicate the halufa number beside the route title --- src/locale/he.json | 21 ++++++++++--------- src/model/busRoute.ts | 2 ++ src/pages/components/RouteSelector.tsx | 28 ++++++++++++++++++++++---- 3 files changed, 37 insertions(+), 14 deletions(-) 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..817d8212 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={(routes) => getRouteTitle(routes, t)} /> ) } From e33b20baf5c62fd15db24633cd730033702b1b7d Mon Sep 17 00:00:00 2001 From: ArkadiK94 Date: Fri, 1 Dec 2023 19:33:03 +0200 Subject: [PATCH 3/3] typo --- src/pages/components/RouteSelector.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/pages/components/RouteSelector.tsx b/src/pages/components/RouteSelector.tsx index 817d8212..612b476e 100644 --- a/src/pages/components/RouteSelector.tsx +++ b/src/pages/components/RouteSelector.tsx @@ -45,7 +45,7 @@ const RouteSelector = ({ routes, routeKey, setRouteKey }: RouteSelectorProps) => renderInput={(params) => ( )} - getOptionLabel={(routes) => getRouteTitle(routes, t)} + getOptionLabel={(route) => getRouteTitle(route, t)} /> ) }