0% found this document useful (0 votes)
30 views2 pages

React Generated Fields Widget

Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as RTF, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
30 views2 pages

React Generated Fields Widget

Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as RTF, PDF, TXT or read online on Scribd

/* eslint-disable @typescript-eslint/no-explicit-any */

import { Typography, Grid } from '@mui/material';


import { useTranslation } from 'react-i18next';
import { IInputParamemeters } from 'shared/atoms/RunQueryDialog';
import moment from 'moment';
import GeneratedField from '../GeneratedField/GeneratedField';

interface IGeneratedFieldsWidget {
parameters: string;
values: any;
onChange: (values: any) => void;
}

export const GeneratedFieldsWidget: [Link]<IGeneratedFieldsWidget>


= ({
parameters,
values,
onChange
}) => {
const parsedParams: IInputParamemeters = parameters &&
[Link](parameters);
const { t } = useTranslation();

return (
<>
<Typography
style={{
marginTop: '32px',
marginBottom: '12px',
color: '#637381'
}}
variant="subtitle2"
>
{[Link]}
</Typography>

{parsedParams && [Link] && (


<Typography variant="caption" style={{ marginBottom: '18px',
color: '#637381' }}>
{t('[Link]', {
interval: parsedParams?.maxInterval,
delimiter: parsedParams?.dateDelimiter
})}
</Typography>
)}

<Grid container spacing={3}>


{parsedParams?.[Link]((el, idx: number) => {
return (
<Grid item xs={6} key={idx}>
<GeneratedField
type={[Link]}
label={[Link]}
placeholder={[Link]}
fieldKey={[Link]}
key={[Link]}
inputProps={{ disabled: true }}

fieldValue={moment(values[[Link]]).subtract([Link],
'day')}
{...([Link] &&
[Link] !== null && {
maxDate:
moment(values[[Link] as keyof unknown]).add(
[Link],
[Link]
),
minDate:
moment(values[el?.configurations?.minDate?.field])
})}
disableFuture={true}
onChange={(ev, key): void => {
onChange({
...values,
[key]: ev
});
}}
/>
</Grid>
);
})}
</Grid>
</>
);
};

You might also like