import React from 'react';
import { Box, Text, Divider, Tooltip } from '@wix/design-system';
import { ChevronRight, ChevronDown, ChevronUp } from '@wix/wix-ui-icons-common';
import { SetupWidgetStep } from '@wix/bex-core';
import { useWixPatternsContainer } from '@wix/bex-core/react';
import { SetupStepIcon } from './SetupStepIcon';
import { st, classes } from './SetupWidget.st.css.js';
export interface SetupStepCardProps {
step: SetupWidgetStep;
/** The recommended next step — soft blue surface + bold title. */
isPrimary: boolean;
/** Inline content is shown below the header. */
expanded: boolean;
onActivate: () => void;
renderStepContent?: (step: SetupWidgetStep) => React.ReactNode;
}
/**
* Mobile step card (per Figma "Support FW on mobile"). 12px padding, a 24px
* icon cell and a trailing chevron that replaces the per-step CTA button: a
* right chevron for navigate / completed (with a completed action) steps, and a
* down/up chevron for inline-expandable steps. The whole card is the click
* target. Collapsed cards are a bare title + chevron; an expanded inline card
* adds a divider, its description, and the consumer content below the header.
*/
export const SetupStepCard = ({
step,
isPrimary,
expanded,
onActivate,
renderStepContent,
}: SetupStepCardProps) => {
const { translate: t } = useWixPatternsContainer();
const isInProgress = step.status === 'in-progress';
const isCompleted = step.status === 'completed';
const isDisabled = step.status === 'disabled';
const isInline = step.expansionMode === 'inline';
const isInlineExpanded = expanded && isInline;
// Completed steps stay actionable only when they carry a completed action.
const showCompletedCta =
isCompleted && !!step.completedCtaLabel && !isDisabled;
// Inline steps toggle; navigate steps act; completed steps fire their action.
const isTogglable = isInline && !isCompleted && !isDisabled;
const isNavigable = !isInline && !isCompleted && !isDisabled;
const clickable = isTogglable || isNavigable || showCompletedCta;
// Disabled steps show a muted chevron (with a permission tooltip); completed
// steps without an action show none. Everything actionable shows a chevron.
const showChevron = clickable || isDisabled;
const ChevronIcon = isInline
? isInlineExpanded
? ChevronUp
: ChevronDown
: ChevronRight;
const chevron = showChevron && (