0
Fork 0
mirror of https://github.com/logto-io/logto.git synced 2024-12-30 20:33:54 -05:00

fix(console): go to onboarding process on clicking create new tenant button (#5663)

This commit is contained in:
Charles Zhao 2024-04-09 17:36:36 +08:00 committed by GitHub
parent 6e980b3b50
commit 59875400c6
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -4,13 +4,14 @@ import { useTranslation } from 'react-i18next';
import OrganizationIcon from '@/assets/icons/organization-preview.svg';
import { useCloudApi } from '@/cloud/hooks/use-cloud-api';
import { type TenantResponse, type InvitationListResponse } from '@/cloud/types/router';
import CreateTenantModal from '@/components/CreateTenantModal';
import { type InvitationListResponse } from '@/cloud/types/router';
import TenantEnvTag from '@/components/TenantEnvTag';
import ThemedIcon from '@/components/ThemedIcon';
import { TenantsContext } from '@/contexts/TenantsProvider';
import Button from '@/ds-components/Button';
import Spacer from '@/ds-components/Spacer';
import useTenantPathname from '@/hooks/use-tenant-pathname';
import useUserOnboardingData from '@/onboarding/hooks/use-user-onboarding-data';
import * as styles from './index.module.scss';
@ -21,12 +22,13 @@ type Props = {
function InvitationList({ invitations }: Props) {
const { t } = useTranslation(undefined, { keyPrefix: 'admin_console' });
const cloudApi = useCloudApi();
const { prependTenant, navigateTenant, resetTenants } = useContext(TenantsContext);
const { navigateTenant, resetTenants } = useContext(TenantsContext);
const { navigate } = useTenantPathname();
const [isJoining, setIsJoining] = useState(false);
const [isCreateModalOpen, setIsCreateModalOpen] = useState(false);
const [isUpdatingOnboardingStatus, setIsUpdatingOnboardingStatus] = useState(false);
const { update } = useUserOnboardingData();
return (
<>
<div className={styles.container}>
<div className={styles.wrapper}>
<div className={styles.title}>{t('invitation.find_your_tenants')}</div>
@ -68,24 +70,20 @@ function InvitationList({ invitations }: Props) {
size="large"
type="outline"
className={styles.createTenantButton}
isLoading={isUpdatingOnboardingStatus}
title="invitation.create_new_tenant"
onClick={() => {
setIsCreateModalOpen(true);
}}
/>
</div>
</div>
<CreateTenantModal
isOpen={isCreateModalOpen}
onClose={async (tenant?: TenantResponse) => {
if (tenant) {
prependTenant(tenant);
navigateTenant(tenant.id);
onClick={async () => {
setIsUpdatingOnboardingStatus(true);
try {
await update({ isOnboardingDone: false });
navigate('/');
} finally {
setIsUpdatingOnboardingStatus(false);
}
setIsCreateModalOpen(false);
}}
/>
</>
</div>
</div>
);
}