Skip to content

Commit

Permalink
Merge pull request #643 from subquery/fix/style
Browse files Browse the repository at this point in the history
feat: style
  • Loading branch information
HuberTRoy authored Jan 25, 2024
2 parents 9cffd4c + e4c9880 commit bd4176c
Show file tree
Hide file tree
Showing 4 changed files with 38 additions and 29 deletions.
1 change: 1 addition & 0 deletions src/components/Status/Status.module.css
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@
font-size: 12px;
line-height: 20px;
text-transform: uppercase;
margin-bottom: 0;
}

.text-blue {
Expand Down
7 changes: 6 additions & 1 deletion src/containers/QueryApolloProvider.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,12 @@ export const QueryApolloProvider: React.FC<PropsWithChildren> = ({ children }) =
}),
defaultOptions: {
query: {
fetchPolicy: 'network-only',
fetchPolicy: 'no-cache',
errorPolicy: 'all',
},
watchQuery: {
fetchPolicy: 'no-cache',
errorPolicy: 'ignore',
},
},
});
Expand Down
57 changes: 30 additions & 27 deletions src/pages/account/Withdrawn/Locked/Home/Locked.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,12 @@ import * as React from 'react';
import { useTranslation } from 'react-i18next';
import { BsExclamationCircle } from 'react-icons/bs';
import InfoCircleOutlined from '@ant-design/icons/InfoCircleOutlined';
import { claimIndexerRewardsModalText, EmptyList, ModalClaimIndexerRewards } from '@components';
import { EmptyList } from '@components';
import { TokenAmount } from '@components/TokenAmount';
import TransactionModal from '@components/TransactionModal';
import { useWeb3 } from '@containers';
import { defaultLockPeriod, useLockPeriod } from '@hooks';
import { useRewardCollectStatus } from '@hooks/useRewardCollectStatus';
import { Spinner, Typography } from '@subql/components';
import { openNotification, Spinner, Typography } from '@subql/components';
import { TableText, TableTitle } from '@subql/components';
import { WithdrawalFieldsFragment as Withdrawls, WithdrawalType } from '@subql/network-query';
import { useGetWithdrawlsLazyQuery } from '@subql/react-hooks';
Expand Down Expand Up @@ -57,47 +56,50 @@ const cancelWithdrwalsTextAndTips = {
},
};

const CancelUnbonding: React.FC<{ id: string; type: WithdrawalType; onSuccess?: () => void }> = ({
id,
type,
onSuccess,
}) => {
const CancelUnbonding: React.FC<{
id: string;
type: WithdrawalType;
indexerAddress: string;
onSuccess?: () => void;
}> = ({ id, type, indexerAddress, onSuccess }) => {
const { contracts } = useWeb3Store();
const { account } = useWeb3();
const rewardClaimStatus = useRewardCollectStatus(account || '');

const cancelUnbonding = () => {
assert(contracts, 'Contracts not available');

return contracts.stakingManager.cancelUnbonding(id);
};

const needClaimedStatus = React.useMemo(() => {
return !rewardClaimStatus.data?.hasClaimedRewards;
}, [rewardClaimStatus.data?.hasClaimedRewards]);

return (
<div>
<TransactionModal
text={
needClaimedStatus
? claimIndexerRewardsModalText
: {
title: '',
steps: [],
text={{
title: '',
steps: [],
}}
actions={[
{
label: capitalize(t('general.cancel')),
key: 'claim',
onClick: async () => {
const res = await contracts?.indexerRegistry.isIndexer(indexerAddress);
if (!res) {
openNotification({
type: 'error',
description: "This indexer has been unregistered. The stake can't be cancel.",
duration: 3,
});
throw new Error('Not an indexer');
}
}
actions={[{ label: capitalize(t('general.cancel')), key: 'claim' }]}
},
},
]}
variant={'textBtn'}
onClick={cancelUnbonding}
width="416px"
className={styles.cancelModal}
onSuccess={onSuccess}
renderContent={(onSubmit, onCancel, isLoading, error) => {
if (needClaimedStatus) {
return <ModalClaimIndexerRewards onSuccess={() => rewardClaimStatus.refetch()} indexer={account ?? ''} />;
}

return (
<div style={{ display: 'flex', flexDirection: 'column' }}>
<div style={{ display: 'flex', alignItems: 'center', marginBottom: '8px' }}>
Expand Down Expand Up @@ -147,11 +149,11 @@ export const Locked: React.FC = () => {
status: WithdrawalStatus.ONGOING,
offset: 0,
};
// TODO: refresh when do the withdrawl action.
const [getWithdrawals, withdrawals] = useGetWithdrawlsLazyQuery({
variables: filterParams,
fetchPolicy: 'network-only',
});

const lockPeriod = useLockPeriod();

const columns: TableProps<SortedWithdrawals>['columns'] = [
Expand Down Expand Up @@ -196,6 +198,7 @@ export const Locked: React.FC = () => {
render: (id, record) => (
<CancelUnbonding
id={id}
indexerAddress={record.indexer}
type={record.type}
onSuccess={() => {
retry(getWithdrawals);
Expand Down
2 changes: 1 addition & 1 deletion src/pages/explorer/Project/Project.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ const ProjectInner: React.FC = () => {
{ link: `${SERVICE_AGREEMENTS}${location.search}`, label: t('explorer.project.tab3') },
];
const flexPlanTab = [{ link: `${FLEX_PLANS}${location.search}`, label: t('explorer.project.tab4') }];
return import.meta.env.VITE_FLEXPLAN_ENABLED === 'true' ? [...tabList, ...flexPlanTab] : tabList;
return [...tabList, ...flexPlanTab];
}, [location.search, asyncProject.data?.type]);

const deploymentId = React.useMemo(() => {
Expand Down

0 comments on commit bd4176c

Please sign in to comment.