import { SlideFade, Image, VStack, Flex, Divider, useDisclosure, useToast } from '@chakra-ui/react'; import React from 'react'; import { FiExternalLink } from 'react-icons/fi'; import { AppConfig } from '../../../core/types'; import { useAppsStore } from '../../../state/appsStore'; import { useSytemStore } from '../../../state/systemStore'; import AppActions from '../components/AppActions'; import InstallModal from '../components/InstallModal'; import StopModal from '../components/StopModal'; import UninstallModal from '../components/UninstallModal'; import UpdateModal from '../components/UpdateModal'; interface IProps { app: AppConfig; } const AppDetails: React.FC = ({ app }) => { const toast = useToast(); const installDisclosure = useDisclosure(); const uninstallDisclosure = useDisclosure(); const stopDisclosure = useDisclosure(); const updateDisclosure = useDisclosure(); const { install, update, uninstall, stop, start, fetchApp } = useAppsStore(); const { internalIp } = useSytemStore(); const handleError = (error: unknown) => { if (error instanceof Error) { toast({ title: 'Error', description: error.message, status: 'error', position: 'top', isClosable: true, }); fetchApp(app.id); } }; const handleInstallSubmit = async (values: Record) => { installDisclosure.onClose(); try { await install(app.id, values); } catch (error) { handleError(error); } }; const handleUnistallSubmit = async () => { uninstallDisclosure.onClose(); try { await uninstall(app.id); } catch (error) { handleError(error); } }; const handleStopSubmit = async () => { stopDisclosure.onClose(); try { await stop(app.id); } catch (error) { handleError(error); } }; const handleStartSubmit = async () => { try { await start(app.id); } catch (e: unknown) { handleError(e); } }; const handleUpdateSubmit = async (values: Record) => { try { await update(app.id, values); toast({ title: 'Success', description: 'App config updated successfully', position: 'top', status: 'success', }); updateDisclosure.onClose(); } catch (error) { handleError(error); } }; const handleOpen = () => { window.open(`http://${internalIp}:${app.port}`, '_blank'); }; return (
{app.name}

{app?.name}

{app?.short_desc}

{app.source && ( Source )}

By {app?.author}

{app?.description}

); }; export default AppDetails;