chore: lint
This commit is contained in:
@@ -18,15 +18,15 @@ interface AddWhereCondModalProps {
|
|||||||
index: number;
|
index: number;
|
||||||
}
|
}
|
||||||
|
|
||||||
export const AddWhereCondModal = ({isOpen, onClose, pair, index}: AddWhereCondModalProps) => {
|
export const AddWhereCondModal = ({ isOpen, onClose, pair, index }: AddWhereCondModalProps) => {
|
||||||
const [whereProp, setWhereProp] = React.useState<string>('');
|
const [whereProp, setWhereProp] = React.useState<string>('');
|
||||||
const [additionalSettings, setAdditionalSettings] = React.useState<string>('');
|
const [additionalSettings, setAdditionalSettings] = React.useState<string>('');
|
||||||
const [newValue, setNewValue] = React.useState<any>('');
|
const [newValue, setNewValue] = React.useState<any>('');
|
||||||
const [checked, setChecked] = React.useState<boolean[]>(new Array(Object.keys(pair.where).length).fill(false));
|
const [checked, setChecked] = React.useState<boolean[]>(new Array(Object.keys(pair.where).length).fill(false));
|
||||||
|
|
||||||
const keyValueFormRef = useRef<{getObject: () => object}>(null);
|
const keyValueFormRef = useRef<{ getObject: () => object }>(null);
|
||||||
|
|
||||||
const {socket} = useSocketStore();
|
const { socket } = useSocketStore();
|
||||||
|
|
||||||
const handlePropSelect = (event: SelectChangeEvent<string>) => {
|
const handlePropSelect = (event: SelectChangeEvent<string>) => {
|
||||||
setWhereProp(event.target.value);
|
setWhereProp(event.target.value);
|
||||||
@@ -40,7 +40,7 @@ export const AddWhereCondModal = ({isOpen, onClose, pair, index}: AddWhereCondMo
|
|||||||
const handleSubmit = () => {
|
const handleSubmit = () => {
|
||||||
switch (whereProp) {
|
switch (whereProp) {
|
||||||
case 'url':
|
case 'url':
|
||||||
if (additionalSettings === 'string'){
|
if (additionalSettings === 'string') {
|
||||||
pair.where.url = newValue;
|
pair.where.url = newValue;
|
||||||
} else {
|
} else {
|
||||||
pair.where.url = { $regex: newValue };
|
pair.where.url = { $regex: newValue };
|
||||||
@@ -50,7 +50,7 @@ export const AddWhereCondModal = ({isOpen, onClose, pair, index}: AddWhereCondMo
|
|||||||
pair.where.selectors = newValue;
|
pair.where.selectors = newValue;
|
||||||
break;
|
break;
|
||||||
case 'cookies':
|
case 'cookies':
|
||||||
pair.where.cookies = keyValueFormRef.current?.getObject() as Record<string,string>
|
pair.where.cookies = keyValueFormRef.current?.getObject() as Record<string, string>
|
||||||
break;
|
break;
|
||||||
case 'before':
|
case 'before':
|
||||||
pair.where.$before = newValue;
|
pair.where.$before = newValue;
|
||||||
@@ -68,7 +68,8 @@ export const AddWhereCondModal = ({isOpen, onClose, pair, index}: AddWhereCondMo
|
|||||||
if (pair.where[Object.keys(pair.where)[i]]) {
|
if (pair.where[Object.keys(pair.where)[i]]) {
|
||||||
booleanArr.push({
|
booleanArr.push({
|
||||||
//@ts-ignore
|
//@ts-ignore
|
||||||
[Object.keys(pair.where)[i]]: pair.where[Object.keys(pair.where)[i]]});
|
[Object.keys(pair.where)[i]]: pair.where[Object.keys(pair.where)[i]]
|
||||||
|
});
|
||||||
}
|
}
|
||||||
deleteKeys.push(Object.keys(pair.where)[i]);
|
deleteKeys.push(Object.keys(pair.where)[i]);
|
||||||
}
|
}
|
||||||
@@ -86,7 +87,7 @@ export const AddWhereCondModal = ({isOpen, onClose, pair, index}: AddWhereCondMo
|
|||||||
setWhereProp('');
|
setWhereProp('');
|
||||||
setAdditionalSettings('');
|
setAdditionalSettings('');
|
||||||
setNewValue('');
|
setNewValue('');
|
||||||
socket?.emit('updatePair', {index: index-1, pair: pair});
|
socket?.emit('updatePair', { index: index - 1, pair: pair });
|
||||||
}
|
}
|
||||||
|
|
||||||
return (
|
return (
|
||||||
@@ -97,8 +98,8 @@ export const AddWhereCondModal = ({isOpen, onClose, pair, index}: AddWhereCondMo
|
|||||||
onClose();
|
onClose();
|
||||||
}} modalStyle={modalStyle}>
|
}} modalStyle={modalStyle}>
|
||||||
<div>
|
<div>
|
||||||
<Typography sx={{margin: '20px 0px'}}>Add where condition:</Typography>
|
<Typography sx={{ margin: '20px 0px' }}>Add where condition:</Typography>
|
||||||
<div style={{margin:'8px'}}>
|
<div style={{ margin: '8px' }}>
|
||||||
<MuiDropdown
|
<MuiDropdown
|
||||||
id="whereProp"
|
id="whereProp"
|
||||||
label="Condition"
|
label="Condition"
|
||||||
@@ -113,7 +114,7 @@ export const AddWhereCondModal = ({isOpen, onClose, pair, index}: AddWhereCondMo
|
|||||||
</MuiDropdown>
|
</MuiDropdown>
|
||||||
</div>
|
</div>
|
||||||
{whereProp ?
|
{whereProp ?
|
||||||
<div style={{margin: '8px'}}>
|
<div style={{ margin: '8px' }}>
|
||||||
<DisplayConditionSettings
|
<DisplayConditionSettings
|
||||||
whereProp={whereProp} additionalSettings={additionalSettings} setAdditionalSettings={setAdditionalSettings}
|
whereProp={whereProp} additionalSettings={additionalSettings} setAdditionalSettings={setAdditionalSettings}
|
||||||
newValue={newValue} setNewValue={setNewValue} checked={checked} setChecked={setChecked}
|
newValue={newValue} setNewValue={setNewValue} checked={checked} setChecked={setChecked}
|
||||||
@@ -145,7 +146,7 @@ export const modalStyle = {
|
|||||||
width: '30%',
|
width: '30%',
|
||||||
backgroundColor: 'background.paper',
|
backgroundColor: 'background.paper',
|
||||||
p: 4,
|
p: 4,
|
||||||
height:'fit-content',
|
height: 'fit-content',
|
||||||
display:'block',
|
display: 'block',
|
||||||
padding: '20px',
|
padding: '20px',
|
||||||
};
|
};
|
||||||
|
|||||||
Reference in New Issue
Block a user