All files / web/src/components/worksheet-parsing ProblemReviewCard.stories.tsx

0% Statements 0/142
0% Branches 0/1
0% Functions 0/1
0% Lines 0/142

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 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143                                                                                                                                                                                                                                                                                             
/**
 * ProblemReviewCard Stories
 *
 * Stories for the individual problem review card used in focus review mode.
 */

import type { Meta, StoryObj } from '@storybook/react'
import type { ParsedProblem } from '@/lib/worksheet-parsing'
import { ProblemReviewCard } from './ProblemReviewCard'

/** Worksheet image for testing */
const WORKSHEET_URL = '/storybook-assets/worksheets/worksheet-20-problems.jpg'

/** Helper to create complete problem objects */
function completeProblem(
  raw: Omit<ParsedProblem, 'notes' | 'excluded' | 'reviewStatus' | 'reviewedAt'> & {
    notes?: string | null
    excluded?: boolean
    reviewStatus?: 'pending' | 'approved' | 'corrected' | 'flagged'
    reviewedAt?: string | null
  }
): ParsedProblem {
  return {
    ...raw,
    notes: raw.notes ?? null,
    excluded: raw.excluded ?? false,
    reviewStatus: raw.reviewStatus ?? 'pending',
    reviewedAt: raw.reviewedAt ?? null,
  }
}

/** Sample problem for card stories */
const SAMPLE_PROBLEM: ParsedProblem = completeProblem({
  problemNumber: 5,
  row: 1,
  column: 5,
  format: 'vertical',
  terms: [57, 52, 14, 5],
  correctAnswer: 128,
  studentAnswer: 100,
  studentAnswerConfidence: 0.85,
  termsConfidence: 0.75,
  problemBoundingBox: { x: 0.406, y: 0.07, width: 0.088, height: 0.18 },
  answerBoundingBox: { x: 0.406, y: 0.205, width: 0.088, height: 0.045 },
})

const meta: Meta<typeof ProblemReviewCard> = {
  title: 'WorksheetParsing/ProblemReviewCard',
  component: ProblemReviewCard,
  parameters: {
    layout: 'centered',
    backgrounds: { default: 'dark' },
  },
  tags: ['autodocs'],
  decorators: [
    (Story) => (
      <div style={{ width: '400px', backgroundColor: '#1a1a2e', padding: '16px' }}>
        <Story />
      </div>
    ),
  ],
}

export default meta
type Story = StoryObj<typeof ProblemReviewCard>

/** Pending review - needs user decision */
export const Pending: Story = {
  args: {
    problem: { ...SAMPLE_PROBLEM, reviewStatus: 'pending' },
    index: 4,
    totalProblems: 20,
    worksheetImageUrl: WORKSHEET_URL,
    onSubmitCorrection: async (correction) => console.log('Submit correction:', correction),
    onApprove: async () => console.log('Approved'),
    onFlag: async () => console.log('Flagged'),
    onNext: () => console.log('Next'),
    onPrev: () => console.log('Prev'),
    isSaving: false,
    isDark: true,
  },
}

/** Correct answer - student got it right */
export const CorrectAnswer: Story = {
  args: {
    problem: {
      ...SAMPLE_PROBLEM,
      studentAnswer: 128, // Correct!
      reviewStatus: 'pending',
    },
    index: 4,
    totalProblems: 20,
    worksheetImageUrl: WORKSHEET_URL,
    onSubmitCorrection: async (correction) => console.log('Submit correction:', correction),
    onApprove: async () => console.log('Approved'),
    onFlag: async () => console.log('Flagged'),
    onNext: () => console.log('Next'),
    onPrev: () => console.log('Prev'),
    isSaving: false,
    isDark: true,
  },
}

/** Low confidence - highlighting uncertainty */
export const LowConfidence: Story = {
  args: {
    problem: {
      ...SAMPLE_PROBLEM,
      termsConfidence: 0.45,
      studentAnswerConfidence: 0.3,
      reviewStatus: 'pending',
    },
    index: 4,
    totalProblems: 20,
    worksheetImageUrl: WORKSHEET_URL,
    onSubmitCorrection: async (correction) => console.log('Submit correction:', correction),
    onApprove: async () => console.log('Approved'),
    onFlag: async () => console.log('Flagged'),
    onNext: () => console.log('Next'),
    onPrev: () => console.log('Prev'),
    isSaving: false,
    isDark: true,
  },
}

/** Saving state - during correction submission */
export const Saving: Story = {
  args: {
    problem: SAMPLE_PROBLEM,
    index: 4,
    totalProblems: 20,
    worksheetImageUrl: WORKSHEET_URL,
    onSubmitCorrection: async (correction) => console.log('Submit correction:', correction),
    onApprove: async () => console.log('Approved'),
    onFlag: async () => console.log('Flagged'),
    onNext: () => console.log('Next'),
    onPrev: () => console.log('Prev'),
    isSaving: true,
    isDark: true,
  },
}