Skip to content

Commit 517d020

Browse files
committed
Merge remote-tracking branch 'origin/dev' into dev
2 parents 0583d66 + ad06851 commit 517d020

1 file changed

Lines changed: 11 additions & 11 deletions

File tree

src/components/WritePlan/GuidanceChoice.jsx

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -64,14 +64,14 @@ function GuidanceChoice({
6464
const states = handleGuidanceGroups([...orgsWithSelectedGuidances, ...orgsWithUnselectedGuidances]);
6565
setCheckboxStates(states);
6666
})
67-
.catch((error) => {setError(error)})
67+
.catch((error) => { setError(error) })
6868
.finally(() => setLoading(false));
6969
}, [planId, researchOutputId]);
7070

7171
useEffect(() => {
7272
if (guidancesData.length === 0) return;
7373
let filtered = [...guidancesData];
74-
if(context === 'research_output'){
74+
if (context === 'research_output') {
7575
if (includeTopic) {
7676
filtered = filtered.filter((org) => org.guidance_groups.find((gg) => gg.topics.includes(topic)));
7777
}
@@ -322,21 +322,21 @@ function GuidanceChoice({
322322
className={guidanceChoiceStyles.checkboxes}
323323
key={`guidance-group-${index}`}
324324
>
325-
{limitHasBeenReached() && !checkboxStates[group.id].checked ? (
325+
{limitHasBeenReached() && !checkboxStates?.[group.id]?.checked ? (
326326
<MdOutlineCheckBoxOutlineBlank
327327
fill="grey"
328328
size={18}
329329
key={`icon-${index}-checkbox-outline-blank-disabled`}
330330
style={{ cursor: 'not-allowed' }}
331331
/>
332-
) : !checkboxStates[group.id].checked ? (
332+
) : !checkboxStates?.[group.id]?.checked ? (
333333
<MdOutlineCheckBoxOutlineBlank
334334
style={{ cursor: 'pointer' }}
335335
size={18}
336336
key={`icon-${index}-checkbox-outline-blank`}
337337
onClick={() => handleCheckboxChange(group.id, true)}
338338
/>
339-
) : countSelectedChild(group.id) === 1 && Object.keys(checkboxStates[group.id].guidance_groups).length > 1 ? (
339+
) : countSelectedChild(group.id) === 1 && Object.keys(checkboxStates?.[group.id]?.guidance_groups || {}).length > 1 ? (
340340
<MdIndeterminateCheckBox
341341
style={{ cursor: 'pointer' }}
342342
size={18}
@@ -355,10 +355,10 @@ function GuidanceChoice({
355355

356356
<label
357357
className={`${guidanceChoiceStyles.label_checkbox}`}
358-
style={{ cursor: limitHasBeenReached() && !checkboxStates[group.id].checked ? 'not-allowed' : 'pointer' }}
358+
style={{ cursor: limitHasBeenReached() && !checkboxStates?.[group.id]?.checked ? 'not-allowed' : 'pointer' }}
359359
onClick={() => {
360-
if (!(limitHasBeenReached() && !checkboxStates[group.id].checked)) {
361-
handleCheckboxChange(group.id, !checkboxStates[group.id].checked);
360+
if (!(limitHasBeenReached() && !checkboxStates?.[group.id]?.checked)) {
361+
handleCheckboxChange(group.id, !checkboxStates?.[group.id]?.checked);
362362
}
363363
}}
364364
key={`label-${index}-guidance-group`}
@@ -387,19 +387,19 @@ function GuidanceChoice({
387387
key={`guidance-group-${index}-childs-${key}-container`}
388388
>
389389
{
390-
limitHasBeenReached() && !checkboxStates[group.id].guidance_groups[guidance.id] ? (
390+
limitHasBeenReached() && !checkboxStates?.[group.id]?.guidance_groups?.[guidance.id] ? (
391391
<MdOutlineCheckBoxOutlineBlank
392392
fill="grey"
393393
size={18}
394394
key={`icon-${index}-${key}-checkbox-outline-blank-disabled`}
395395
style={{ cursor: 'not-allowed' }}
396396
/>
397-
) : !checkboxStates[group.id].guidance_groups[guidance.id] ? (
397+
) : !checkboxStates?.[group.id]?.guidance_groups?.[guidance.id] ? (
398398
<MdOutlineCheckBoxOutlineBlank
399399
style={{ cursor: 'pointer' }}
400400
size={18}
401401
key={`icon-${index}-${key}-checkbox-outline-blank`}
402-
onClick={() => handleNestedCheckboxChange(group.id, guidance.id, !checkboxStates[group.id].guidance_groups[guidance.id])}
402+
onClick={() => handleNestedCheckboxChange(group.id, guidance.id, !checkboxStates?.[group.id]?.guidance_groups?.[guidance.id])}
403403
/>
404404
) : (
405405
<MdCheckBox

0 commit comments

Comments
 (0)