veza/apps/web/dist_verification/assets/SettingsPage-DSklKTTs.js

4 lines
34 KiB
JavaScript
Raw Normal View History

2026-02-07 19:36:48 +00:00
import{a as n,j as e}from"./vendor-react-YMhRUmcb.js";import{d as de,h as Ce,g as Se,p as Z,a as P,E as B,C as q,b as K,c as W,f as $,e as H,B as b,D as ke,m as ue,S as re,u as _e,L as J,t as ne}from"./index-D2uzyr9g.js";import{u as oe}from"./users-DDt25V_U.js";import{T as Ae,a as Ee,b as M,c as U}from"./Tabs-C8UCeQNW.js";import{L as d,I as A}from"./input-DL1WY4HG.js";import{S as ee}from"./Select-So_RP28r.js";import{ak as Te,ar as Fe,A as me,al as se,T as le,as as De,at as Re,au as he,g as ae,d as xe,a as Pe,C as Le,O as pe,av as qe,aw as Ve,ax as Ie,ay as ze}from"./vendor-icons-DINCNwpk.js";import{C as w}from"./checkbox-Cwr-kRad.js";import{A as fe,a as ge}from"./alert-COAUu9KR.js";import{r as Q}from"./features-CKIBrJL0.js";import{o as O,e as ie,s as Me,b as y}from"./vendor-utils-4BWoYre8.js";import"./vendor-fFnFILYR.js";import"./vendor-router-DX94Iu-2.js";import"./vendor-tanstack-CoFNL2zy.js";import"./dropdown-DLDDI8f2.js";const je=n.forwardRef(({className:s,value:t,onValueChange:a,disabled:r,children:i,...l},c)=>e.jsx("div",{ref:c,className:de("grid gap-2",s),role:"radiogroup",...l,children:n.Children.map(i,o=>n.isValidElement(o)&&o.type===G?n.cloneElement(o,{checked:o.props.value===t,onCheckedChange:()=>a?.(o.props.value),disabled:r||o.props.disabled}):o)}));je.displayName="RadioGroup";const G=n.forwardRef(({className:s,value:t,checked:a,onCheckedChange:r,disabled:i,...l},c)=>e.jsxs("label",{className:de("aspect-square h-4 w-4 rounded-full border border-kodo-steel text-kodo-steel","ring-offset-kodo-void focus-within:outline-none focus-within:ring-2 focus-within:ring-kodo-steel focus-within:ring-offset-2","disabled:cursor-not-allowed disabled:opacity-50","cursor-pointer relative inline-flex items-center justify-center",a&&"border-kodo-steel",s),children:[e.jsx("input",{ref:c,type:"radio",value:t,checked:a,onChange:r,disabled:i,className:"sr-only",...l}),a&&e.jsx(Te,{className:"h-2.5 w-2.5 fill-current text-current"})]}));G.displayName="RadioGroupItem";const Ue=[{value:"en",label:"English"},{value:"fr",label:"Français"},{value:"es",label:"Español"},{value:"de",label:"Deutsch"},{value:"it",label:"Italiano"},{value:"pt",label:"Português"},{value:"ru",label:"Русский"},{value:"ja",label:"日本語"},{value:"zh",label:"中文"},{value:"ko",label:"한국어"}],Oe=[{value:"UTC",label:"UTC"},{value:"Europe/Paris",label:"Europe/Paris"},{value:"America/New_York",label:"America/New_York"},{value:"America/Los_Angeles",label:"America/Los_Angeles"},{value:"Asia/Tokyo",label:"Asia/Tokyo"},{value:"Asia/Shanghai",label:"Asia/Shanghai"}];function Ge({preferences:s,onChange:t}){const a=l=>{t({...s,language:Array.isArray(l)?l[0]:l})},r=l=>{t({...s,timezone:Array.isArray(l)?l[0]:l})},i=l=>{t({...s,theme:l})};return e.jsx("div",{className:"space-y-6",children:e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(d,{htmlFor:"language",children:"Langue"}),e.jsx(ee,{options:Ue,value:s.language,onChange:a,placeholder:"Sélectionner une langue",name:"language"})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(d,{htmlFor:"timezone",children:"Fuseau horaire"}),e.jsx(ee,{options:Oe,value:s.timezone,onChange:r,placeholder:"Sélectionner un fuseau horaire",name:"timezone"})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(d,{children:"Thème"}),e.jsxs(je,{value:s.theme,onValueChange:i,children:[e.jsxs("div",{className:"flex items-center space-x-2",children:[e.jsx(G,{value:"light",id:"theme-light"}),e.jsx(d,{htmlFor:"theme-light",className:"font-normal",children:"Clair"})]}),e.jsxs("div",{className:"flex items-center space-x-2",children:[e.jsx(G,{value:"dark",id:"theme-dark"}),e.jsx(d,{htmlFor:"theme-dark",className:"font-normal",children:"Sombre"})]}),e.jsxs("div",{className:"flex items-center space-x-2",children:[e.jsx(G,{value:"auto",id:"theme-auto"}),e.jsx(d,{htmlFor:"theme-auto",className:"font-normal",children:"Automatique"})]})]})]})]})})}function He({notifications:s,onChange:t}){const a=(r,i)=>{t({...s,[r]:i})};return e.jsxs("div",{className:"space-y-6",children:[e.jsxs("div",{
`)),a("Backup codes copied to clipboard"))},[m,a]),N=n.useCallback(()=>{if(!m?.recovery_codes)return;const S=document.createElement("a"),V=new Blob([m.recovery_codes.join(`
`)],{type:"text/plain"});S.href=URL.createObjectURL(V),S.download="veza-backup-codes.txt",document.body.appendChild(S),S.click(),a("Backup codes downloaded")},[m,a]),C=n.useCallback(()=>{c("totp"),i(2)},[]),E=n.useCallback(()=>{a("SMS method not yet available in this region","info")},[a]);return{step:r,setStep:i,method:l,verificationCode:o,setVerificationCode:h,loading:u,setupData:m,error:f,fetchSetupData:v,handleVerify:k,copyCodes:g,downloadCodes:N,goToStep2Totp:C,handleSmsUnavailable:E}}function ts({onBack:s,onComplete:t}){const{addToast:a}=ue(),{step:r,method:i,verificationCode:l,setVerificationCode:c,loading:o,setupData:h,handleVerify:u,copyCodes:x,downloadCodes:m,goToStep2Totp:p,handleSmsUnavailable:f}=as(s),j=()=>{h&&(navigator.clipboard.writeText(h.secret),a("Secret Key copied"))};return e.jsxs("div",{className:"animate-fadeIn max-w-2xl mx-auto",children:[e.jsx(Ze,{onBack:s}),r===1&&e.jsx(Je,{onChooseTotp:p,onChooseSms:f}),r===2&&e.jsx(es,{method:i,loading:o,setupData:h,verificationCode:l,onVerificationCodeChange:c,onVerify:u,onCopySecret:j,onSendSmsPlaceholder:()=>a("Code sent to your phone","info")}),r===3&&e.jsx(ss,{setupData:h,onCopy:x,onDownload:m,onComplete:t})]})}const rs=()=>{const[s,t]=n.useState(null),[a,r]=n.useState(!0),[i,l]=n.useState(!1),c=async()=>{r(!0);try{const o=await te.getStatus();t(o.enabled)}catch(o){console.error("Failed to fetch 2FA status",o)}finally{r(!1)}};return n.useEffect(()=>{c()},[]),i?e.jsx(q,{className:"border-primary/20 bg-primary/5",children:e.jsx(H,{className:"pt-6",children:e.jsx(ts,{onBack:()=>l(!1),onComplete:()=>{l(!1),c()}})})}):e.jsxs(q,{children:[e.jsxs(K,{children:[e.jsxs(W,{className:"flex items-center gap-2",children:[e.jsx(pe,{className:"h-5 w-5"}),"Two-Factor Authentication (2FA)"]}),e.jsx($,{children:"Add an extra layer of security to your account"})]}),e.jsx(H,{children:a?e.jsxs("div",{className:"flex items-center gap-2 text-muted-foreground text-sm",children:[e.jsx(ae,{className:"h-4 w-4 animate-spin"})," Checking 2FA status..."]}):s?e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"flex items-center gap-3 p-4 bg-lime-500/10 border border-lime-500/20 rounded-lg",children:[e.jsx(qe,{className:"h-8 w-8 text-lime-500"}),e.jsxs("div",{children:[e.jsx("h4",{className:"font-bold text-white",children:"2FA is enabled"}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"Your account is protected by an additional security layer."})]})]}),e.jsx(b,{variant:"outline",className:"text-destructive hover:bg-destructive/10 hover:text-destructive border-destructive/20",onClick:()=>{confirm("Are you sure you want to disable 2FA? This will make your account less secure.")&&t(!1)},children:"Disable 2FA"})]}):e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"flex items-center gap-3 p-4 bg-orange-500/5 border border-orange-500/10 rounded-lg",children:[e.jsx(Ve,{className:"h-8 w-8 text-orange-500"}),e.jsxs("div",{children:[e.jsx("h4",{className:"font-bold text-white",children:"2FA is not enabled"}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"We highly recommend enabling 2FA to protect your music and assets."})]})]}),e.jsx(b,{onClick:()=>l(!0),children:"Setup 2FA"})]})})]})};function ns(){const{mutationError:s,retryCount:t,maxRetry:a,handleRetry:r,dismissError:i,isChangingPassword:l,currentPassword:c,setCurrentPassword:o,newPassword:h,setNewPassword:u,confirmPassword:x,setConfirmPassword:m,passwordError:p,handleChangePassword:f,isDeleteDialogOpen:j,setIsDeleteDialogOpen:v,isDeletingAccount:k,deletePassword:g,setDeletePassword:N,deleteReason:C,setDeleteReason:E,deleteConfirmText:S,setDeleteConfirmText:V,deleteValidationError:I,setDeleteValidationError:X,handleDeleteAccount:_,handleExportData:z}=Qe();return e.jsxs("div",{className:"space-y-6",children:[s&&e.jsx(Be,{error:s,retryCount:t,maxRetry:a,onRetry:r,onDismiss:i}),e.jsx(Ke,{currentPassword:c,setCurrentPassword:o,newPassword:h,setNewPassword:u,confirmPassword:x,setConfirmPassword:m,passwordError:p,isChangingPassword:l,onSubmit:f}),e.jsx(rs,{}),e.jsx(We,{onExpo