/* eslint react/no-multi-comp:off */ import { useContext, useEffect, useState } from 'react'; import { Avatar, Link, Icon, IconButton, Button, LinearProgress, Typography, } from '@material-ui/core'; import { Link as LinkIcon } from '@material-ui/icons'; import ConditionallyRender from '../common/ConditionallyRender/ConditionallyRender'; // import { // formatFullDateTimeWithLocale, // formatDateWithLocale, // } from '../common/util'; import { UPDATE_APPLICATION } from '../providers/AccessProvider/permissions'; import ApplicationView from './ApplicationView'; import ApplicationUpdate from './ApplicationUpdate'; import TabNav from '../common/TabNav/TabNav'; import Dialogue from '../common/Dialogue'; import PageContent from '../common/PageContent'; import HeaderTitle from '../common/HeaderTitle'; import AccessContext from '../../contexts/AccessContext'; import useApplicationsApi from '../../hooks/api/actions/useApplicationsApi/useApplicationsApi'; import useApplication from '../../hooks/api/getters/useApplication/useApplication'; import { useHistory, useParams } from 'react-router-dom'; const EditApplication = () => { const history = useHistory(); const { name } = useParams<{ name: string }>(); const { refetchApplication, application } = useApplication(name); const { appName, url, description, icon = 'apps', createdAt } = application; const { hasAccess } = useContext(AccessContext); const { deleteApplication } = useApplicationsApi(); const [loading, setLoading] = useState(true); const [showDialog, setShowDialog] = useState(false); useEffect(() => { refetchApplication(); setLoading(false); // eslint-disable-next-line }, []); const toggleModal = () => { setShowDialog(!showDialog); }; // missing the settings hook (locale) //const formatDate = v => formatDateWithLocale(v, locale); const onDeleteApplication = async (evt: Event) => { evt.preventDefault(); await deleteApplication(appName); history.push('/applications'); }; const renderModal = () => ( ); const tabData = [ { label: 'Application overview', component: , }, { label: 'Edit application', component: , }, ]; if (loading) { return (

Loading...

); } else if (!application) { return

Application ({appName}) not found

; } return ( {icon || 'apps'} {appName} } actions={ <> } /> Delete } /> } /> } >
{description || ''} {/* // need to use formatDate once we have the useSettings hook ready */} Created: {createdAt}
{renderModal()} } />
); }; export default EditApplication;