Skip to content

Commit

Permalink
improve renewals (#223)
Browse files Browse the repository at this point in the history
* improve renewals

* consistent order

* add warning

* info banner
  • Loading branch information
Szegoo authored Aug 17, 2024
1 parent e9a80cb commit 0c9fc02
Show file tree
Hide file tree
Showing 4 changed files with 52 additions and 5 deletions.
18 changes: 16 additions & 2 deletions src/components/Paras/ParaDisplay/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,20 +4,33 @@ import Image from 'next/image';
import { chainData } from '@/chaindata';
import { NetworkType } from '@/models';

import Unknown from '../../../assets/unknown.svg';

interface ParaDisplayProps {
paraId: number;
network: NetworkType;
}
export const ParaDisplay = ({ paraId, network }: ParaDisplayProps) => {
const data = chainData[network][paraId];

if (data === undefined) return <>{paraId}</>;
if (data === undefined)
return (
<Stack direction='row' alignItems='center' gap='0.5rem'>
<Image
src={Unknown}
width={32}
height={32}
style={{ borderRadius: '100%' }}
alt=''
/>
Parachain #{paraId}
</Stack>
);

const { name, logo } = data;

return (
<Stack direction='row' alignItems='center' gap='0.5rem'>
{paraId}
{logo === undefined ? (
<></>
) : (
Expand All @@ -30,6 +43,7 @@ export const ParaDisplay = ({ paraId, network }: ParaDisplayProps) => {
/>
)}
{name}
<p>#{paraId}</p>
</Stack>
);
};
2 changes: 1 addition & 1 deletion src/contexts/orders/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@ const OrderProvider = ({ children }: Props) => {
...item,
totalContribution: parseInt(item.contribution),
contribution: await getContribution(item.orderId),
} as Order)
}) as Order
)
)
);
Expand Down
2 changes: 1 addition & 1 deletion src/hooks/order/processed.ts
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ export const useProcessedOrders = () => {
mask,
account: seller,
reward,
} as OrderItem)
}) as OrderItem
)
);
}
Expand Down
35 changes: 34 additions & 1 deletion src/pages/paras/renewal.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -20,12 +20,13 @@ import { useRenewableParachains } from '@/hooks/renewableParas';
import { useSubmitExtrinsic } from '@/hooks/submitExtrinsic';
import { getBalanceString, timesliceToTimestamp } from '@/utils/functions';

import { Balance, ParaDisplay, ProgressButton } from '@/components';
import { Balance, Banner, ParaDisplay, ProgressButton } from '@/components';

import { useAccounts } from '@/contexts/account';
import { useCoretimeApi, useRelayApi } from '@/contexts/apis';
import { ApiState } from '@/contexts/apis/types';
import { useNetwork } from '@/contexts/network';
import { useSaleInfo } from '@/contexts/sales';
import { useToast } from '@/contexts/toast';
import { BrokerStatus, ContextStatus } from '@/models';

Expand All @@ -37,6 +38,7 @@ const Renewal = () => {
state: { activeAccount, activeSigner },
} = useAccounts();
const { status, parachains } = useRenewableParachains();
const { saleInfo } = useSaleInfo();

const {
state: { api: relayApi, apiState: relayApiState },
Expand Down Expand Up @@ -248,6 +250,37 @@ const Renewal = () => {
/>
</Stack>
</Stack>
{saleInfo.coresSold === saleInfo.coresOffered && (
<Stack width='75%' margin='0 auto' mt='1rem'>
<Banner
content={
'No more cores are on sale! Attempting to renew will fail. To avoid these kind of \
issues in the future, please renew during the interlude phase '
}
link={{
title: 'Renewal FAQ',
href: 'https://docs.regionx.tech/docs/faq/renewal-questions',
}}
severity='warning'
/>
</Stack>
)}
{/* If not all cores are sold inform the user: */}
{saleInfo.coresSold < saleInfo.coresOffered && (
<Stack width='75%' margin='0 auto' mt='1rem'>
<Banner
content={
'It is highly recommended to renew during the interlude phase, as doing so guarantees \
that the core will be available for renewal. '
}
link={{
title: 'Renewal FAQ',
href: 'https://docs.regionx.tech/docs/faq/renewal-questions',
}}
severity='info'
/>
</Stack>
)}
<Stack
direction='row'
gap='1rem'
Expand Down

0 comments on commit 0c9fc02

Please sign in to comment.