import { State } from '@actyx/machine-runner' import { useState } from 'react' import { BidData, Passenger } from './machines/index.js' type UIPassengerInitialProps = { state: State.Of } export const UIPassengerInitial = ({ state }: UIPassengerInitialProps) => { const [pickup, setPickup] = useState('') const [destination, setDestination] = useState('') const buttonEnabled = pickup.trim().length > 0 && destination.trim().length > 0 && state.commands !== undefined return (
) } export type UIPassengerAuctionProps = { state: State.Of } export const UIPassengerAuction = ({ state }: UIPassengerAuctionProps) => { const [selection, setSelection] = useState(state.payload.bids[0] || null) const buttonEnabled = selection !== null && state.commands !== undefined return (
) } export type UIPassengerRideProps = { state: State.Of } // Extracted for unit test demo export const isTaxiRideCancelEnabled = (state: UIPassengerRideProps['state']) => state.commands !== undefined export const UIPassengerRide = ({ state }: UIPassengerRideProps) => { const buttonEnabled = isTaxiRideCancelEnabled(state) return (
) }