1 line
17 KiB
JavaScript
1 line
17 KiB
JavaScript
import{a as e,c as t,d as n,i as r,n as i,o as a,t as o}from"./app-CBC6ZGaO.js";import{t as s}from"./AuthenticatedLayout-DI4WLw0Y.js";import{n as c,t as l}from"./swal-ClfUb7Hm.js";import{n as u,r as d,t as f}from"./filepond-plugin-file-validate-type-Bm_JOscj.js";var p=n(t(),1),m=n(c(),1),h=d(),g=n(u(),1),_=n(f(),1),v=o();(0,h.registerPlugin)(g.default,_.default);function y({title:e,description:t,children:n,delay:r=`0s`,variant:i=`default`}){let a=i===`danger`;return(0,v.jsxs)(`div`,{className:`bg-white rounded-2xl border ${a?`border-red-200 shadow-none`:`border-gray-100 shadow-sm`} overflow-hidden h-full flex flex-col anim-up`,style:{animationDelay:r},children:[(0,v.jsxs)(`div`,{className:`px-6 py-4 border-b ${a?`border-red-100 bg-red-50`:`border-gray-50 bg-gray-50/30`}`,children:[(0,v.jsx)(`h2`,{className:`text-sm font-bold tracking-tight ${a?`text-red-600`:`text-[#3D4E4B]`}`,children:e}),(0,v.jsx)(`p`,{className:`text-xs font-semibold tracking-tight mt-1 ${a?`text-red-400`:`text-gray-400`}`,children:t})]}),(0,v.jsx)(`div`,{className:`p-8 flex-1`,children:n})]})}function b({label:e,id:t,type:n=`text`,value:r,onChange:i,error:a,placeholder:o,required:s=!1}){return(0,v.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,v.jsxs)(`label`,{htmlFor:t,className:`block text-xs font-semibold text-gray-500 tracking-tight ml-1`,children:[e,` `,s&&(0,v.jsx)(`span`,{className:`text-red-500`,children:`*`})]}),(0,v.jsx)(`input`,{id:t,type:n,value:r,onChange:i,placeholder:o,className:`input-field${a?` is-error`:``}`}),a&&(0,v.jsx)(`p`,{className:`text-xs text-red-500 font-semibold ml-1 mt-1`,children:a})]})}var x=[`profile`,`security`,`2fa`,`danger`];function S(){let e=window.location.hash.replace(`#`,``);return x.includes(e)?e:`profile`}function C({twoFactor:t}){let{user:n}=a().props.auth,[o,c]=(0,p.useState)(S);(0,p.useEffect)(()=>{let e=()=>c(S());return window.addEventListener(`hashchange`,e),()=>window.removeEventListener(`hashchange`,e)},[]);let u=e=>{window.location.hash=e,c(e)},{data:d,setData:f,post:g,processing:_,errors:x}=e({first_name:n.first_name||``,last_name:n.last_name||``,email:n.email||``,phone:n.phone||``,bio:n.bio||``,avatar_file:null,_method:`PATCH`}),[C,w]=(0,p.useState)([]),T=e=>{e.preventDefault(),g(route(`profile.update`),{preserveScroll:!0,onSuccess:()=>l.success(`Saved`,`Profile updated successfully.`)})},{data:E,setData:D,put:O,processing:k,errors:A,reset:j}=e({current_password:``,password:``,password_confirmation:``}),M=e=>{e.preventDefault(),O(route(`password.update`),{preserveScroll:!0,onSuccess:()=>{j(),l.success(`Saved`,`Password updated successfully.`)}})},N=async()=>{if((await l.confirm(`Delete account?`,`This action is irreversible.`,`Delete Permanently`)).isConfirmed){let{value:e}=await m.default.fire({title:`Confirm Password`,input:`password`,inputPlaceholder:`Enter your current password`,showCancelButton:!0,confirmButtonText:`Delete`,confirmButtonColor:`#dc2626`});e&&r.delete(route(`profile.destroy`),{data:{password:e},preserveScroll:!0,onSuccess:()=>l.success(`Deleted`,`Account removed.`),onError:e=>l.error(`Error`,e.password||`Incorrect password.`)})}},P=`${n.first_name?.charAt(0)||``}${n.last_name?.charAt(0)||``}`.toUpperCase(),[F,I]=(0,p.useState)(!1),[L,R]=(0,p.useState)(!1),z=e({code:``});return(0,v.jsxs)(s,{children:[(0,v.jsx)(i,{title:`Account Settings`}),(0,v.jsx)(`div`,{className:`flex items-center justify-between mb-8 anim-down`,children:(0,v.jsxs)(`div`,{children:[(0,v.jsx)(`h1`,{className:`text-xl font-bold text-[#3D4E4B] tracking-tight leading-none`,children:`Account Settings`}),(0,v.jsx)(`p`,{className:`text-sm font-semibold text-gray-400 tracking-tight mt-2`,children:`Manage your personal credentials and security preferences`})]})}),(0,v.jsxs)(`div`,{className:`flex items-center gap-1 border-b border-gray-100 w-full mb-8 anim-down`,style:{animationDelay:`0.05s`},children:[(0,v.jsxs)(`button`,{type:`button`,onClick:()=>u(`profile`),className:`relative pb-3 px-1 mr-8 text-sm font-bold tracking-tight transition-colors ${o===`profile`?`text-[#3D4E4B]`:`text-gray-400 hover:text-[#3D4E4B]`}`,children:[`Profile Information`,o===`profile`&&(0,v.jsx)(`span`,{className:`absolute bottom-0 left-0 w-full h-0.5 bg-[#D4A017] rounded-t-full`})]}),(0,v.jsxs)(`button`,{type:`button`,onClick:()=>u(`security`),className:`relative pb-3 px-1 mr-8 text-sm font-bold tracking-tight transition-colors ${o===`security`?`text-[#3D4E4B]`:`text-gray-400 hover:text-[#3D4E4B]`}`,children:[`Security & Password`,o===`security`&&(0,v.jsx)(`span`,{className:`absolute bottom-0 left-0 w-full h-0.5 bg-[#D4A017] rounded-t-full`})]}),(0,v.jsxs)(`button`,{type:`button`,onClick:()=>u(`2fa`),className:`relative pb-3 px-1 mr-8 text-sm font-bold tracking-tight transition-colors ${o===`2fa`?`text-[#3D4E4B]`:`text-gray-400 hover:text-[#3D4E4B]`}`,children:[`Two-Factor Auth`,o===`2fa`&&(0,v.jsx)(`span`,{className:`absolute bottom-0 left-0 w-full h-0.5 bg-[#D4A017] rounded-t-full`})]}),(0,v.jsxs)(`button`,{type:`button`,onClick:()=>u(`danger`),className:`relative pb-3 px-1 text-sm font-bold tracking-tight transition-colors ${o===`danger`?`text-red-600`:`text-gray-400 hover:text-red-600`}`,children:[`Danger Zone`,o===`danger`&&(0,v.jsx)(`span`,{className:`absolute bottom-0 left-0 w-full h-0.5 bg-red-500 rounded-t-full`})]})]}),(0,v.jsxs)(`div`,{className:`space-y-8 pb-20`,children:[o===`profile`&&(0,v.jsx)(`div`,{className:`space-y-8 anim-fade`,children:(0,v.jsxs)(`div`,{className:`grid grid-cols-1 lg:grid-cols-3 gap-8`,children:[(0,v.jsx)(`div`,{className:`lg:col-span-2`,children:(0,v.jsx)(y,{title:`Identity`,description:`Manage your public name and contact email`,delay:`0.1s`,children:(0,v.jsxs)(`form`,{onSubmit:T,className:`space-y-8`,children:[(0,v.jsxs)(`div`,{className:`grid grid-cols-1 sm:grid-cols-2 gap-6`,children:[(0,v.jsx)(b,{label:`First Name`,id:`first_name`,value:d.first_name,onChange:e=>f(`first_name`,e.target.value),error:x.first_name,required:!0,placeholder:`e.g. John`}),(0,v.jsx)(b,{label:`Last Name`,id:`last_name`,value:d.last_name,onChange:e=>f(`last_name`,e.target.value),error:x.last_name,required:!0,placeholder:`e.g. Doe`})]}),(0,v.jsx)(b,{label:`Email Address`,id:`email`,type:`email`,value:d.email,onChange:e=>f(`email`,e.target.value),error:x.email,required:!0,placeholder:`e.g. john.doe@example.com`}),(0,v.jsx)(b,{label:`Phone Number`,id:`phone`,value:d.phone,onChange:e=>f(`phone`,e.target.value),error:x.phone,placeholder:`e.g. +62 812 3456 7890`}),(0,v.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,v.jsx)(`label`,{htmlFor:`bio`,className:`block text-xs font-semibold text-gray-500 tracking-tight ml-1`,children:`Bio`}),(0,v.jsx)(`textarea`,{id:`bio`,value:d.bio,onChange:e=>f(`bio`,e.target.value),rows:3,placeholder:`A short description about yourself...`,className:`input-field py-3 resize-none${x.bio?` is-error`:``}`}),x.bio&&(0,v.jsx)(`p`,{className:`text-xs text-red-500 font-semibold ml-1 mt-1`,children:x.bio})]}),(0,v.jsx)(`div`,{className:`flex justify-end pt-4 border-t border-gray-50`,children:(0,v.jsx)(`button`,{type:`submit`,disabled:_,className:`h-10 px-8 bg-[#3D4E4B] text-white text-sm font-bold tracking-tight rounded-xl hover:bg-[#2D3A38] transition-all shadow-lg shadow-[#3D4E4B]/20 disabled:opacity-60`,children:_?`Saving...`:`Save Profile`})})]})})}),(0,v.jsx)(`div`,{className:`lg:col-span-1`,children:(0,v.jsx)(y,{title:`Profile Photo`,description:`Update your avatar`,delay:`0.15s`,children:(0,v.jsxs)(`div`,{className:`flex flex-col items-center gap-6`,children:[(0,v.jsx)(`div`,{className:`w-24 h-24 rounded-2xl bg-[#3D4E4B] flex items-center justify-center text-white text-2xl font-bold shadow-lg shadow-[#3D4E4B]/10 overflow-hidden border-2 border-white`,children:n.avatar_url?(0,v.jsx)(`img`,{src:n.avatar_url,className:`w-full h-full object-cover`}):P}),(0,v.jsx)(`div`,{className:`w-full`,children:(0,v.jsx)(h.FilePond,{files:C,onupdatefiles:e=>{w(e),f(`avatar_file`,e[0]?.file||null)},allowMultiple:!1,maxFiles:1,labelIdle:`Drop Photo here`})})]})})})]})}),o===`security`&&(0,v.jsx)(`div`,{className:`max-w-4xl anim-fade`,children:(0,v.jsx)(y,{title:`Password`,description:`Update your secure access key`,delay:`0.1s`,children:(0,v.jsxs)(`form`,{onSubmit:M,className:`space-y-8`,children:[(0,v.jsx)(`div`,{className:`max-w-md`,children:(0,v.jsx)(b,{label:`Current Password`,id:`current_password`,type:`password`,value:E.current_password,onChange:e=>D(`current_password`,e.target.value),error:A.current_password,required:!0,placeholder:`••••••••`})}),(0,v.jsx)(`div`,{className:`h-px bg-gray-50 -mx-8`}),(0,v.jsxs)(`div`,{className:`grid grid-cols-1 sm:grid-cols-2 gap-8`,children:[(0,v.jsx)(b,{label:`New Password`,id:`password`,type:`password`,value:E.password,onChange:e=>D(`password`,e.target.value),error:A.password,required:!0,placeholder:`Enter new password`}),(0,v.jsx)(b,{label:`Confirm New Password`,id:`password_confirmation`,type:`password`,value:E.password_confirmation,onChange:e=>D(`password_confirmation`,e.target.value),error:A.password_confirmation,required:!0,placeholder:`Repeat new password`})]}),(0,v.jsx)(`div`,{className:`flex justify-end pt-4 border-t border-gray-50`,children:(0,v.jsx)(`button`,{type:`submit`,disabled:k,className:`h-10 px-8 bg-[#3D4E4B] text-white text-sm font-bold tracking-tight rounded-xl hover:bg-[#2D3A38] transition-all shadow-lg shadow-[#3D4E4B]/20 disabled:opacity-60`,children:k?`Updating...`:`Update Password`})})]})})}),o===`2fa`&&(0,v.jsxs)(`div`,{className:`max-w-3xl space-y-6 anim-fade`,children:[(0,v.jsxs)(`div`,{className:`p-5 bg-amber-50 border border-amber-200 rounded-2xl flex items-start gap-3`,children:[(0,v.jsx)(`svg`,{className:`w-5 h-5 text-amber-500 mt-0.5 shrink-0`,fill:`none`,viewBox:`0 0 24 24`,stroke:`currentColor`,strokeWidth:2.5,children:(0,v.jsx)(`path`,{strokeLinecap:`round`,strokeLinejoin:`round`,d:`M12 9v2m0 4h.01M10.29 3.86L1.82 18a2 2 0 001.71 3h16.94a2 2 0 001.71-3L13.71 3.86a2 2 0 00-3.42 0z`})}),(0,v.jsxs)(`div`,{children:[(0,v.jsx)(`p`,{className:`text-xs font-bold text-amber-800 mb-1`,children:`Two-Factor Authentication (2FA)`}),(0,v.jsx)(`p`,{className:`text-[11px] text-amber-700 font-medium leading-relaxed`,children:`2FA menambah lapisan keamanan ekstra dengan meminta kode OTP dari aplikasi authenticator setiap kali login.`})]})]}),t.enabled?(0,v.jsxs)(`div`,{className:`space-y-4`,children:[(0,v.jsxs)(`div`,{className:`bg-white rounded-2xl border border-emerald-100 shadow-sm p-6 flex items-center gap-4`,children:[(0,v.jsx)(`div`,{className:`w-12 h-12 rounded-xl bg-emerald-50 flex items-center justify-center shrink-0`,children:(0,v.jsx)(`svg`,{className:`w-6 h-6 text-emerald-600`,fill:`none`,viewBox:`0 0 24 24`,stroke:`currentColor`,strokeWidth:2.5,children:(0,v.jsx)(`path`,{strokeLinecap:`round`,strokeLinejoin:`round`,d:`M9 12l2 2 4-4m5.618-4.016A11.955 11.955 0 0112 2.944a11.955 11.955 0 01-8.618 3.04A12.02 12.02 0 003 9c0 5.591 3.824 10.29 9 11.622 5.176-1.332 9-6.03 9-11.622 0-1.042-.133-2.052-.382-3.016z`})})}),(0,v.jsxs)(`div`,{className:`flex-1`,children:[(0,v.jsx)(`div`,{className:`text-sm font-bold text-[#3D4E4B]`,children:`Two-Factor Authentication Aktif`}),(0,v.jsx)(`div`,{className:`text-xs text-gray-400 font-medium mt-0.5`,children:`Akun Anda dilindungi dengan TOTP authentication.`})]}),(0,v.jsx)(`button`,{onClick:async()=>{let{value:e}=await m.default.fire({title:`Disable 2FA`,text:`Enter your password to confirm.`,input:`password`,inputPlaceholder:`Your current password`,showCancelButton:!0,confirmButtonText:`Disable`,confirmButtonColor:`#dc2626`});e&&r.post(route(`two-factor.disable`),{password:e},{preserveScroll:!0,onSuccess:()=>l.success(`Disabled`,`2FA has been disabled.`)})},type:`button`,className:`h-9 px-5 text-xs font-bold text-red-500 border border-red-200 rounded-xl hover:bg-red-50 transition-all`,children:`Disable 2FA`})]}),(0,v.jsx)(y,{title:`Recovery Codes`,description:`Simpan kode ini dengan aman — gunakan jika kehilangan akses ke authenticator`,children:(0,v.jsxs)(`div`,{className:`space-y-4`,children:[(0,v.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,v.jsx)(`button`,{onClick:()=>R(!L),type:`button`,className:`h-8 px-4 text-xs font-bold text-[#3D4E4B] border border-gray-200 rounded-lg hover:bg-gray-50 transition-all`,children:L?`Hide`:`Show Codes`}),(0,v.jsx)(`button`,{onClick:async()=>{(await l.confirm(`Regenerate Codes?`,`Old recovery codes will be invalidated.`,`Regenerate`)).isConfirmed&&r.post(route(`two-factor.recovery-codes`),{},{preserveScroll:!0,onSuccess:()=>{R(!0),l.success(`Regenerated`,`New recovery codes generated.`)}})},type:`button`,className:`h-8 px-4 text-xs font-bold text-[#D4A017] border border-amber-200 rounded-lg hover:bg-amber-50 transition-all`,children:`Regenerate`})]}),L&&t.recovery_codes.length>0&&(0,v.jsxs)(`div`,{children:[(0,v.jsx)(`div`,{className:`grid grid-cols-2 gap-2`,children:t.recovery_codes.map((e,t)=>(0,v.jsx)(`code`,{className:`px-4 py-2.5 bg-gray-50 border border-gray-100 rounded-xl text-xs font-mono text-[#3D4E4B] tracking-wider text-center`,children:e},t))}),(0,v.jsx)(`p`,{className:`text-[11px] text-amber-600 font-semibold mt-3`,children:`⚠ Setiap kode hanya bisa digunakan sekali.`})]})]})})]}):(0,v.jsx)(y,{title:`Setup Authenticator App`,description:`Scan QR code dengan Google Authenticator, Authy, atau TOTP app lainnya`,children:(0,v.jsxs)(`div`,{className:`flex flex-col md:flex-row gap-10 items-center md:items-start`,children:[(0,v.jsx)(`div`,{className:`shrink-0`,children:(0,v.jsx)(`div`,{className:`p-4 bg-white border-2 border-gray-100 rounded-2xl inline-block shadow-sm`,children:t.qr_code&&(0,v.jsx)(`img`,{src:t.qr_code,alt:`2FA QR Code`,className:`w-44 h-44`})})}),(0,v.jsxs)(`div`,{className:`flex-1 space-y-6`,children:[(0,v.jsx)(`div`,{className:`space-y-3`,children:[`Install aplikasi authenticator (Google Authenticator, Authy, 1Password)`,`Scan QR code atau masukkan manual key di bawah`,`Masukkan kode 6 digit dari aplikasi untuk mengaktifkan`].map((e,t)=>(0,v.jsxs)(`div`,{className:`flex items-start gap-3`,children:[(0,v.jsx)(`div`,{className:`w-6 h-6 rounded-full bg-[#3D4E4B] text-white text-[10px] font-black flex items-center justify-center shrink-0 mt-0.5`,children:t+1}),(0,v.jsx)(`p`,{className:`text-xs font-medium text-gray-500 leading-relaxed pt-0.5`,children:e})]},t))}),(0,v.jsxs)(`div`,{children:[(0,v.jsx)(`label`,{className:`block text-xs font-semibold text-gray-400 mb-1.5`,children:`Manual Key`}),(0,v.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,v.jsx)(`code`,{className:`flex-1 text-xs font-mono bg-gray-50 border border-gray-100 rounded-xl px-4 py-3 text-[#3D4E4B] tracking-wider`,children:t.secret}),(0,v.jsx)(`button`,{onClick:()=>{navigator.clipboard.writeText(t.secret||``),I(!0),setTimeout(()=>I(!1),2e3)},type:`button`,className:`shrink-0 h-11 px-4 border border-gray-200 rounded-xl text-xs font-bold text-gray-500 hover:bg-gray-50 transition-all`,children:F?`✓ Copied`:`Copy`})]})]}),(0,v.jsxs)(`form`,{onSubmit:e=>{e.preventDefault(),z.post(route(`two-factor.enable`),{preserveScroll:!0,onSuccess:()=>{z.reset(),l.success(`Enabled`,`2FA is now active on your account.`)}})},className:`space-y-3`,children:[(0,v.jsxs)(`div`,{children:[(0,v.jsx)(`label`,{className:`block text-xs font-semibold text-gray-400 mb-1.5`,children:`Verification Code *`}),(0,v.jsx)(`input`,{type:`text`,inputMode:`numeric`,maxLength:6,value:z.data.code,onChange:e=>z.setData(`code`,e.target.value),className:`input-field w-full text-center tracking-[0.5em] font-bold text-lg`,placeholder:`000000`}),z.errors.code&&(0,v.jsx)(`p`,{className:`text-xs text-red-500 font-semibold mt-1`,children:z.errors.code})]}),(0,v.jsx)(`button`,{type:`submit`,disabled:z.processing||z.data.code.length<6,className:`w-full h-11 bg-[#3D4E4B] text-white text-xs font-bold rounded-xl hover:bg-[#2D3A38] transition-all disabled:opacity-60`,children:z.processing?`Verifying...`:`Enable Two-Factor Authentication`})]})]})]})})]}),o===`danger`&&(0,v.jsx)(`div`,{className:`max-w-4xl anim-fade`,children:(0,v.jsx)(y,{title:`Account Lifecycle`,description:`Critical and irreversible account actions`,delay:`0.1s`,children:(0,v.jsxs)(`div`,{className:`flex items-center justify-between gap-10 p-6 rounded-2xl bg-red-50 border border-red-100`,children:[(0,v.jsxs)(`div`,{className:`flex items-center gap-6`,children:[(0,v.jsx)(`div`,{className:`w-14 h-14 rounded-2xl bg-white border border-red-100 flex items-center justify-center text-red-600 shrink-0`,children:(0,v.jsx)(`svg`,{className:`w-7 h-7`,fill:`none`,viewBox:`0 0 24 24`,stroke:`currentColor`,strokeWidth:2.5,children:(0,v.jsx)(`path`,{d:`M19 7l-.867 12.142A2 2 0 0116.138 21H7.862a2 2 0 01-1.995-1.858L5 7m5 4v6m4-6v6m1-10V4a1 1 0 00-1-1h-4a1 1 0 00-1 1v3M4 7h16`})})}),(0,v.jsxs)(`div`,{children:[(0,v.jsx)(`p`,{className:`text-base font-bold text-red-900 leading-none`,children:`Delete Account Permanently`}),(0,v.jsx)(`p`,{className:`text-xs text-red-700/60 font-semibold mt-2 leading-relaxed`,children:`Proceeding will scrub your identity, logs, and settings from our database. This action is irreversible.`})]})]}),(0,v.jsx)(`button`,{onClick:N,className:`h-11 px-8 bg-red-600 text-white text-xs font-bold uppercase tracking-widest rounded-xl hover:bg-red-700 transition-all shrink-0`,children:`Delete Account`})]})})})]})]})}export{C as default}; |