chore: lint

This commit is contained in:
amhsirak
2025-01-09 19:17:10 +05:30
parent 1842ebbda6
commit c52c10a132

View File

@@ -56,30 +56,30 @@ export const PairEditForm: FC<PairEditFormProps> = (
event.preventDefault(); event.preventDefault();
let whereFromPair, whatFromPair; let whereFromPair, whatFromPair;
// validate where // validate where
whereFromPair = { whereFromPair = {
where: pairProps.where && pairProps.where !== '{"url":"","selectors":[""] }' where: pairProps.where && pairProps.where !== '{"url":"","selectors":[""] }'
? JSON.parse(pairProps.where) ? JSON.parse(pairProps.where)
: {}, : {},
what: [], what: [],
}; };
const validationError = Preprocessor.validateWorkflow({workflow: [whereFromPair]}); const validationError = Preprocessor.validateWorkflow({ workflow: [whereFromPair] });
setErrors({ ...errors, where: null }); setErrors({ ...errors, where: null });
if (validationError) { if (validationError) {
setErrors({ ...errors, where: validationError.message }); setErrors({ ...errors, where: validationError.message });
return; return;
} }
// validate what // validate what
whatFromPair = { whatFromPair = {
where: {}, where: {},
what: pairProps.what && pairProps.what !== '[{"action":"","args":[""] }]' what: pairProps.what && pairProps.what !== '[{"action":"","args":[""] }]'
? JSON.parse(pairProps.what): [], ? JSON.parse(pairProps.what) : [],
}; };
const validationErrorWhat = Preprocessor.validateWorkflow({workflow: [whatFromPair]}); const validationErrorWhat = Preprocessor.validateWorkflow({ workflow: [whatFromPair] });
setErrors({ ...errors, "what": null }); setErrors({ ...errors, "what": null });
if (validationErrorWhat) { if (validationErrorWhat) {
setErrors({ ...errors, what: validationErrorWhat.message }); setErrors({ ...errors, what: validationErrorWhat.message });
return; return;
} }
//validate index //validate index
const index = parseInt(pairProps?.index, 10); const index = parseInt(pairProps?.index, 10);
if (index > (numberOfPairs + 1)) { if (index > (numberOfPairs + 1)) {
@@ -99,18 +99,18 @@ export const PairEditForm: FC<PairEditFormProps> = (
} else { } else {
setErrors({ ...errors, index: '' }); setErrors({ ...errors, index: '' });
} }
// submit the pair // submit the pair
onSubmitOfPair(pairProps.id onSubmitOfPair(pairProps.id
? { ? {
id: pairProps.id, id: pairProps.id,
where: whereFromPair?.where || {}, where: whereFromPair?.where || {},
what: whatFromPair?.what || [], what: whatFromPair?.what || [],
} }
: { : {
where: whereFromPair?.where || {}, where: whereFromPair?.where || {},
what: whatFromPair?.what || [], what: whatFromPair?.what || [],
} }
, index); , index);
}; };
return ( return (
@@ -122,33 +122,33 @@ export const PairEditForm: FC<PairEditFormProps> = (
marginTop: "36px", marginTop: "36px",
}} }}
> >
<Typography sx={{marginBottom:'30px'}} variant='h5'>Raw pair edit form:</Typography> <Typography sx={{ marginBottom: '30px' }} variant='h5'>Raw pair edit form:</Typography>
<TextField sx={{ <TextField sx={{
display:"block", display: "block",
marginBottom: "20px" marginBottom: "20px"
}} id="index" label="Index" type="number" }} id="index" label="Index" type="number"
InputProps={{ inputProps: { min: 1 } }} InputProps={{ inputProps: { min: 1 } }}
InputLabelProps={{ InputLabelProps={{
shrink: true, shrink: true,
}} defaultValue={pairProps.index} }} defaultValue={pairProps.index}
onChange={handleInputChange} onChange={handleInputChange}
error={!!errors.index} helperText={errors.index} error={!!errors.index} helperText={errors.index}
required required
/> />
<TextField sx={{ <TextField sx={{
marginBottom: "20px" marginBottom: "20px"
}} id="id" label="Id" type="string" }} id="id" label="Id" type="string"
defaultValue={pairProps.id} defaultValue={pairProps.id}
onChange={handleInputChange} onChange={handleInputChange}
/> />
<TextField multiline sx={{marginBottom: "20px"}} <TextField multiline sx={{ marginBottom: "20px" }}
id="where" label="Where" variant="outlined" onChange={handleInputChange} id="where" label="Where" variant="outlined" onChange={handleInputChange}
defaultValue={ where || '{"url":"","selectors":[""]}' } defaultValue={where || '{"url":"","selectors":[""]}'}
error={!!errors.where} helperText={errors.where}/> error={!!errors.where} helperText={errors.where} />
<TextField multiline sx={{marginBottom: "20px"}} <TextField multiline sx={{ marginBottom: "20px" }}
id="what" label="What" variant="outlined" onChange={handleInputChange} id="what" label="What" variant="outlined" onChange={handleInputChange}
defaultValue={ what || '[{"action":"","args":[""]}]' } defaultValue={what || '[{"action":"","args":[""]}]'}
error={!!errors.what} helperText={errors.what}/> error={!!errors.what} helperText={errors.what} />
<Button <Button
type="submit" type="submit"
variant="contained" variant="contained"