Skip to content

Commit

Permalink
Fixed config bug (#121)
Browse files Browse the repository at this point in the history
  • Loading branch information
gsproston-scottlogic authored Aug 11, 2023
1 parent b462409 commit 50cafd6
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 19 deletions.
5 changes: 0 additions & 5 deletions frontend/src/components/DefenceBox/DefenceBox.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,6 @@ function DefenceBox({

// update triggered defences
useEffect(() => {
console.log("updating triggered defences: ", triggeredDefences);
// update state
const newDefences = defenceDetails.map((defenceDetail) => {
defenceDetail.isTriggered = triggeredDefences.includes(defenceDetail.id);
Expand Down Expand Up @@ -109,10 +108,6 @@ function DefenceBox({
});
};

useEffect(() => {
console.log("defenceDetails: ", defenceDetails);
}, [defenceDetails]);

return (
<div id="strategy-box">
{defenceDetails.map((defenceDetail, index) => {
Expand Down
5 changes: 3 additions & 2 deletions frontend/src/components/DefenceBox/DefenceConfiguration.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,10 @@ function DefenceConfiguration(
setConfigurationValue: (configId: string, value: string) => void;
}
) {
const setConfiguration = (event: React.KeyboardEvent<HTMLInputElement>) => {
const setConfiguration = (event: React.KeyboardEvent<HTMLDivElement>) => {
if (event.key === "Enter") {
setConfigurationValue(config.id, event.currentTarget.value);
const value = event.currentTarget.innerText.trim();
setConfigurationValue(config.id, value);
}
};

Expand Down
24 changes: 13 additions & 11 deletions frontend/src/components/DefenceBox/DefenceMechanism.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -77,17 +77,19 @@ function DefenceMechanism({
{isInfoBoxVisible ? (
<div className="strategy-mechanism-info-box">
<div>{defenceDetail.info}</div>
<div className="defence-mechanism-config">
{defenceDetail.config?.map((config, index) => {
return (
<DefenceConfiguration
key={config.id}
config={config}
setConfigurationValue={setConfigurationValue}
/>
);
})}
</div>
{defenceDetail.config ? (
<div className="defence-mechanism-config">
{defenceDetail.config.map((config, index) => {
return (
<DefenceConfiguration
key={config.id}
config={config}
setConfigurationValue={setConfigurationValue}
/>
);
})}
</div>
) : null}
</div>
) : null}
</div>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,9 @@ function ModelSelectionBox() {
placeholder={modelInUse}
>
{chatModelOptions.map((model) => (
<option value={model}>{model}</option>
<option key={model} value={model}>
{model}
</option>
))}
;
</select>
Expand Down

0 comments on commit 50cafd6

Please sign in to comment.