chore: lint

This commit is contained in:
karishmas6
2024-08-30 03:19:56 +05:30
parent 38042adbc0
commit 19f840259e

View File

@@ -29,59 +29,60 @@ export const InterpretationButtons = ({ enableStepping }: InterpretationButtonsP
actionType: string, actionType: string,
selector: string, selector: string,
action: string, action: string,
open:boolean open: boolean
}>({ pair: null, actionType: '', selector: '', action: '', open: false} ); }>({ pair: null, actionType: '', selector: '', action: '', open: false });
const { socket } = useSocketStore(); const { socket } = useSocketStore();
const { notify } = useGlobalInfoStore(); const { notify } = useGlobalInfoStore();
const finishedHandler = useCallback(() => { const finishedHandler = useCallback(() => {
setInfo({...info, isPaused: false}); setInfo({ ...info, isPaused: false });
enableStepping(false); enableStepping(false);
}, [info, enableStepping]); }, [info, enableStepping]);
const breakpointHitHandler = useCallback(() => { const breakpointHitHandler = useCallback(() => {
setInfo({running: false, isPaused: true}); setInfo({ running: false, isPaused: true });
notify('warning', 'Please restart the interpretation, after updating the recording'); notify('warning', 'Please restart the interpretation, after updating the recording');
enableStepping(true); enableStepping(true);
}, [info, enableStepping]); }, [info, enableStepping]);
const decisionHandler = useCallback( const decisionHandler = useCallback(
({pair, actionType, lastData} ({ pair, actionType, lastData }
: {pair: WhereWhatPair | null, actionType: string, lastData: { selector: string, action: string }}) => { : { pair: WhereWhatPair | null, actionType: string, lastData: { selector: string, action: string } }) => {
const {selector, action} = lastData; const { selector, action } = lastData;
setDecisionModal((prevState) => { setDecisionModal((prevState) => {
return { return {
pair, pair,
actionType, actionType,
selector, selector,
action, action,
open: true, open: true,
} }
}) })
}, [decisionModal]); }, [decisionModal]);
const handleDecision = (decision: boolean) => { const handleDecision = (decision: boolean) => {
const {pair, actionType} = decisionModal; const { pair, actionType } = decisionModal;
socket?.emit('decision', {pair, actionType, decision}); socket?.emit('decision', { pair, actionType, decision });
setDecisionModal({pair: null, actionType: '', selector: '', action: '', open: false}); setDecisionModal({ pair: null, actionType: '', selector: '', action: '', open: false });
} }
const handleDescription = () => { const handleDescription = () => {
switch (decisionModal.actionType){ switch (decisionModal.actionType) {
case 'customAction': case 'customAction':
return ( return (
<React.Fragment> <React.Fragment>
<Typography> <Typography>
Do you want to use the previously recorded selector Do you want to use the previously recorded selector
as a where condition for matching the action? as a where condition for matching the action?
</Typography> </Typography>
<Box style={{marginTop: '4px'}}> <Box style={{ marginTop: '4px' }}>
[previous action: <b>{decisionModal.action}</b>] [previous action: <b>{decisionModal.action}</b>]
<pre>{decisionModal.selector}</pre> <pre>{decisionModal.selector}</pre>
</Box> </Box>
</React.Fragment>); </React.Fragment>);
default: return null;} default: return null;
}
} }
useEffect(() => { useEffect(() => {
@@ -100,12 +101,12 @@ export const InterpretationButtons = ({ enableStepping }: InterpretationButtonsP
const handlePlay = async () => { const handlePlay = async () => {
if (info.isPaused) { if (info.isPaused) {
socket?.emit("resume"); socket?.emit("resume");
setInfo({running: true, isPaused: false}); setInfo({ running: true, isPaused: false });
enableStepping(false); enableStepping(false);
} else { } else {
setInfo({...info, running: true}); setInfo({ ...info, running: true });
const finished = await interpretCurrentRecording(); const finished = await interpretCurrentRecording();
setInfo({...info, running: false}); setInfo({ ...info, running: false });
if (finished) { if (finished) {
notify('info', 'Interpretation finished'); notify('info', 'Interpretation finished');
} else { } else {
@@ -131,45 +132,45 @@ export const InterpretationButtons = ({ enableStepping }: InterpretationButtonsP
return ( return (
<Stack direction="row" spacing={3} <Stack direction="row" spacing={3}
sx={{ marginTop: '10px', marginBottom: '5px', justifyContent: 'space-evenly',}} > sx={{ marginTop: '10px', marginBottom: '5px', justifyContent: 'space-evenly', }} >
<IconButton disabled={!info.running} sx={{display:'grid', '&:hover': { color: '#1976d2', backgroundColor: 'transparent' }}} <IconButton disabled={!info.running} sx={{ display: 'grid', '&:hover': { color: '#1976d2', backgroundColor: 'transparent' } }}
aria-label="pause" size="small" title="Pause" onClick={handlePause}> aria-label="pause" size="small" title="Pause" onClick={handlePause}>
<PauseCircle sx={{ fontSize: 30, justifySelf:'center' }}/> <PauseCircle sx={{ fontSize: 30, justifySelf: 'center' }} />
Pause Pause
</IconButton> </IconButton>
<IconButton disabled={info.running} sx={{display:'grid', '&:hover': { color: '#1976d2', backgroundColor: 'transparent' }}} <IconButton disabled={info.running} sx={{ display: 'grid', '&:hover': { color: '#1976d2', backgroundColor: 'transparent' } }}
aria-label="play" size="small" title="Play" onClick={handlePlay}> aria-label="play" size="small" title="Play" onClick={handlePlay}>
<PlayCircle sx={{ fontSize: 30, justifySelf:'center' }}/> <PlayCircle sx={{ fontSize: 30, justifySelf: 'center' }} />
{info.isPaused ? 'Resume' : 'Start'} {info.isPaused ? 'Resume' : 'Start'}
</IconButton> </IconButton>
<IconButton disabled={!info.running && !info.isPaused} sx={{display:'grid', '&:hover': { color: '#1976d2', backgroundColor: 'transparent' }}} <IconButton disabled={!info.running && !info.isPaused} sx={{ display: 'grid', '&:hover': { color: '#1976d2', backgroundColor: 'transparent' } }}
aria-label="stop" size="small" title="Stop" onClick={handleStop}> aria-label="stop" size="small" title="Stop" onClick={handleStop}>
<StopCircle sx={{ fontSize: 30, justifySelf:'center' }}/> <StopCircle sx={{ fontSize: 30, justifySelf: 'center' }} />
Stop Stop
</IconButton> </IconButton>
<GenericModal onClose={() => {}} isOpen={decisionModal.open} canBeClosed={false} <GenericModal onClose={() => { }} isOpen={decisionModal.open} canBeClosed={false}
modalStyle={{ modalStyle={{
position: 'absolute', position: 'absolute',
top: '50%', top: '50%',
left: '50%', left: '50%',
transform: 'translate(-50%, -50%)', transform: 'translate(-50%, -50%)',
width: 500, width: 500,
background: 'white', background: 'white',
border: '2px solid #000', border: '2px solid #000',
boxShadow: '24', boxShadow: '24',
height:'fit-content', height: 'fit-content',
display:'block', display: 'block',
overflow:'scroll', overflow: 'scroll',
padding: '5px 25px 10px 25px', padding: '5px 25px 10px 25px',
}}> }}>
<div style={{padding: '15px'}}> <div style={{ padding: '15px' }}>
<HelpIcon/> <HelpIcon />
{ {
handleDescription() handleDescription()
} }
<div style={{float: 'right'}}> <div style={{ float: 'right' }}>
<Button onClick={() => handleDecision(true)} color='success'>yes</Button> <Button onClick={() => handleDecision(true)} color='success'>yes</Button>
<Button onClick={() => handleDecision(false)} color='error'>no</Button> <Button onClick={() => handleDecision(false)} color='error'>no</Button>
</div> </div>
</div> </div>
</GenericModal> </GenericModal>