import { State } from '@actyx/machine-runner' import { useState } from 'react' import { Taxi } from './machines/index.js' type UITaxiInitialProps = { state: State.Of } export const UITaxiInitial = ({ state }: UITaxiInitialProps) => { return
Waiting for passengers...
} type UITaxiFirstBidProps = { state: State.Of } export const UITaxiFirstBid = ({ state }: UITaxiFirstBidProps) => { const [price, setPrice] = useState(null) const buttonEnabled = state.commands !== undefined return (
{ const nextValue = e.target.value.trim() if (nextValue === '') { setPrice(null) } const asNumber = Number(nextValue) if (!Number.isNaN(asNumber)) { setPrice(Math.max(asNumber, 1)) } }} >
) } type UITaxiAuctionProps = { state: State.Of } export const UITaxiAuction = ({ state }: UITaxiAuctionProps) => { const [price, setPrice] = useState(null) const buttonEnabled = state.commands !== undefined return (
{ const nextValue = e.target.value.trim() if (nextValue === '') { setPrice(null) } const asNumber = Number(nextValue) if (!Number.isNaN(asNumber)) { setPrice(Math.max(asNumber, 1)) } }} >
) } type UITaxiRideProps = { state: State.Of } export const UITaxiRide = ({ state }: UITaxiRideProps) => { return null }