PageSourceSearch

https://dietacademy.jp/_app/MemberAchievements-H4pysolO.js

js dietacademy.jp collected 2026-10-07 11:48:40 UTC 10,151 bytes, 1 lines download raw bytes

1import{u as H,c as J,b as c,j as e}from"./index-D5yTtBfj.js";import{r as v}from"./react-w2_hd-Mb.js";import{M as K}from"./MemberSidebar-BTYZILLM.js";import{M as O}from"./MemberListSkeleton-BoJJv-Xo.js";import{t as b,_ as U,a4 as w,ao as Q,a as V}from"./lucide-ZnjHBfqS.js";import"./supabase-DkYWVPkI.js";const te=()=>{var N,_;const{session:o}=H(),{t:i}=J(),[x,f]=v.useState([]),[$,h]=v.useState(!0);v.useEffect(()=>{o!=null&&o.user&&C()},[o]);const C=async()=>{h(!0);try{const s=o.user.id,{data:d}=await c.from("enrollments").select("course_id").eq("student_id",s).eq("status","active");if(!d||d.length===0){f([]),h(!1);return}const m=d.map(r=>r.course_id),{data:l}=await c.from("courses").select("id, title, achievements_enabled").in("id",m).eq("achievements_enabled",!0).eq("is_hidden",!1);if(!l||l.length===0){f([]),h(!1);return}const a=l.map(r=>r.id),{data:j}=await c.from("achievement_definitions").select("id, course_id, title, description, image_url, progress_threshold, sequence_order").in("course_id",a).order("sequence_order"),n=(j||[]).map(r=>r.id);let u=[];if(n.length>0){const{data:r}=await c.from("student_achievements").select("achievement_id, unlocked_at").eq("student_id",s).in("achievement_id",n);u=r||[]}const{data:y}=await c.from("modules").select("id, course_id").in("course_id",a),k=(y||[]).map(r=>r.id);let I=[];if(k.length>0){const{data:r}=await c.from("lessons").select("id, module_id").in("module_id",k);I=r||[]}const{data:E}=await c.from("progress").select("lesson_id").eq("student_id",s),P=new Set((E||[]).map(r=>r.lesson_id)),D=l.map(r=>{const z=(j||[]).filter(t=>t.course_id===r.id),L=u.filter(t=>z.some(G=>G.id===t.achievement_id)),F=new Set(L.map(t=>t.achievement_id)),S={};L.forEach(t=>{S[t.achievement_id]=t.unlocked_at});const R=(y||[]).filter(t=>t.course_id===r.id).map(t=>t.id),q=I.filter(t=>R.includes(t.module_id)),M=q.length,T=q.filter(t=>P.has(t.id)).length,B=M>0?Math.round(T/M*100):0;return{courseId:r.id,courseTitle:r.title,definitions:z.map(t=>({id:t.id,title:t.title,description:t.description,image_url:t.image_url,progress_threshold:t.progress_threshold,sequence_order:t.sequence_order})),unlockedIds:F,unlockedDates:S,progressPercent:B}}).filter(r=>r.definitions.length>0);f(D)}catch(s){console.error(s)}finally{h(!1)}},g=x.reduce((s,d)=>s+d.unlockedIds.size,0),p=x.reduce((s,d)=>s+d.definitions.length,0),A=((_=(N=o==null?void 0:o.user)==null?void 0:N.user_metadata)==null?void 0:_.full_name)||"Aluno";return e.jsxs("div",{className:"min-h-screen bg-[#FDFCFB] flex flex-col md:flex-row",children:[e.jsx(K,{userName:A,memberStatus:i("member.sidebar.premium")}),e.jsx("main",{className:"flex-1 p-6 md:p-10 lg:p-14 max-w-5xl",children:$?e.jsx(O,{variant:"stats-list",rows:3}):e.jsxs("div",{className:"space-y-10 animate-fadeIn",children:[e.jsx("header",{className:"animate-fadeInUp",children:e.jsxs("div",{className:"flex items-center gap-3 mb-3",children:[e.jsx("div",{className:"w-12 h-12 rounded-2xl bg-gradient-to-br from-amber-400 via-yellow-500 to-amber-600 flex items-center justify-center text-white shadow-lg shadow-amber-200/50",children:e.jsx(b,{size:24})}),e.jsxs("div",{children:[e.jsx("h1",{className:"text-2xl md:text-3xl font-bold text-stone-800 font-serif-jp",children:i("member.achievements.title")}),e.jsx("p",{className:"text-sm text-stone-500 font-medium",children:i("member.achievements.subtitle")})]})]})}),e.jsxs("div",{className:"grid grid-cols-3 gap-4 animate-fadeInUp stagger-1",children:[e.jsx("div",{className:"bg-white rounded-2xl p-5 border border-stone-100 shadow-sm hover:shadow-md transition-shadow",children:e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("div",{className:"w-10 h-10 rounded-xl bg-gradient-to-br from-amber-50 to-amber-100 flex items-center justify-center text-amber-500",children:e.jsx(b,{size:20})}),e.jsxs("div",{children:[e.jsx("div",{className:"text-2xl font-extrabold text-stone-800",children:g}),e.jsx("div",{className:"text-[10px] font-bold text-stone-400 uppercase tracking-wider",children:i("member.achievements.unlocked")})]})]})}),e.jsx("div",{className:"bg-white rounded-2xl p-5 border border-stone-100 shadow-sm hover:shadow-md transition-shadow",children:e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("div",{className:"w-10 h-10 rounded-xl bg-gradient-to-br from-stone-50 to-stone-100 flex items-center justify-center text-stone-400",children:e.jsx(U,{size:20})}),e.jsxs("div",{children:[e.jsx("div",{className:"text-2xl font-extrabold text-stone-800",children:p-g}),e.jsx("div",{className:"text-[10px] font-bold text-stone-400 uppercase tracking-wider",children:i("member.achievements.remaining")})]})]})}),e.jsx("div",{className:"bg-white rounded-2xl p-5 border border-stone-100 shadow-sm hover:shadow-md transition-shadow",children:e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("div",{className:"w-10 h-10 rounded-xl bg-gradient-to-br from-emerald-50 to-emerald-100 flex items-center justify-center text-emerald-500",children:e.jsx(w,{size:20})}),e.jsxs("div",{children:[e.jsxs("div",{className:"text-2xl font-extrabold text-stone-800",children:[p>0?Math.round(g/p*100):0,"%"]}),e.jsx("div",{className:"text-[10px] font-bold text-stone-400 uppercase tracking-wider",children:i("member.achievements.completion")})]})]})})]}),x.length===0&&e.jsxs("div",{className:"bg-gradient-to-br from-stone-50 to-white rounded-[2rem] p-14 text-center border border-stone-100 shadow-sm animate-fadeInUp stagger-2",children:[e.jsx("div",{className:"w-20 h-20 rounded-full bg-gradient-to-br from-amber-100 to-amber-200 flex items-center justify-center mx-auto mb-5",children:e.jsx(b,{size:36,className:"text-amber-400"})}),e.jsx("h3",{className:"text-lg font-bold text-stone-700 font-serif-jp mb-2",children:i("member.achievements.empty")}),e.jsx("p",{className:"text-sm text-stone-400 max-w-sm mx-auto",children:i("member.achievements.emptyDesc")})]}),x.map((s,d)=>{const m=s.definitions.length-s.unlockedIds.size,l=s.definitions.find(a=>!s.unlockedIds.has(a.id));return e.jsxs("section",{className:"bg-white rounded-[2rem] border border-stone-100 shadow-sm overflow-hidden animate-fadeInUp",style:{animationDelay:`${(d+2)*100}ms`},children:[e.jsxs("div",{className:"bg-gradient-to-r from-stone-800 to-stone-700 p-6 text-white",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{children:[e.jsx("h2",{className:"text-lg font-bold font-serif-jp",children:s.courseTitle}),e.jsxs("p",{className:"text-white/60 text-xs font-bold mt-1",children:[s.unlockedIds.size,"/",s.definitions.length," ",i("member.achievements.achievementsLabel")]})]}),e.jsxs("div",{className:"text-right",children:[e.jsxs("div",{className:"text-2xl font-extrabold",children:[s.progressPercent,"%"]}),e.jsx("div",{className:"text-[10px] text-white/50 font-bold uppercase",children:i("study.courseProgress")})]})]}),e.jsx("div",{className:"h-1.5 w-full bg-white/10 rounded-full mt-4 overflow-hidden",children:e.jsx("div",{className:"h-full rounded-full bg-gradient-to-r from-amber-400 to-yellow-500 transition-all duration-1000",style:{width:`${s.progressPercent}%`}})})]}),e.jsxs("div",{className:"p-6",children:[e.jsx("div",{className:"grid grid-cols-2 sm:grid-cols-3 md:grid-cols-4 lg:grid-cols-5 ga
1p-4",children:s.definitions.map((a,j)=>{const n=s.unlockedIds.has(a.id),u=s.unlockedDates[a.id];return e.jsxs("div",{className:`relative group text-center p-4 rounded-2xl border transition-all duration-300 ${n?"bg-gradient-to-br from-amber-50 to-yellow-50 border-amber-200/60 hover:shadow-lg hover:shadow-amber-100/50 hover:-translate-y-1":"bg-stone-50/50 border-stone-100 opacity-60"}`,children:[e.jsxs("div",{className:"relative mx-auto mb-3",children:[a.image_url?e.jsx("div",{className:`w-16 h-16 rounded-full mx-auto overflow-hidden border-[3px] shadow-md transition-all ${n?"border-amber-400 shadow-amber-200/50 group-hover:scale-110":"border-stone-200 grayscale blur-[1px]"}`,children:e.jsx("img",{src:a.image_url,alt:a.title,className:"w-full h-full object-cover"})}):e.jsx("div",{className:`w-16 h-16 rounded-full mx-auto flex items-center justify-center border-[3px] shadow-md transition-all ${n?"bg-gradient-to-br from-amber-400 to-yellow-600 border-amber-300 shadow-amber-200/50 group-hover:scale-110":"bg-stone-200 border-stone-200"}`,children:n?e.jsx(b,{size:24,className:"text-white"}):e.jsx(U,{size:20,className:"text-stone-400"})}),n&&e.jsx("div",{className:"absolute inset-0 w-16 h-16 mx-auto rounded-full bg-amber-400/20 blur-md group-hover:bg-amber-400/30 transition-all"})]}),e.jsx("p",{className:`text-xs font-bold mb-1 leading-tight ${n?"text-stone-800":"text-stone-400"}`,children:n?a.title:"???"}),n?e.jsx("p",{className:"text-[9px] text-amber-600 font-bold",children:new Date(u).toLocaleDateString()}):e.jsxs("p",{className:"text-[9px] text-stone-400 font-bold",children:[a.progress_threshold,"% ",i("member.achievements.toUnlock")]})]},a.id)})}),m>0&&e.jsxs("div",{className:"mt-6 bg-gradient-to-r from-amber-50 to-yellow-50 rounded-xl p-4 border border-amber-100 flex items-center gap-3",children:[e.jsx("div",{className:"w-10 h-10 rounded-full bg-gradient-to-br from-amber-400 to-yellow-500 flex items-center justify-center text-white flex-shrink-0",children:e.jsx(Q,{size:18})}),e.jsxs("div",{className:"flex-1",children:[e.jsx("p",{className:"text-sm font-bold text-amber-800",children:i("member.achievements.motivational").replace("{count}",String(m))}),l&&e.jsxs("p",{className:"text-xs text-amber-600/70 mt-0.5 flex items-center gap-1",children:[e.jsx(V,{size:12}),i("member.achievements.next"),": ",e.jsx("strong",{children:l.title})," (",l.progress_threshold,"%)"]})]})]}),m===0&&s.definitions.length>0&&e.jsx("div",{className:"mt-6 bg-gradient-to-r from-emerald-50 to-teal-50 rounded-xl p-4 border border-emerald-100 text-center",children:e.jsxs("p",{className:"text-sm font-bold text-emerald-700 flex items-center justify-center gap-2",children:[e.jsx(w,{size:16,className:"text-amber-500"}),i("member.achievements.allCompleted"),e.jsx(w,{size:16,className:"text-amber-500"})]})})]})]},s.courseId)})]})})]})};export{te as MemberAchievements};

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.