import React from 'react'; import {State, EventData} from 'xstate'; import './wallet.scss'; import {Flex, Heading, Progress} from 'rimble-ui'; import {ChannelId} from './channel-id'; import { isConfirmCreateChannel, getConfirmCreateChannelService, getChallengeChannelService, getApplicationOpenProgress, isApplicationOpening, getApplicationStateValue, isApplicationChallenging } from './selectors'; import {ChallengeChannel} from './challenge-channel-workflow'; import {ConfirmCreateChannel} from './confirm-create-channel-workflow'; import {Application} from '../workflows'; interface Props { current: Application.WorkflowState; send: (event: any, payload?: EventData | undefined) => State; } export const ApplicationWorkflow = (props: Props) => { const current = props.current; const messages: Record = { branchingOnFundingStrategy: '', // UI never sees this state confirmingWithUser: 'Confirming with user...', creatingChannel: 'Creating channel...', joiningChannel: 'Joining channel ... ', openChannelAndFundProtocol: 'Opening channel...', running: 'Running channel...', sendChallenge: 'Challenging channel...', closing: 'Closing channel...', done: 'Channel closed', failure: 'Something went wrong ...', fundingChannel: 'Funding channel ... ' }; return (
{messages[getApplicationStateValue(current)]} {!isConfirmCreateChannel(current) && !isApplicationChallenging(current) && ( )} {isConfirmCreateChannel(current) && ( )} {isApplicationChallenging(current) && ( )} {!isConfirmCreateChannel(current) && isApplicationOpening(current) && ( )}
); }; export default ApplicationWorkflow;