PageSourceSearch

https://raktasewa-client-production.up.railway.app/assets/GamiConfigPage-Bb6DXFKZ.js

js raktasewa-client-production.up.railway.app collected 2026-10-03 12:13:38 UTC 11,805 bytes, 1 lines download raw bytes

1import{r as o,j as e,B as j,C as K,T as b,A as U,d as V,c as Y,l as n,D as h,p as $,q as Q,s as X,t as Z,i,k as r,v as ee,f as te,w as ae,h as le,x as ie,b as se,y as ne,z as re,E as oe,F as ue,H as de,I as ce,J as he,K as ge,L as ve,N as pe,O as xe,n as _}from"./index-Bkjca68x.js";import{T as me,a as g}from"./Tabs-BvVS_UXi.js";const fe=["cash","gift","certificate","tour","coupon","recognition","custom"];function _e(){var f;const[d,w]=o.useState(0),[C,m]=o.useState(!0),[y,S]=o.useState([]),[W,k]=o.useState([]),[T,z]=o.useState([]),[A,F]=o.useState([]),[M,R]=o.useState([]),[D,E]=o.useState([]),[P,O]=o.useState([]),[H,N]=o.useState([]),[s,p]=o.useState(null),[a,l]=o.useState({}),x=async()=>{m(!0);try{const[t,c,v,I,G,L,q,J]=await Promise.all([te(),ae(),le(),ie(),se(),ne(),re(),oe()]);S(t.missions||[]),k(c.rewards||[]),z(v.rules||[]),F(I.tiers||[]),R(G.achievements||[]),E(L.campaigns||[]),O(q.themes||[]),N(J.celebrations||[])}finally{m(!1)}};o.useEffect(()=>{x()},[]);const u=(t,c={})=>{p(t),l(c)},B=async()=>{var t,c;try{s==="mission"?a.id?await ue(a.id,a):await de(a):s==="reward"?await ce(a):s==="rule"?await he(a):s==="tier"?await ge(a):s==="achievement"?await ve(a):s==="campaign"?await pe(a):s==="theme"&&await xe({...a,css_vars:a.css_vars||{accent:"#F59E0B",glow:"rgba(245,158,11,0.3)"}}),p(null),await x(),_.fire({icon:"success",title:"Saved",timer:1200,showConfirmButton:!1})}catch(v){_.fire("Error",((c=(t=v==null?void 0:v.response)==null?void 0:t.data)==null?void 0:c.message)||"Save failed","error")}};return C?e.jsx(j,{sx:{display:"flex",justifyContent:"center",py:8},children:e.jsx(K,{})}):e.jsxs(j,{sx:{p:{xs:2,md:3}},children:[e.jsx(b,{variant:"h4",sx:{mb:.5},children:"Gamification Config"}),e.jsx(b,{variant:"body2",color:"text.secondary",sx:{mb:2},children:"Super Admin / Admin — create unlimited targets, rewards, point rules, tiers, campaigns, and themes."}),e.jsx(U,{severity:"info",sx:{mb:2},children:"Existing blood-ops pages are unchanged. This panel only configures the mission layer."}),e.jsxs(me,{value:d,onChange:(t,c)=>w(c),variant:"scrollable",allowScrollButtonsMobile:!0,sx:{mb:2},children:[e.jsx(g,{label:"Missions"}),e.jsx(g,{label:"Rewards"}),e.jsx(g,{label:"Point Rules"}),e.jsx(g,{label:"Tiers"}),e.jsx(g,{label:"Achievements"}),e.jsx(g,{label:"Campaigns"}),e.jsx(g,{label:"Themes"}),e.jsx(g,{label:"Celebrations"})]}),e.jsxs(V,{elevation:0,sx:{p:2,borderRadius:3,border:`1px solid ${Y.border}`},children:[d===0&&e.jsxs(e.Fragment,{children:[e.jsx(n,{variant:"contained",sx:{mb:2},onClick:()=>u("mission",{scope:"user",calc_type:"points_sum",target_value:100,status:"active",priority:0}),children:"New mission / target"}),e.jsx(h,{autoHeight:!0,rows:y,columns:[{field:"id",width:70},{field:"title",flex:1},{field:"scope",width:100},{field:"target_value",width:110},{field:"current_value",width:120},{field:"status",width:100},{field:"actions",width:180,sortable:!1,renderCell:t=>e.jsxs(e.Fragment,{children:[e.jsx(n,{size:"small",onClick:()=>u("mission",t.row),children:"Edit"}),e.jsx(n,{size:"small",color:"warning",onClick:async()=>{await $(t.row.id),x()},children:"Archive"})]})}],pageSizeOptions:[10],initialState:{pagination:{paginationModel:{pageSize:10}}}})]}),d===1&&e.jsxs(e.Fragment,{children:[e.jsx(n,{variant:"contained",sx:{mb:2},onClick:()=>u("reward",{reward_type:"cash",is_active:1}),children:"New reward"}),e.jsx(h,{autoHeight:!0,rows:W,columns:[{field:"id",width:70},{field:"title",flex:1},{field:"reward_type",width:120},{field:"value_text",flex:1},{field:"is_active",width:90}],pageSizeOptions:[10],initialState:{pagination:{paginationModel:{pageSize:10}}}})]}),d===2&&e.jsxs(e.Fragment,{children:[e.jsx(n,{variant:"contained",sx:{mb:2},onClick:()=>u("rule",{points:10,is_active:1,is_negative:0}),children:"New / update rule"}),e.jsx(h,{autoHeight:!0,rows:T,columns:[{field:"action_key",flex:1},{field:"label",flex:1},{field:"points",width:100},{field:"is_active",width:90},{field:"edit",width:100,renderCell:t=>e.jsx(n,{size:"small",onClick:()=>u("rule",t.row),children:"Edit"})}],pageSizeOptions:[15],initialState:{pagination:{paginationModel:{pageSize:15}}}})]}),d===3&&e.jsxs(e.Fragment,{children:[e.jsx(n,{variant:"contained",sx:{mb:2},onClick:()=>u("tier",{min_points:0,sort_order:0,is_active:1}),children:"New tier"}),e.jsx(h,{autoHeight:!0,rows:A,columns:[{field:"name",flex:1},{field:"min_points",width:120},{field:"theme_key",width:120},{field:"sort_order",width:100},{field:"edit",width:100,renderCell:t=>e.jsx(n,{size:"small",onClick:()=>u("tier",t.row),children:"Edit"})}],pageSizeOptions:[10],initialState:{pagination:{paginationModel:{pageSize:10}}}})]}),d===4&&e.jsxs(e.Fragment,{children:[e.jsx(n,{variant:"contained",sx:{mb:2},onClick:()=>u("achievement",{rule_type:"points_total",rule_value:100,is_active:1}),children:"New achievement"}),e.jsx(h,{autoHeight:!0,rows:M,columns:[{field:"code",width:140},{field:"title",flex:1},{field:"rule_type",width:130},{field:"rule_value",width:110},{field:"edit",width:100,renderCell:t=>e.jsx(n,{size:"small",onClick:()=>u("achievement",t.row),children:"Edit"})}],pageSizeOptions:[10],initialState:{pagination:{paginationModel:{pageSize:10}}}})]}),d===5&&e.jsxs(e.Fragment,{children:[e.jsx(n,{variant:"contained",sx:{mb:2},onClick:()=>u("campaign",{goal_value:500,calc_type:"points_sum",status:"active"}),children:"New campaign"}),e.jsx(h,{autoHeight:!0,rows:D,columns:[{field:"id",width:70},{field:"title",flex:1},{field:"goal_value",width:110},{field:"status",width:100}],pageSizeOptions:[10],initialState:{pagination:{paginationModel:{pageSize:10}}}})]}),d===6&&e.jsxs(e.Fragment,{children:[e.jsx(n,{variant:"contained",sx:{mb:2},onClick:()=>u("theme",{is_active:1}),children:"New theme"}),e.jsx(h,{autoHeight:!0,rows:P,getRowId:t=>t.id,columns:[{field:"theme_key",width:140},{field:"label",flex:1},{field:"is_active",width:90}],pageSizeOptions:[10],initialState:{pagination:{paginationModel:{pageSize:10}}}})]}),d===7&&e.jsx(h,{autoHeight:!0,rows:H,columns:[{field:"id",width:70},{field:"user_id",width:90},{field:"event_type",width:140},{field:"title",flex:1},{field:"created_at",flex:1}],pageSizeOptions:[15],initialState:{pagination:{paginationModel:{pageSize:15}}}})]}),e.jsxs(Q,{open:!!s,onClose:()=>p(null),fullWidth:!0,maxWidth:"sm",children:[e.jsxs(X,{children:["Configure ",s]}),e.jsxs(Z,{sx:{display:"flex",flexDirection:"column",gap:2,pt:1},children:[s==="mission"&&e.jsxs(e.Fragment,{children:[e.jsx(i,{label:"Title",value:a.title||"",onChange:t=>l({...a,title:t.target.value}),fullWidth:!0}),e.jsx(i,{label:"Description",value:a.description||"",onChange:t=>l({...a,description:t.target.value}),fullWidth:!0,multiline:!0}),e.jsx(i,{label:"Target value",type:"number",value:a.target_value??"",onChange:t=>l({...a,target_value:t.target.value}),fullWidth:!0}),e.jsxs(i,{select:!0,label:"Calc type",value:a.calc_type||"points_sum",onChange:t=>l({...a,calc_type:t.target.value}),fullWidth:!0,children:[e.jsx(r,{value:"points_sum",children:"Points sum"}),e.jsx(r,{value:"action_count",children:"Action count"}),e.jsx(r,{value:"action_points",children:"Action points"})]}),e.jsx(i,{label:"Action key (optional)",value:a.action_key||"",onChange:t=>l({...a,action_key:t.target.value}),fullWidth:!0}),e.jsxs(i,{select:!0,label:"Scope",value:a.scope||"user",onChange:t=>l({...a,scope:t.target.value}),fullWidth:!0,children:[e.jsx(r,{value:"user",children:"User"}),e.jsx(r,{value:"team",children:"Team"}),e.jsx(r,{value:"global",children:"Global"})]}),e.jsx(i,{label:"Reward ID",type:"number",value:a.reward_id??"",onChange:t=>l({...a,reward_id:t.target.value||null}),fullWidth:!0}),e.jsx(i,{label:"Priority",type:"number",value:a.priority??0,onChange:t=>l({...a,priority:t.target.value}),fullWidth:!0}),e.jsxs(i,{select:!0,label:"Status",value:a.status||"active",onChange:t=>l({...a,status:t.target.value}),fullWidth:!0,children:[e.jsx(r,{value:"active",children:"Active"}),e.jsx(r,{value:"paused",children:"Paused"}),e.jsx(r,{value:"archived",children:"Archived"})]}),e.jsx(i,{label:"Start at (ISO)",value:a.start_at||"",onChange:t=>l({...a,start_at:t.target.value}),fullWidth:!0}),e.jsx(i,{label:"End at (ISO)",value:a.end_at||"",onChange:t=>l({...a,end_at:t.target.value}),fullWidth:!0})]}),s==="reward"&&e.jsxs(e.Fragment,{children:[e.jsx(i,{label:"Title",value:a.title||"",onChange:t=>l({...a,title:t.target.value}),fullWidth:!0}),e.jsx(i,{select:!0,label:"Type",value:a.reward_type||"custom",onChange:t=>l({...a,reward_type:t.target.value}),fullWidth:!0,children:fe.map(t=>e.jsx(r,{value:t,children:t},t))}),e.jsx(i,{label:"Value text",value:a.value_text||"",onChange:t=>l({...a,value_text:t.target.value}),fullWidth:!0,placeholder:"Rs 5000 / Family package / Pokhara tour…"}),e.jsx(i,{label:"Description",value:a.description||"",onChange:t=>l({...a,description:t.target.value}),fullWidth:!0,multiline:!0})]}),s==="rule"&&e.jsxs(e.Fragment,{children:[e.jsx(i,{label:"Action key",value:a.action_key||"",onChange:t=>l({...a,action_key:t.target.value}),fullWidth:!0}),e.jsx(i,{label:"Label",value:a.label||"",onChange:t=>l({...a,label:t.target.value}),fullWidth:!0}),e.jsx(i,{label:"Points",type:"number",value:a.points??0,onChange:t=>l({...a,points:t.target.value}),fullWidth:!0})]}),s==="tier"&&e.jsxs(e.Fragment,{children:[e.jsx(i,{label:"Name",value:a.name||"",onChange:t=>l({...a,name:t.target.value}),fullWidth:!0}),e.jsx(i,{label:"Min points",type:"number",value:a.min_points??0,onChange:t=>l({...a,min_points:t.target.value}),fullWidth:!0}),e.jsx(i,{label:"Theme key",value:a.theme_key||"",onChange:t=>l({...a,theme_key:t.target.value}),fullWidth:!0}),e.jsx(i,{label:"Sort order",type:"number",value:a.sort_order??0,onChange:t=>l({...a,sort_order:t.target.value}),fullWidth:!0})]}),s==="achievement"&&e.jsxs(e.Fragment,{children:[e.jsx(i,{label:"Code",value:a.code||"",onChange:t=>l({...a,code:t.target.value}),fullWidth:!0}),e.jsx(i,{label:"Title",value:a.title||"",onChange:t=>l({...a,title:t.target.value}),fullWidth:!0}),e.jsx(i,{label:"Description",value:a.description||"",onChange:t=>l({...a,description:t.target.value}),fullWidth:!0}),e.jsxs(i,{select:!0,label:"Rule type",value:a.rule_type||"points_total",onChange:t=>l({...a,rule_type:t.target.value}),fullWidth:!0,children:[e.jsx(r,{value:"points_total",children:"Points total"}),e.jsx(r,{value:"action_count",children:"Action count"}),e.jsx(r,{value:"points_period",children:"Monthly points"}),e.jsx(r,{value:"streak_days",children:"Streak days"})]}),e.jsx(i,{label:"Rule value",type:"number",value:a.rule_value??1,onChange:t=>l({...a,rule_value:t.target.value}),fullWidth:!0}),e.jsx(i,{label:"Action key",value:a.action_key||"",onChange:t=>l({...a,action_key:t.target.value}),fullWidth:!0})]}),s==="campaign"&&e.jsxs(e.Fragment,{children:[e.jsx(i,{label:"Title",value:a.title||"",onChange:t=>l({...a,title:t.target.value}),fullWidth:!0}),e.jsx(i,{label:"Description",value:a.description||"",onChange:t=>l({...a,description:t.target.value}),fullWidth:!0}),e.jsx(i,{label:"Goal value",type:"number",value:a.goal_value??1,onChange:t=>l({...a,goal_value:t.target.value}),fullWidth:!0}),e.jsx(i,{label:"Reward ID",type:"number",value:a.reward_id??"",onChange:t=>l({...a,reward_id:t.target.value||null}),fullWidth:!0})]}),s==="theme"&&e.jsxs(e.Fragment,{children:[e.jsx(i,{label:"Theme key",value:a.theme_key||"",onChange:t=>l({...a,theme_key:t.target.value}),fullWidth:!0}),e.jsx(i,{label:"Label",value:a.label||"",onChange:t=>l({...a,label:t.target.value}),fullWidth:!0}),e.jsx(i,{label:"Accent color",value:((f=a.css_vars)==null?void 0:f.accent)||"",onChange:t=>l({...a,css_vars:{...a.css_vars||{},accent:t.target.value}}),fullWidth:!0})]})]}),e.jsxs(ee,{children:[e.jsx(n,{onClick:()=>p(null),children:"Cancel"}),e.jsx(n,{variant:"contained",onClick:B,children:"Save"})]})]})]})}export{_e 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.