PageSourceSearch

https://fitdietaihkapp.manus.space/assets/HydrationLog-XZLeptTb.js

js fitdietaihkapp.manus.space collected 2026-10-03 05:01:46 UTC 13,825 bytes, 6 lines download raw bytes

1import{f as B,u as A,a as E,t as d,r as m,b as i,j as t,A as P,C as r,e as o,S as T,c as p,d as y,s as F,B as H,D as k}from"./index-bM8UT4Os.js";import{I as D}from"./input-BwpLlRYf.js";import{L as S}from"./label-2Seh_wFH.js";import{P as G}from"./plus-DSaqw8wa.js";import{T as $}from"./trash-2-4iirX7DH.js";import"./dialog-CxcTDVnZ.js";import"./useComposition-DO5dIJEj.js";/**
2 * @license lucide-react v0.453.0 - ISC
3 *
4 * This source code is licensed under the ISC license.
5 * See the LICENSE file in the root directory of this source tree.
6 */const W=B("Info",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"M12 16v-4",key:"1dtifu"}],["path",{d:"M12 8h.01",key:"e9boi3"}]]);function V(){A();const e=E(),s=d.useUtils(),[u,j]=m.useState(""),[g,N]=m.useState("2000"),[f,I]=m.useState(!1),{data:c}=d.recommendations.getDaily.useQuery();m.useEffect(()=>{c?.water?.recommended&&N(String(c.water.recommended))},[c?.water?.recommended]);const{data:n,refetch:b}=d.hydration.getByDate.useQuery({date:e}),x=d.hydration.add.useMutation({onSuccess:()=>{i.success("飲水記錄已記低!💧"),j(""),b();const a=e.toISOString().slice(0,10);s.hydration.getByDate.invalidate({date:e}),s.meals.getByDate.invalidate({date:e}),s.workouts.getByDate.invalidate({date:e}),s.sleep.getByDate.invalidate({date:e}),s.supplements.getDailyChecklist.invalidate({date:a})},onError:()=>{i.error("加唔到,試多次")}}),v=d.hydration.delete.useMutation({onSuccess:()=>{i.success("記錄已剷咗"),b();const a=e.toISOString().slice(0,10);s.hydration.getByDate.invalidate({date:e}),s.meals.getByDate.invalidate({date:e}),s.workouts.getByDate.invalidate({date:e}),s.sleep.getByDate.invalidate({date:e}),s.supplements.getDailyChecklist.invalidate({date:a})},onError:()=>{i.error("剷唔到,試多次")}}),M=async a=>{if(a.preventDefault(),!u){i.error("入返飲水量先");return}await x.mutateAsync({waterIntake:parseFloat(u),dailyGoal:parseFloat(g)})},h=n?.reduce((a,C)=>a+(Number(C.waterIntake)||0),0)||0,L=parseFloat(g)||2e3,l=h/L*100,w=l>=100?{text:"達標喇!做得好 🎉",color:"text-green-400"}:l>=75?{text:"就快達標,加油呀!💪",color:"text-cyan-400"}:l>=50?{text:"飲咗一半,繼續保持!",color:"text-blue-400"}:l>=25?{text:"開始得唔錯,記得繼續飲水",color:"text-yellow-400"}:{text:`仲差 ${Math.round(L-h)} ml,記得飲水呀`,color:"text-muted-foreground"};return t.jsx(P,{"data-loc":"client/src/pages/HydrationLog.tsx:101",title:"飲水記錄",showBack:!0,children:t.jsx("div",{"data-loc":"client/src/pages/HydrationLog.tsx:102",className:"py-6 px-4",children:t.jsxs("div",{"data-loc":"client/src/pages/HydrationLog.tsx:103",className:"max-w-3xl mx-auto space-y-5",children:[t.jsxs("div",{"data-loc":"client/src/pages/HydrationLog.tsx:104",className:"mb-2",children:[t.jsx("h1",{"data-loc":"client/src/pages/HydrationLog.tsx:105",className:"text-2xl md:text-3xl font-bold text-foreground",children:"💧 飲水記錄"}),t.jsx("p",{"data-loc":"client/src/pages/HydrationLog.tsx:106",className:"text-sm text-muted-foreground mt-1",children:"記低你每日嘅飲水量,保持水分平衡"})]}),c?.water&&t.jsx(r,{"data-loc":"client/src/pages/HydrationLog.tsx:111",className:"card-premium !border-cyan-800/30",children:t.jsx(o,{"data-loc":"client/src/pages/HydrationLog.tsx:112",className:"pt-5",children:t.jsxs("div",{"data-loc":"client/src/pages/HydrationLog.tsx:113",className:"flex items-start gap-3",children:[t.jsx("div",{"data-loc":"client/src/pages/HydrationLog.tsx:114",className:"bg-cyan-500/15 p-2.5 rounded-xl",children:t.jsx(T,{"data-loc":"client/src/pages/HydrationLog.tsx:115",className:"w-5 h-5 text-cyan-400"})}),t.jsxs("div",{"data-loc":"client/src/pages/HydrationLog.tsx:117",className:"flex-1",children:[t.jsxs("div",{"data-loc":"client/src/pages/HydrationLog.tsx:118",className:"flex items-center gap-2 mb-1",children:[t.jsx("p",{"data-loc":"client/src/pages/HydrationLog.tsx:119",className:"font-semibold text-cyan-300 text-sm",children:"AI 個性化飲水目標"}),t.jsx("button",{"data-loc":"client/src/pages/HydrationLog.tsx:120",onClick:()=>I(!f),className:"text-muted-foreground hover:text-cyan-400 transition-colors",children:t.jsx(W,{"data-loc":"client/src/pages/HydrationLog.tsx:124",className:"w-3.5 h-3.5"})})]}),t.jsxs("div",{"data-loc":"client/src/pages/HydrationLog.tsx:127",className:"flex items-baseline gap-2",children:[t.jsx("span",{"data-loc":"client/src/pages/HydrationLog.tsx:128",className:"text-2xl font-bold text-foreground",children:c.water.recommended}),t.jsx("span",{"data-loc":"client/src/pages/HydrationLog.tsx:129",className:"text-sm text-muted-foreground",children:"ml / 日"})]}),t.jsxs("div",{"data-loc":"client/src/pages/HydrationLog.tsx:131",className:"flex gap-4 mt-2 text-xs text-muted-foreground",children:[t.jsxs("span",{"data-loc":"client/src/pages/HydrationLog.tsx:132",children:["最低 ",c.water.minimum," ml"]}),t.jsxs("span",{"data-loc":"client/src/pages/HydrationLog.tsx:133",children:["最高 ",c.water.maximum," ml"]})]}),f&&t.jsxs("p",{"data-loc":"client/src/pages/HydrationLog.tsx:136",className:"text-xs text-muted-foreground mt-3 bg-secondary/60 p-3 rounded-lg leading-relaxed",children:[c.water.explanation,t.jsx("br",{"data-loc":"client/src/pages/HydrationLog.tsx:138"}),t.jsx("br",{"data-loc":"client/src/pages/HydrationLog.tsx:138"}),"計算方式:體重 × 35ml × 活動量係數。運動日建議額外補充 500-1000ml。"]})]})]})})}),t.jsxs(r,{"data-loc":"client/src/pages/HydrationLog.tsx:149",className:"card-premium overflow-hidden relative",children:[t.jsx("div",{"data-loc":"client/src/pages/HydrationLog.tsx:150",className:"absolute inset-0 bg-gradient-to-br from-cyan-500/5 to-blue-500/5 pointer-events-none"}),t.jsx(p,{"data-loc":"client/src/pages/HydrationLog.tsx:151",className:"pb-2 relative",children:t.jsxs(y,{"data-loc":"client/src/pages/HydrationLog.tsx:152",className:"flex items-center gap-2 text-foreground text-lg",children:[t.jsx(F,{"data-loc":"client/src/pages/HydrationLog.tsx:153",className:"w-5 h-5"}),"今日飲水進度"]})}),t.jsx(o,{"data-loc":"client/src/pages/HydrationLog.tsx:157",className:"relative",children:t.jsxs("div",{"data-loc":"client/src/pages/HydrationLog.tsx:158",className:"space-y-3",children:[t.jsxs("div",{"data-loc":"client/src/pages/HydrationLog.tsx:159",className:"flex justify-between items-end",children:[t.jsx("span",{"data-loc":"client/src/pages/HydrationLog.tsx:160",className:"text-3xl font-bold text-foreground",children:Math.round(h)}),t.jsxs("span",{"data-loc":"client/src/pages/HydrationLog.tsx:161",className:"text-muted-foreground text-sm",children:["/ ",Math.round(L)," ml"]})]}),t.jsx("div",{"data-loc":"client/src/pages/HydrationLog.tsx:163",className:"w-full bg-secondary rounded-full h-3 overflow-hidden",children:t.jsx("div",{"data-loc":"client/src/pages/HydrationLog.tsx:164",className:`h-full transition-all duration-500 ease-out rounded-full ${l>=100?"bg-gradient-to-r from-green-400 to-emerald-500":"bg-gradient-to-r from-cyan-400 to-blue-500"}`,style:{width:`${Math.min(l,100)}%`}})}),t.jsx("p",{"data-loc":"client/src/pages/HydrationLog.tsx:173",className:`text-sm font-medium ${w.color}`,children:w.text})]})})]}),t.jsxs(r,{"data-loc":"client/src/pages/HydrationLog.tsx:181",className:"card-premium",children:[t.jsx(p,{"data-loc":"client/src/pages/HydrationLog.tsx:182",className:"pb-3",children:t.jsx(y,{"data-loc":"client/src/pages/HydrationLog.tsx:183",className:"text-base text-foreground
6/90",children:"快手加水"})}),t.jsx(o,{"data-loc":"client/src/pages/HydrationLog.tsx:185",children:t.jsx("div",{"data-loc":"client/src/pages/HydrationLog.tsx:186",className:"grid grid-cols-4 gap-2",children:[250,500,750,1e3].map(a=>t.jsxs(H,{"data-loc":"client/src/pages/HydrationLog.tsx:188",variant:"outline",onClick:()=>{x.mutate({waterIntake:a,dailyGoal:parseFloat(g)})},disabled:x.isPending,className:"text-sm h-12 border-cyan-800/30 hover:bg-cyan-900/30 hover:border-cyan-600/50 text-foreground/90",children:[t.jsx(k,{"data-loc":"client/src/pages/HydrationLog.tsx:200",className:"w-3.5 h-3.5 mr-1 text-cyan-400"}),a,"ml"]},a))})})]}),t.jsxs(r,{"data-loc":"client/src/pages/HydrationLog.tsx:209",className:"card-premium",children:[t.jsx(p,{"data-loc":"client/src/pages/HydrationLog.tsx:210",className:"pb-3",children:t.jsx(y,{"data-loc":"client/src/pages/HydrationLog.tsx:211",className:"text-base text-foreground/90",children:"自定義記錄"})}),t.jsx(o,{"data-loc":"client/src/pages/HydrationLog.tsx:213",children:t.jsxs("form",{"data-loc":"client/src/pages/HydrationLog.tsx:214",onSubmit:M,className:"space-y-4",children:[t.jsxs("div",{"data-loc":"client/src/pages/HydrationLog.tsx:215",className:"grid grid-cols-2 gap-4",children:[t.jsxs("div",{"data-loc":"client/src/pages/HydrationLog.tsx:216",children:[t.jsx(S,{"data-loc":"client/src/pages/HydrationLog.tsx:217",htmlFor:"intake",className:"text-sm font-medium text-foreground/80",children:"飲水量 (ml)"}),t.jsx(D,{"data-loc":"client/src/pages/HydrationLog.tsx:220",id:"intake",type:"text",inputMode:"numeric",pattern:"[0-9]*",placeholder:"250",value:u,onChange:a=>j(a.target.value.replace(/[^0-9]/g,"")),className:"mt-2"})]}),t.jsxs("div",{"data-loc":"client/src/pages/HydrationLog.tsx:232",children:[t.jsx(S,{"data-loc":"client/src/pages/HydrationLog.tsx:233",htmlFor:"goal",className:"text-sm font-medium text-foreground/80",children:"每日目標 (ml)"}),t.jsx(D,{"data-loc":"client/src/pages/HydrationLog.tsx:236",id:"goal",type:"text",inputMode:"numeric",pattern:"[0-9]*",value:g,onChange:a=>N(a.target.value.replace(/[^0-9]/g,"")),className:"mt-2"})]})]}),t.jsxs(H,{"data-loc":"client/src/pages/HydrationLog.tsx:248",type:"submit",disabled:x.isPending,className:"w-full bg-cyan-600 hover:bg-cyan-700",children:[t.jsx(G,{"data-loc":"client/src/pages/HydrationLog.tsx:253",className:"w-4 h-4 mr-2"}),"加入記錄"]})]})})]}),t.jsxs("div",{"data-loc":"client/src/pages/HydrationLog.tsx:261",className:"space-y-3 mb-6",children:[t.jsxs("h2",{"data-loc":"client/src/pages/HydrationLog.tsx:262",className:"text-lg font-semibold text-foreground/90 mb-3",children:["今日記錄 (",n?.length||0,")"]}),n&&n.length>0?n.map(a=>t.jsx(r,{"data-loc":"client/src/pages/HydrationLog.tsx:267",className:"card-premium hover:opacity-90 transition-opacity",children:t.jsx(o,{"data-loc":"client/src/pages/HydrationLog.tsx:268",className:"py-3 px-4",children:t.jsxs("div",{"data-loc":"client/src/pages/HydrationLog.tsx:269",className:"flex justify-between items-center",children:[t.jsxs("div",{"data-loc":"client/src/pages/HydrationLog.tsx:270",className:"flex items-center gap-3",children:[t.jsx("div",{"data-loc":"client/src/pages/HydrationLog.tsx:271",className:"bg-cyan-500/10 p-2 rounded-lg",children:t.jsx(k,{"data-loc":"client/src/pages/HydrationLog.tsx:272",className:"w-4 h-4 text-cyan-400"})}),t.jsxs("div",{"data-loc":"client/src/pages/HydrationLog.tsx:274",children:[t.jsxs("p",{"data-loc":"client/src/pages/HydrationLog.tsx:275",className:"font-semibold text-foreground",children:[Number(a.waterIntake)," ml"]}),t.jsx("p",{"data-loc":"client/src/pages/HydrationLog.tsx:276",className:"text-xs text-muted-foreground",children:new Date(a.createdAt).toLocaleTimeString("zh-TW",{hour:"2-digit",minute:"2-digit"})})]})]}),t.jsx(H,{"data-loc":"client/src/pages/HydrationLog.tsx:281",variant:"ghost",size:"sm",onClick:()=>v.mutate({id:a.id}),disabled:v.isPending,className:"hover:bg-red-900/20",children:t.jsx($,{"data-loc":"client/src/pages/HydrationLog.tsx:288",className:"w-4 h-4 text-red-400"})})]})})},a.id)):t.jsx(r,{"data-loc":"client/src/pages/HydrationLog.tsx:295",className:"card-glass-subtle",children:t.jsx(o,{"data-loc":"client/src/pages/HydrationLog.tsx:296",className:"py-8",children:t.jsx("p",{"data-loc":"client/src/pages/HydrationLog.tsx:297",className:"text-muted-foreground text-center",children:"今日未有飲水記錄,快啲飲杯水啦 💧"})})})]}),t.jsxs(r,{"data-loc":"client/src/pages/HydrationLog.tsx:304",className:"card-glass-subtle",children:[t.jsx(p,{"data-loc":"client/src/pages/HydrationLog.tsx:305",className:"pb-2",children:t.jsx(y,{"data-loc":"client/src/pages/HydrationLog.tsx:306",className:"text-base text-foreground",children:"💡 飲水小貼士"})}),t.jsxs(o,{"data-loc":"client/src/pages/HydrationLog.tsx:308",className:"text-sm text-muted-foreground space-y-2",children:[t.jsx("p",{"data-loc":"client/src/pages/HydrationLog.tsx:309",children:t.jsx("strong",{"data-loc":"client/src/pages/HydrationLog.tsx:310",className:"text-foreground
6/80",children:"建議飲水時間表:"})}),t.jsxs("div",{"data-loc":"client/src/pages/HydrationLog.tsx:312",className:"grid grid-cols-2 gap-2 text-xs",children:[t.jsx("div",{"data-loc":"client/src/pages/HydrationLog.tsx:313",className:"bg-secondary/60 p-2 rounded-lg",children:"☀️ 起身:250-500ml"}),t.jsx("div",{"data-loc":"client/src/pages/HydrationLog.tsx:314",className:"bg-secondary/60 p-2 rounded-lg",children:"🌤️ 上午:500ml"}),t.jsx("div",{"data-loc":"client/src/pages/HydrationLog.tsx:315",className:"bg-secondary/60 p-2 rounded-lg",children:"🍽️ 午餐前:250ml"}),t.jsx("div",{"data-loc":"client/src/pages/HydrationLog.tsx:316",className:"bg-secondary/60 p-2 rounded-lg",children:"☁️ 下午:500ml"}),t.jsx("div",{"data-loc":"client/src/pages/HydrationLog.tsx:317",className:"bg-secondary/60 p-2 rounded-lg",children:"🌙 晚餐前:250ml"}),t.jsx("div",{"data-loc":"client/src/pages/HydrationLog.tsx:318",className:"bg-secondary/60 p-2 rounded-lg",children:"🏋️ 運動時:+500ml"})]}),t.jsx("p",{"data-loc":"client/src/pages/HydrationLog.tsx:320",className:"text-xs text-muted-foreground mt-3",children:"運動前後同天氣熱嘅時候記得額外補水!飲凍水可以幫助提升新陳代謝。"})]})]})]})})})}export{V 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.