diff --git a/packages/atlas/src/components/_crt/CreateTokenDrawer/steps/TokenIssuanceStep/TokenIssuanceStep.tsx b/packages/atlas/src/components/_crt/CreateTokenDrawer/steps/TokenIssuanceStep/TokenIssuanceStep.tsx index 7e7209fbdb..529bc012d3 100644 --- a/packages/atlas/src/components/_crt/CreateTokenDrawer/steps/TokenIssuanceStep/TokenIssuanceStep.tsx +++ b/packages/atlas/src/components/_crt/CreateTokenDrawer/steps/TokenIssuanceStep/TokenIssuanceStep.tsx @@ -176,7 +176,7 @@ export const TokenIssuanceStep = ({ const data = assuranceType === 'custom' ? generateChartData(Number(customCliff ?? 0), Number(customVesting ?? 0), firstPayout ? firstPayout : 0) - : generateChartData(...getDataBasedOnType(assuranceType)) + : generateChartData(...(getDataBasedOnType(assuranceType) as [number, number, number])) setPreview( diff --git a/packages/atlas/src/components/_crt/CreateTokenDrawer/steps/TokenIssuanceStep/TokenIssuanceStep.utils.ts b/packages/atlas/src/components/_crt/CreateTokenDrawer/steps/TokenIssuanceStep/TokenIssuanceStep.utils.ts index 855950e685..03140a42f4 100644 --- a/packages/atlas/src/components/_crt/CreateTokenDrawer/steps/TokenIssuanceStep/TokenIssuanceStep.utils.ts +++ b/packages/atlas/src/components/_crt/CreateTokenDrawer/steps/TokenIssuanceStep/TokenIssuanceStep.utils.ts @@ -1,6 +1,8 @@ import { Datum } from '@nivo/line' import { z } from 'zod' +import { IssuanceStepForm } from '@/components/_crt/CreateTokenDrawer/CreateTokenDrawer.types' + export const assuranceOptions = [ { label: 'Secure', @@ -172,13 +174,15 @@ export const generateChartData = (cliffTime: number, vestingTime: number, firstP return data } -export const getDataBasedOnType = (type: 'secure' | 'safe' | 'risky'): [number, number, number] => { +export const getDataBasedOnType = (type: IssuanceStepForm['assuranceType']): [number, number, number] | null => { switch (type) { case 'secure': return [6, 12, 50] case 'safe': return [0, 6, 50] case 'risky': - return [0, 0, 0] + return [0, 0, 100] + case 'custom': + return null } } diff --git a/packages/atlas/src/components/_crt/CreateTokenDrawer/steps/TokenSummaryStep.tsx b/packages/atlas/src/components/_crt/CreateTokenDrawer/steps/TokenSummaryStep.tsx index 9a20c262ca..c3d856f46e 100644 --- a/packages/atlas/src/components/_crt/CreateTokenDrawer/steps/TokenSummaryStep.tsx +++ b/packages/atlas/src/components/_crt/CreateTokenDrawer/steps/TokenSummaryStep.tsx @@ -1,5 +1,6 @@ import styled from '@emotion/styled' import { ReactNode } from 'react' +import { useNavigate } from 'react-router-dom' import { SvgAlertsInformative24 } from '@/assets/icons' import { Banner } from '@/components/Banner' @@ -7,6 +8,7 @@ import { NumberFormat } from '@/components/NumberFormat' import { Text } from '@/components/Text' import { Tooltip } from '@/components/Tooltip' import { CrtFormWrapper } from '@/components/_crt/CrtFormWrapper' +import { absoluteRoutes } from '@/config/routes' import { useMountEffect } from '@/hooks/useMountEffect' import { useFee, useJoystream } from '@/providers/joystream' import { useTransaction } from '@/providers/transactions/transactions.hooks' @@ -14,7 +16,7 @@ import { useUser } from '@/providers/user/user.hooks' import { sizes } from '@/styles' import { formatNumber } from '@/utils/number' -import { cliffOptions, vestingOptions } from './TokenIssuanceStep/TokenIssuanceStep.utils' +import { cliffOptions, getDataBasedOnType, vestingOptions } from './TokenIssuanceStep/TokenIssuanceStep.utils' import { CommonStepProps } from './types' const cliffBanner = ( @@ -36,11 +38,16 @@ export const TokenSummaryStep = ({ setPrimaryButtonProps, form }: CommonStepProp const { joystream, proxyCallback } = useJoystream() const { channelId, memberId } = useUser() const handleTransaction = useTransaction() - const { loading, fullFee } = useFee('issueCreatorTokenTx') + const navigate = useNavigate() + const { fullFee } = useFee('issueCreatorTokenTx') - console.log(form) const handleSubmitTx = async () => { if (!joystream || !channelId || !memberId) return + const [cliff, vesting, payout] = getDataBasedOnType(form.assuranceType) ?? [ + form.cliff, + form.vesting, + form.firstPayout, + ] return handleTransaction({ fee: fullFee, txFactory: async (handleUpdate) => @@ -52,22 +59,19 @@ export const TokenSummaryStep = ({ setPrimaryButtonProps, form }: CommonStepProp form.revenueShare, { amount: String(form.creatorIssueAmount ?? 0), - cliffAmountPercentage: form.firstPayout ?? 0, - vestingDuration: form.vesting ? monthDurationToBlocks(+form.vesting) : 0, - blocksBeforeCliff: form.cliff ? monthDurationToBlocks(+form.cliff) : 0, + cliffAmountPercentage: payout ?? 0, + vestingDuration: vesting ? monthDurationToBlocks(+vesting) : 0, + blocksBeforeCliff: cliff ? monthDurationToBlocks(+cliff) : 0, }, proxyCallback(handleUpdate) ), - onTxSync: async (data) => { - console.log(data, ' kurwa') - return undefined + onTxSync: async () => { + navigate(absoluteRoutes.studio.crtDashboard()) }, snackbarSuccessMessage: { - title: 'NFT price changed successfully', - description: 'You can update the price anytime.', + title: `$${form.name} minted successfuly.`, }, }) - // const adw = await } useMountEffect(() => {