import React from 'react'; import PropTypes from 'prop-types'; import { ProjectCategory, ProjectCategoryCopy } from 'shared/constants/projects'; import toast from 'shared/utils/toast'; import useApi from 'shared/hooks/api'; import { Form, Breadcrumbs } from 'shared/components'; import { FormCont, FormHeading, FormElement, ActionButton } from './Styles'; const propTypes = { project: PropTypes.object.isRequired, fetchProject: PropTypes.func.isRequired, }; const ProjectSettings = ({ project, fetchProject }) => { const [{ isUpdating }, updateProject] = useApi.put('/project'); return (
({ name: get('name'), url: get('url'), category: get('category'), description: get('description'), }))} validations={{ name: [Form.is.required(), Form.is.maxLength(100)], url: Form.is.url(), category: Form.is.required(), }} onSubmit={async (values, form) => { try { await updateProject(values); await fetchProject(); toast.success('Changes have been saved successfully.'); } catch (error) { Form.handleAPIError(error, form); } }} > Project Details Save changes
); }; const categoryOptions = Object.values(ProjectCategory).map(category => ({ value: category, label: ProjectCategoryCopy[category], })); ProjectSettings.propTypes = propTypes; export default ProjectSettings;