PageSourceSearch

https://fitdietaihkapp.manus.space/assets/SupplementChecklist-CtlGKLYw.js

js fitdietaihkapp.manus.space collected 2026-10-03 05:02:15 UTC 11,438 bytes, 1 lines download raw bytes

1import{l as P,t as h,r as u,b as m,j as e,A as E,C as b,e as y,B as L,m as D,n as O}from"./index-bM8UT4Os.js";import{P as A}from"./progress-DbNowpEk.js";import{S as $}from"./skeleton-DVHVUV4f.js";const M={protein_powder:"蛋白粉",creatine:"肌酸",bcaa:"支鏈胺基酸",pre_workout:"訓練前",post_workout:"訓練後",collagen:"膠原蛋白",hyaluronic_acid:"透明質酸",vitamin_c:"維他命C",retinol:"視黃醇",milk_thistle:"乳薊",schisandra:"五味子",n_acetyl_cysteine:"NAC",multivitamin:"綜合維他命",vitamin_d:"維他命D",vitamin_b_complex:"維他命B群",iron:"鐵",magnesium:"鎂",zinc:"鋅",fish_oil:"魚油",omega_3:"Omega-3",flaxseed:"亞麻籽",female_cycle_support:"女性周期",calcium:"鈣",birth_control_reminder:"避孕藥",testosterone_support:"睪酮支持",male_vitality:"男性活力",saw_palmetto:"鋸棕櫚"};function T(){const i=new Date;return new Date(i.getTime()+480*60*1e3).toISOString().split("T")[0]}function U(i){const p=[];for(let n=0;n<i;n++){const o=new Date;o.setTime(o.getTime()+480*60*1e3),o.setDate(o.getDate()-n),p.push(o.toISOString().split("T")[0])}return p}function z(i){const p=T(),n=(()=>{const d=new Date;return d.setTime(d.getTime()+480*60*1e3),d.setDate(d.getDate()-1),d.toISOString().split("T")[0]})();if(i===p)return"今日";if(i===n)return"尋日";const[,o,g]=i.split("-"),l=new Date(i+"T12:00:00"),k=["日","一","二","三","四","五","六"];return`${parseInt(o)}/${parseInt(g)} (${k[l.getDay()]})`}function H(){const[,i]=P(),p=h.useUtils(),[n,o]=u.useState(T()),g=u.useMemo(()=>U(7),[]),{data:l,isLoading:k,refetch:d}=h.supplements.getDailyChecklist.useQuery({date:n},{refetchOnWindowFocus:!1}),f=h.supplements.recordIntake.useMutation({onSuccess:()=>{d(),p.supplements.getDailyChecklist.invalidate({date:n}),m.success("已記錄服用 ✓")},onError:()=>m.error("記錄唔到,試多次")}),N=h.supplements.undoIntake.useMutation({onSuccess:()=>{d(),p.supplements.getDailyChecklist.invalidate({date:n}),m.success("已取消咗")},onError:()=>m.error("取消唔到,試多次")}),[v,C]=u.useState(null),x=u.useRef(null),[S,j]=u.useState(null),I=(s,r,a)=>{r&&a?N.mutate({intakeId:a}):f.mutate({supplementId:s,date:n})},R=s=>{j(s),x.current?.click()},B=async s=>{const r=s.target.files?.[0];if(!(!r||!S)){if(r.size>10*1024*1024){m.error("圖片太大喇,最大 10MB");return}C(S);try{const a=new FileReader;a.onload=async _=>{const c=(_.target?.result).split(",")[1],w=await(await fetch("/api/upload-supplement-photo",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({imageBase64:c,mimeType:r.type||"image/jpeg"})})).json();w.url?(f.mutate({supplementId:S,date:n,photoUrl:w.url}),m.success("已影相記錄服用 📸")):m.error("上傳失敗"),C(null),j(null)},a.readAsDataURL(r)}catch{m.error("上傳失敗"),C(null),j(null)}x.current&&(x.current.value="")}};return e.jsx(E,{"data-loc":"client/src/pages/SupplementChecklist.tsx:171",title:"每日打卡",showBack:!0,backHref:"/supplements",children:e.jsxs("div",{"data-loc":"client/src/pages/SupplementChecklist.tsx:172",className:"pb-24",children:[e.jsxs("div",{"data-loc":"client/src/pages/SupplementChecklist.tsx:174",className:"px-4 pt-4 pb-1",children:[e.jsx("h1",{"data-loc":"client/src/pages/SupplementChecklist.tsx:175",className:"text-2xl font-bold text-foreground",children:"💊 每日補充劑"}),e.jsx("p",{"data-loc":"client/src/pages/SupplementChecklist.tsx:176",className:"text-sm text-muted-foreground mt-1",children:"按時間逐樣打卡,完成今日補充計劃"})]}),e.jsx("div",{"data-loc":"client/src/pages/SupplementChecklist.tsx:180",className:"px-4 py-3 overflow-x-auto",children:e.jsx("div",{"data-loc":"client/src/pages/SupplementChecklist.tsx:181",className:"flex gap-2 min-w-max",children:g.map(s=>e.jsxs("button",{"data-loc":"client/src/pages/SupplementChecklist.tsx:183",onClick:()=>o(s),className:`flex flex-col items-center px-3 py-2 rounded-xl text-sm transition-all ${n===s?"bg-primary text-primary-foreground shadow-md scale-105":"text-card-foreground border border-border hover:border-primary/50"}`,children:[e.jsx("span",{"data-loc":"client/src/pages/SupplementChecklist.tsx:192",className:"font-medium",children:z(s)}),e.jsx("span",{"data-loc":"client/src/pages/SupplementChecklist.tsx:193",className:"text-xs opacity-70",children:s.slice(5)})]},s))})}),l&&e.jsx("div",{"data-loc":"client/src/pages/SupplementChecklist.tsx:201",className:"px-4 py-2",children:e.jsx(b,{"data-loc":"client/src/pages/SupplementChecklist.tsx:202",className:"card-premium",children:e.jsxs(y,{"data-loc":"client/src/pages/SupplementChecklist.tsx:203",className:"p-4",children:[e.jsxs("div",{"data-loc":"client/src/pages/SupplementChecklist.tsx:204",className:"flex items-center justify-between mb-2",children:[e.jsx("span",{"data-loc":"client/src/pages/SupplementChecklist.tsx:205",className:"text-sm text-muted-foreground",children:"今日完成率"}),e.jsxs("span",{"data-loc":"client/src/pages/SupplementChecklist.tsx:206",className:"text-lg font-bold text-primary",children:[l.takenDaily,"/",l.totalDaily]})]}),e.jsx(A,{"data-loc":"client/src/pages/SupplementChecklist.tsx:210",value:l.completionRate,className:"h-2"}),e.jsxs("p",{"data-loc":"client/src/pages/SupplementChecklist.tsx:211",className:"text-xs text-muted-foreground mt-1 text-right",children:[l.completionRate,"%"]})]})})}),e.jsx("div",{"data-loc":"client/src/pages/SupplementChecklist.tsx:220",className:"px-4 py-2 space-y-2",children:k?Array.from({length:4}).map((s,r)=>e.jsx($,{"data-loc":"client/src/pages/SupplementChecklist.tsx:223",className:"h-16 w-full rounded-xl"},r)):l?.supplements.length===0?e.jsx(b,{"data-loc":"client/src/pages/SupplementChecklist.tsx:226",className:"card-premium border-dashed border-2",children:e.jsxs(y,{"data-loc":"client/src/pages/SupplementChecklist.tsx:227",className:"p-8 text-center",children:[e.jsx("p",{"data-loc":"client/src/pages/SupplementChecklist.tsx:228",className:"text-4xl mb-3",children:"💊"}),e.jsx("p",{"data-loc":"client/src/pages/SupplementChecklist.tsx:229",className:"text-muted-foreground mb-2",children:"未有補充劑記錄"}),e.jsx(L,{"data-loc":"client/src/pages/SupplementChecklist.tsx:230",variant:"outline",size:"sm",onClick:()=>i("/supplements"),children:"去加入補充劑"})]})}):(()=>{const s=["empty_stomach","after_breakfast","with_meal","pre_workout","post_workout","before_sleep","anytime"],r={pre_workout:{label:"操練前",emoji:"🏋️"},post_workout:{label:"操練後",emoji:"💪"},before_sleep:{label:"臨睦前",emoji:"🌙"},after_breakfast:{label:"早餐後",emoji:"🍳"},empty_stomach:{label:"空腹",emoji:"🌟"},with_meal:{label:"隨餐",emoji:"🍽️"},anytime:{label:"隨時",emoji:"⏰"}},a={};
1return l?.supplements.forEach(c=>{const t=c.timingTag||"anytime";a[t]||(a[t]=[]),a[t].push(c)}),s.filter(c=>a[c]?.length>0).map(c=>e.jsxs("div",{"data-loc":"client/src/pages/SupplementChecklist.tsx:259",className:"mb-3",children:[e.jsxs("div",{"data-loc":"client/src/pages/SupplementChecklist.tsx:260",className:"flex items-center gap-2 mb-2 px-1",children:[e.jsx("span",{"data-loc":"client/src/pages/SupplementChecklist.tsx:261",className:"text-sm",children:r[c]?.emoji}),e.jsx("span",{"data-loc":"client/src/pages/SupplementChecklist.tsx:262",className:"text-xs font-bold text-purple-300 uppercase tracking-wide",children:r[c]?.label}),e.jsx("div",{"data-loc":"client/src/pages/SupplementChecklist.tsx:263",className:"flex-1 h-px bg-border/50"}),e.jsxs("span",{"data-loc":"client/src/pages/SupplementChecklist.tsx:264",className:"text-xs text-muted-foreground",children:[a[c].filter(t=>t.taken).length,"/",a[c].length]})]}),e.jsx("div",{"data-loc":"client/src/pages/SupplementChecklist.tsx:266",className:"space-y-2",children:a[c].map(t=>e.jsx(b,{"data-loc":"client/src/pages/SupplementChecklist.tsx:269",className:`card-premium transition-all duration-200 ${t.taken?"border-green-500/30 bg-green-500/5":"border-border hover:border-primary/30"}`,children:e.jsx(y,{"data-loc":"client/src/pages/SupplementChecklist.tsx:277",className:"p-4",children:e.jsxs("div",{"data-loc":"client/src/pages/SupplementChecklist.tsx:278",className:"flex items-center gap-3",children:[e.jsx("button",{"data-loc":"client/src/pages/SupplementChecklist.tsx:280",onClick:()=>I(t.id,t.taken,t.intakeId),disabled:f.isPending||N.isPending,className:`w-7 h-7 rounded-full border-2 flex items-center justify-center transition-all duration-200 shrink-0 ${t.taken?"bg-green-500 border-green-500 text-white scale-110":"border-muted-foreground/40 hover:border-primary active:scale-95"}`,children:t.taken&&e.jsx("svg",{"data-loc":"client/src/pages/SupplementChecklist.tsx:290",width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"3",children:e.jsx("polyline",{"data-loc":"client/src/pages/SupplementChecklist.tsx:291",points:"20 6 9 17 4 12"})})}),e.jsxs("div",{"data-loc":"client/src/pages/SupplementChecklist.tsx:297",className:"flex-1 min-w-0",children:[e.jsxs("div",{"data-loc":"client/src/pages/SupplementChecklist.tsx:298",className:"flex items-center gap-2",children:[e.jsx("span",{"data-loc":"client/src/pages/SupplementChecklist.tsx:299",className:`font-medium ${t.taken?"line-through text-muted-foreground":"text-foreground"}`,children:t.name}),e.jsx(D,{"data-loc":"client/src/pages/SupplementChecklist.tsx:302",variant:"secondary",className:"text-xs shrink-0",children:M[t.category]||t.category})]}),e.jsxs("div",{"data-loc":"client/src/pages/SupplementChecklist.tsx:306",className:"flex items-center gap-2 mt-0.5",children:[t.dosage&&e.jsx("span",{"data-loc":"client/src/pages/SupplementChecklist.tsx:308",className:"text-xs text-muted-foreground",children:t.dosage}),t.scheduledTime&&e.jsxs("span",{"data-loc":"client/src/pages/SupplementChecklist.tsx:311",className:"text-xs text-muted-foreground",children:["⏰ ",t.scheduledTime.slice(0,5)]}),t.frequency==="as_needed"&&e.jsx(D,{"data-loc":"client/src/pages/SupplementChecklist.tsx:316",variant:"outline",className:"text-xs",children:"按需"})]})]}),!t.taken&&e.jsx("button",{"data-loc":"client/src/pages/SupplementChecklist.tsx:323",onClick:()=>R(t.id),disabled:v===t.id,className:"w-8 h-8 rounded-full border border-purple-500/50 flex items-center justify-center text-purple-400 hover:bg-purple-500/10 transition-all active:scale-95 shrink-0",title:"影相記錄",children:v===t.id?e.jsx("div",{"data-loc":"client/src/pages/SupplementChecklist.tsx:330",className:"w-4 h-4 border-2 border-purple-400 border-t-transparent rounded-full animate-spin"}):e.jsx(O,{"data-loc":"client/src/pages/SupplementChecklist.tsx:332",className:"w-4 h-4"})}),t.taken&&e.jsx("span",{"data-loc":"client/src/pages/SupplementChecklist.tsx:339",className:"text-green-500 text-xs font-medium",children:"已服用"})]})})},t.id))})]},c))})()}),e.jsx("input",{"data-loc":"client/src/pages/SupplementChecklist.tsx:353",ref:x,type:"file",accept:"image/*",className:"hidden",onChange:B}),l&&l.supplements.length>0&&e.jsx("div",{"data-loc":"client/src/pages/SupplementChecklist.tsx:363",className:"px-4 py-4 text-center",children:e.jsx("p",{"data-loc":"client/src/pages/SupplementChecklist.tsx:364",className:"text-xs text-muted-foreground",children:l.completionRate===100?"🎉 今日全部食晒!做得好!":l.completionRate>=50?"💪 繼續加油,仲有幾樣未食!":"📋 記得食補充劑,身體會多謝你㗎!"})})]})})}export{H 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.