chore: lint

This commit is contained in:
amhsirak
2025-01-09 19:16:58 +05:30
parent cc369c5332
commit 1842ebbda6

View File

@@ -51,26 +51,26 @@ export const PairDetail = ({ pair, index }: PairDetailProps) => {
}
}, [pair])
const handleChangeValue = (value: any, where: boolean, keys: (string|number)[]) => {
const handleChangeValue = (value: any, where: boolean, keys: (string | number)[]) => {
// a moving reference to internal objects within pair.where or pair.what
let schema: any = where ? pair?.where : pair?.what;
const length = keys.length;
for(let i = 0; i < length-1; i++) {
for (let i = 0; i < length - 1; i++) {
const elem = keys[i];
if( !schema[elem] ) schema[elem] = {}
if (!schema[elem]) schema[elem] = {}
schema = schema[elem];
}
schema[keys[length-1]] = value;
schema[keys[length - 1]] = value;
if (pair && socket) {
socket.emit('updatePair', {index: index-1, pair: pair});
socket.emit('updatePair', { index: index - 1, pair: pair });
}
setRerender(!rerender);
}
const DisplayValueContent = (value: any, keys: (string|number)[], where: boolean = true) => {
switch (typeof(value)) {
const DisplayValueContent = (value: any, keys: (string | number)[], where: boolean = true) => {
switch (typeof (value)) {
case 'string':
return <TextField
size='small'
@@ -108,23 +108,23 @@ export const PairDetail = ({ pair, index }: PairDetailProps) => {
return DisplayValueContent(element, [...keys, index], where);
})
}
<AddButton handleClick={()=> {
let prevValue:any = where ? pair?.where : pair?.what;
<AddButton handleClick={() => {
let prevValue: any = where ? pair?.where : pair?.what;
for (const key of keys) {
prevValue = prevValue[key];
}
handleChangeValue([...prevValue, ''], where, keys);
setRerender(!rerender);
}} hoverEffect={false}/>
<RemoveButton handleClick={()=> {
let prevValue:any = where ? pair?.where : pair?.what;
}} hoverEffect={false} />
<RemoveButton handleClick={() => {
let prevValue: any = where ? pair?.where : pair?.what;
for (const key of keys) {
prevValue = prevValue[key];
}
prevValue.splice(-1);
handleChangeValue(prevValue, where, keys);
setRerender(!rerender);
}}/>
}} />
</React.Fragment>
)
} else {
@@ -136,11 +136,10 @@ export const PairDetail = ({ pair, index }: PairDetailProps) => {
key={`tree-view-nested-${keys.join('-')}-${where}`}
>
{
Object.keys(value).map((key2, index) =>
{
Object.keys(value).map((key2, index) => {
return (
<TreeItem nodeId={`${key2}-${index}`} label={`${key2}:`} key={`${key2}-${index}`}>
{ DisplayValueContent(value[key2], [...keys, key2], where) }
{DisplayValueContent(value[key2], [...keys, key2], where)}
</TreeItem>
)
})
@@ -157,25 +156,25 @@ export const PairDetail = ({ pair, index }: PairDetailProps) => {
return (
<React.Fragment>
{ pair &&
{pair &&
<React.Fragment>
<AddWhatCondModal isOpen={addWhatCondOpen} onClose={() => setAddWhatCondOpen(false)}
pair={pair} index={index}/>
pair={pair} index={index} />
<AddWhereCondModal isOpen={addWhereCondOpen} onClose={() => setAddWhereCondOpen(false)}
pair={pair} index={index}/>
pair={pair} index={index} />
</React.Fragment>
}
{
pairIsSelected
? (
<div style={{padding: '10px', overflow: 'hidden'}}>
<div style={{ padding: '10px', overflow: 'hidden' }}>
<Typography>Pair number: {index}</Typography>
<TextField
size='small'
label='id'
onChange={(e) => {
if (pair && socket) {
socket.emit('updatePair', {index: index-1, pair: pair});
socket.emit('updatePair', { index: index - 1, pair: pair });
pair.id = e.target.value;
}
}}
@@ -193,16 +192,16 @@ export const PairDetail = ({ pair, index }: PairDetailProps) => {
<Typography>Where</Typography>
<Tooltip title='Add where condition' placement='right'>
<div>
<AddButton handleClick={()=> {
<AddButton handleClick={() => {
setAddWhereCondOpen(true);
}} style={{color:'rgba(0, 0, 0, 0.54)', background:'transparent'}}/>
}} style={{ color: 'rgba(0, 0, 0, 0.54)', background: 'transparent' }} />
</div>
</Tooltip>
</Stack>
{(collapseWhere && pair && pair.where)
?
<React.Fragment>
{ Object.keys(pair.where).map((key, index) => {
{Object.keys(pair.where).map((key, index) => {
return (
<TreeView
expanded={expanded}
@@ -237,16 +236,16 @@ export const PairDetail = ({ pair, index }: PairDetailProps) => {
<Tooltip title='Add what condition' placement='right'>
<div>
<AddButton handleClick={()=> {
<AddButton handleClick={() => {
setAddWhatCondOpen(true);
}} style={{color:'rgba(0, 0, 0, 0.54)', background:'transparent'}}/>
}} style={{ color: 'rgba(0, 0, 0, 0.54)', background: 'transparent' }} />
</div>
</Tooltip>
</Stack>
{(collapseWhat && pair && pair.what)
?(
? (
<React.Fragment>
{ Object.keys(pair.what).map((key, index) => {
{Object.keys(pair.what).map((key, index) => {
return (
<TreeView
defaultCollapseIcon={<ExpandMoreIcon />}
@@ -260,12 +259,12 @@ export const PairDetail = ({ pair, index }: PairDetailProps) => {
DisplayValueContent(pair.what[key], [key], false)
}
<Tooltip title='remove action' placement='left'>
<div style={{float:'right'}}>
<div style={{ float: 'right' }}>
<CloseButton handleClick={() => {
//@ts-ignore
pair.what.splice(key, 1);
setRerender(!rerender);
}}/>
}} />
</div>
</Tooltip>
</TreeItem>
@@ -279,7 +278,7 @@ export const PairDetail = ({ pair, index }: PairDetailProps) => {
</div>
)
: <WarningText>
<NotificationImportantIcon color="warning"/>
<NotificationImportantIcon color="warning" />
No pair from the left side panel was selected.
</WarningText>
}
@@ -292,19 +291,19 @@ interface CollapseButtonProps {
isCollapsed?: boolean;
}
const CollapseButton = ({handleClick, isCollapsed } : CollapseButtonProps) => {
const CollapseButton = ({ handleClick, isCollapsed }: CollapseButtonProps) => {
return (
<IconButton aria-label="add" size={"small"} onClick={handleClick}>
{ isCollapsed ? <KeyboardArrowDown/> : <KeyboardArrowUp/>}
{isCollapsed ? <KeyboardArrowDown /> : <KeyboardArrowUp />}
</IconButton>
);
}
const CloseButton = ({handleClick } : CollapseButtonProps) => {
const CloseButton = ({ handleClick }: CollapseButtonProps) => {
return (
<IconButton aria-label="add" size={"small"} onClick={handleClick}
sx={{'&:hover': { color: '#1976d2', backgroundColor: 'white' }}}>
<Close/>
sx={{ '&:hover': { color: '#1976d2', backgroundColor: 'white' } }}>
<Close />
</IconButton>
);
}