improvement: lab/clinic commiunication flow completely overhauled. no more shit.
This commit is contained in:
@@ -22,6 +22,7 @@ interface PastTreatmentsPanelProps {
|
||||
loading?: boolean;
|
||||
selectedPreviewId?: string | null;
|
||||
onSelectTreatment?: (treatment: PastTreatment) => void;
|
||||
compact?: boolean;
|
||||
}
|
||||
|
||||
function formatHistoryTimestamp(iso: string): string {
|
||||
@@ -47,10 +48,12 @@ export function PastTreatmentsPanel({
|
||||
loading,
|
||||
selectedPreviewId,
|
||||
onSelectTreatment,
|
||||
compact = false,
|
||||
}: PastTreatmentsPanelProps) {
|
||||
const t = useTranslations('treatment');
|
||||
const [notShippedOnly, setNotShippedOnly] = useState(false);
|
||||
const [filterDate, setFilterDate] = useState('');
|
||||
const [filtersOpen, setFiltersOpen] = useState(false);
|
||||
|
||||
const hasActiveFilters = notShippedOnly || Boolean(filterDate);
|
||||
|
||||
@@ -70,53 +73,56 @@ export function PastTreatmentsPanel({
|
||||
|
||||
const filterInputClass = `${FORM_SELECT_CLASS} rounded-md px-2 py-1.5 text-xs min-w-[9.5rem]`;
|
||||
|
||||
return (
|
||||
<div className="surface-card p-4 space-y-3">
|
||||
<div>
|
||||
<h3 className="text-sm font-semibold text-text-primary">
|
||||
{patientName ? t('historyPatientScope', { patientName }) : t('historyTitle')}
|
||||
</h3>
|
||||
<p className="text-[11px] text-text-muted mt-0.5">{t('historySubtitle')}</p>
|
||||
</div>
|
||||
|
||||
<div className="flex flex-wrap items-center gap-x-3 gap-y-2 rounded-[var(--radius-md)] border border-border/60 bg-background-secondary/30 p-2.5">
|
||||
<Checkbox
|
||||
checked={notShippedOnly}
|
||||
onChange={setNotShippedOnly}
|
||||
label={t('historyFilterNotShipped')}
|
||||
className="text-xs [&_span:last-child]:text-xs shrink-0"
|
||||
const filtersBlock = (
|
||||
<div
|
||||
className={`flex flex-wrap items-center gap-x-3 gap-y-2 rounded-[var(--radius-md)] border border-border/60 bg-background-secondary/30 ${
|
||||
compact ? 'p-2' : 'p-2.5'
|
||||
}`}
|
||||
>
|
||||
<Checkbox
|
||||
checked={notShippedOnly}
|
||||
onChange={setNotShippedOnly}
|
||||
label={t('historyFilterNotShipped')}
|
||||
className="text-xs [&_span:last-child]:text-xs shrink-0"
|
||||
/>
|
||||
<label className="flex items-center gap-1.5 shrink-0">
|
||||
<span className="text-xs font-medium text-text-muted whitespace-nowrap">
|
||||
{t('historyFilterDate')}
|
||||
</span>
|
||||
<input
|
||||
type="date"
|
||||
value={filterDate}
|
||||
onChange={(e) => setFilterDate(e.target.value)}
|
||||
className={filterInputClass}
|
||||
/>
|
||||
<label className="flex items-center gap-1.5 shrink-0">
|
||||
<span className="text-xs font-medium text-text-muted whitespace-nowrap">
|
||||
{t('historyFilterDate')}
|
||||
</span>
|
||||
<input
|
||||
type="date"
|
||||
value={filterDate}
|
||||
onChange={(e) => setFilterDate(e.target.value)}
|
||||
className={filterInputClass}
|
||||
/>
|
||||
</label>
|
||||
<Button
|
||||
variant="ghost"
|
||||
size="sm"
|
||||
onClick={clearFilters}
|
||||
disabled={!hasActiveFilters}
|
||||
className="shrink-0"
|
||||
>
|
||||
{t('historyClearFilters')}
|
||||
</Button>
|
||||
</div>
|
||||
</label>
|
||||
<Button
|
||||
variant="ghost"
|
||||
size="sm"
|
||||
onClick={clearFilters}
|
||||
disabled={!hasActiveFilters}
|
||||
className="shrink-0"
|
||||
>
|
||||
{t('historyClearFilters')}
|
||||
</Button>
|
||||
</div>
|
||||
);
|
||||
|
||||
{loading && <p className="text-sm text-text-muted">{t('loadingHistory')}</p>}
|
||||
const listBlock = (
|
||||
<>
|
||||
{loading && <p className="text-xs text-text-muted">{t('loadingHistory')}</p>}
|
||||
|
||||
{!loading && displayedItems.length === 0 && (
|
||||
<p className="text-sm text-text-muted">
|
||||
<p className="text-xs text-text-muted">
|
||||
{hasActiveFilters ? t('historyFilterEmpty') : t('historyEmpty')}
|
||||
</p>
|
||||
)}
|
||||
|
||||
<div className="space-y-1.5 max-h-[min(420px,50vh)] overflow-y-auto overscroll-y-contain pr-1">
|
||||
<div
|
||||
className={`space-y-1 overflow-y-auto overscroll-y-contain pr-1 ${
|
||||
compact ? 'max-h-[min(220px,32vh)]' : 'max-h-[min(420px,50vh)]'
|
||||
}`}
|
||||
>
|
||||
{displayedItems.map((treatment) => {
|
||||
const isSelected = selectedPreviewId === treatment.id;
|
||||
const isCurrentAppointment =
|
||||
@@ -188,6 +194,35 @@ export function PastTreatmentsPanel({
|
||||
);
|
||||
})}
|
||||
</div>
|
||||
</>
|
||||
);
|
||||
|
||||
if (compact) {
|
||||
return (
|
||||
<div className="space-y-2 pt-2">
|
||||
<button
|
||||
type="button"
|
||||
onClick={() => setFiltersOpen((open) => !open)}
|
||||
className="text-[10px] font-medium text-primary hover:underline"
|
||||
>
|
||||
{filtersOpen ? t('historyHideFilters') : t('historyShowFilters')}
|
||||
</button>
|
||||
{filtersOpen ? filtersBlock : null}
|
||||
{listBlock}
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
||||
return (
|
||||
<div className="surface-card p-4 space-y-3">
|
||||
<div>
|
||||
<h3 className="text-sm font-semibold text-text-primary">
|
||||
{patientName ? t('historyPatientScope', { patientName }) : t('historyTitle')}
|
||||
</h3>
|
||||
<p className="text-[11px] text-text-muted mt-0.5">{t('historySubtitle')}</p>
|
||||
</div>
|
||||
{filtersBlock}
|
||||
{listBlock}
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user