PageSourceSearch

https://mathpal.study/assets/RedeemCodeModal-DcAj-VYn.js

js mathpal.study collected 2026-09-24 13:53:56 UTC 8,796 bytes, 1 lines download raw bytes

1import{j as e}from"./index-Du2OnknB.js";import{r as d}from"./vendor-react-DWrb1CVO.js";import{s as F,t as w}from"./vendor-firebase-P8isnFtX.js";import{X as T,p as S,l as k,e as f,Z as M,aS as c}from"./vendor-ui-J5w_n61H.js";const L={vi:{title:"Nhập Mã Kích Hoạt",subtitle:"Nhập số điện thoại bạn đã dùng khi chuyển khoản",inputLabel:"Số Điện Thoại",inputPlaceholder:"0912345678",nextButton:"Tiếp tục",backButton:"Quay lại",cancelButton:"Hủy",validateButton:"Xác thực",activateButton:"Kích hoạt ngay",validating:"Đang xác thực...",activating:"Đang kích hoạt...",confirmTitle:"Xác nhận kích hoạt",successTitle:"Kích hoạt thành công!",successMessage:"Tài khoản của bạn đã được nâng cấp thành công",energy:"năng lượng reset hàng tuần",features:{allFeatures:"Tất cả tính năng AI",unlimitedOCR:"OCR scan không giới hạn",practiceMode:"Practice & Advisory mode",monthlyReset:"Năng lượng reset hàng tuần",lifetime:"Truy cập trọn đời"},errors:{invalidFormat:"Vui lòng nhập đúng 10 chữ số của số điện thoại",invalidPhoneFormat:"Số điện thoại phải bắt đầu bằng số 0",tooShort:"Số điện thoại phải có 10 chữ số",unknown:"Có lỗi xảy ra. Vui lòng thử lại."}},en:{title:"Redeem Activation Code",subtitle:"Enter the phone number you used for bank transfer",inputLabel:"Phone Number",inputPlaceholder:"0912345678",nextButton:"Next",backButton:"Back",cancelButton:"Cancel",validateButton:"Validate",activateButton:"Activate Now",validating:"Validating...",activating:"Activating...",confirmTitle:"Confirm Activation",successTitle:"Successfully Activated!",successMessage:"Your account has been upgraded successfully",energy:"energy resets weekly",features:{allFeatures:"All AI features unlocked",unlimitedOCR:"Unlimited OCR scans",practiceMode:"Practice & Advisory mode",monthlyReset:"Energy resets weekly",lifetime:"Lifetime access"},errors:{invalidFormat:"Please enter exactly 10 digits",invalidPhoneFormat:"Phone number must start with 0",tooShort:"Phone number must be 10 digits",unknown:"An error occurred. Please try again."}}},I=({isOpen:C,onClose:P,onSuccess:R,lang:p})=>{const[m,b]=d.useState(""),[i,u]=d.useState(!1),[x,a]=d.useState(null),[o,v]=d.useState(null),[l,r]=d.useState("input"),t=L[p],j=F(),g=()=>{b(""),a(null),v(null),r("input"),P()},N=async()=>{a(null);const s=m.trim();if(!/^\d{10}$/.test(s)){a(t.errors.invalidFormat);return}if(!s.startsWith("0")){a(t.errors.invalidPhoneFormat);return}u(!0);try{const h=await w(j,"validateActivationCode")({code:s});h.data.valid&&h.data.tier?(v(h.data),r("confirm")):a(h.data.error||t.errors.unknown)}catch(n){console.error("Validation error:",n),a(n.message||t.errors.unknown)}finally{u(!1)}},y=async()=>{a(null),u(!0);try{const n=await w(j,"redeemActivationCode")({code:m.trim()});n.data.success?(r("success"),setTimeout(()=>{R(),g()},2e3)):(a(n.data.error||t.errors.unknown),r("input"))}catch(s){console.error("Redemption error:",s),a(s.message||t.errors.unknown),r("input")}finally{u(!1)}},A=s=>{s.key==="Enter"&&!i&&(l==="input"?N():l==="confirm"&&y())};if(!C)return null;const B=()=>{if(!o)return"";const{tier:s,billingPeriod:n}=o;return s==="lifetime"?"Premium":s==="pro"?n==="yearly"?"Pro Yearly":"Pro Monthly":s};return e.jsx("div",{className:"fixed inset-0 bg-black/50 flex items-center justify-center z-50 p-4",children:e.jsxs("div",{className:"bg-white rounded-2xl max-w-md w-full shadow-2xl overflow-hidden",children:[e.jsxs("div",{className:"bg-gradient-to-r from-blue-500 to-purple-600 p-6 text-white relative",children:[e.jsx("button",{onClick:g,className:"absolute top-4 right-4 p-2 hover:bg-white/20 rounded-lg transition",disabled:i,children:e.jsx(T,{className:"w-5 h-5"})}),e.jsxs("div",{className:"flex items-center gap-3 mb-2",children:[e.jsx("div",{className:"p-3 bg-white/20 rounded-xl",children:e.jsx(S,{className:"w-6 h-6"})}),e.jsx("h2",{className:"text-2xl font-bold",children:l==="success"?t.successTitle:l==="confirm"?t.confirmTitle:t.title})]}),l==="input"&&e.jsx("p",{className:"text-white/90 text-sm",children:t.subtitle})]}),e.jsxs("div",{className:"p-6",children:[l==="input"&&e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"mb-6",children:[e.jsx("label",{className:"block text-sm font-medium text-slate-700 mb-2",children:t.input
1Label}),e.jsx("input",{type:"text",placeholder:t.inputPlaceholder,value:m,onChange:s=>{const n=s.target.value.replace(/\D/g,"");b(n),a(null)},onKeyPress:A,className:"w-full px-4 py-3 border-2 border-slate-200 rounded-xl font-mono text-center text-lg tracking-wider focus:border-blue-500 focus:outline-none transition",maxLength:10,autoFocus:!0,disabled:i}),e.jsx("p",{className:"text-xs text-slate-500 mt-2 text-center",children:p==="vi"?"Ví dụ: 0912345678":"Example: 0912345678"})]}),x&&e.jsxs("div",{className:"flex items-start gap-3 p-4 bg-red-50 border border-red-200 text-red-700 rounded-xl mb-6",children:[e.jsx(k,{className:"w-5 h-5 mt-0.5 flex-shrink-0"}),e.jsx("span",{className:"text-sm",children:x})]}),e.jsxs("div",{className:"flex gap-3",children:[e.jsx("button",{onClick:g,className:"flex-1 px-4 py-3 border-2 border-slate-200 text-slate-700 rounded-xl hover:bg-slate-50 font-medium transition",disabled:i,children:t.cancelButton}),e.jsx("button",{onClick:N,className:"flex-1 px-4 py-3 bg-gradient-to-r from-blue-500 to-purple-600 text-white rounded-xl hover:opacity-90 font-medium transition disabled:opacity-50 flex items-center justify-center gap-2",disabled:i||m.length<10,children:i?e.jsxs(e.Fragment,{children:[e.jsx(f,{className:"w-4 h-4 animate-spin"}),t.validating]}):t.nextButton})]})]}),l==="confirm"&&o&&e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"bg-gradient-to-br from-blue-50 to-purple-50 p-6 rounded-2xl mb-6",children:[e.jsxs("div",{className:"text-center mb-4",children:[e.jsx("div",{className:"inline-block px-4 py-2 bg-white rounded-full shadow-sm mb-3",children:e.jsx("span",{className:"text-2xl font-bold text-transparent bg-clip-text bg-gradient-to-r from-blue-600 to-purple-600",children:B()})}),e.jsx("div",{className:"mb-4",children:e.jsxs("div",{className:"bg-white p-4 rounded-xl inline-block",children:[e.jsx(M,{className:"w-5 h-5 text-blue-500 mx-auto mb-2"}),e.jsx("div",{className:"text-2xl font-bold text-slate-800",children:o.tier==="lifetime"?"Premium":"Pro"}),e.jsx("div",{className:"text-xs text-slate-600",children:t.energy})]})})]}),e.jsxs("div",{className:"space-y-2 text-sm",children:[e.jsxs("div",{className:"flex items-center gap-2 text-slate-700",children:[e.jsx(c,{className:"w-4 h-4 text-green-500 flex-shrink-0"}),t.features.allFeatures]}),e.jsxs("div",{className:"flex items-center gap-2 text-slate-700",children:[e.jsx(c,{className:"w-4 h-4 text-green-500 flex-shrink-0"}),t.features.unlimitedOCR]}),e.jsxs("div",{className:"flex items-center gap-2 text-slate-700",children:[e.jsx(c,{className:"w-4 h-4 text-green-500 flex-shrink-0"}),t.features.practiceMode]}),e.jsxs("div",{className:"flex items-center gap-2 text-slate-700",children:[e.jsx(c,{className:"w-4 h-4 text-green-500 flex-shrink-0"}),o.billingPeriod==="lifetime"?t.features.lifetime:t.features.monthlyReset]})]})]}),x&&e.jsxs("div",{className:"flex items-start gap-3 p-4 bg-red-50 border border-red-200 text-red-700 rounded-xl mb-6",children:[e.jsx(k,{className:"w-5 h-5 mt-0.5 flex-shrink-0"}),e.jsx("span",{className:"text-sm",children:x})]}),e.jsxs("div",{className:"flex gap-3",children:[e.jsx("button",{onClick:()=>r("input"),className:"flex-1 px-4 py-3 border-2 border-slate-200 text-slate-700 rounded-xl hover:bg-slate-50 font-medium transition",disabled:i,children:t.backButton}),e.jsx("button",{onClick:y,className:"flex-1 px-4 py-3 bg-gradient-to-r from-blue-500 to-purple-600 text-white rounded-xl hover:opacity-90 font-medium transition disabled:opacity-50 flex items-center justify-center gap-2",disabled:i,children:i?e.jsxs(e.Fragment,{children:[e.jsx(f,{className:"w-4 h-4 animate-spin"}),t.activating]}):e.jsxs(e.Fragment,{children:[t.activateButton,e.jsx(c,{className:"w-4 h-4"})]})})]})]}),l==="success"&&e.jsxs("div",{className:"text-center py-8",children:[e.jsx("div",{className:"w-20 h-20 bg-green-100 rounded-full flex items-center justify-center mx-auto mb-6",children:e.jsx(c,{className:"w-12 h-12 text-green-500"})}),e.jsx("h3",{className:"text-2xl font-bold text-slate-800 mb-2",children:t.successTitle}),e.jsx("p",{className:"text-slate-600 mb-6",children:t.successMessage}),e.jsxs("div",{className:"flex items-center justify-center gap-2 text-blue-600",children:[e.jsx(f,{className:"w-4 h-4 animate-spin"}),e.jsx("span",{className:"text-sm",children:p==="vi"?"Đang tải lại...":"Reloading..."})]})]})]})]})})};export{I as RedeemCodeModal};

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.