PageSourceSearch

https://fitdietaihkapp.manus.space/assets/SleepLog-70eHxOOn.js

js fitdietaihkapp.manus.space collected 2026-10-03 05:01:44 UTC 8,669 bytes, 1 lines download raw bytes

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.