import React from "react";
import { Dropdown as MuiDropdown } from "../../src/components/ui/DropdownMui";
import { Checkbox, FormControlLabel, FormGroup, MenuItem, Stack, TextField } from "@mui/material";
import { AddButton } from "../../src/components/ui/buttons/AddButton";
import { RemoveButton } from "../../src/components/ui/buttons/RemoveButton";
import { KeyValueForm } from "../../src/components/recorder/KeyValueForm";
import { WarningText } from "../../src/components/ui/texts";
interface DisplayConditionSettingsProps {
whereProp: string;
additionalSettings: string;
setAdditionalSettings: (value: any) => void;
newValue: any;
setNewValue: (value: any) => void;
keyValueFormRef: React.RefObject<{ getObject: () => object }>;
whereKeys: string[];
checked: boolean[];
setChecked: (value: boolean[]) => void;
}
export const DisplayConditionSettings = (
{ whereProp, setAdditionalSettings, additionalSettings,
setNewValue, newValue, keyValueFormRef, whereKeys, checked, setChecked }
: DisplayConditionSettingsProps) => {
switch (whereProp) {
case 'url':
return (
setAdditionalSettings(e.target.value)}>
{additionalSettings ? setNewValue(e.target.value)}
value={newValue}
/> : null}
)
case 'selectors':
return (
{
newValue.map((selector: string, index: number) => {
return setNewValue([
...newValue.slice(0, index),
e.target.value,
...newValue.slice(index + 1)
])} />
})
}
setNewValue([...newValue, ''])} />
{
const arr = newValue;
arr.splice(-1);
setNewValue([...arr]);
}} />
)
case 'cookies':
return
case 'before':
return setNewValue(e.target.value)}
/>
case 'after':
return setNewValue(e.target.value)}
/>
case 'boolean':
return (
setAdditionalSettings(e.target.value)}>
{
whereKeys.map((key: string, index: number) => {
return (
setChecked([
...checked.slice(0, index),
!checked[index],
...checked.slice(index + 1)
])}
key={`checkbox-${key}-${index}`}
/>
} label={key} key={`control-label-form-${key}-${index}`} />
)
})
}
Choose at least 2 where conditions. Nesting of boolean operators
is possible by adding more conditions.
)
default:
return null;
}
}