From eff96f9e5ee9aa4b12626ae9ccfb28a1d36f8d0b Mon Sep 17 00:00:00 2001 From: Bilal Catic Date: Wed, 20 Nov 2019 13:45:54 +0100 Subject: [PATCH] fix mapping screen crash when office/resource is unknown --- .../components/SingleMapping.js | 116 +++++++++--------- 1 file changed, 60 insertions(+), 56 deletions(-) diff --git a/client/src/scenes/RoomOfficeNameMapping/components/SingleMapping.js b/client/src/scenes/RoomOfficeNameMapping/components/SingleMapping.js index 2e7d36d..61daa4a 100644 --- a/client/src/scenes/RoomOfficeNameMapping/components/SingleMapping.js +++ b/client/src/scenes/RoomOfficeNameMapping/components/SingleMapping.js @@ -76,67 +76,71 @@ class SingleMapping extends Component { }; render() { - const { singleMapping: { officeSlug, resourceSlug } } = this.props; - const { officeId, resourceId, officeOptions, allResourceOptions, pendingMappings } = this.props; - const { showDeletePrompt, newOfficeId, newResourceId } = this.state; + try { + const {singleMapping: {officeSlug, resourceSlug}} = this.props; + const {officeId, resourceId, officeOptions, allResourceOptions, pendingMappings} = this.props; + const {showDeletePrompt, newOfficeId, newResourceId} = this.state; - const selectedOfficeId = newOfficeId ? newOfficeId : officeId; - const selectedResourceId = newResourceId ? newResourceId : resourceId; + const selectedOfficeId = newOfficeId ? newOfficeId : officeId; + const selectedResourceId = newResourceId ? newResourceId : resourceId; - const resourceOptions = allResourceOptions && officeId ? allResourceOptions[selectedOfficeId].roomOptions : []; + const resourceOptions = allResourceOptions && officeId ? allResourceOptions[selectedOfficeId].roomOptions : []; - const enableActions = !pendingMappings; - const enableSave = enableActions && ((newOfficeId !== null) || (newResourceId !== null)); - const saveIconColor = enableSave ? 'green' : null; + const enableActions = !pendingMappings; + const enableSave = enableActions && ((newOfficeId !== null) || (newResourceId !== null)); + const saveIconColor = enableSave ? 'green' : null; - return ( - - - - - - - + - - - - - - - - - - ); + + + + + + + + + + + + + + + ); + }catch (e) { + return null; + } } }