(self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[544],{56690:function(e,a,i){Promise.resolve().then(i.bind(i,3128))},3128:function(e,a,i){"use strict";i.r(a),i.d(a,{default:function(){return s}});var t=i(57437),n=i(2265),l=i(80605),r=i(22611);function s(){let{data:e}=(0,l.useSession)(),[a,i]=(0,n.useState)(!1),[s,o]=(0,n.useState)(null),[p,d]=(0,n.useState)(""),[u,c]=(0,n.useState)(""),[x,m]=(0,n.useState)({text:"",type:""});(0,n.useEffect)(()=>{var a;(null==e?void 0:null===(a=e.user)||void 0===a?void 0:a.id)&&fetch("/api/user/profile").then(e=>e.json()).then(e=>{e.user&&(o(e.user),d(e.user.whatsappNumber||""),c(e.user.telegramId||""))}).catch(console.error)},[e]);let h=async e=>{e.preventDefault(),i(!0),m({text:"",type:""});try{let e=await fetch("/api/user/profile",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({whatsappNumber:p,telegramId:u})}),a=await e.json();if(!e.ok)throw Error(a.error||"Gagal menyimpan profil");m({text:"Profil berhasil diperbarui!",type:"success"})}catch(e){m({text:e.message,type:"error"})}finally{i(!1)}};return(0,t.jsxs)("main",{style:{minHeight:"100vh",background:"#0a0a0f",display:"flex",flexDirection:"column"},children:[(0,t.jsx)(r.default,{}),(0,t.jsxs)("div",{style:{paddingTop:"80px",maxWidth:"800px",margin:"0 auto",padding:"80px 24px 60px",width:"100%"},children:[(0,t.jsx)("h1",{className:"font-game",style:{fontSize:"28px",fontWeight:700,color:"#f1f5f9",marginBottom:"8px"},children:"\uD83D\uDC64 Pengaturan Profil"}),(0,t.jsx)("p",{style:{color:"#64748b",marginBottom:"32px"},children:"Atur pengaitan akun untuk menerima notifikasi pesanan otomatis."}),(0,t.jsxs)("form",{onSubmit:h,className:"card",style:{padding:"32px"},children:[x.text&&(0,t.jsx)("div",{style:{padding:"12px",borderRadius:"8px",marginBottom:"24px",fontSize:"14px",background:"error"===x.type?"rgba(239,68,68,0.1)":"rgba(16,185,129,0.1)",color:"error"===x.type?"#ef4444":"#10b981",border:"1px solid ".concat("error"===x.type?"rgba(239,68,68,0.2)":"rgba(16,185,129,0.2)")},children:x.text}),(0,t.jsxs)("div",{style:{display:"flex",flexDirection:"column",gap:"20px"},children:[(0,t.jsxs)("div",{children:[(0,t.jsx)("label",{className:"label",children:"Nama Lengkap"}),(0,t.jsx)("input",{className:"input",value:(null==s?void 0:s.name)||"",disabled:!0,style:{opacity:.7}})]}),(0,t.jsxs)("div",{children:[(0,t.jsx)("label",{className:"label",children:"Email Terdaftar"}),(0,t.jsx)("input",{className:"input",value:(null==s?void 0:s.email)||"",disabled:!0,style:{opacity:.7}}),(0,t.jsx)("div",{style:{fontSize:"12px",color:"#64748b",marginTop:"6px"},children:"Notifikasi email akan selalu dikirim ke alamat ini."})]}),(0,t.jsx)("hr",{style:{border:"none",borderTop:"1px solid rgba(255,255,255,0.05)",margin:"10px 0"}}),(0,t.jsx)("h3",{style:{color:"#f1f5f9",fontSize:"16px",margin:0},children:"Pengaitan Platform Bot"}),(0,t.jsxs)("div",{children:[(0,t.jsx)("label",{className:"label",children:"Nomor WhatsApp"}),(0,t.jsx)("input",{className:"input",placeholder:"Contoh: 6281234567890",value:p,onChange:e=>d(e.target.value)}),(0,t.jsx)("div",{style:{fontSize:"12px",color:"#64748b",marginTop:"6px"},children:"Gunakan kode negara (62). Notifikasi sukses/gagal akan dikirim ke WA ini."})]}),(0,t.jsxs)("div",{children:[(0,t.jsx)("label",{className:"label",children:"Telegram Chat ID"}),(0,t.jsx)("input",{className:"input",placeholder:"Contoh: 123456789",value:u,onChange:e=>c(e.target.value)}),(0,t.jsx)("div",{style:{fontSize:"12px",color:"#64748b",marginTop:"6px"},children:"Masukkan Chat ID Telegram Anda. Anda juga bisa menautkan secara otomatis nanti."})]}),(0,t.jsx)("button",{type:"submit",className:"btn btn-primary",disabled:a,style:{marginTop:"10px"},children:a?"Menyimpan...":"Simpan Profil"})]})]})]})]})}}},function(e){e.O(0,[648,605,611,971,117,744],function(){return e(e.s=56690)}),_N_E=e.O()}]);