mirror of
https://github.com/lux-tel/websites.git
synced 2026-10-30 20:31:36 +00:00
65 lines
2.3 KiB
TypeScript
65 lines
2.3 KiB
TypeScript
import { SubmitRemoveFunds } from '@/app/stake/[address]/SubmitRemoveFunds';
|
|
import { SubmitRemoveFundsVesting } from '@/app/stake/[address]/SubmitRemoveFundsVesting';
|
|
import { WithdrawStakeOperatorNotice } from '@/app/stake/[address]/WithdrawStakeOperatorNotice';
|
|
import { WalletInteractionButtonWithLocales } from '@/components/WalletInteractionButtonWithLocales';
|
|
import { useActiveVestingContract } from '@/providers/vesting-provider';
|
|
import { ButtonDataTestId } from '@/testing/data-test-ids';
|
|
import type { ContributionContract } from '@session/staking-api-js/schema';
|
|
import { useTranslations } from 'next-intl';
|
|
import { type Dispatch, type SetStateAction, useState } from 'react';
|
|
|
|
export function OperatorRemoveStake({
|
|
contract,
|
|
setIsSubmitting,
|
|
refetch,
|
|
}: {
|
|
contract: ContributionContract;
|
|
setIsSubmitting: Dispatch<SetStateAction<boolean>>;
|
|
refetch: () => void;
|
|
}) {
|
|
const dictionary = useTranslations('actionModules.staking.manage');
|
|
const [isRemoveStake, setIsRemoveStake] = useState(false);
|
|
const [userConfirmingRemoveStake, setUserConfirmingRemoveStake] = useState(false);
|
|
|
|
const vestingContract = useActiveVestingContract();
|
|
|
|
const handleRemoveStake = () => {
|
|
setIsSubmitting(true);
|
|
setUserConfirmingRemoveStake(true);
|
|
};
|
|
|
|
return (
|
|
<>
|
|
{!isRemoveStake ? (
|
|
userConfirmingRemoveStake ? (
|
|
<WithdrawStakeOperatorNotice onContinue={() => setIsRemoveStake(true)} />
|
|
) : (
|
|
<WalletInteractionButtonWithLocales
|
|
variant="destructive"
|
|
className="w-full"
|
|
data-testid={ButtonDataTestId.Stake_Manage_Remove_Stake}
|
|
aria-label={dictionary('buttonRemoveStakeAndRegistration.aria')}
|
|
onClick={handleRemoveStake}
|
|
>
|
|
{dictionary('buttonRemoveStakeAndRegistration.text')}
|
|
</WalletInteractionButtonWithLocales>
|
|
)
|
|
) : null}
|
|
{isRemoveStake ? (
|
|
vestingContract ? (
|
|
<SubmitRemoveFundsVesting
|
|
setIsSubmitting={setIsSubmitting}
|
|
contractAddress={contract.address}
|
|
/>
|
|
) : (
|
|
<SubmitRemoveFunds
|
|
setIsSubmitting={setIsSubmitting}
|
|
contractAddress={contract.address}
|
|
refetch={refetch}
|
|
/>
|
|
)
|
|
) : null}
|
|
</>
|
|
);
|
|
}
|