Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 6 additions & 6 deletions mapping/domesticHotWaterMapper.ts
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ function mapShowersData(state: ResolvedState) {
const { wwhrs, hotWaterOutlets } = state.domesticHotWater;
let WWHRS: SchemaWWHRS | undefined = undefined;

const mixedShowerEntries = hotWaterOutlets.filter(x => x.typeOfHotWaterOutlet === "mixedShower").map((x): [string, SchemaMixerShower] => {
const mixedShowerEntries = (hotWaterOutlets ?? []).filter(x => x.typeOfHotWaterOutlet === "mixedShower").map((x): [string, SchemaMixerShower] => {
const key = x.name;
let associatedWwhrs: WwhrsData | undefined;

Expand Down Expand Up @@ -96,7 +96,7 @@ function mapShowersData(state: ResolvedState) {
return [key, mixedShower];
});

const electricShowerEntries = state.domesticHotWater.hotWaterOutlets.filter(x => x.typeOfHotWaterOutlet === "electricShower").map((x): [string, SchemaInstantElecShower] => {
const electricShowerEntries = (state.domesticHotWater.hotWaterOutlets ?? []).filter(x => x.typeOfHotWaterOutlet === "electricShower").map((x): [string, SchemaInstantElecShower] => {
const key = x.name;
const val: SchemaInstantElecShower = {
type: "InstantElecShower",
Expand All @@ -112,7 +112,7 @@ function mapShowersData(state: ResolvedState) {
}

function mapBathsData(state: ResolvedState) {
const bathEntries = state.domesticHotWater.hotWaterOutlets.filter(x => x.typeOfHotWaterOutlet === "bath").map((x): [string, SchemaBathDetails] => {
const bathEntries = (state.domesticHotWater.hotWaterOutlets ?? []).filter(x => x.typeOfHotWaterOutlet === "bath").map((x): [string, SchemaBathDetails] => {
const key = x.name;
const val: SchemaBathDetails = {
ColdWaterSource: coldWaterSourceMap[x.coldWaterSource],
Expand All @@ -127,7 +127,7 @@ function mapBathsData(state: ResolvedState) {
}

function mapOthersData(state: ResolvedState) {
const otherEntries = state.domesticHotWater.hotWaterOutlets.filter(x => x.typeOfHotWaterOutlet === "otherHotWaterOutlet").map((x): [string, SchemaOtherWaterUseDetails] => {
const otherEntries = (state.domesticHotWater.hotWaterOutlets ?? []).filter(x => x.typeOfHotWaterOutlet === "otherHotWaterOutlet").map((x): [string, SchemaOtherWaterUseDetails] => {
const key = x.name;
const val: SchemaOtherWaterUseDetails = {
ColdWaterSource: coldWaterSourceMap[x.coldWaterSource],
Expand Down Expand Up @@ -415,7 +415,7 @@ function mapHotWaterSourcesWithWaterStorage(state: ResolvedState, waterStorage:
const { mappedWSHeatSource, mappedHeatSourceWet }
= mapWaterStorageHeatSource(waterStorage, dhwHeatSource, actualHeatSource, state);

const pipework = state.domesticHotWater.pipework.filter(x => x.waterStorage === waterStorage.id);
const pipework = (state.domesticHotWater.pipework ?? []).filter(x => x.waterStorage === waterStorage.id);

return {
HotWaterSource: {
Expand Down Expand Up @@ -583,7 +583,7 @@ export function mapPreheatedWaterSourceData(state: ResolvedState): Partial<FhsIn
}

export function mapHotWaterSourcesData(state: ResolvedState) {
const waterStorage = state.domesticHotWater.waterStorage[0];
const waterStorage = state.domesticHotWater.waterStorage?.[0];

if (!waterStorage) {
return mapHotWaterSourcesWithoutWaterStorage(state);
Expand Down
Loading