1import{r as x,t as i,b as n,j as e,X as y}from"./index-C3Qps0S4.js";import{L as p}from"./loader-circle-DohmWZz_.js";import{T as w}from"./trophy-C56YBVkm.js";import{P as C}from"./plus-BLlLQSZn.js";import{S as k}from"./save-DgLGcrQc.js";import{P as S}from"./pencil-BOPWUr1Y.js";import{T as E}from"./trash-2-DOBLe4Vk.js";const h=[{value:"games",label:"à¹à¸à¸¡"},{value:"referral",label:"à¹à¸à¸°à¸à¸³à¹à¸à¸·à¹à¸à¸"},{value:"checkin",label:"à¹à¸à¹à¸à¸à¸´à¸"},{value:"credits",label:"Point"},{value:"special",label:"à¸à¸´à¹à¸¨à¸©"}],v={key:"",name:"",description:"",icon:"ð",category:"games",requirement:1,rewardCredits:"0",rewardPoints:0};function U(){const[A,c]=x.useState(!1),[d,u]=x.useState(null),[s,a]=x.useState(v),{data:l,isLoading:b}=i.achievement.adminList.useQuery(),m=i.useUtils(),o=i.achievement.adminCreate.useMutation({onSuccess:()=>{n.success("สรà¹à¸²à¸ Achievement สำà¹à¸£à¹à¸"),m.achievement.adminList.invalidate(),r()},onError:t=>n.error(t.message)}),g=i.achievement.adminUpdate.useMutation({onSuccess:()=>{n.success("à¸à¸±à¸à¹à¸à¸ Achievement สำà¹à¸£à¹à¸"),m.achievement.adminList.invalidate(),r()},onError:t=>n.error(t.message)}),P=i.achievement.adminDelete.useMutation({onSuccess:()=>{n.success("ลภAchievement สำà¹à¸£à¹à¸"),m.achievement.adminList.invalidate()},onError:t=>n.error(t.message)}),r=()=>{c(!1),u(null),a(v)},f=t=>{a({key:t.key,name:t.name,description:t.description,icon:t.icon,category:t.category,requirement:t.requirement,rewardCredits:String(t.rewardCredits),rewardPoints:t.rewardPoints}),u(t.id),c(!0)},j=()=>
1{if(!s.key||!s.name||!s.description){n.error("à¸à¸£à¸¸à¸à¸²à¸à¸£à¸à¸à¸à¹à¸à¸¡à¸¹à¸¥à¹à¸«à¹à¸à¸£à¸");return}const t={...s,category:s.category,requirement:Number(s.requirement),rewardPoints:Number(s.rewardPoints)};d?g.mutate({id:d,...t}):o.mutate(t)};return b?e.jsx("div",{"data-loc":"client/src/pages/admin/AdminAchievementsPage.tsx:111",className:"flex items-center justify-center py-20",children:e.jsx(p,{"data-loc":"client/src/pages/admin/AdminAchievementsPage.tsx:112",className:"w-6 h-6 text-orange-400 animate-spin"})}):e.jsxs("div",{"data-loc":"client/src/pages/admin/AdminAchievementsPage.tsx:118",className:"space-y-4",children:[e.jsxs("div",{"data-loc":"client/src/pages/admin/AdminAchievementsPage.tsx:120",className:"flex items-center justify-between",children:[e.jsxs("div",{"data-loc":"client/src/pages/admin/AdminAchievementsPage.tsx:121",className:"flex items-center gap-2",children:[e.jsx(w,{"data-loc":"client/src/pages/admin/AdminAchievementsPage.tsx:122",className:"w-5 h-5 text-amber-400"}),e.jsx("h1",{"data-loc":"client/src/pages/admin/AdminAchievementsPage.tsx:123",className:"text-lg font-bold text-foreground",children:"à¸à¸±à¸à¸à¸²à¸£ Achievements"})]}),e.jsxs("button",{"data-loc":"client/src/pages/admin/AdminAchievementsPage.tsx:125",onClick:()=>{r(),c(!0)},className:"flex items-center gap-1.5 px-3 py-1.5 rounded-lg bg-orange-500/20 border border-orange-500/30 text-orange-400 text-xs font-medium hover:bg-orange-500/30 transition-colors",children:[e.jsx(C,{"data-loc":"client/src/pages/admin/AdminAchievementsPage.tsx:129",className:"w-3.5 h-3.5"}),"à¹à¸à¸´à¹à¸¡à¹à¸«à¸¡à¹"]})]}),A&&e.jsxs("div",{"data-loc":"client/src/pages/admin/AdminAchievementsPage.tsx:136",className:"glass-card rounded-xl p-4 border border-orange-500/20",children:[e.jsxs("div",{"data-loc":"client/src/pages/admin/AdminAchievementsPage.tsx:137",className:"flex items-center justify-between mb-3",children:[e.jsx("p",{"data-loc":"client/src/pages/admin/AdminAchievementsPage.tsx:138",className:"text-sm font-bold text-foreground",children:d?"à¹à¸à¹à¹à¸ Achievement":"สรà¹à¸²à¸ Achievement à¹à¸«à¸¡à¹"}),e.jsx("button",{"data-loc":"client/src/pages/admin/AdminAchievementsPage.tsx:141",onClick:r,className:"p-1 rounded text-muted-foreground hover:text-foreground",children:e.jsx(y,{"data-loc":"client/src/pages/admin/AdminAchievementsPage.tsx:142",className:"w-4 h-4"})})]}),e.jsxs("div",{"data-loc":"client/src/pages/admin/AdminAchievementsPage.tsx:145",className:"grid grid-cols-2 gap-2",children:[e.jsxs("div",{"data-loc":"client/src/pages/admin/AdminAchievementsPage.tsx:146",children:[e.jsx("label",{"data-loc":"client/src/pages/admin/AdminAchievementsPage.tsx:147",className:"text-[10px] text-muted-foreground",children:"Key (unique)"}),e.jsx("input",{"data-loc":"client/src/pages/admin/AdminAchievementsPage.tsx:148",value:s.key,onChange:t=>a({...s,key:t.target.value}),className:"w-full px-2 py-1.5 rounded-lg bg-muted/50 border border-border text-xs text-foreground",placeholder:"games_100"})]}),e.jsxs("div",{"data-loc":"client/src/pages/admin/AdminAchievementsPage.tsx:155",children:[e.jsx("label",{"data-loc":"client/src/pages/admin/AdminAchievementsPage.tsx:156",className:"text-[10px] text-muted-foreground",children:"à¸à¸·à¹à¸"}),e.jsx("input",{"data-loc":"client/src/pages/admin/AdminAchievementsPage.tsx:157",value:s.name,onChange:t=>a({...s,name:t.target.value}),className:"w-full px-2 py-1.5 rounded-lg bg-muted/50 border border-border text-xs text-foreground",placeholder:"à¸à¸±à¸à¹à¸¥à¹à¸ 100 à¹à¸à¸¡"})]}),e.jsxs("div",{"data-loc":"client/src/pages/admin/AdminAchievementsPage.tsx:164",className:"col-span-2",children:[e.jsx("label",{"data-loc":"client/src/pages/admin/AdminAchievementsPage.tsx:165",className:"text-[10px] text-muted-foreground",children:"à¸à¸³à¸à¸à¸´à¸à¸²à¸¢"}),e.jsx("input",{"data-loc":"client/src/pages/admin/AdminAchievementsPage.tsx:166",value:s.description,onChange:t=>a({...s,description:t.target.value}),className:"w-full px-2 py-1.5 rounded-lg bg-muted/50 border border-border text-xs text-foreground",placeholder:"à¹à¸¥à¹à¸à¸à¸£à¸ 100 à¹à¸à¸¡"})]}),e.jsxs("div",{"data-loc":"client/src/pages/admin/AdminAchievementsPage.tsx:173",children:[e.jsx("label",{"data-loc":"client/src/pages/admin/AdminAchievementsPage.tsx:174",className:"text-[10px] text-muted-foreground",children:"à¹à¸à¸à¸à¸ (Emoji)"}),e.jsx("input",{"data-loc":"client/src/pages/admin/AdminAchievementsPage.tsx:175",value:s.icon,onChange:t=>a({...s,icon:t.target.value}),className:"w-full px-2 py-1.5 rounded-lg bg-muted/50 border border-border text-xs text-foreground",placeholder:"ð"})]}),e.jsxs("div",{"data-loc":"client/src/pages/admin/AdminAchievementsPage.tsx:182",children:[e.jsx("label",{"data-loc":"client/src/pages/admin/AdminAchievementsPage.tsx:183",className:"text-[10px] text-muted-foreground",children:"หมวà¸à¸«à¸¡à¸¹à¹"}),e.jsx("select",{"data-loc":"client/src/pages/admin/AdminAchievementsPage.tsx:184",value:s.category,onChange:t=>a({...s,category:t.target.value}),className:"w-full px-2 py-1.5 rounded-lg bg-muted/50 border border-border text-xs text-foreground",children:h.map(t=>e.jsx("option",{"data-loc":"client/src/pages/admin/AdminAchievementsPage.tsx:190",value:t.value,children:t.label},t.value))})]}),e.jsxs("div",{"data-loc":"client/src/pages/admin/AdminAchievementsPage.tsx:194",children:[e.jsx("label",{"data-loc":"client/src/pages/admin/AdminAchievementsPage.tsx:195",className:"text-[10px] text-muted-foreground",children:"à¹à¸à¸·à¹à¸à¸à¹à¸ (à¸à¸³à¸à¸§à¸)"}),e.jsx("input",{"data-loc":"client/src/pages/admin/AdminAchievementsPage.tsx:196",type:"number",value:s.requirement,onChange:t=>a({...s,requirement:Number(t.target.value)}),className:"w-full px-2 py-1.5 rounded-lg bg-muted/50 border border-border text-xs text-foreground",min:1})]}),e.jsxs("div",{"data-loc":"client/src/pages/admin/AdminAchievementsPage.tsx:204",children:[e.jsx("label",{"data-loc":"client/src/pages/admin/AdminAchievementsPage.tsx:205",className:"text-[10px] text-muted-foreground",children:"ราà¸à¸§à¸±à¸¥ Point"}),e.jsx("input",{"data-loc":"client/src/pages/admin/AdminAchievementsPage.tsx:206",value:s.rewardCredits,onChange:t=>a({...s,rewardCredits:t.target.value}),className:"w-full px-2 py-1.5 rounded-lg bg-muted/50 border border-border text-xs text-foreground",placeholder:"10"})]}),e.jsxs("div",{"data-loc":"client/src/pages/admin/AdminAchievementsPage.tsx:213",children:[e.jsx("label",{"data-loc":"client/src/pages/admin/AdminAchievementsPage.tsx:214",className:"text-[10px] text-muted-foreground",children:"ราà¸à¸§à¸±à¸¥ VIP Points"}),e.jsx("input",{"data-loc":"client/src/pages/admin/AdminAchievementsPage.tsx:215",type:"number",value:s.rewardPoints,onChange:t=>a({...s,rewardPoints:Number(t.target.value)}),className:"w-full px-2 py-1.5 rounded-lg bg-muted/50 border border-border text-xs text-foreground",min:0})]})]}),e.jsx("button",{"data-loc":"client/src/pages/admin/AdminAchievementsPage.tsx:224",onClick:j,disabled:o.isPending||g.isPending,className:"mt-3 w-full flex items-center justify-center gap-1.5 py-2 rounded-lg bg-gradient-to-r from-orange-500 to-red-500 text-white text-xs font-bold disabled:opacity-50",children:o.isPending||g.isPending?e.jsx(p,{"data-loc":"client/src/pages/admin/AdminAchievementsPage.tsx:230",className:"w-4 h-4 animate-spin"}):e.jsxs(e.Fragment,{children:[e.jsx(k,{"data-loc":"client/src/pages/admin/AdminAchievementsPage.tsx:233",className:"w-3.5 h-3.5"}),d?"à¸à¸±à¸à¹à¸à¸":"สรà¹à¸²à¸"]})})]}),e.jsxs("div",{"data-loc":"client/src/pages/admin/AdminAchievementsPage.tsx:242",className:"space-y-2",children:[l?.map(t=>e.jsxs("div",{"data-loc":"client/src/pages/admin/AdminAchievementsPage.tsx:244",className:"glass-card rounded-xl p-3 flex items-center gap-3",children:[e.jsx("div",{"data-loc":"client/src/pages/admin/AdminAchievementsPage.tsx:245",className:"w-10 h-10 rounded-lg bg-amber-500/20 flex items-center justify-center text-lg shrink-0",children:t.icon}),e.jsxs("div",{"data-loc":"client/src/pages/admin/AdminAchievementsPage.tsx:248",className:"flex-1 min-w-0",children:[e.jsxs("div",{"data-loc":"client/src/pages/admin/AdminAchievementsPage.tsx:249",className:"flex items-center gap-2",children:[e.jsx("p",{"data-loc":"client/src/pages/admin/AdminAchievementsPage.tsx:250",className:"text-xs font-bold text-foreground truncate",children:t.name}),e.jsx("span",{"data-loc":"client/src/pages/admin/AdminAchievementsPage.tsx:251",className:"text-[9px] px-1.5 py-0.5 rounded bg-muted/50 text-muted-foreground",children:h.find(N=>N.value===t.category)?.label})]}),e.jsx("p",{"data-loc":"client/src/pages/admin/AdminAchievementsPage.tsx:255",className:"text-[10px] text-muted-foreground truncate",children:t.description}),e.jsxs("div",{"data-loc":"client/src/pages/admin/AdminAchievementsPage.tsx:256",className:"flex items-center gap-2 mt-0.5 text-[9px] text-muted-foreground",children:[e.jsxs("span",{"data-loc":"client/src/pages/admin/AdminAchievementsPage.tsx:257",children:["à¹à¸à¸·à¹à¸à¸à¹à¸: ",t.requirement]}),Number(t.rewardCredits)>0&&e.jsxs("span",{"data-loc":"client/src/pages/admin/AdminAchievementsPage.tsx:258",children:["+",t.rewardCredits," Point"]}),t.rewardPoints>0&&e.jsxs("span",{"data-loc":"client/src/pages/admin/AdminAchievementsPage.tsx:259",children:["+",t.rewardPoints," Points"]})]})]}),e.jsxs("div",{"data-loc":"client/src/pages/admin/AdminAchievementsPage.tsx:262",className:"flex items-center gap-1 shrink-0",children:[e.jsx("button",{"data-loc":"client/src/pages/admin/AdminAchievementsPage.tsx:263",onClick:()=>f(t),className:"p-1.5 rounded-lg bg-blue-500/20 text-blue-400 hover:bg-blue-500/30 transition-colors",children:e.jsx(S,{"data-loc":"client/src/pages/admin/AdminAchievementsPage.tsx:267",className:"w-3.5 h-3.5"})}),e.jsx("button",{"data-loc":"client/src/pages/admin/AdminAchievementsPage.tsx:269",onClick:()=>{confirm("à¸à¹à¸à¸à¸à¸²à¸£à¸¥à¸ Achievement à¸à¸µà¹?")&&P.mutate({id:t.id})},className:"p-1.5 rounded-lg bg-red-500/20 text-red-400 hover:bg-red-500/30 transition-colors",children:e.jsx(E,{"data-loc":"client/src/pages/admin/AdminAchievementsPage.tsx:277",className:"w-3.5 h-3.5"})})]})]},t.id)),(!l||l.length===0)&&e.jsx("div",{"data-loc":"client/src/pages/admin/AdminAchievementsPage.tsx:283",className:"text-center py-8 text-sm text-muted-foreground",children:"ยัà¸à¹à¸¡à¹à¸¡à¸µ Achievement"})]})]})}export{U 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.