Skip to content

Commit

Permalink
feat: show remove button conditionally
Browse files Browse the repository at this point in the history
  • Loading branch information
deeonwuli committed Nov 28, 2024
1 parent 05a544d commit 1a5e33a
Show file tree
Hide file tree
Showing 7 changed files with 27 additions and 9 deletions.
9 changes: 6 additions & 3 deletions i18n/en.pot
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@ msgstr ""
"Content-Type: text/plain; charset=utf-8\n"
"Content-Transfer-Encoding: 8bit\n"
"Plural-Forms: nplurals=2; plural=(n != 1)\n"
"POT-Creation-Date: 2024-11-12T13:57:18.029Z\n"
"PO-Revision-Date: 2024-11-12T13:57:18.029Z\n"
"POT-Creation-Date: 2024-11-27T21:40:09.970Z\n"
"PO-Revision-Date: 2024-11-27T21:40:09.970Z\n"

msgid "Low"
msgstr ""
Expand Down Expand Up @@ -162,7 +162,10 @@ msgstr ""
msgid "Create Risk Assessment"
msgstr ""

msgid "Add new Assessment"
msgid "Edit Risk Assessment"
msgstr ""

msgid "Add new Grade"
msgstr ""

msgid "Risk assessment incomplete"
Expand Down
7 changes: 5 additions & 2 deletions i18n/es.po
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
msgid ""
msgstr ""
"Project-Id-Version: i18next-conv\n"
"POT-Creation-Date: 2024-11-12T13:57:18.029Z\n"
"POT-Creation-Date: 2024-11-27T21:40:09.970Z\n"
"PO-Revision-Date: 2018-10-25T09:02:35.143Z\n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n"
Expand Down Expand Up @@ -161,7 +161,10 @@ msgstr ""
msgid "Create Risk Assessment"
msgstr ""

msgid "Add new Assessment"
msgid "Edit Risk Assessment"
msgstr ""

msgid "Add new Grade"
msgstr ""

msgid "Risk assessment incomplete"
Expand Down
1 change: 1 addition & 0 deletions src/webapp/components/form/Form.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ export const Form: React.FC<FormProps> = React.memo(props => {
handleAddNew={handleAddNew}
addNewField={section.addNewField}
handleRemove={handleRemove}
removeOption={section.removeOption}
/>
);
})}
Expand Down
4 changes: 3 additions & 1 deletion src/webapp/components/form/FormSection.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ type FormSectionProps = {
handleAddNew?: () => void;
addNewField?: AddNewFieldState;
handleRemove?: (id: string) => void;
removeOption?: boolean;
};

export const FormSection: React.FC<FormSectionProps> = React.memo(
Expand All @@ -41,6 +42,7 @@ export const FormSection: React.FC<FormSectionProps> = React.memo(
handleAddNew,
addNewField,
handleRemove,
removeOption = false,
}) => {
return (
<FormSectionContainer>
Expand Down Expand Up @@ -91,7 +93,7 @@ export const FormSection: React.FC<FormSectionProps> = React.memo(
);
})}

{handleRemove && (
{removeOption && handleRemove && (
<ButtonContainer>
<Button onClick={() => handleRemove(id)}>Remove</Button>
</ButtonContainer>
Expand Down
2 changes: 1 addition & 1 deletion src/webapp/components/form/FormSectionsState.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ export type FormSectionState = {
subsections?: FormSectionState[];
onClickInfo?: (id: string) => void;
addNewField?: AddNewFieldState;
onRemove?: () => void;
removeOption?: boolean;
};

// HELPERS:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -300,6 +300,7 @@ export function mapSingleIncidentResponseActionToInitialFormState(
verificationOptions: verificationOptions,
},
isIncidentManager: isIncidentManager,
isSingleIncidentResponseAction: true,
index: 0,
});

Expand All @@ -323,8 +324,15 @@ function getResponseActionSection(options: {
};
isIncidentManager: boolean;
index: number;
isSingleIncidentResponseAction?: boolean;
}) {
const { incidentResponseAction, options: formOptions, index, isIncidentManager } = options;
const {
incidentResponseAction,
options: formOptions,
index,
isIncidentManager,
isSingleIncidentResponseAction,
} = options;
const { searchAssignROOptions, statusOptions, verificationOptions } = formOptions;

const responseActionSection: FormSectionState = {
Expand Down Expand Up @@ -420,6 +428,7 @@ function getResponseActionSection(options: {
disabled: false,
},
],
removeOption: isSingleIncidentResponseAction ? false : true,
};

return responseActionSection;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -834,7 +834,7 @@ function getRiskAssessmentCustomQuestionSection(
width: "100%",
},
],

removeOption: true,
direction: "row",
subsections: [],
};
Expand Down

0 comments on commit 1a5e33a

Please sign in to comment.