PageSourceSearch

https://www.guozhong.app/assets/RedeemPage-CmO43PpL.js

js guozhong.app collected 2026-10-07 08:15:46 UTC 3,469 bytes, 1 lines download raw bytes

1import{aS as v,aR as w,a8 as C,P as E,af as e,ac as z}from"./index-B3RcUG2d.js";import{l as o}from"./vendor-charts-CCORyT6D.js";import"./vendor-supabase-CD_YAFfX.js";import"./vendor-katex-Cwc2KRvW.js";const i="3px solid #000",p="4px 4px 0 #000",R="#FFD93D",W="#FF6B6B",D="#C4B5FD",L={invalid_code:"找不到這組開通碼",already_used:"這組開通碼已被使用或已過期",need_login:"請先登入"};function P(){const[,u]=v(),{login:a}=w(),[n,m]=o.useState(""),[x,g]=o.useState(!1),[r,s]=o.useState(null),[S,b]=o.useState(!1),[y,k]=o.useState(3),f=o.useCallback(async()=>{const t=n.trim().toUpperCase();if(t.length<6){s({text:"開通碼格式不正確",ok:!1});return}g(!0),s(null);try{const{data:l,error:h}=await C().rpc("redeem_activation",{p_code:t});if(h)throw h;const d=String(l);if(d==="ok"){b(!0),sessionStorage.setItem(E,"/teacher");let c=3;const j=window.setInterval(()=>{c-=1,k(c),c<=0&&(window.clearInterval(j),a())},1e3)}else s({text:L[d]??d,ok:!1})}catch(l){console.warn("[RedeemPage]",l),s({text:"兌換失敗,請稍後再試",ok:!1})}finally{g(!1)}},[n,a]);return e.jsxs("div",{style:{maxWidth:480,margin:"0 auto",padding:"20px 20px calc(128px + env(safe-area-inset-bottom))"},children:[e.jsx("button",{onClick:()=>u("/"),style:{border:"none",background:"none",fontSize:"14px",fontWeight:700,color:"#555",padding:"0 0 16px",cursor:"pointer"},children:"← 回首頁"}),e.jsx("p",{style:{fontSize:"24px",fontWeight:900,margin:"0 0 8px"},children:"老師開通"}),e.jsx("p",{style:{fontSize:"14px",color:"#555",margin:"0 0 24px",lineHeight:1.6},children:"輸入申請通過後收到的開通碼,即可啟用老師功能。"}),S?e.jsxs("div",{style:{border:i,boxShadow:p,background:D,padding:24,textAlign:"center"},children:[e.jsx("p",{style:{fontSize:"20px",fontWeight:900,margin:0},children:"開通成功 🎉"}),e.jsxs("p",{style:{fontSize:"14px",margin:"10px 0 0",lineHeight:1.6},children:[y," 秒後將自動重新登入,",e.jsx("br",{}),"完成後會直接進入老師端。"]}),e.jsx("button",{onClick:a,style:{marginTop:16,border:i,boxShadow:"3px 3px 0 #000",background:"#fff",fontSize:"14px",fontWeight:900,padding:"10px 18px",cursor:"pointer"},children:"進入老師端 →"})]}):z()?e.jsxs("div",{style:{border:i,boxShadow:p,background:"#fff",padding:20},children:[e.jsxs("div",{style:{display:"flex",gap:10},children:[e.jsx("input",{value:n,onChange:t=>m(t.target.value.toUpperCase().slice(0,20)),onKeyDown:t=>{t.key==="Enter"&&!t.nativeEvent.isComposing&&f()},placeholder:"TRIAL-XXXXXX",autoCapitalize:"characters",autoCorrect:"off",spellCheck:!1,style:{flex:1,minWidth:0,border:i,padding:"12px 14px",fontSize:"16px",fontWeight:900,letterSpacing:"2px",textAlign:"center",outline:"none"}}),e.jsx("button",{onClick:()=>{f()},disabled:x||n.trim().length<6,style:{flexShrink:0,border:i,boxShadow:"3px 3px 0 #000",background:n.trim().length>=6?R:"#eee",fontSize:"15px",fontWeight:900,padding:"12px 18px",cursor:x||n.trim().length<6?"not-allowed":"pointer"},children:"開通"})]}),r&&e.jsx("p",{style:{fontSize:"14px",fontWeight:700,marginTop:14,marginBottom:0,color:r.ok?"#000":W},children:r.text})]}):e.jsxs("div",{style:{border:i,boxShadow:p,background:"#fff",padding:20},children:[e.jsx("p",{style:{fontSize:"15px",fontWeight:900,margin:0},children:"請先用 LINE 登入"}),e.jsx("p",{style:{fontSize:"13px",color:"#666",margin:"8px 0 0"},children:"登入後回到這個頁面即可輸入開通碼。"})]})]})}export{P 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.