From d382b2ee6a37c5387057e3b1edb8c1999ac30fe5 Mon Sep 17 00:00:00 2001 From: majkshkurti Date: Wed, 23 Oct 2024 15:41:46 +0200 Subject: [PATCH] fix: goat-community/goat#3362 --- .../oev-gueteklassen/OevGueteklassen.tsx | 50 ++++++++++++++++++- apps/web/i18n/locales/de/common.json | 10 ++-- apps/web/i18n/locales/en/common.json | 10 ++-- apps/web/lib/validations/tools.ts | 7 ++- 4 files changed, 66 insertions(+), 11 deletions(-) diff --git a/apps/web/components/map/panels/toolbox/tools/oev-gueteklassen/OevGueteklassen.tsx b/apps/web/components/map/panels/toolbox/tools/oev-gueteklassen/OevGueteklassen.tsx index bccd22d..3dad715 100644 --- a/apps/web/components/map/panels/toolbox/tools/oev-gueteklassen/OevGueteklassen.tsx +++ b/apps/web/components/map/panels/toolbox/tools/oev-gueteklassen/OevGueteklassen.tsx @@ -13,7 +13,11 @@ import { accessibilityIndicatorsStaticPayload } from "@/lib/constants/payloads"; import { setRunningJobIds } from "@/lib/store/jobs/slice"; import { setMaskLayer } from "@/lib/store/map/slice"; import { jobTypeEnum } from "@/lib/validations/jobs"; -import { oevGueteklassenSchema, toolboxMaskLayerNames } from "@/lib/validations/tools"; +import { + oevGueteklassenCatchmentType, + oevGueteklassenSchema, + toolboxMaskLayerNames, +} from "@/lib/validations/tools"; import type { SelectorItem } from "@/types/map/common"; import type { IndicatorBaseProps } from "@/types/map/toolbox"; @@ -43,6 +47,22 @@ const OevGueteklassen = ({ onBack, onClose }: IndicatorBaseProps) => { const { filteredLayers } = useLayerByGeomType(["feature"], ["polygon"], projectId as string); const [referenceLayer, setReferenceLayer] = useState(undefined); + const catchmentAreaTypes: SelectorItem[] = useMemo(() => { + return [ + { + value: oevGueteklassenCatchmentType.Enum.buffer, + label: t("buffer"), + icon: ICON_NAME.BULLSEYE, + }, + { + value: oevGueteklassenCatchmentType.Enum.network, + label: t("network"), + icon: ICON_NAME.STREET_NETWORK, + }, + ]; + }, [t]); + const [catchmentArea, setCatchmentArea] = useState(catchmentAreaTypes[0]); + dispatch(setMaskLayer(toolboxMaskLayerNames.pt)); const { @@ -67,6 +87,7 @@ const OevGueteklassen = ({ onBack, onClose }: IndicatorBaseProps) => { const handleRun = async () => { const payload = { + catchment_type: catchmentArea?.value, reference_area_layer_project_id: referenceLayer?.value, station_config: accessibilityIndicatorsStaticPayload, time_window: { @@ -96,6 +117,7 @@ const OevGueteklassen = ({ onBack, onClose }: IndicatorBaseProps) => { const handleReset = () => { setReferenceLayer(undefined); + setCatchmentArea(catchmentAreaTypes[0]); resetPTConfiguration(); }; @@ -171,6 +193,32 @@ const OevGueteklassen = ({ onBack, onClose }: IndicatorBaseProps) => { } /> + + {/* CONFIGURATION */} + + + + { + setCatchmentArea(item as SelectorItem); + }} + items={catchmentAreaTypes} + label={t("oev_gueteklassen_catchement_area")} + tooltip={t("oev_gueteklassen_catchment_area_tooltip")} + /> + + } + /> } diff --git a/apps/web/i18n/locales/de/common.json b/apps/web/i18n/locales/de/common.json index 1dd4292..0b5c413 100644 --- a/apps/web/i18n/locales/de/common.json +++ b/apps/web/i18n/locales/de/common.json @@ -326,14 +326,14 @@ "is_at_most": "Ist höchstens", "is_before": "Ist vorher", "is_between": "Liegt zwischen", - "is_empty_string": "Ist leer", "is_blank": "Is blank", + "is_empty_string": "Ist leer", "is_greater_than": "Ist größer als", "is_less_than": "Ist weniger als", "is_not": "Ist nicht", "is_not_between": "Liegt nicht dazwischen", - "is_not_empty_string": "Ist nicht leer", "is_not_blank": "Is not blank", + "is_not_empty_string": "Ist nicht leer", "is_not_on": "Ist nicht eingeschaltet", "is_on": "Ist eingeschaltet", "not_in_the_last": "Nicht im letzten", @@ -532,8 +532,8 @@ }, "type": { "feature": "Feature", - "table": "Table", - "raster": "Raster" + "raster": "Raster", + "table": "Table" } }, "metadata_updated_error": "Fehler beim aktualisieren der Metadaten", @@ -599,6 +599,8 @@ "oev_gueteklasse": "ÖV-Güteklassen", "oev_gueteklasse_description": "ÖV-Güteklassen zeigen die Attraktivität des öffentlichen Verkehrs in einem bestimmten Gebiet an.", "oev_gueteklasse_header": "ÖV-Güteklassen", + "oev_gueteklassen_catchement_area": "Einzugsgebietstyp", + "oev_gueteklassen_catchment_area_tooltip": "Erreichbarkeit von Bahnhöfen über Pufferstrecke oder Straßennetzrouting", "oev_gueteklassen_computation_started": "Berechnung der ÖV-Güteklassen gestartet", "oev_guteklassen": "ÖV-Güteklassen", "ok": "OK", diff --git a/apps/web/i18n/locales/en/common.json b/apps/web/i18n/locales/en/common.json index b04665c..0872f8c 100644 --- a/apps/web/i18n/locales/en/common.json +++ b/apps/web/i18n/locales/en/common.json @@ -326,14 +326,14 @@ "is_at_most": "Is at most", "is_before": "Is before", "is_between": "Is between", - "is_empty_string": "Is empty string", "is_blank": "Is blank", + "is_empty_string": "Is empty string", "is_greater_than": "Is greater than", "is_less_than": "Is less than", "is_not": "Is not", "is_not_between": "Is not between", - "is_not_empty_string": "Is not empty string", "is_not_blank": "Is not blank", + "is_not_empty_string": "Is not empty string", "is_not_on": "Is not on", "is_on": "Is on", "not_in_the_last": "Not in the last", @@ -532,8 +532,8 @@ }, "type": { "feature": "Feature", - "table": "Table", - "raster": "Raster" + "raster": "Raster", + "table": "Table" } }, "metadata_updated_error": "Error updating metadata", @@ -599,6 +599,8 @@ "oev_gueteklasse": "ÖV-Güteklassen", "oev_gueteklasse_description": "The Public Transport Quality Classes (German: ÖV-Güteklassen) show the attractiveness of public transport services for a selected area.", "oev_gueteklasse_header": "ÖV-Güteklassen", + "oev_gueteklassen_catchement_area": "Catchment area type", + "oev_gueteklassen_catchment_area_tooltip": "Accessiblity to stations using buffer distance or street network routing", "oev_gueteklassen_computation_started": "ÖV-Güteklassen computation started", "oev_guteklassen": "ÖV-Güteklassen", "ok": "ok", diff --git a/apps/web/lib/validations/tools.ts b/apps/web/lib/validations/tools.ts index 7ef55aa..4510ba9 100644 --- a/apps/web/lib/validations/tools.ts +++ b/apps/web/lib/validations/tools.ts @@ -136,7 +136,8 @@ export type PostActiveMobilityAndCarCatchmentArea = z.infer; //**=== OEV-GUETEKLASSEN + TRIP COUNT === */ -const stationConfigSchema = z.object({ +export const oevGueteklassenCatchmentType = z.enum(["buffer", "network"]); +export const stationConfigSchema = z.object({ groups: z.record(z.string()), time_frequency: z.array(z.number()), categories: z.array(z.record(z.number())), @@ -150,7 +151,9 @@ export const tripCountSchema = z.object({ scenario_id: z.string().optional(), }); -export const oevGueteklassenSchema = tripCountSchema.extend({}); +export const oevGueteklassenSchema = tripCountSchema.extend({ + catchment_type: oevGueteklassenCatchmentType.default("buffer") +}); export type PostTripCount = z.infer; export type PostOevGueteKlassen = z.infer;