import type { CSSProperties } from 'react'; import { formatDate, formatRial } from '../lib/utils'; import { FilesServiceSuccess, FilesServiceMore } from './icons/FilesServiceIcons'; export interface SessionCardData { uuid: string; services?: Array<{ service_name?: string; name?: string }>; visit_price_rials?: number; doctor_name?: string | null; final_price_rials?: number; patient_debt_rials?: number; is_paid?: boolean; invoice_uuid?: string | null; notes?: string | null; created_at?: number; } /** label:value row inside the service card (mirrors tauri ServiceInfoRow). */ function Row({ label, value, valueStyle }: { label: string; value: string; valueStyle?: CSSProperties }) { return (
{label}: {value}
); } /** * A patient «مراجعه» (session) card — visit + performed services — ported * pixel-for-pixel from tauri files/services/ServiceCard. Paid cards show * «مشاهده فاکتور», unpaid ones «تکمیل پرداخت». */ export default function SessionServiceCard({ session, onSettle, onViewInvoice, settling }: { session: SessionCardData; onSettle: (uuid: string) => void; onViewInvoice: (invoiceUuid: string) => void; settling?: boolean; }) { const paid = !!session.is_paid; const names = (session.services ?? []).map((s) => s.service_name || s.name).filter(Boolean) as string[]; if ((session.visit_price_rials ?? 0) > 0) names.unshift('ویزیت'); // A «مراجعه» = the visit plus the services performed in it. const title = 'مراجعه'; const subtitle = names.length ? names.join(' - ') : 'ویزیت'; const debt = session.patient_debt_rials ?? 0; return (
{title} {subtitle}
{!paid && }
{paid ? ( ) : ( )}
); }