Skip to content

Commit

Permalink
fix: errors on navigation from ordinal bin
Browse files Browse the repository at this point in the history
on ordinal bins with multiple prompts, two runtime errors were thrown when navigating from last prompt to next stage. both were related to prompt being undefined. this fix adds optional chaining to evaluate prompt.id and prompt.bucketSortOrder to undefined instead of throwing an error.
  • Loading branch information
buckhalt committed Jan 29, 2024
1 parent 9082855 commit 0ac9615
Showing 1 changed file with 10 additions and 22 deletions.
32 changes: 10 additions & 22 deletions lib/interviewer/containers/Interfaces/OrdinalBin.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,31 +12,22 @@ import { getNetworkNodesForType } from '../../selectors/interface';
import { getPromptVariable } from '../../selectors/prop';

/**
* OrdinalBin Interface
*/
const OrdinalBin = ({
prompt,
nodesForPrompt,
stage,
}) => {
const {
prompts,
} = stage;
* OrdinalBin Interface
*/
const OrdinalBin = ({ prompt, nodesForPrompt, stage }) => {
const { prompts } = stage;

return (
<div className="ordinal-bin-interface">
<div className="ordinal-bin-interface__prompt">
<Prompts
prompts={prompts}
currentPrompt={prompt.id}
/>
<Prompts prompts={prompts} currentPrompt={prompt?.id} />
</div>
<div className="ordinal-bin-interface__bucket">
<MultiNodeBucket
nodes={nodesForPrompt}
listId={`${stage.id}_${prompt.id}_NODE_BUCKET`}
listId={`${stage.id}_${prompt?.id}_NODE_BUCKET`}
itemType="EXISTING_NODE"
sortOrder={prompt.bucketSortOrder}
sortOrder={prompt?.bucketSortOrder}
/>
</div>
<div className="ordinal-bin-interface__bins">
Expand All @@ -58,14 +49,11 @@ function makeMapStateToProps() {
const activePromptVariable = getPromptVariable(state, props);

return {
nodesForPrompt: stageNodes.filter(
(node) => isNil(node[entityAttributesProperty][activePromptVariable]),
nodesForPrompt: stageNodes.filter((node) =>
isNil(node[entityAttributesProperty][activePromptVariable]),
),
};
};
}

export default compose(
withPrompt,
connect(makeMapStateToProps),
)(OrdinalBin);
export default compose(withPrompt, connect(makeMapStateToProps))(OrdinalBin);

0 comments on commit 0ac9615

Please sign in to comment.