Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixed config bug #121

Merged
merged 1 commit into from
Aug 11, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 0 additions & 5 deletions frontend/src/components/DefenceBox/DefenceBox.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,6 @@ function DefenceBox({ triggeredDefences }: { triggeredDefences: string[] }) {

// 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 @@ -99,10 +98,6 @@ function DefenceBox({ triggeredDefences }: { triggeredDefences: string[] }) {
});
};

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