chore(workspace): move the app to apps/app under a pnpm workspace (step 2)
144 files moved with git mv (pure renames). Root package.json delegates dev/typecheck/test:run/lint/build to the packages; Node 24 LTS and pnpm 10.13.1 pinned (.nvmrc, .node-version, engines, packageManager, root devDependency, engine-strict). Dockerfile builds @faunosteo/app on node:24-alpine and copies apps/app/dist; nginx and runtime config unchanged. CI workflow for Gitea Actions. packages/ reserved (README only). Docs synced: WORKSPACE.md, CLAUDE.md, README, DEPLOY, CHANGELOG, plan. 271/271 tests, typecheck, lint, build green from the root.
This commit is contained in:
1 parent
c8d48ab4cc
commit
8673475293
164 files changed
+348
-128
No files matched your search
@@ -0,0 +1,115 @@
|
||||
import { useState } from 'react'
|
||||
import Dialog from '@/components/ui/Dialog'
|
||||
import Button from '@/components/ui/Button'
|
||||
import Chip from '@/components/ui/Chip'
|
||||
import type { Vertebra, VertebralRegion } from '@/domain/schema/observation'
|
||||
import type { VertebralFormula } from '@/domain/species/types'
|
||||
import { useT } from '@/i18n/useT'
|
||||
|
||||
const REGIONS: VertebralRegion[] = ['C', 'T', 'L', 'S', 'Cd']
|
||||
const REGION_KEY: Record<VertebralRegion, string> = {
|
||||
C: 'vertebra.region.C',
|
||||
T: 'vertebra.region.T',
|
||||
L: 'vertebra.region.L',
|
||||
S: 'vertebra.region.S',
|
||||
Cd: 'vertebra.region.Cd',
|
||||
}
|
||||
|
||||
export interface VertebraPickerProps {
|
||||
open: boolean
|
||||
onClose: () => void
|
||||
onConfirm: (vertebrae: Vertebra[]) => void
|
||||
initial: Vertebra[]
|
||||
formula: VertebralFormula
|
||||
title: string
|
||||
/** Tab to open on. Takes priority so a click always lands on its own zone. */
|
||||
initialRegion?: VertebralRegion
|
||||
}
|
||||
|
||||
export default function VertebraPicker({
|
||||
open,
|
||||
onClose,
|
||||
onConfirm,
|
||||
initial,
|
||||
formula,
|
||||
title,
|
||||
initialRegion,
|
||||
}: VertebraPickerProps) {
|
||||
const t = useT()
|
||||
const [selected, setSelected] = useState<Vertebra[]>(initial)
|
||||
const [activeRegion, setActiveRegion] = useState<VertebralRegion>(
|
||||
() => initialRegion ?? initial[0]?.region ?? 'C',
|
||||
)
|
||||
|
||||
const has = (r: VertebralRegion, i: number) =>
|
||||
selected.some((v) => v.region === r && v.index === i)
|
||||
|
||||
const toggle = (r: VertebralRegion, i: number) => {
|
||||
setSelected((cur) =>
|
||||
has(r, i)
|
||||
? cur.filter((v) => !(v.region === r && v.index === i))
|
||||
: [...cur, { region: r, index: i }],
|
||||
)
|
||||
}
|
||||
|
||||
const all = (r: VertebralRegion, count: number) => {
|
||||
setSelected((cur) => {
|
||||
const rest = cur.filter((v) => v.region !== r)
|
||||
return [...rest, ...Array.from({ length: count }, (_, k) => ({ region: r, index: k + 1 }))]
|
||||
})
|
||||
}
|
||||
|
||||
const none = (r: VertebralRegion) =>
|
||||
setSelected((cur) => cur.filter((v) => v.region !== r))
|
||||
|
||||
const count = formula[activeRegion]
|
||||
|
||||
return (
|
||||
<Dialog open={open} onClose={onClose} title={title} size="lg">
|
||||
<div role="tablist" className="flex flex-wrap gap-2 mb-4">
|
||||
{REGIONS.map((r) => (
|
||||
<button
|
||||
key={r}
|
||||
role="tab"
|
||||
aria-selected={activeRegion === r}
|
||||
onClick={() => setActiveRegion(r)}
|
||||
className={[
|
||||
'rounded-full px-4 py-2.5 sm:py-1.5 text-sm font-medium border min-h-[2.75rem]',
|
||||
activeRegion === r
|
||||
? 'bg-[var(--color-accent)] text-white border-[var(--color-accent)]'
|
||||
: 'bg-white text-[var(--color-ink)] border-[var(--color-border)]',
|
||||
].join(' ')}
|
||||
>
|
||||
{t(REGION_KEY[r])}
|
||||
</button>
|
||||
))}
|
||||
</div>
|
||||
|
||||
<div className="flex flex-wrap gap-2 mb-4 max-h-64 overflow-auto">
|
||||
{Array.from({ length: count }, (_, k) => k + 1).map((i) => (
|
||||
<Chip
|
||||
key={i}
|
||||
active={has(activeRegion, i)}
|
||||
onClick={() => toggle(activeRegion, i)}
|
||||
>
|
||||
{activeRegion}{i}
|
||||
</Chip>
|
||||
))}
|
||||
</div>
|
||||
|
||||
<div className="flex flex-wrap items-center gap-2 mb-6">
|
||||
<Button variant="ghost" size="sm" onClick={() => all(activeRegion, count)}>
|
||||
{t('vertebra.check_all')}
|
||||
</Button>
|
||||
<Button variant="ghost" size="sm" onClick={() => none(activeRegion)}>
|
||||
{t('vertebra.uncheck_all')}
|
||||
</Button>
|
||||
</div>
|
||||
|
||||
<div className="flex justify-end gap-2">
|
||||
<Button variant="ghost" onClick={onClose}>{t('common.cancel')}</Button>
|
||||
<Button onClick={() => onConfirm(selected)}>{t('common.confirm')}</Button>
|
||||
</div>
|
||||
</Dialog>
|
||||
)
|
||||
}
|
||||
Reference in new issue
Block a user