Registry and Schedule sections on top of the shared doctors store
- registry: section tabs — «Регистратура» day overview (stats, today's queue with next-step buttons, nearest free slots) and parallel «Запись на приём» tabs; tab label shows the chosen patient - booking wizard: free slots of all doctors by date range, day part, specialty, doctor → patient, funding, service, comment → ticket; same-day warning, same-time block, «slot just taken» guard; reschedule cancels the old appointment - schedule: day list across doctors with date nav, doctor/patient filters, status pills, online/canceled toggles, sorting; side sheet with appointment details and status flow (пришёл → на приёме → завершён, неявка, отмена с подтверждением, перенос) - appointments gain status, source, booked by/at, funding, service, comment; demo data derives statuses from the current time - patient card «Записать на приём» opens a booking tab with the patient - kit: Stepper, PatientPicker; shadcn sheet Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
parent
83d3e840b5
commit
c099858ad7
|
|
@ -14,9 +14,11 @@ export * from "./page-tabs"
|
|||
export * from "./pagination"
|
||||
export * from "./patient-avatar"
|
||||
export * from "./patient-panel"
|
||||
export * from "./patient-picker"
|
||||
export * from "./person-chip"
|
||||
export * from "./save-bar"
|
||||
export * from "./search-input"
|
||||
export * from "./stat-tile"
|
||||
export * from "./status-badge"
|
||||
export * from "./stepper"
|
||||
export * from "./time-range-input"
|
||||
|
|
|
|||
|
|
@ -0,0 +1,124 @@
|
|||
import * as React from "react"
|
||||
import { ChevronsUpDownIcon, UserSearchIcon, XIcon } from "lucide-react"
|
||||
|
||||
import { cn } from "@/lib/utils"
|
||||
import { Command, CommandEmpty, CommandGroup, CommandInput, CommandItem, CommandList } from "@/components/ui/command"
|
||||
import { Popover, PopoverContent, PopoverTrigger } from "@/components/ui/popover"
|
||||
import { GenderMark, PatientAvatar, type AvatarPerson } from "./patient-avatar"
|
||||
|
||||
export interface PickerPatient extends AvatarPerson {
|
||||
readonly id: number
|
||||
readonly middleName?: string
|
||||
readonly birthDate: string
|
||||
readonly phone?: string
|
||||
readonly cardNumber?: string
|
||||
}
|
||||
|
||||
/** Выбор пациента из картотеки: поиск по ФИО, телефону, номеру карты. */
|
||||
export function PatientPicker({
|
||||
patients,
|
||||
value,
|
||||
onChange,
|
||||
placeholder = "Найдите пациента",
|
||||
invalid,
|
||||
className,
|
||||
}: {
|
||||
patients: readonly PickerPatient[]
|
||||
value: number | null
|
||||
onChange: (id: number | null) => void
|
||||
placeholder?: string
|
||||
invalid?: boolean
|
||||
className?: string
|
||||
}) {
|
||||
const [open, setOpen] = React.useState(false)
|
||||
const selected = patients.find((p) => p.id === value)
|
||||
const name = (p: PickerPatient) => `${p.lastName} ${p.firstName} ${p.middleName ?? ""}`.trim()
|
||||
|
||||
return (
|
||||
<Popover open={open} onOpenChange={setOpen}>
|
||||
<PopoverTrigger asChild>
|
||||
<button
|
||||
type="button"
|
||||
role="combobox"
|
||||
aria-expanded={open}
|
||||
aria-invalid={invalid}
|
||||
className={cn(
|
||||
"flex min-h-12 w-full items-center gap-3 rounded-lg border border-input bg-transparent px-3 py-2 text-left text-sm shadow-xs transition outline-none",
|
||||
"focus-visible:border-ring focus-visible:ring-[3px] focus-visible:ring-ring/50 aria-invalid:border-destructive",
|
||||
className,
|
||||
)}
|
||||
>
|
||||
{selected ? (
|
||||
<>
|
||||
<PatientAvatar patient={selected} className="size-8" />
|
||||
<span className="min-w-0 flex-1">
|
||||
<span className="block truncate font-semibold">
|
||||
{name(selected)} <GenderMark gender={selected.gender} className="text-xs" />
|
||||
</span>
|
||||
<span className="block text-xs text-muted-foreground">
|
||||
{selected.birthDate}
|
||||
{selected.cardNumber && <> · карта {selected.cardNumber}</>}
|
||||
{selected.phone && <> · {selected.phone}</>}
|
||||
</span>
|
||||
</span>
|
||||
<span
|
||||
role="button"
|
||||
tabIndex={0}
|
||||
aria-label="Очистить"
|
||||
onClick={(e) => {
|
||||
e.stopPropagation()
|
||||
onChange(null)
|
||||
}}
|
||||
onKeyDown={(e) => {
|
||||
if (e.key === "Enter") {
|
||||
e.stopPropagation()
|
||||
onChange(null)
|
||||
}
|
||||
}}
|
||||
className="grid size-6 place-items-center rounded text-muted-foreground hover:bg-muted hover:text-foreground"
|
||||
>
|
||||
<XIcon className="size-3.5" />
|
||||
</span>
|
||||
</>
|
||||
) : (
|
||||
<>
|
||||
<UserSearchIcon className="size-4 text-muted-foreground" />
|
||||
<span className="flex-1 text-muted-foreground">{placeholder}</span>
|
||||
<ChevronsUpDownIcon className="size-4 text-muted-foreground" />
|
||||
</>
|
||||
)}
|
||||
</button>
|
||||
</PopoverTrigger>
|
||||
<PopoverContent align="start" className="w-(--radix-popover-trigger-width) min-w-80 p-0">
|
||||
<Command>
|
||||
<CommandInput placeholder="ФИО, телефон или номер карты…" />
|
||||
<CommandList>
|
||||
<CommandEmpty>Пациент не найден</CommandEmpty>
|
||||
<CommandGroup>
|
||||
{patients.map((p) => (
|
||||
<CommandItem
|
||||
key={p.id}
|
||||
value={`${name(p)} ${p.phone ?? ""} ${p.cardNumber ?? ""} ${p.id}`}
|
||||
onSelect={() => {
|
||||
onChange(p.id)
|
||||
setOpen(false)
|
||||
}}
|
||||
className="gap-3"
|
||||
>
|
||||
<PatientAvatar patient={p} className="size-7" />
|
||||
<div className="min-w-0 flex-1">
|
||||
<div className="truncate font-medium">{name(p)}</div>
|
||||
<div className="text-xs text-muted-foreground">
|
||||
{p.birthDate}
|
||||
{p.cardNumber && <> · карта {p.cardNumber}</>}
|
||||
</div>
|
||||
</div>
|
||||
</CommandItem>
|
||||
))}
|
||||
</CommandGroup>
|
||||
</CommandList>
|
||||
</Command>
|
||||
</PopoverContent>
|
||||
</Popover>
|
||||
)
|
||||
}
|
||||
|
|
@ -0,0 +1,58 @@
|
|||
import { CheckIcon } from "lucide-react"
|
||||
|
||||
import { cn } from "@/lib/utils"
|
||||
|
||||
export interface StepItem {
|
||||
readonly label: string
|
||||
/** Подпись под шагом: выбранный слот, пациент… */
|
||||
readonly hint?: string
|
||||
}
|
||||
|
||||
/** Шаги мастера: пройденные — с галочкой и кликабельны, будущие — недоступны. */
|
||||
export function Stepper({
|
||||
steps,
|
||||
current,
|
||||
onStepClick,
|
||||
className,
|
||||
}: {
|
||||
steps: readonly StepItem[]
|
||||
current: number
|
||||
onStepClick?: (index: number) => void
|
||||
className?: string
|
||||
}) {
|
||||
return (
|
||||
<ol className={cn("flex items-center gap-2", className)}>
|
||||
{steps.map((step, i) => {
|
||||
const done = i < current
|
||||
const active = i === current
|
||||
const clickable = Boolean(onStepClick) && done
|
||||
return (
|
||||
<li key={step.label} className="flex min-w-0 items-center gap-2">
|
||||
{i > 0 && <span className={cn("h-px w-6 shrink-0 sm:w-10", done || active ? "bg-primary/50" : "bg-border")} />}
|
||||
<button
|
||||
type="button"
|
||||
disabled={!clickable}
|
||||
onClick={() => onStepClick?.(i)}
|
||||
className={cn("flex min-w-0 items-center gap-2 rounded-lg px-1.5 py-1 text-left transition", clickable && "hover:bg-muted")}
|
||||
>
|
||||
<span
|
||||
className={cn(
|
||||
"grid size-6 shrink-0 place-items-center rounded-full text-xs font-semibold",
|
||||
done && "bg-primary text-primary-foreground",
|
||||
active && "bg-primary/15 text-primary ring-2 ring-primary/40",
|
||||
!done && !active && "bg-muted text-muted-foreground",
|
||||
)}
|
||||
>
|
||||
{done ? <CheckIcon className="size-3.5" /> : i + 1}
|
||||
</span>
|
||||
<span className="min-w-0 leading-tight">
|
||||
<span className={cn("block text-sm font-medium", !done && !active && "text-muted-foreground")}>{step.label}</span>
|
||||
{step.hint && <span className="block truncate text-[11px] text-muted-foreground">{step.hint}</span>}
|
||||
</span>
|
||||
</button>
|
||||
</li>
|
||||
)
|
||||
})}
|
||||
</ol>
|
||||
)
|
||||
}
|
||||
|
|
@ -0,0 +1,141 @@
|
|||
|
||||
import * as React from "react"
|
||||
import { cn } from "@/lib/utils"
|
||||
import { XIcon } from "lucide-react"
|
||||
import { Dialog as SheetPrimitive } from "radix-ui"
|
||||
|
||||
function Sheet({ ...props }: React.ComponentProps<typeof SheetPrimitive.Root>) {
|
||||
return <SheetPrimitive.Root data-slot="sheet" {...props} />
|
||||
}
|
||||
|
||||
function SheetTrigger({
|
||||
...props
|
||||
}: React.ComponentProps<typeof SheetPrimitive.Trigger>) {
|
||||
return <SheetPrimitive.Trigger data-slot="sheet-trigger" {...props} />
|
||||
}
|
||||
|
||||
function SheetClose({
|
||||
...props
|
||||
}: React.ComponentProps<typeof SheetPrimitive.Close>) {
|
||||
return <SheetPrimitive.Close data-slot="sheet-close" {...props} />
|
||||
}
|
||||
|
||||
function SheetPortal({
|
||||
...props
|
||||
}: React.ComponentProps<typeof SheetPrimitive.Portal>) {
|
||||
return <SheetPrimitive.Portal data-slot="sheet-portal" {...props} />
|
||||
}
|
||||
|
||||
function SheetOverlay({
|
||||
className,
|
||||
...props
|
||||
}: React.ComponentProps<typeof SheetPrimitive.Overlay>) {
|
||||
return (
|
||||
<SheetPrimitive.Overlay
|
||||
data-slot="sheet-overlay"
|
||||
className={cn(
|
||||
"fixed inset-0 z-50 bg-black/50 data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:animate-in data-[state=open]:fade-in-0",
|
||||
className
|
||||
)}
|
||||
{...props}
|
||||
/>
|
||||
)
|
||||
}
|
||||
|
||||
function SheetContent({
|
||||
className,
|
||||
children,
|
||||
side = "right",
|
||||
showCloseButton = true,
|
||||
...props
|
||||
}: React.ComponentProps<typeof SheetPrimitive.Content> & {
|
||||
side?: "top" | "right" | "bottom" | "left"
|
||||
showCloseButton?: boolean
|
||||
}) {
|
||||
return (
|
||||
<SheetPortal>
|
||||
<SheetOverlay />
|
||||
<SheetPrimitive.Content
|
||||
data-slot="sheet-content"
|
||||
className={cn(
|
||||
"fixed z-50 flex flex-col gap-4 bg-background shadow-lg transition ease-in-out data-[state=closed]:animate-out data-[state=closed]:duration-300 data-[state=open]:animate-in data-[state=open]:duration-500",
|
||||
side === "right" &&
|
||||
"inset-y-0 right-0 h-full w-3/4 border-l data-[state=closed]:slide-out-to-right data-[state=open]:slide-in-from-right sm:max-w-sm",
|
||||
side === "left" &&
|
||||
"inset-y-0 left-0 h-full w-3/4 border-r data-[state=closed]:slide-out-to-left data-[state=open]:slide-in-from-left sm:max-w-sm",
|
||||
side === "top" &&
|
||||
"inset-x-0 top-0 h-auto border-b data-[state=closed]:slide-out-to-top data-[state=open]:slide-in-from-top",
|
||||
side === "bottom" &&
|
||||
"inset-x-0 bottom-0 h-auto border-t data-[state=closed]:slide-out-to-bottom data-[state=open]:slide-in-from-bottom",
|
||||
className
|
||||
)}
|
||||
{...props}
|
||||
>
|
||||
{children}
|
||||
{showCloseButton && (
|
||||
<SheetPrimitive.Close className="absolute top-4 right-4 rounded-xs opacity-70 ring-offset-background transition-opacity hover:opacity-100 focus:ring-2 focus:ring-ring focus:ring-offset-2 focus:outline-hidden disabled:pointer-events-none data-[state=open]:bg-secondary">
|
||||
<XIcon className="size-4" />
|
||||
<span className="sr-only">Close</span>
|
||||
</SheetPrimitive.Close>
|
||||
)}
|
||||
</SheetPrimitive.Content>
|
||||
</SheetPortal>
|
||||
)
|
||||
}
|
||||
|
||||
function SheetHeader({ className, ...props }: React.ComponentProps<"div">) {
|
||||
return (
|
||||
<div
|
||||
data-slot="sheet-header"
|
||||
className={cn("flex flex-col gap-1.5 p-4", className)}
|
||||
{...props}
|
||||
/>
|
||||
)
|
||||
}
|
||||
|
||||
function SheetFooter({ className, ...props }: React.ComponentProps<"div">) {
|
||||
return (
|
||||
<div
|
||||
data-slot="sheet-footer"
|
||||
className={cn("mt-auto flex flex-col gap-2 p-4", className)}
|
||||
{...props}
|
||||
/>
|
||||
)
|
||||
}
|
||||
|
||||
function SheetTitle({
|
||||
className,
|
||||
...props
|
||||
}: React.ComponentProps<typeof SheetPrimitive.Title>) {
|
||||
return (
|
||||
<SheetPrimitive.Title
|
||||
data-slot="sheet-title"
|
||||
className={cn("font-semibold text-foreground", className)}
|
||||
{...props}
|
||||
/>
|
||||
)
|
||||
}
|
||||
|
||||
function SheetDescription({
|
||||
className,
|
||||
...props
|
||||
}: React.ComponentProps<typeof SheetPrimitive.Description>) {
|
||||
return (
|
||||
<SheetPrimitive.Description
|
||||
data-slot="sheet-description"
|
||||
className={cn("text-sm text-muted-foreground", className)}
|
||||
{...props}
|
||||
/>
|
||||
)
|
||||
}
|
||||
|
||||
export {
|
||||
Sheet,
|
||||
SheetTrigger,
|
||||
SheetClose,
|
||||
SheetContent,
|
||||
SheetHeader,
|
||||
SheetFooter,
|
||||
SheetTitle,
|
||||
SheetDescription,
|
||||
}
|
||||
Loading…
Reference in New Issue