diff --git a/packages/console/src/pages/ApplicationDetails/components/DeleteForm/index.module.scss b/packages/console/src/pages/ApplicationDetails/components/DeleteForm/index.module.scss new file mode 100644 index 000000000..9ff74c268 --- /dev/null +++ b/packages/console/src/pages/ApplicationDetails/components/DeleteForm/index.module.scss @@ -0,0 +1,24 @@ +@use '@/scss/underscore' as _; + +.content { + > :not(:first-child) { + margin-top: _.unit(6); + } + + .description { + font: var(--font-body-2); + } + + .hightlight { + color: var(--color-primary-50); + } +} + +.actions { + display: flex; + justify-content: flex-end; + + > :not(:first-child) { + margin-left: _.unit(4); + } +} diff --git a/packages/console/src/pages/ApplicationDetails/components/DeleteForm/index.tsx b/packages/console/src/pages/ApplicationDetails/components/DeleteForm/index.tsx new file mode 100644 index 000000000..48a1023aa --- /dev/null +++ b/packages/console/src/pages/ApplicationDetails/components/DeleteForm/index.tsx @@ -0,0 +1,85 @@ +import React, { useState } from 'react'; +import { toast } from 'react-hot-toast'; +import { Trans, useTranslation } from 'react-i18next'; +import { useNavigate } from 'react-router-dom'; + +import Button from '@/components/Button'; +import ModalLayout from '@/components/ModalLayout'; +import TextInput from '@/components/TextInput'; +import useApi from '@/hooks/use-api'; + +import * as styles from './index.module.scss'; + +type Props = { + id: string; + name: string; + onClose: () => void; +}; + +const DeleteForm = ({ id, name, onClose }: Props) => { + const api = useApi(); + const { t } = useTranslation(undefined, { keyPrefix: 'admin_console' }); + + const navigate = useNavigate(); + + const [inputName, setInputName] = useState(''); + const [loading, setLoading] = useState(false); + + const inputMismatched = inputName !== name; + + const handleDelete = async () => { + setLoading(true); + + try { + await api.delete(`/api/applications/${id}`); + onClose(); + navigate(`/applications`); + toast.success(t('application_details.application_deleted', { name })); + } finally { + setLoading(false); + } + }; + + return ( + +