From 8ac7843c7e03c3ade6d797aae24d7f20f4b33baa Mon Sep 17 00:00:00 2001 From: nikolar Date: Wed, 24 Jan 2024 09:56:23 -0800 Subject: [PATCH] improve variable names and update docs Signed-off-by: nikolar --- .changeset/perfect-shoes-arrive.md | 2 +- plugins/entity-feedback/README.md | 2 +- .../FeedbackResponseDialog.tsx | 12 ++++++------ 3 files changed, 8 insertions(+), 8 deletions(-) diff --git a/.changeset/perfect-shoes-arrive.md b/.changeset/perfect-shoes-arrive.md index 52cc34d675..5ba02e2184 100644 --- a/.changeset/perfect-shoes-arrive.md +++ b/.changeset/perfect-shoes-arrive.md @@ -5,7 +5,7 @@ -Add in logic to require comments for specific feedback responses +Add in logic to link the feedback comment box to specific feedback responses const requireComments = ( ... diff --git a/plugins/entity-feedback/README.md b/plugins/entity-feedback/README.md index 4878b2e01e..b66cf6f567 100644 --- a/plugins/entity-feedback/README.md +++ b/plugins/entity-feedback/README.md @@ -90,7 +90,7 @@ const overviewContent = ( ); -// Require comments for specific feedback responses +// Link the feedback comment box to specific feedback responses const overviewContent = ( ... diff --git a/plugins/entity-feedback/src/components/FeedbackResponseDialog/FeedbackResponseDialog.tsx b/plugins/entity-feedback/src/components/FeedbackResponseDialog/FeedbackResponseDialog.tsx index 4e98f3b8d8..1acf58003a 100644 --- a/plugins/entity-feedback/src/components/FeedbackResponseDialog/FeedbackResponseDialog.tsx +++ b/plugins/entity-feedback/src/components/FeedbackResponseDialog/FeedbackResponseDialog.tsx @@ -97,7 +97,7 @@ export const FeedbackResponseDialog = (props: FeedbackResponseDialogProps) => { .filter(r => r.mustComment) .map(r => r.id); - const isMandatedBoxChecked = () => { + const isLinkedBoxChecked = () => { const checkedBoxes = Object.keys(responseSelections).filter( id => responseSelections[id], ); @@ -106,7 +106,7 @@ export const FeedbackResponseDialog = (props: FeedbackResponseDialogProps) => { const [{ loading: saving }, saveResponse] = useAsyncFn(async () => { if (requireComments.length > 0) { - if (comments.length === 0 && isMandatedBoxChecked()) { + if (comments.length === 0 && isLinkedBoxChecked()) { alertApi.post({ message: 'The selected option(s) require a comment. Please provide a comment.', @@ -114,7 +114,7 @@ export const FeedbackResponseDialog = (props: FeedbackResponseDialogProps) => { }); return; } - if (comments.length > 0 && !isMandatedBoxChecked()) { + if (comments.length > 0 && !isLinkedBoxChecked()) { alertApi.post({ message: 'Please select the option(s) that require a comment.', severity: 'info', @@ -136,7 +136,7 @@ export const FeedbackResponseDialog = (props: FeedbackResponseDialogProps) => { } }, [comments, consent, entity, feedbackApi, onClose, responseSelections]); - const selectMandatedBox = (res: boolean) => { + const selectLinkedBox = (res: boolean) => { const newResponseSelections = { ...responseSelections }; requireComments.forEach(id => newResponseSelections[id] === res); setResponseSelections(newResponseSelections); @@ -145,9 +145,9 @@ export const FeedbackResponseDialog = (props: FeedbackResponseDialogProps) => { const verifyComments = (e: any) => { setComments(e.target.value); if (requireComments.length > 0) { - selectMandatedBox(true); + selectLinkedBox(true); if (e.target.value.length === 0) { - selectMandatedBox(false); + selectLinkedBox(false); } } };