import { useState } from 'react' import { Button } from '../ui/Button.tsx' import type { Ticket, TicketType } from '../../lib/types.ts' const SUBJECT_MAX = 128 const DESCRIPTION_MAX = 2000 function CharCount({ current, max }: { current: number; max: number }) { const remaining = max - current const isWarning = remaining <= max * 0.1 // warn in the last 10% const isOver = remaining < 0 return ( {current}/{max} ) } // ─── Fake transactions ──────────────────────────────────────────────────────── export interface FakeTransaction { id: string label: string amount: string date: string } export const FAKE_TRANSACTIONS: FakeTransaction[] = [ { id: 'TXN-48291', label: 'Pro Plan — Monthly', amount: '$12.00', date: 'Mar 1, 2026' }, { id: 'TXN-47103', label: 'Add-on: Extra Storage', amount: '$4.99', date: 'Feb 15, 2026' }, { id: 'TXN-45882', label: 'Pro Plan — Monthly', amount: '$12.00', date: 'Feb 1, 2026' }, ] // ─── Step definitions ───────────────────────────────────────────────────────── interface Option { label: string description: string icon: string type: TicketType subOptions?: SubOption[] } interface SubOption { label: string description: string icon: string type: TicketType } const CATEGORIES: Option[] = [ { label: 'Something broke', description: 'Unexpected behavior or errors', icon: '⚠️', type: 'bug', subOptions: [ { label: 'Page or feature not loading', description: 'Blank screens, crashes, or freezes', icon: '🖥️', type: 'bug' }, { label: 'Error message appeared', description: 'Something went wrong unexpectedly', icon: '🔴', type: 'bug' }, { label: 'Data looks wrong', description: 'Missing or incorrect information', icon: '📊', type: 'bug' }, ], }, { label: 'Billing or payment', description: 'Charges, invoices, or subscriptions', icon: '💳', type: 'billing', subOptions: [ { label: 'Unexpected charge', description: "A charge I didn't expect or recognise", icon: '❓', type: 'billing' }, { label: 'Refund request', description: "I'd like money returned", icon: '↩️', type: 'billing' }, { label: 'Subscription issue', description: 'Plan, renewal, or upgrade problem', icon: '🔄', type: 'billing' }, ], }, { label: 'My account', description: 'Login, settings, or profile', icon: '👤', type: 'account', subOptions: [ { label: "Can't sign in", description: 'Login or password issues', icon: '🔐', type: 'account' }, { label: 'Profile or settings', description: 'Change name, email, or preferences', icon: '⚙️', type: 'account' }, { label: 'Account access or security', description: 'Suspicious activity or locked out', icon: '🛡️', type: 'account' }, ], }, { label: 'Suggest an idea', description: 'Feature requests or improvements', icon: '💡', type: 'feature-request', subOptions: [ { label: 'New feature idea', description: "Something you'd love to see added", icon: '✨', type: 'feature-request' }, { label: 'Improve something existing', description: 'Make a current feature better', icon: '🔧', type: 'feature-request' }, { label: 'Share general feedback', description: 'Thoughts on your experience', icon: '💬', type: 'feedback' }, ], }, { label: 'Something else', description: 'Anything not listed above', icon: '📝', type: 'other', }, ] // ─── Sub-components ──────────────────────────────────────────────────────────── function StepIndicator({ step, total }: { step: number; total: number }) { return (
{Array.from({ length: total }).map((_, i) => (
))}
) } interface OptionCardProps { icon: string label: string description: string onClick: () => void } function OptionCard({ icon, label, description, onClick }: OptionCardProps) { return ( ) } // ─── Main form ──────────────────────────────────────────────────────────────── type FormData = Pick interface NewTicketFormProps { onSubmit: (data: FormData) => void } type Step = 'category' | 'sub' | 'details' const inputClass = ` w-full rounded-md border border-border-100 bg-bg-300 px-3 py-2 text-sm text-fg-100 placeholder:text-fg-300 outline-none transition-colors focus:border-border-200 focus:ring-1 focus:ring-ring-100 ` export function NewTicketForm({ onSubmit }: NewTicketFormProps) { const [step, setStep] = useState('category') const [selectedCategory, setSelectedCategory] = useState