diff --git a/src/lib/sketch/v3/InfrastructureTypeSubform.svelte b/src/lib/sketch/v3/InfrastructureTypeSubform.svelte
index 1bc9c12c..5c916826 100644
--- a/src/lib/sketch/v3/InfrastructureTypeSubform.svelte
+++ b/src/lib/sketch/v3/InfrastructureTypeSubform.svelte
@@ -12,10 +12,24 @@
import MeasureSubform from "./MeasureSubform.svelte";
export let intervention: V3Intervention;
- const intervention_type_options: InfrastructureSubtype[] =
- intervention.intervention_type !== ""
- ? infrastructureFormInformation[intervention.intervention_type].types
+ $: intervention_type_options = getInterventionTypeOptions(
+ intervention.intervention_type,
+ );
+
+ function getInterventionTypeOptions(
+ interventionType:
+ | "amenity"
+ | "bus_stop_treatment"
+ | "crossing"
+ | "junction_treatment"
+ | "link_segment"
+ | "place-making"
+ | "",
+ ): InfrastructureSubtype[] {
+ return interventionType !== ""
+ ? infrastructureFormInformation[interventionType].types
: [];
+ }
function getSubtypeObject(
subtype: string,
@@ -44,11 +58,18 @@
return [original, capitalisedSubsstrings.join(" ")];
}
- const subtypes: [string, string][] = intervention_type_options.map(
- (type_options) => {
- return formatForRadio(type_options.name);
- },
- );
+ $: subtypes = getSubtypes(intervention_type_options);
+
+ function getSubtypes(
+ interventionTypeOptions: InfrastructureSubtype[],
+ ): [string, string][] {
+ if (!interventionTypeOptions) {
+ return [];
+ }
+ return interventionTypeOptions.map((type_option) => {
+ return formatForRadio(type_option.name);
+ });
+ }
$: subtypeObject = getSubtypeObject(
intervention.properties.intervention_subtype,
@@ -148,17 +169,21 @@
}
-