1import{p as s,B as i,a5 as C,v as b,a as f,$ as W,a1 as D,y,C as k,aL as B,a2 as v}from"./index-CDR_1Atn.js";import{H as A}from"./head-BsaqoWFB.js";import{P as N}from"./Person-cXmsFGRq.js";import{C as T}from"./custom-tabs-UEKPhASk.js";import{c as U,F as w,O as E}from"./form-buttons-CG7rtDql.js";import{F as K}from"./form-rrUnVAqF.js";import{P}from"./password-field-Dyz_OrYr.js";import{P as O}from"./password-strength-bar-DjvyXny8.js";import{C as _}from"./Close-Crxs1AqS.js";import{E as M}from"./ErrorOutline-BnL2nNCS.js";import{a as L,D as R}from"./DialogContent-DnI_gUlL.js";import{D as V}from"./DialogTitle-1FESg6D7.js";import{D as I}from"./DialogContentText-xN4zFncX.js";import{D as z}from"./DialogActions-CWylcpyX.js";import{w as F,E as H}from"./UserPreference-BUVQCgLs.js";import{F as j}from"./TextField-D3dW0tg2.js";import"./Tabs-RLqEGSO6.js";import"./CardHeader-BupYmJmI.js";import"./index.esm-Bkz8LqnY.js";import"./InputAdornment-CRAoTzrD.js";import"./useControlled-DOy8mt1H.js";import"./isMuiElement-DD88vA2u.js";const G={oldPassword:"",newPassword:"",confirmPassword:""},Q={BAD_REQUEST:{name:"oldPassword",errorOption:{type:"custom",params:{i18n:"invalid_old_password"}}}},Y={shouldUnregister:!0,defaultValues:G,errorMapping:Q};function J({open:t,onClose:r,email:n}){return s.jsx(L,{"data-testid":"deletion-dialog",open:t,children:s.jsxs(i,{sx:{maxWidth:"552px",margin:"0 auto"},children:[s.jsx(i,{sx:e=>({padding:e.spacing(2)}),children:s.jsx(C,{"aria-label":"close",onClick:()=>r(!1),sx:e=>({position:"absolute",right:e.spacing(1),top:e.spacing(1),color:e.palette.grey[500]}),children:s.jsx(_,{})})}),s.jsxs(V,{variant:"h3",sx:e=>({lineHeight:e.spacing(4)}),children:[s.jsx(M,{color:"error",fontSize:"large"})," ",s.jsx("br",{}),"Sind Sie sicher, dass Sie Ihr Konto löschen möchten?"]}),s.jsxs(R,{children:[s.jsxs(I,{sx:e=>({paddingY:e.spacing(2)}),children:["Ihr Kundenkonto ",s.jsx("strong",{children:n})," wird unwiderruflich gelöscht."]}),s.jsx(I,{sx:e=>({paddingY:e.spacing(2)}),children:"Dadurch verlieren Sie dauerhaft den Zugriff auf Ihre gespeicherten Vergleiche, Anträge und alle anderen mit Ihrem Konto verknüpften Daten. Es wird empfohlen, vor dem Löschen alle wichtigen Daten oder Dokumente zu sichern, falls Sie diese später noch benötigen."})]}),s.jsxs(z,{sx:e=>({padding:e.spacing(2)}),children:[s.jsx(b,{"data-testid":"deletion-dialog-cancel-button",variant:"outlined",sx:{flex:{xs:"unset",sm:"1"}},onClick:()=>r(!1),children:"Nein, Konto behalten"}),s.jsx(b,{"data-testid":"deletion-dialog-confirm-button",variant:"outlined",color:"error",sx:{flex:{xs:"unset",sm:"1"}},onClick:()=>r(!0),children:"Ja, Konto löschen"})]})]})})}const Z=({onSuccess:t,onError:r})=>{const[n,e]=f.useState(!1),[p,m]=f.useState(null),u=W(),o=D().data,l=y.user.delete.useMutation({onSuccess:()=>{u.addNotification({title:"Kundenkonto erfolgreich gelöscht",message:"Ihr Kundenkonto wurde erfolgreich gelöscht.",type:"success"}),t==null||t()},onError:a=>{u.addNotification({title:"Fehler beim Löschen des Kundenkontos",message:"Es ist ein Fehler aufgetreten. Bitte versuchen Sie es erneut.",type:"error"}),r==null||r(a)}}),x=y.auth.updatePassword.useMutation({onSuccess:()=>{m(null),u.addNotification({title:"Passwort erfolgreich geändert",message:"Ihr Passwort wurde erfolgreich geändert.",type:"success"}),t==null||t()},onError:a=>{m(a),r==null||r(a)}}),d=a=>{if(o!=null&&o.id)try{x.mutate({userId:o.id,oldPassword:a.oldPassword,newPassword:a.newPassword})}catch{}},c=()=>{if(o!=null&&o.id)try{l.mutate(o.id),e(!1)}catch{}},g=a=>{a?c():e(!1)};return{dialogMessage:n,setDialogMessage:e,updateError:p,status:U(x,l),handleSubmit:d,handleDeleteAccount:c,handleDialogClose:g}},$=k({oldPassword:H.shape.oldPassword,newPassword:F.shape.newPassword,confirmPassword:F.shape.newPassword}).refine(t=>t.newPassword===t.confirmPassword,{path:["confirmPassword"],params:{i18n:"password_must_match"}}).refine(t=>t.oldPassword!==t.newPassword,{path:["newPassword"],params:{i18n:"password_must_be_different"}}),q=({onSuccess:t,onError:r})=>{const{dialogMessage:n,updateError:e,status:p,setDialogMessage:m,handleSubmit:u,handleDialogClose:o}=Z({onSuccess:t,onError:r}),{data:l}=D(),x=(l==null?void 0:l.email)||"";return s.jsx(s.Fragment,{children:s.jsx(K,{"data-testid":"password-update-form",onSubmit:u,schema:$,error:e,options:Y,children:({formState:d,reset:c,watch:g,trigger:a})=>{const S=g("newPassword");return f.useEffect(()=>{d.isSubmitSuccessful&&c()},[d.isSubmitSuccessful,c]),s.jsxs(i,{sx:{width:"100%"},children:[s.jsx(i,{sx:{flexWrap:"wrap",display:"flex"},children:s.jsxs(i,{sx:{display:"flex",width:"100%",flexWrap:"wrap",columnGap:2},children:[s.jsx(j,{fullWidth:!0,sx:h=>({display:"flex",flex:"1",paddingBottom:h.spacing(2),minWidth:"240px",maxWidth:"568px"}),children:s.jsx(P,{name:"oldPassword",label:"Altes Passwort eingeben",showInfo:!1})}),s.jsx(i,{sx:{display:"flex",flex:1,minWidth:"240px",height:"0px"}})]})}),s.jsxs(i,{sx:{display:"flex",flexDirection:"row",flexWrap:"wrap",gap:2},children:[s.jsxs(j,{fullWidth:!0,sx:h=>({flex:"1",paddingBottom:h.spacing(2),minWidth:"240px"}),children:[s.jsx(P,{name:"newPassword",label:"Neues Passwort",onChange:()=>
1{d.errors.confirmPassword&&d.dirtyFields.confirmPassword&&a("confirmPassword")},showInfo:!0}),S&&s.jsx(O,{password:S})]}),s.jsx(j,{fullWidth:!0,sx:h=>({flex:"1",paddingBottom:h.spacing(2),minWidth:"240px"}),children:s.jsx(P,{name:"confirmPassword",onChange:()=>{a("confirmPassword")},label:"Neues Passwort wiederholen",showValidIndicator:!0})})]}),s.jsxs(w,{operationStatus:p,isDirty:d.isDirty,children:[s.jsx(b,{"data-testid":"delete-account-button",type:"button",variant:"text",color:"error",loading:p===E.LOADING,onClick:()=>m(!0),fullWidth:!0,children:"Kundenkonto löschen"}),s.jsxs(i,{sx:[B,{marginLeft:{xs:0,sm:"auto"}}],children:[s.jsx(w.Reset,{reset:c,label:"Abbrechen"}),s.jsx(w.Submit,{label:"Speichern"})]})]}),s.jsx(i,{children:n&&s.jsx(J,{open:!0,onClose:o,email:x})})]})}})})};function X(){const[t]=f.useState({login:!0}),r=D(),n=[{id:10,label:"Passwort",title:"Passwort ändern",isInfoFilled:t.login?"ändern":"bitte hinzufügen",infoText:"Erstellen Sie Ihr neues, sicheres Passwort.",content:s.jsx(q,{}),image:s.jsx(N,{})}];return s.jsxs(s.Fragment,{children:[s.jsx(v,{children:"Sicherheit"}),s.jsx(T,{status:r.status,tabs:n})]})}const Ds=()=>s.jsxs(s.Fragment,{children:[s.jsx(A,{title:"Sicherheit"}),s.jsx(X,{})]});export{Ds as UserSecurityRoute};
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.