import React from 'react'; import PropTypes from 'prop-types'; import { Modal, ModalHeader, ModalSection, ModalFooter } from 'strapi-helper-plugin'; import { useIntl } from 'react-intl'; import { Button, Label, InputText } from '@buffetjs/core'; import Select from 'react-select'; import { Formik } from 'formik'; import { object, string } from 'yup'; import useEditLocale from '../../hooks/useEditLocale'; import { getTrad } from '../../utils'; const ModalEdit = ({ localeToEdit, onClose, locales }) => { const { isEditing, editLocale } = useEditLocale(); const { formatMessage } = useIntl(); const isOpened = Boolean(localeToEdit); const handleSubmit = ({ displayName }) => { const id = localeToEdit.id; const name = displayName || localeToEdit.code; return editLocale(id, name).then(onClose); }; let options = []; let defaultOption; if (localeToEdit) { options = locales.map(locale => ({ label: locale.code, value: locale.id })); defaultOption = options.find(option => option.value === localeToEdit.id); } return ( {({ values, handleSubmit, handleChange, errors }) => (