Projects STRLCPY opencti Commits 4ccfd360
🤬
  • ■ ■ ■ ■ ■ ■
    opencti-platform/opencti-front/src/components/SelectField.js
    1 1  import React from 'react';
    2 2  import { isNil } from 'ramda';
    3  -import { useField } from 'formik';
     3 +import { getIn, useField } from 'formik';
    4 4  import MuiSelect from '@mui/material/Select';
    5 5  import InputLabel from '@mui/material/InputLabel';
    6 6  import FormControl from '@mui/material/FormControl';
    7 7  import FormHelperText from '@mui/material/FormHelperText';
    8  -import { fieldToSelect } from 'formik-mui';
     8 + 
     9 +const fieldToSelect = ({
     10 + disabled,
     11 + field: { onBlur: _onBlur, onChange: fieldOnChange, ...field },
     12 + form: { isSubmitting, touched, errors, setTouched, setFieldValue },
     13 + onClose,
     14 + ...props
     15 +}) => {
     16 + const fieldError = getIn(errors, field.name);
     17 + const showError = getIn(touched, field.name) && !!fieldError;
     18 + return {
     19 + disabled: disabled ?? isSubmitting,
     20 + error: showError,
     21 + formError: showError ? fieldError : undefined,
     22 + onBlur: () => {},
     23 + onChange: fieldOnChange ?? (() => {}),
     24 + onClose: onClose ?? (async (e) => {
     25 + const { dataset } = e.target;
     26 + if (dataset && dataset.value) {
     27 + await setFieldValue(field.name, dataset.value);
     28 + }
     29 + setTouched(true);
     30 + }),
     31 + ...field,
     32 + ...props,
     33 + };
     34 +};
    9 35   
    10 36  const SelectField = (props) => {
    11 37   const {
    skipped 67 lines
Please wait...
Page is in error, reload to recover