import React, { FC, PropsWithChildren, Ref } from 'react' import { Button } from '@wordpress/components' import { external } from '@wordpress/icons' import { Badge, Stack, Text } from '@wordpress/ui' import { useI18n } from '@wordpress/react-i18n' export type SetUpStepStatus = 'done' | 'started' | 'current' | 'next' | 'todo' export type SetUpStepAction = { label: string } & ( | { href: string; external?: boolean; onClick?: () => void } | { onClick: () => void } ) export declare interface SetUpStepProps { number: number status: SetUpStepStatus title: string description: string where?: string action?: SetUpStepAction /** Lets the steps move focus to this step's action */ actionRef?: Ref } /** * A step the merchant has started outside this page, such as opening Mybring, * looks done: we cannot tell whether it was finished, and the next step is * where they should carry on. */ const numberLooks: Record = { done: 'done', started: 'done', current: 'current', next: 'next', todo: 'next', } const linkProps = (action: SetUpStepAction) => 'href' in action ? { href: action.href, target: action.external ? '_blank' : undefined, rel: action.external ? 'noreferrer' : undefined, icon: action.external ? external : undefined, } : {} /** One numbered step of the set-up, with its status and what to do next. */ const SetUpStep: FC> = ({ number, status, title, description, where, action, actionRef, children, }) => { const { __ } = useI18n() const doneLooking = numberLooks[status] === 'done' return (
  • {title}

    {doneLooking ? ( {__('Done', 'posten-bring-checkout')} ) : ( {__('To do', 'posten-bring-checkout')} )}

    {description}

    {status !== 'done' && action && ( )}
    {children} {where && ( {__('Where:', 'posten-bring-checkout')}{' '} {where} )}
  • ) } export default SetUpStep