// Copyright 2017-2021 @polkadot/app-assets authors & contributors // SPDX-License-Identifier: Apache-2.0 import type { SubmittableExtrinsic } from '@polkadot/api/types'; import type { AssetId } from '@polkadot/types/interfaces'; import type { InfoState, MetadataState, TeamState } from './types'; import React, { useEffect, useState } from 'react'; import { Button, Modal, TxButton } from '@polkadot/react-components'; import { useApi, useStepper } from '@polkadot/react-hooks'; import { useTranslation } from '../../translate'; import Info from './Info'; import Metadata from './Metadata'; import Team from './Team'; interface Props { assetIds: AssetId[]; className?: string; onClose: () => void; } function Create ({ assetIds, className, onClose }: Props): React.ReactElement { const { t } = useTranslation(); const { api } = useApi(); const [step, nextStep, prevStep] = useStepper(); const [asset, setAsset] = useState(null); const [metadata, setMetadata] = useState(null); const [team, setTeam] = useState(null); const [extrinsic, setExtrinsic] = useState | null>(null); useEffect((): void => { setExtrinsic( () => asset && metadata && team ? team.teamTx ? api.tx.utility.batchAll([asset.createTx, metadata.metadataTx, team.teamTx]) : api.tx.utility.batchAll([asset.createTx, metadata.metadataTx]) : null ); }, [api, asset, metadata, team]); return ( ('create asset {{step}}/{{steps}}', { replace: { step, steps: 3 } })} size='large' > {step === 1 && ( )} {step === 2 && ( )} {step === 3 && ( )} {step === 1 &&