All files / web/src/components/create/abacus PrintDecision.tsx

100% Statements 53/53
100% Branches 2/2
100% Functions 1/1
100% Lines 53/53

Press n or j to go to the next uncovered block, b, p or k for the previous block.

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 541x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 5x 5x 5x 5x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 5x 5x 5x 5x 5x 5x 5x 5x 5x 5x 5x 5x 5x 5x 5x 5x 5x 5x  
import type { ReactNode } from 'react'
import { button, STUDIO } from '@/components/studio/theme'
import type { CommitmentSummary } from './abacus-commitment'
import { PrintCommitmentCard } from './PrintCommitmentCard'
 
export interface PrintDecisionProps {
  summary: CommitmentSummary
  plate?: ReactNode
  gates: ReactNode[]
  prep?: ReactNode
  submit: {
    label: string
    disabled: boolean
    pending: boolean
    onClick: () => void
    title?: string
  }
}
export function PrintDecision({ summary, plate, gates, prep, submit }: PrintDecisionProps) {
  return (
    <>
      <PrintCommitmentCard summary={summary} plate={plate} />
      {gates.length > 0 && (
        <div
          data-element="print-gates"
          style={{ display: 'flex', flexDirection: 'column', gap: STUDIO.space.card }}
        >
          <div
            data-element="print-gates-heading"
            style={{ ...STUDIO.type.eyebrow, marginBottom: 2 }}
          >
            Before you can print
          </div>
          {gates}
        </div>
      )}
      {prep}
      <button
        type="button"
        data-action="submit-print-job"
        disabled={submit.disabled}
        onClick={submit.onClick}
        title={submit.title}
        // the studio's ONE primary style — the disabled look follows the real
        // `disabled` (it used to key off submitBlocked alone, so a two-stage seam
        // miss left a dead button looking live)
        style={button('primary', { disabled: submit.disabled })}
      >
        {submit.label}
      </button>
    </>
  )
}