mirror of
https://github.com/logto-io/logto.git
synced 2024-12-16 20:26:19 -05:00
chore: launch us region (#5962)
This commit is contained in:
parent
0decba0308
commit
d544d343b5
4 changed files with 18 additions and 15 deletions
|
@ -20,9 +20,10 @@ import * as styles from './index.module.scss';
|
||||||
type Props = {
|
type Props = {
|
||||||
readonly plan: SubscriptionPlan;
|
readonly plan: SubscriptionPlan;
|
||||||
readonly onSelect: () => void;
|
readonly onSelect: () => void;
|
||||||
|
readonly buttonProps?: Partial<React.ComponentProps<typeof Button>>;
|
||||||
};
|
};
|
||||||
|
|
||||||
function PlanCardItem({ plan, onSelect }: Props) {
|
function PlanCardItem({ plan, onSelect, buttonProps }: Props) {
|
||||||
const { t } = useTranslation(undefined, { keyPrefix: 'admin_console.upsell.create_tenant' });
|
const { t } = useTranslation(undefined, { keyPrefix: 'admin_console.upsell.create_tenant' });
|
||||||
const { tenants } = useContext(TenantsContext);
|
const { tenants } = useContext(TenantsContext);
|
||||||
const { stripeProducts, id: planId, name: planName } = plan;
|
const { stripeProducts, id: planId, name: planName } = plan;
|
||||||
|
@ -88,6 +89,7 @@ function PlanCardItem({ plan, onSelect }: Props) {
|
||||||
type={isFreePlan ? 'outline' : 'primary'}
|
type={isFreePlan ? 'outline' : 'primary'}
|
||||||
size="large"
|
size="large"
|
||||||
onClick={onSelect}
|
onClick={onSelect}
|
||||||
|
{...buttonProps}
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
{planId === ReservedPlanId.Hobby && (
|
{planId === ReservedPlanId.Hobby && (
|
||||||
|
|
|
@ -1,5 +1,6 @@
|
||||||
import { ReservedPlanId } from '@logto/schemas';
|
import { ReservedPlanId } from '@logto/schemas';
|
||||||
import { conditional } from '@silverhand/essentials';
|
import { conditional } from '@silverhand/essentials';
|
||||||
|
import { useState } from 'react';
|
||||||
import { Trans, useTranslation } from 'react-i18next';
|
import { Trans, useTranslation } from 'react-i18next';
|
||||||
import Modal from 'react-modal';
|
import Modal from 'react-modal';
|
||||||
|
|
||||||
|
@ -27,6 +28,7 @@ type Props = {
|
||||||
};
|
};
|
||||||
|
|
||||||
function SelectTenantPlanModal({ tenantData, onClose }: Props) {
|
function SelectTenantPlanModal({ tenantData, onClose }: Props) {
|
||||||
|
const [isSubmitting, setIsSubmitting] = useState<string>();
|
||||||
const { t } = useTranslation(undefined, { keyPrefix: 'admin_console' });
|
const { t } = useTranslation(undefined, { keyPrefix: 'admin_console' });
|
||||||
const { data: subscriptionPlans } = useSubscriptionPlans();
|
const { data: subscriptionPlans } = useSubscriptionPlans();
|
||||||
const { subscribe } = useSubscribe();
|
const { subscribe } = useSubscribe();
|
||||||
|
@ -40,6 +42,7 @@ function SelectTenantPlanModal({ tenantData, onClose }: Props) {
|
||||||
const handleSelectPlan = async (plan: SubscriptionPlan) => {
|
const handleSelectPlan = async (plan: SubscriptionPlan) => {
|
||||||
const { id: planId } = plan;
|
const { id: planId } = plan;
|
||||||
try {
|
try {
|
||||||
|
setIsSubmitting(planId);
|
||||||
if (planId === ReservedPlanId.Free) {
|
if (planId === ReservedPlanId.Free) {
|
||||||
const { name, tag, regionName } = tenantData;
|
const { name, tag, regionName } = tenantData;
|
||||||
const newTenant = await cloudApi.post('/api/tenants', { body: { name, tag, regionName } });
|
const newTenant = await cloudApi.post('/api/tenants', { body: { name, tag, regionName } });
|
||||||
|
@ -52,6 +55,8 @@ function SelectTenantPlanModal({ tenantData, onClose }: Props) {
|
||||||
await subscribe({ planId, tenantData });
|
await subscribe({ planId, tenantData });
|
||||||
} catch (error: unknown) {
|
} catch (error: unknown) {
|
||||||
void toastResponseError(error);
|
void toastResponseError(error);
|
||||||
|
} finally {
|
||||||
|
setIsSubmitting(undefined);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -82,6 +87,10 @@ function SelectTenantPlanModal({ tenantData, onClose }: Props) {
|
||||||
<PlanCardItem
|
<PlanCardItem
|
||||||
key={plan.id}
|
key={plan.id}
|
||||||
plan={plan}
|
plan={plan}
|
||||||
|
buttonProps={{
|
||||||
|
isLoading: isSubmitting === plan.id,
|
||||||
|
disabled: Boolean(isSubmitting),
|
||||||
|
}}
|
||||||
onSelect={() => {
|
onSelect={() => {
|
||||||
void handleSelectPlan(plan);
|
void handleSelectPlan(plan);
|
||||||
}}
|
}}
|
||||||
|
|
|
@ -10,7 +10,6 @@ import CreateTenantHeaderIcon from '@/assets/icons/create-tenant-header.svg';
|
||||||
import { useCloudApi } from '@/cloud/hooks/use-cloud-api';
|
import { useCloudApi } from '@/cloud/hooks/use-cloud-api';
|
||||||
import { type TenantResponse } from '@/cloud/types/router';
|
import { type TenantResponse } from '@/cloud/types/router';
|
||||||
import Region, { RegionName } from '@/components/Region';
|
import Region, { RegionName } from '@/components/Region';
|
||||||
import { isDevFeaturesEnabled } from '@/consts/env';
|
|
||||||
import Button from '@/ds-components/Button';
|
import Button from '@/ds-components/Button';
|
||||||
import DangerousRaw from '@/ds-components/DangerousRaw';
|
import DangerousRaw from '@/ds-components/DangerousRaw';
|
||||||
import FormField from '@/ds-components/FormField';
|
import FormField from '@/ds-components/FormField';
|
||||||
|
@ -90,6 +89,7 @@ function CreateTenantModal({ isOpen, onClose }: Props) {
|
||||||
}
|
}
|
||||||
footer={
|
footer={
|
||||||
<Button
|
<Button
|
||||||
|
isLoading={isSubmitting}
|
||||||
disabled={isSubmitting}
|
disabled={isSubmitting}
|
||||||
htmlType="submit"
|
htmlType="submit"
|
||||||
title="tenants.create_modal.create_button"
|
title="tenants.create_modal.create_button"
|
||||||
|
@ -108,6 +108,7 @@ function CreateTenantModal({ isOpen, onClose }: Props) {
|
||||||
autoFocus
|
autoFocus
|
||||||
{...register('name', { required: true })}
|
{...register('name', { required: true })}
|
||||||
error={Boolean(errors.name)}
|
error={Boolean(errors.name)}
|
||||||
|
disabled={isSubmitting}
|
||||||
/>
|
/>
|
||||||
</FormField>
|
</FormField>
|
||||||
<FormField
|
<FormField
|
||||||
|
@ -126,14 +127,11 @@ function CreateTenantModal({ isOpen, onClose }: Props) {
|
||||||
key={region}
|
key={region}
|
||||||
title={
|
title={
|
||||||
<DangerousRaw>
|
<DangerousRaw>
|
||||||
<Region
|
<Region regionName={region} />
|
||||||
regionName={region}
|
|
||||||
isComingSoon={!isDevFeaturesEnabled && region !== RegionName.EU}
|
|
||||||
/>
|
|
||||||
</DangerousRaw>
|
</DangerousRaw>
|
||||||
}
|
}
|
||||||
value={region}
|
value={region}
|
||||||
isDisabled={!isDevFeaturesEnabled && region !== RegionName.EU}
|
isDisabled={isSubmitting}
|
||||||
/>
|
/>
|
||||||
))}
|
))}
|
||||||
</RadioGroup>
|
</RadioGroup>
|
||||||
|
|
|
@ -14,7 +14,6 @@ import ActionBar from '@/components/ActionBar';
|
||||||
import { type CreateTenantData } from '@/components/CreateTenantModal/types';
|
import { type CreateTenantData } from '@/components/CreateTenantModal/types';
|
||||||
import PageMeta from '@/components/PageMeta';
|
import PageMeta from '@/components/PageMeta';
|
||||||
import Region, { RegionName } from '@/components/Region';
|
import Region, { RegionName } from '@/components/Region';
|
||||||
import { isDevFeaturesEnabled } from '@/consts/env';
|
|
||||||
import { TenantsContext } from '@/contexts/TenantsProvider';
|
import { TenantsContext } from '@/contexts/TenantsProvider';
|
||||||
import Button from '@/ds-components/Button';
|
import Button from '@/ds-components/Button';
|
||||||
import DangerousRaw from '@/ds-components/DangerousRaw';
|
import DangerousRaw from '@/ds-components/DangerousRaw';
|
||||||
|
@ -132,16 +131,11 @@ function CreateTenant() {
|
||||||
key={region}
|
key={region}
|
||||||
title={
|
title={
|
||||||
<DangerousRaw>
|
<DangerousRaw>
|
||||||
<Region
|
<Region regionName={region} />
|
||||||
regionName={region}
|
|
||||||
isComingSoon={!isDevFeaturesEnabled && region !== RegionName.EU}
|
|
||||||
/>
|
|
||||||
</DangerousRaw>
|
</DangerousRaw>
|
||||||
}
|
}
|
||||||
value={region}
|
value={region}
|
||||||
isDisabled={
|
isDisabled={isSubmitting}
|
||||||
isSubmitting || (!isDevFeaturesEnabled && region !== RegionName.EU)
|
|
||||||
}
|
|
||||||
/>
|
/>
|
||||||
))}
|
))}
|
||||||
</RadioGroup>
|
</RadioGroup>
|
||||||
|
|
Loading…
Reference in a new issue