mirror of
https://github.com/logto-io/logto.git
synced 2025-01-06 20:40:08 -05:00
refactor(console): show confirm box when inviting a member as admin (#5649)
This commit is contained in:
parent
ad9f34e7ea
commit
79645d7b9d
5 changed files with 36 additions and 3 deletions
|
@ -1,5 +1,9 @@
|
||||||
@use '@/scss/underscore' as _;
|
@use '@/scss/underscore' as _;
|
||||||
|
|
||||||
|
.overlay {
|
||||||
|
z-index: 1000;
|
||||||
|
}
|
||||||
|
|
||||||
.content {
|
.content {
|
||||||
font: var(--font-body-2);
|
font: var(--font-body-2);
|
||||||
|
|
||||||
|
|
|
@ -50,8 +50,8 @@ function ConfirmModal({
|
||||||
<ReactModal
|
<ReactModal
|
||||||
shouldCloseOnEsc
|
shouldCloseOnEsc
|
||||||
isOpen={isOpen}
|
isOpen={isOpen}
|
||||||
className={modalStyles.content}
|
className={classNames(modalStyles.content)}
|
||||||
overlayClassName={modalStyles.overlay}
|
overlayClassName={classNames(modalStyles.overlay, styles.overlay)}
|
||||||
onRequestClose={onCancel}
|
onRequestClose={onCancel}
|
||||||
>
|
>
|
||||||
<ModalLayout
|
<ModalLayout
|
||||||
|
|
|
@ -60,6 +60,8 @@
|
||||||
font: var(--font-body-2);
|
font: var(--font-body-2);
|
||||||
background: transparent;
|
background: transparent;
|
||||||
flex: 1;
|
flex: 1;
|
||||||
|
padding: 0;
|
||||||
|
appearance: none;
|
||||||
|
|
||||||
&::placeholder {
|
&::placeholder {
|
||||||
color: var(--color-placeholder);
|
color: var(--color-placeholder);
|
||||||
|
|
|
@ -0,0 +1,11 @@
|
||||||
|
@use '@/scss/underscore' as _;
|
||||||
|
|
||||||
|
ul {
|
||||||
|
padding-inline-start: _.unit(6);
|
||||||
|
|
||||||
|
> li {
|
||||||
|
font: var(--font-body-2);
|
||||||
|
margin-block: _.unit(2);
|
||||||
|
padding-inline-start: _.unit(1);
|
||||||
|
}
|
||||||
|
}
|
|
@ -2,7 +2,7 @@ import { TenantRole } from '@logto/schemas';
|
||||||
import { useContext, useEffect, useMemo, useState } from 'react';
|
import { useContext, useEffect, useMemo, useState } from 'react';
|
||||||
import { Controller, FormProvider, useForm } from 'react-hook-form';
|
import { Controller, FormProvider, useForm } from 'react-hook-form';
|
||||||
import { toast } from 'react-hot-toast';
|
import { toast } from 'react-hot-toast';
|
||||||
import { useTranslation } from 'react-i18next';
|
import { Trans, useTranslation } from 'react-i18next';
|
||||||
import ReactModal from 'react-modal';
|
import ReactModal from 'react-modal';
|
||||||
|
|
||||||
import { useAuthedCloudApi } from '@/cloud/hooks/use-cloud-api';
|
import { useAuthedCloudApi } from '@/cloud/hooks/use-cloud-api';
|
||||||
|
@ -10,6 +10,7 @@ import { TenantsContext } from '@/contexts/TenantsProvider';
|
||||||
import FormField from '@/ds-components/FormField';
|
import FormField from '@/ds-components/FormField';
|
||||||
import ModalLayout from '@/ds-components/ModalLayout';
|
import ModalLayout from '@/ds-components/ModalLayout';
|
||||||
import Select, { type Option } from '@/ds-components/Select';
|
import Select, { type Option } from '@/ds-components/Select';
|
||||||
|
import { useConfirmModal } from '@/hooks/use-confirm-modal';
|
||||||
import * as modalStyles from '@/scss/modal.module.scss';
|
import * as modalStyles from '@/scss/modal.module.scss';
|
||||||
|
|
||||||
import InviteEmailsInput from '../InviteEmailsInput';
|
import InviteEmailsInput from '../InviteEmailsInput';
|
||||||
|
@ -17,6 +18,7 @@ import useEmailInputUtils from '../InviteEmailsInput/hooks';
|
||||||
import { type InviteMemberForm } from '../types';
|
import { type InviteMemberForm } from '../types';
|
||||||
|
|
||||||
import Footer from './Footer';
|
import Footer from './Footer';
|
||||||
|
import './index.module.scss';
|
||||||
|
|
||||||
type Props = {
|
type Props = {
|
||||||
isOpen: boolean;
|
isOpen: boolean;
|
||||||
|
@ -30,6 +32,7 @@ function InviteMemberModal({ isOpen, onClose }: Props) {
|
||||||
const [isLoading, setIsLoading] = useState(false);
|
const [isLoading, setIsLoading] = useState(false);
|
||||||
const cloudApi = useAuthedCloudApi();
|
const cloudApi = useAuthedCloudApi();
|
||||||
const { parseEmailOptions } = useEmailInputUtils();
|
const { parseEmailOptions } = useEmailInputUtils();
|
||||||
|
const { show } = useConfirmModal();
|
||||||
|
|
||||||
const formMethods = useForm<InviteMemberForm>({
|
const formMethods = useForm<InviteMemberForm>({
|
||||||
defaultValues: {
|
defaultValues: {
|
||||||
|
@ -61,6 +64,19 @@ function InviteMemberModal({ isOpen, onClose }: Props) {
|
||||||
);
|
);
|
||||||
|
|
||||||
const onSubmit = handleSubmit(async ({ emails, role }) => {
|
const onSubmit = handleSubmit(async ({ emails, role }) => {
|
||||||
|
if (role === TenantRole.Admin) {
|
||||||
|
const [result] = await show({
|
||||||
|
ModalContent: () => (
|
||||||
|
<Trans components={{ ul: <ul />, li: <li /> }}>{t('assign_admin_confirm')}</Trans>
|
||||||
|
),
|
||||||
|
confirmButtonText: 'general.confirm',
|
||||||
|
});
|
||||||
|
|
||||||
|
if (!result) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
setIsLoading(true);
|
setIsLoading(true);
|
||||||
try {
|
try {
|
||||||
await Promise.all(
|
await Promise.all(
|
||||||
|
|
Loading…
Reference in a new issue