1import{u as Q,a as k,t as o,r as n,b as c,j as e,A as M,C as d,c as p,d as g,e as x,B as b,M as T}from"./index-bM8UT4Os.js";import{I as D}from"./input-BwpLlRYf.js";import{L as u}from"./label-2Seh_wFH.js";import{S as A,a as E,b as F,c as I,d as r}from"./select-CDP2pHh8.js";import{T as q}from"./trash-2-4iirX7DH.js";import"./dialog-CxcTDVnZ.js";import"./useComposition-DO5dIJEj.js";import"./chevron-up-TG6jWiKP.js";function z(){Q();const s=k(),a=o.useUtils(),m=s.toISOString().slice(0,10),[i,h]=n.useState(""),[S,L]=n.useState("good"),[j,f]=n.useState(""),{data:l,refetch:N}=o.sleep.getByDate.useQuery({date:s}),v=o.sleep.upsert.useMutation({onSuccess:()=>{c.success("ç¡ç è¨éå·²è¨ä½ï¼ð´"),h(""),L("good"),f(""),N(),a.sleep.getByDate.invalidate({date:s}),a.meals.getByDate.invalidate({date:s}),a.workouts.getByDate.invalidate({date:s}),a.hydration.getByDate.invalidate({date:s}),a.supplements.getDailyChecklist.invalidate({date:m})},onError:()=>{c.error("å²ååå°ï¼è©¦å¤æ¬¡")}}),y=o.sleep.delete.useMutation({onSuccess:()=>{c.success("è¨éå·²å·å"),N(),a.sleep.getByDate.invalidate({date:s}),a.meals.getByDate.invalidate({date:s}),a.workouts.getByDate.invalidate({date:s}),a.hydration.getByDate.invalidate({date:s}),a.supplements.getDailyChecklist.invalidate({date:m})},onError:()=>{c.error("å·åå°ï¼è©¦å¤æ¬¡")}}),C=async t=>{if(t.preventDefault(),!i){c.error("å
¥è¿çåå¹¾èå
");return}await v.mutateAsync({sleepDuration:parseFloat(i),sleepQuality:S,notes:j||void 0,date:s})},w=t=>{switch(t){case"poor":return"text-red-600";case"fair":return"text-yellow-600";case"good":return"text-blue-600";case"excellent":return"text-green-600";default:return"text-foreground/70"}},B=t=>{switch(t){case"poor":return"好差";case"fair":return"麻麻";case"good":return"è¯å¥½";case"excellent":return"好æ£";default:return""}};return e.jsx(M,{"data-loc":"client/src/pages/SleepLog.tsx:107",title:"ç¡ç è¨é",showBack:!0,children:e.jsx("div",{"data-loc":"client/src/pages/SleepLog.tsx:108",className:"py-6 px-4",children:e.jsxs("div",{"data-loc":"client/src/pages/SleepLog.tsx:109",className:"max-w-3xl mx-auto space-y-5",children:[e.jsxs("div",{"data-loc":"client/src/pages/SleepLog.tsx:110",className:"mb-2",children:[e.jsx("h1",{"data-loc":"client/src/pages/SleepLog.tsx:111",className:"text-2xl md:text-3xl font-bold text-foreground",children:"ð´ ç¡ç è¨é"}),e.jsx("p",{"data-loc":"client/src/pages/SleepLog.tsx:112",className:"text-muted-foreground text-sm mt-1",children:"è¨ä½ä½ å
ç¡ç æéåè³ªç´ ï¼å¹«ä½ ç徿´å¥½"})]}),e.jsxs(d,{"data-loc":"client/src/pages/SleepLog.tsx:116",className:"card-premium",children:[e.jsx(p,{"data-loc":"client/src/pages/SleepLog.tsx:117",children:e.jsx(g,{"data-loc":"client/src/pages/SleepLog.tsx:118",className:"text-foreground",children:"â¡ï¸ è¨ä½ä»æ¨ç¡ç "})}),e.jsx(x,{"data-loc":"client/src/pages/SleepLog.tsx:120",children:e.jsxs("form",{"data-loc":"client/src/pages/SleepLog.tsx:121",onSubmit:C,className:"space-y-4",children:[e.jsxs("div",{"data-loc":"client/src/pages/SleepLog.tsx:122",className:"grid grid-cols-2 gap-4",children:[e.jsxs("div",{"data-loc":"client/src/pages/SleepLog.tsx:123",children:[e.jsx(u,{"data-loc":"client/src/pages/SleepLog.tsx:124",htmlFor:"duration",className:"text-sm font-semibold text-foreground/80",children:"ç¡ç ææ¸ (å°æ)"}),e.jsx(D,{"data-loc":"client/src/pages/SleepLog.tsx:127",id:"duration",type:"number",step:"0.5",min:"0",max:"24",placeholder:"7.5",value:i,onChange:t=>h(t.target.value),className:"mt-2"})]}),e.jsxs("div",{"data-loc":"client/src/pages/SleepLog.tsx:140",children:[e.jsx(u,{"data-loc":"client/src/pages/SleepLog.tsx:141",htmlFor:"quality",className:"text-sm font-semibold text-foreground/80",children:"çè¦ºè³ªç´ "}),e.jsxs(A,{"data-loc":"client/src/pages/SleepLog.tsx:144",value:S,onValueChange:t=>L(t),children:[e.jsx(E,{"data-loc":"client/src/pages/SleepLog.tsx:145",id:"quality",className:"mt-2",children:e.jsx(F,{"data-loc":"client/src/pages/SleepLog.tsx:146"})}),e.jsxs(I,{"data-loc":"client/src/pages/SleepLog.tsx:148",children:[e.jsx(r,{"data-loc":"client/src/pages/SleepLog.tsx:149",value:"poor",children:"å¾å·®"}),e.jsx(r,{"data-loc":"client/src/pages/SleepLog.tsx:150",value:"fair",children:"ä¸è¬"}),e.jsx(r,{"data-loc":"client/src/pages/SleepLog.tsx:151",value:"good",children:"è¯å¥½"}),e.jsx(r,{"data-loc":"client/src/pages/SleepLog.tsx:152",value:"excellent",children:"åªç§"})]})]})]})]}),e.jsxs("div",{"data-loc":"client/src/pages/SleepLog.tsx:158",children:[e.jsx(u,{"data-loc":"client/src/pages/SleepLog.tsx:159",htmlFor:"notes",className:"text-sm font-semibold text-foreground
1/80",children:"å註ï¼å¯é¸ï¼"}),e.jsx(D,{"data-loc":"client/src/pages/SleepLog.tsx:162",id:"notes",placeholder:"ä¾ï¼ä¸ééäºä¸æ¬¡ãææé¼»é¼¾",value:j,onChange:t=>f(t.target.value),className:"mt-2 border-indigo-200 focus:border-indigo-500"})]}),e.jsxs(b,{"data-loc":"client/src/pages/SleepLog.tsx:171",type:"submit",disabled:v.isPending,className:"w-full bg-gradient-to-r from-indigo-600 to-blue-600 hover:from-indigo-700 hover:to-blue-700 text-white font-semibold",children:[e.jsx(T,{"data-loc":"client/src/pages/SleepLog.tsx:176",className:"w-4 h-4 mr-2"}),"è¨ä½ç¡ç "]})]})})]}),l&&e.jsxs(d,{"data-loc":"client/src/pages/SleepLog.tsx:185",className:"card-premium",children:[e.jsx(p,{"data-loc":"client/src/pages/SleepLog.tsx:186",children:e.jsx(g,{"data-loc":"client/src/pages/SleepLog.tsx:187",className:"text-foreground",children:"仿¥ç¡ç çµ±è¨"})}),e.jsx(x,{"data-loc":"client/src/pages/SleepLog.tsx:189",children:e.jsxs("div",{"data-loc":"client/src/pages/SleepLog.tsx:190",className:"space-y-4",children:[e.jsxs("div",{"data-loc":"client/src/pages/SleepLog.tsx:191",className:"grid grid-cols-2 gap-4",children:[e.jsxs("div",{"data-loc":"client/src/pages/SleepLog.tsx:192",className:"bg-indigo-500/10 p-4 rounded-lg",children:[e.jsx("p",{"data-loc":"client/src/pages/SleepLog.tsx:193",className:"text-sm text-foreground/70 mb-1",children:"ç¡ç æé·"}),e.jsxs("p",{"data-loc":"client/src/pages/SleepLog.tsx:194",className:"text-2xl font-bold text-indigo-400",children:[Number(l.sleepDuration)||0," å°æ"]})]}),e.jsxs("div",{"data-loc":"client/src/pages/SleepLog.tsx:199",className:"bg-purple-500/10 p-4 rounded-lg",children:[e.jsx("p",{"data-loc":"client/src/pages/SleepLog.tsx:200",className:"text-sm text-foreground/70 mb-1",children:"çè¦ºè³ªç´ "}),e.jsx("p",{"data-loc":"client/src/pages/SleepLog.tsx:201",className:`text-2xl font-bold ${w(l.sleepQuality||"")}`,children:B(l.sleepQuality||"")})]})]}),l.notes&&e.jsxs("div",{"data-loc":"client/src/pages/SleepLog.tsx:208",className:"bg-secondary p-4 rounded-lg",children:[e.jsx("p",{"data-loc":"client/src/pages/SleepLog.tsx:209",className:"text-sm text-foreground/70 mb-1",children:"å註"}),e.jsx("p",{"data-loc":"client/src/pages/SleepLog.tsx:210",className:"text-foreground/90",children:l.notes})]}),e.jsxs(b,{"data-loc":"client/src/pages/SleepLog.tsx:214",variant:"destructive",onClick:()=>y.mutate({id:l.id}),disabled:y.isPending,className:"w-full",children:[e.jsx(q,{"data-loc":"client/src/pages/SleepLog.tsx:220",className:"w-4 h-4 mr-2"}),"å·èµ°"]})]})})]}),e.jsxs(d,{"data-loc":"client/src/pages/SleepLog.tsx:229",className:"card-premium",children:[e.jsx(p,{"data-loc":"client/src/pages/SleepLog.tsx:230",children:e.jsx(g,{"data-loc":"client/src/pages/SleepLog.tsx:231",className:"text-foreground",children:"ð¡ ç¡ç 貼士"})}),e.jsxs(x,{"data-loc":"client/src/pages/SleepLog.tsx:233",className:"text-sm text-foreground/80 space-y-2",children:[e.jsxs("p",{"data-loc":"client/src/pages/SleepLog.tsx:234",children:[e.jsx("strong",{"data-loc":"client/src/pages/SleepLog.tsx:235",children:"建è°ç¡ç æé·ï¼"})," æäººæ¯æ 7-9 å°æ"]}),e.jsx("p",{"data-loc":"client/src/pages/SleepLog.tsx:237",children:e.jsx("strong",{"data-loc":"client/src/pages/SleepLog.tsx:238",children:"çè¦ºè³ªç´ æå建è°ï¼"})}),e.jsxs("ul",{"data-loc":"client/src/pages/SleepLog.tsx:240",className:"list-disc list-inside space-y-1 ml-2",children:[e.jsx("li",{"data-loc":"client/src/pages/SleepLog.tsx:241",children:"ä¿æè¦å¾çç¡ç æé表"}),e.jsx("li",{"data-loc":"client/src/pages/SleepLog.tsx:242",children:"ç¡å 1 å°æé¿å
使ç¨é»åè¨å"}),e.jsx("li",{"data-loc":"client/src/pages/SleepLog.tsx:243",children:"ä¿æè¥å®¤æ¶¼ç½ã黿ãå®é"}),e.jsx("li",{"data-loc":"client/src/pages/SleepLog.tsx:244",children:"é¿å
ç¡å飲ç¨åå¡å 飲æ"}),e.jsx("li",{"data-loc":"client/src/pages/SleepLog.tsx:245",children:"宿éåï¼ä½ä¸è¦å¨ç¡åé²è¡ï¼"})]})]})]})]})})})}export{z as default};
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.