{
  "$schema": "https://ui.shadcn.com/schema/registry-item.json",
  "name": "client-profile",
  "title": "Client profile",
  "description": "Cover-art client card with lifetime value, visits and copyable contact details, editable tags, a monthly spend chart, next-visit card, visit timeline with ratings, team notes with undo and copyable color formulas, plus book and SMS actions.",
  "dependencies": [
    "lucide-react"
  ],
  "registryDependencies": [
    "https://goodui.dev/r/avatar.json",
    "https://goodui.dev/r/badge.json",
    "https://goodui.dev/r/button.json",
    "https://goodui.dev/r/dialog.json",
    "https://goodui.dev/r/input.json",
    "https://goodui.dev/r/number-flow.json",
    "https://goodui.dev/r/rating.json",
    "https://goodui.dev/r/tabs.json"
  ],
  "files": [
    {
      "path": "registry/blocks/booking/client-profile.tsx",
      "content": "\"use client\"\n\nimport * as React from \"react\"\nimport { CalendarPlus, Check, Copy, Crown, Gift, Mail, MessageSquare, Pencil, Phone, Plus, Scissors, Sparkles, Star, Trash2, Undo2 } from \"lucide-react\"\nimport { Avatar } from \"@/components/goodui/avatar\"\nimport { Badge } from \"@/components/goodui/badge\"\nimport { Button } from \"@/components/goodui/button\"\nimport { Dialog } from \"@/components/goodui/dialog\"\nimport { Input } from \"@/components/goodui/input\"\nimport { Rating } from \"@/components/goodui/rating\"\nimport { Tabs, TabsContent, TabsList, TabsTrigger } from \"@/components/goodui/tabs\"\nimport { NumberFlow } from \"@/components/goodui/number-flow\"\nimport { cn } from \"@/lib/utils\"\n\n/* ---------- Demo data ---------- */\n\ntype Visit = { id: string; date: string; service: string; staff: string; price: number; rating: number | null; note?: string }\nconst VISITS: Visit[] = [\n  { id: \"v1\", date: \"28 Feb 2026\", service: \"Balayage + gloss\", staff: \"Ana Petrova\", price: 240, rating: 5, note: \"Loved the warmer tone. Keep ends 1cm longer next time.\" },\n  { id: \"v2\", date: \"14 Jan 2026\", service: \"Cut & blow-dry\", staff: \"Ana Petrova\", price: 85, rating: 5 },\n  { id: \"v3\", date: \"2 Dec 2025\", service: \"Root touch-up\", staff: \"Mia Okafor\", price: 120, rating: 4, note: \"Asked for less ash next time.\" },\n  { id: \"v4\", date: \"20 Oct 2025\", service: \"Balayage\", staff: \"Ana Petrova\", price: 220, rating: 5 },\n  { id: \"v5\", date: \"3 Sep 2025\", service: \"Cut & blow-dry\", staff: \"Leo Martins\", price: 85, rating: 3, note: \"Fringe too short.\" },\n  { id: \"v6\", date: \"12 Jul 2025\", service: \"Olaplex treatment\", staff: \"Mia Okafor\", price: 60, rating: null },\n]\nconst FORMULAS = [\n  { label: \"Root\", value: \"6.0 + 6.1 (1:1) · 20 vol · 35 min\" },\n  { label: \"Lengths\", value: \"Blondme lifting + 7 vol · 45 min\" },\n  { label: \"Gloss\", value: \"9N + 9V (2:1) · 10 min\" },\n]\nconst INITIAL_TAGS = [\"VIP\", \"Prefers Ana\", \"Sensitive scalp\"]\nconst MONTHS = [\"Jul\", \"Aug\", \"Sep\", \"Oct\", \"Nov\", \"Dec\", \"Jan\", \"Feb\"]\nconst SPEND = [60, 0, 85, 220, 0, 120, 85, 240]\n\n/* ---------- Block ---------- */\n\nexport default function ClientProfile() {\n  const [tags, setTags] = React.useState(INITIAL_TAGS)\n  const [newTag, setNewTag] = React.useState(\"\")\n  const [addingTag, setAddingTag] = React.useState(false)\n  const [notes, setNotes] = React.useState<{ id: string; text: string; when: string }[]>([\n    { id: \"n1\", text: \"Allergic to PPD, patch test done 12 Jul 2025.\", when: \"Jul 2025\" },\n    { id: \"n2\", text: \"Getting married in June, wants a trial up-do in May.\", when: \"Feb 2026\" },\n  ])\n  const [noteDraft, setNoteDraft] = React.useState(\"\")\n  const [removed, setRemoved] = React.useState<{ id: string; text: string; when: string; index: number } | null>(null)\n  const [copied, setCopied] = React.useState<string | null>(null)\n  const [booked, setBooked] = React.useState(false)\n  const [messageOpen, setMessageOpen] = React.useState(false)\n  const [message, setMessage] = React.useState(\"Hi Maya, it's been a few weeks since your balayage. Ready for a gloss refresh? Reply and I'll find you a slot.\")\n  const [sent, setSent] = React.useState(false)\n\n  const total = VISITS.reduce((s, v) => s + v.price, 0)\n  const avg = Math.round(total / VISITS.length)\n  const rated = VISITS.filter((v) => v.rating !== null)\n  const avgRating = rated.reduce((s, v) => s + (v.rating ?? 0), 0) / rated.length\n  const max = Math.max(...SPEND)\n\n  const copy = (what: string, value: string) => {\n    void navigator.clipboard?.writeText(value)\n    setCopied(what)\n    window.setTimeout(() => setCopied(null), 1500)\n  }\n  const addTag = () => {\n    const t = newTag.trim()\n    if (!t || tags.includes(t)) return\n    setTags([...tags, t])\n    setNewTag(\"\")\n    setAddingTag(false)\n  }\n  const addNote = () => {\n    const t = noteDraft.trim()\n    if (!t) return\n    setNotes([{ id: `n${Date.now()}`, text: t, when: \"Just now\" }, ...notes])\n    setNoteDraft(\"\")\n  }\n  const removeNote = (id: string) => {\n    const index = notes.findIndex((n) => n.id === id)\n    const n = notes[index]\n    if (!n) return\n    setRemoved({ ...n, index })\n    setNotes(notes.filter((x) => x.id !== id))\n    window.setTimeout(() => setRemoved((r) => (r?.id === id ? null : r)), 6000)\n  }\n\n  return (\n    <div className=\"p-4 md:p-6\">\n      <div className=\"mx-auto grid max-w-6xl gap-4 lg:grid-cols-[320px_1fr]\">\n        {/* Identity card */}\n        <aside className=\"relative overflow-hidden rounded-2xl border bg-card shadow-xs\">\n          <div className=\"h-24 bg-[linear-gradient(120deg,var(--chart-1),var(--chart-4))] opacity-80\" />\n          <div className=\"-mt-10 px-5 pb-5\">\n            <Avatar name=\"Maya Chen\" size=\"2xl\" ring=\"solid\" tone=\"primary\" className=\"bg-card\" />\n            <div className=\"mt-3 flex items-start justify-between gap-2\">\n              <div>\n                <h2 className=\"font-heading text-xl font-semibold tracking-tight\">Maya Chen</h2>\n                <p className=\"text-sm text-muted-foreground\">Client since Jul 2025 · she/her</p>\n              </div>\n              <Badge variant=\"gradient\" tone=\"warning\" size=\"sm\" icon={<Crown />}>\n                VIP\n              </Badge>\n            </div>\n\n            <dl className=\"mt-4 grid grid-cols-3 gap-2 text-center\">\n              <div className=\"rounded-xl bg-muted/60 p-2\">\n                <dt className=\"text-[11px] text-muted-foreground\">Visits</dt>\n                <dd className=\"text-lg font-semibold tabular-nums\">{VISITS.length}</dd>\n              </div>\n              <div className=\"rounded-xl bg-muted/60 p-2\">\n                <dt className=\"text-[11px] text-muted-foreground\">Lifetime</dt>\n                <dd className=\"text-lg font-semibold tabular-nums\">\n                  <NumberFlow value={total} prefix=\"$\" />\n                </dd>\n              </div>\n              <div className=\"rounded-xl bg-muted/60 p-2\">\n                <dt className=\"text-[11px] text-muted-foreground\">Avg. ticket</dt>\n                <dd className=\"text-lg font-semibold tabular-nums\">${avg}</dd>\n              </div>\n            </dl>\n\n            <div className=\"mt-4 space-y-1.5 text-sm\">\n              <ContactRow icon={<Phone />} value=\"+1 (415) 555-0142\" onCopy={() => copy(\"phone\", \"+14155550142\")} copied={copied === \"phone\"} />\n              <ContactRow icon={<Mail />} value=\"maya.chen@example.com\" onCopy={() => copy(\"email\", \"maya.chen@example.com\")} copied={copied === \"email\"} />\n            </div>\n\n            <div className=\"mt-4\">\n              <div className=\"mb-1.5 text-xs font-medium text-muted-foreground\">Tags</div>\n              <div className=\"flex flex-wrap gap-1.5\">\n                {tags.map((t) => (\n                  <Badge key={t} variant=\"soft\" tone={t === \"VIP\" ? \"warning\" : \"neutral\"} size=\"sm\" removable onRemove={() => setTags(tags.filter((x) => x !== t))}>\n                    {t}\n                  </Badge>\n                ))}\n                {addingTag ? (\n                  <form\n                    className=\"flex items-center gap-1\"\n                    onSubmit={(e) => {\n                      e.preventDefault()\n                      addTag()\n                    }}\n                  >\n                    <Input size=\"sm\" label=\"New tag\" labelMode=\"none\" value={newTag} onValueChange={setNewTag} placeholder=\"Tag name\" autoFocus className=\"w-32\" />\n                    <Button size=\"sm\" type=\"submit\" iconOnly aria-label=\"Add tag\">\n                      <Check />\n                    </Button>\n                  </form>\n                ) : (\n                  <Button size=\"xs\" variant=\"dashed\" tone=\"neutral\" shape=\"pill\" iconLeft={<Plus />} onClick={() => setAddingTag(true)}>\n                    Add\n                  </Button>\n                )}\n              </div>\n            </div>\n\n            <div className=\"mt-5 grid grid-cols-2 gap-2\">\n              <Button size=\"sm\" iconLeft={booked ? <Check /> : <CalendarPlus />} tone={booked ? \"success\" : \"primary\"} variant={booked ? \"soft\" : \"solid\"} onClick={() => setBooked(true)} disabled={booked}>\n                {booked ? \"Booked Sat\" : \"Book\"}\n              </Button>\n              <Button size=\"sm\" variant=\"outline\" tone=\"neutral\" iconLeft={<MessageSquare />} onClick={() => setMessageOpen(true)}>\n                Message\n              </Button>\n            </div>\n          </div>\n        </aside>\n\n        {/* Main */}\n        <div className=\"min-w-0 space-y-4\">\n          {/* Spend chart + next */}\n          <div className=\"grid gap-4 md:grid-cols-[1fr_240px]\">\n            <div className=\"rounded-2xl border bg-card p-5 shadow-xs\">\n              <div className=\"flex items-center justify-between\">\n                <div>\n                  <div className=\"text-sm font-medium\">Spend by month</div>\n                  <div className=\"text-xs text-muted-foreground\">Last 8 months</div>\n                </div>\n                <div className=\"flex items-center gap-1.5 text-sm\">\n                  <Rating value={Math.round(avgRating * 2) / 2} precision={0.5} readOnly size=\"sm\" />\n                  <span className=\"tabular-nums text-muted-foreground\">{avgRating.toFixed(1)}</span>\n                </div>\n              </div>\n              <div className=\"mt-4 flex h-28 items-end gap-2\" role=\"img\" aria-label={`Monthly spend, highest $${max}`}>\n                {SPEND.map((v, i) => (\n                  <div key={i} className=\"flex flex-1 flex-col items-center gap-1.5\">\n                    <div className=\"flex h-20 w-full items-end\">\n                      <div\n                        className={cn(\"w-full rounded-md transition-[height] duration-700 motion-reduce:transition-none\", v === 0 ? \"bg-muted\" : \"bg-[var(--chart-1)]\")}\n                        style={{ height: v === 0 ? 4 : `${Math.max(8, (v / max) * 100)}%` }}\n                        title={`${MONTHS[i]}: $${v}`}\n                      />\n                    </div>\n                    <span className=\"text-[10px] text-muted-foreground\">{MONTHS[i]}</span>\n                  </div>\n                ))}\n              </div>\n            </div>\n            <div className=\"rounded-2xl border border-primary/30 bg-primary/5 p-5\">\n              <div className=\"flex items-center gap-2 text-xs font-medium text-primary\">\n                <Sparkles className=\"size-3.5\" /> Next visit\n              </div>\n              <div className=\"mt-2 text-lg font-semibold\">Sat 14 Mar · 10:30</div>\n              <div className=\"text-sm text-foreground/70\">Gloss refresh with Ana</div>\n              <div className=\"mt-3 flex items-center gap-2 text-xs text-foreground/70\">\n                <Gift className=\"size-3.5\" /> 1,240 points · $12 reward ready\n              </div>\n            </div>\n          </div>\n\n          <Tabs defaultValue=\"visits\" variant=\"underline\" transition=\"fade\">\n            <TabsList aria-label=\"Client details\">\n              <TabsTrigger value=\"visits\" icon={<Scissors />} count={VISITS.length}>\n                Visits\n              </TabsTrigger>\n              <TabsTrigger value=\"notes\" icon={<Pencil />} count={notes.length}>\n                Notes\n              </TabsTrigger>\n              <TabsTrigger value=\"formulas\" icon={<Star />}>\n                Color formulas\n              </TabsTrigger>\n            </TabsList>\n\n            <TabsContent value=\"visits\">\n              <ol className=\"relative mt-4 space-y-0 border-l pl-6 ml-2\">\n                {VISITS.map((v, i) => (\n                  <li key={v.id} className=\"relative pb-5 last:pb-0\">\n                    <span className={cn(\"absolute -left-[31px] top-1 flex size-4 items-center justify-center rounded-full border-2 border-card\", i === 0 ? \"bg-primary\" : \"bg-muted-foreground/40\")} aria-hidden=\"true\" />\n                    <div className=\"flex flex-wrap items-start justify-between gap-2\">\n                      <div>\n                        <div className=\"text-sm font-medium\">{v.service}</div>\n                        <div className=\"text-xs text-muted-foreground\">\n                          {v.date} · with {v.staff}\n                        </div>\n                        {v.note && <div className=\"mt-1.5 rounded-lg bg-muted/60 px-2.5 py-1.5 text-xs text-foreground/80\">“{v.note}”</div>}\n                      </div>\n                      <div className=\"text-right\">\n                        <div className=\"text-sm font-semibold tabular-nums\">${v.price}</div>\n                        {v.rating !== null ? <Rating value={v.rating} readOnly size=\"sm\" /> : <span className=\"text-xs text-muted-foreground\">Not rated</span>}\n                      </div>\n                    </div>\n                  </li>\n                ))}\n              </ol>\n            </TabsContent>\n\n            <TabsContent value=\"notes\">\n              <div className=\"mt-4 space-y-3\">\n                <form\n                  className=\"flex gap-2\"\n                  onSubmit={(e) => {\n                    e.preventDefault()\n                    addNote()\n                  }}\n                >\n                  <Input label=\"New note\" labelMode=\"none\" placeholder=\"Add a note the whole team should know…\" value={noteDraft} onValueChange={setNoteDraft} fullWidth />\n                  <Button type=\"submit\" iconLeft={<Plus />} disabled={!noteDraft.trim()}>\n                    Add\n                  </Button>\n                </form>\n                <div aria-live=\"polite\">\n                  {removed && (\n                    <div className=\"flex items-center justify-between gap-2 rounded-xl border border-dashed px-3 py-2 text-xs\">\n                      Note deleted.\n                      <Button\n                        size=\"xs\"\n                        variant=\"soft\"\n                        tone=\"neutral\"\n                        iconLeft={<Undo2 />}\n                        onClick={() => {\n                          const next = [...notes]\n                          next.splice(removed.index, 0, { id: removed.id, text: removed.text, when: removed.when })\n                          setNotes(next)\n                          setRemoved(null)\n                        }}\n                      >\n                        Undo\n                      </Button>\n                    </div>\n                  )}\n                </div>\n                <ul className=\"space-y-2\">\n                  {notes.map((n) => (\n                    <li key={n.id} className=\"group flex items-start gap-3 rounded-xl border bg-card p-3\">\n                      <Pencil className=\"mt-0.5 size-4 shrink-0 text-muted-foreground\" aria-hidden=\"true\" />\n                      <div className=\"min-w-0 flex-1\">\n                        <p className=\"text-sm\">{n.text}</p>\n                        <p className=\"text-xs text-muted-foreground\">{n.when}</p>\n                      </div>\n                      <Button size=\"xs\" variant=\"ghost\" tone=\"danger\" iconOnly aria-label=\"Delete note\" onClick={() => removeNote(n.id)}>\n                        <Trash2 />\n                      </Button>\n                    </li>\n                  ))}\n                </ul>\n              </div>\n            </TabsContent>\n\n            <TabsContent value=\"formulas\">\n              <div className=\"mt-4 overflow-hidden rounded-2xl border bg-card\">\n                {FORMULAS.map((f, i) => (\n                  <div key={f.label} className={cn(\"flex items-center gap-3 px-4 py-3\", i > 0 && \"border-t\")}>\n                    <span className=\"w-16 text-xs font-medium text-muted-foreground\">{f.label}</span>\n                    <code className=\"flex-1 font-mono text-sm\">{f.value}</code>\n                    <Button size=\"xs\" variant=\"ghost\" tone=\"neutral\" iconOnly aria-label={`Copy ${f.label} formula`} onClick={() => copy(f.label, f.value)}>\n                      {copied === f.label ? <Check /> : <Copy />}\n                    </Button>\n                  </div>\n                ))}\n                <div className=\"border-t bg-muted/40 px-4 py-2 text-xs text-muted-foreground\">Last used 28 Feb 2026 by Ana Petrova</div>\n              </div>\n            </TabsContent>\n          </Tabs>\n        </div>\n      </div>\n\n      <Dialog\n        open={messageOpen}\n        onOpenChange={(o) => {\n          setMessageOpen(o)\n          if (!o) setSent(false)\n        }}\n        title=\"Message Maya\"\n        description=\"Sent as SMS to +1 (415) 555-0142.\"\n        icon={<MessageSquare />}\n        mobile=\"sheet\"\n        onConfirm={async () => {\n          await new Promise((r) => setTimeout(r, 600))\n          setSent(true)\n        }}\n        confirmText={sent ? \"Sent\" : \"Send SMS\"}\n        closeOnConfirm={false}\n      >\n        <Input multiline rows={4} label=\"Message\" labelMode=\"none\" value={message} onValueChange={setMessage} showCount maxLength={320} fullWidth />\n        {sent && (\n          <div role=\"status\" className=\"mt-3 flex items-center gap-2 rounded-lg bg-emerald-500/10 px-3 py-2 text-sm text-emerald-800 dark:text-emerald-300\">\n            <Check className=\"size-4\" /> Delivered just now.\n          </div>\n        )}\n      </Dialog>\n    </div>\n  )\n}\n\nfunction ContactRow({ icon, value, onCopy, copied }: { icon: React.ReactNode; value: string; onCopy: () => void; copied: boolean }) {\n  return (\n    <div className=\"flex items-center gap-2\">\n      <span className=\"text-muted-foreground [&_svg]:size-4\">{icon}</span>\n      <span className=\"min-w-0 flex-1 truncate\">{value}</span>\n      <Button size=\"xs\" variant=\"ghost\" tone=\"neutral\" iconOnly aria-label={copied ? \"Copied\" : `Copy ${value}`} onClick={onCopy}>\n        {copied ? <Check /> : <Copy />}\n      </Button>\n    </div>\n  )\n}\n",
      "type": "registry:component",
      "target": "components/goodui/client-profile.tsx"
    }
  ],
  "categories": [
    "booking"
  ],
  "type": "registry:block"
}
