diff --git a/packages/console/src/components/PermissionsTable/EditPermissionModal.tsx b/packages/console/src/components/PermissionsTable/EditPermissionModal.tsx new file mode 100644 index 00000000000..040a1e30330 --- /dev/null +++ b/packages/console/src/components/PermissionsTable/EditPermissionModal.tsx @@ -0,0 +1,79 @@ +import { type ScopeResponse } from '@logto/schemas'; +import { useForm } from 'react-hook-form'; +import { useTranslation } from 'react-i18next'; +import ReactModal from 'react-modal'; + +import Button from '@/ds-components/Button'; +import FormField from '@/ds-components/FormField'; +import ModalLayout from '@/ds-components/ModalLayout'; +import TextInput from '@/ds-components/TextInput'; +import * as modalStyles from '@/scss/modal.module.scss'; +import { trySubmitSafe } from '@/utils/form'; + +type Props = { + data: ScopeResponse; + onClose: () => void; + onSubmit: (scope: ScopeResponse) => Promise; +}; + +function EditPermissionModal({ data, onClose, onSubmit }: Props) { + const { t } = useTranslation(undefined, { keyPrefix: 'admin_console' }); + + const { + handleSubmit, + register, + formState: { isSubmitting }, + } = useForm({ defaultValues: data }); + + const onSubmitHandler = handleSubmit( + trySubmitSafe(async (formData) => { + await onSubmit({ ...data, ...formData }); + onClose(); + }) + ); + + return ( + { + onClose(); + }} + > + +