PageSourceSearch

https://drophighlight.com/assets/AccountSettings-DQpVor3o.js

js drophighlight.com collected 2026-09-30 06:37:13 UTC 15,373 bytes, 1 lines download raw bytes

1import{a as y,j as e,C as q,h as U,i as _,k as H,l as F,u as J,r as i,M as V,B as g,J as h,aH as G,aI as $,aJ as K,aK as Q,Q as Y,aL as Z,U as X,V as ee,W as se,Y as ae,Z as te,_ as ne,$ as re,s as z,t as ie}from"./index-P0N1Je5T.js";import{u as le}from"./useCompanySettings-C4UUNq59.js";import{L as j}from"./label-CoHN_xq2.js";import{S as de,a as ce,b as oe,c as me,d as ue}from"./select-Supfcq-S.js";import{G as he}from"./globe-Dl8HrUsL.js";import{I as N}from"./input-1tKBwIjz.js";import{A as D,a as L}from"./alert-BjIlbniu.js";import{E as I}from"./eye-off-BqJujGZL.js";import{E as T}from"./eye-BxqX1t91.js";import{u as xe,P as ge}from"./PasswordCriteriaList-CpGut5MH.js";import{L as pe}from"./lock-RLl-dMWe.js";import{T as B}from"./triangle-alert-Dfdm1-MX.js";import{T as W}from"./trash-2-Dwmr_5Bh.js";import{P as je}from"./PageHeader-zjaF7toz.js";import{U as fe}from"./user-CvuxPiRQ.js";import{S as we}from"./save-BIgwChhU.js";import"./useMutation-DJI0oEf-.js";import"./useDebounce-IpreLc5E.js";const Ne=[{code:"en",name:"English",flag:"🇺🇸"},{code:"pt",name:"Português",flag:"🇧🇷"},{code:"es",name:"Español",flag:"🇪🇸"},{code:"fr",name:"Français",flag:"🇫🇷"}],ve=({formData:s,onInputChange:r,disabled:a})=>{const{t}=y();return e.jsxs(q,{children:[e.jsxs(U,{children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(he,{className:"h-5 w-5"}),e.jsx(_,{children:t("admin.settings.language.title")})]}),e.jsx(H,{children:t("admin.settings.language.description")})]}),e.jsx(F,{className:"space-y-4",children:e.jsxs("div",{className:"space-y-2",children:[e.jsx(j,{htmlFor:"preferred_language",children:t("admin.settings.language.preferredLanguage")}),e.jsxs(de,{value:s.preferred_language,onValueChange:n=>r("preferred_language",n),disabled:a,children:[e.jsx(ce,{children:e.jsx(oe,{placeholder:t("admin.settings.language.selectLanguage")})}),e.jsx(me,{children:Ne.map(n=>e.jsx(ue,{value:n.code,children:e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("span",{children:n.flag}),e.jsx("span",{children:n.name})]})},n.code))})]})]})})]})},be=()=>{const{user:s,changeEmail:r}=J(),{t:a}=y(),[t,n]=i.useState(""),[c,o]=i.useState(""),[m,d]=i.useState(!1),[f,x]=i.useState(!1),[A,u]=i.useState(""),[R,v]=i.useState(!1),[b,p]=i.useState(!1),[S,k]=i.useState(""),E=async w=>{var l,P,O;if(w.preventDefault(),x(!0),u(""),v(!1),!t){h.error(a("admin.settings.emailRequired")),x(!1);return}if(t.toLowerCase()===((l=s==null?void 0:s.email)==null?void 0:l.toLowerCase())){u(a("admin.settings.sameEmailError")),h.error(a("admin.settings.sameEmailError")),x(!1);return}if(!/^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(t)){u(a("admin.settings.invalidEmail")),h.error(a("admin.settings.invalidEmail")),x(!1);return}if(!c){u(a("admin.settings.emailPasswordRequired")),h.error(a("admin.settings.emailPasswordRequired")),x(!1);return}const{error:C}=await r(c,t);C?C.code==="INVALID_CURRENT_PASSWORD"||(P=C.message)!=null&&P.toLowerCase().includes("invalid login")?u(a("admin.settings.incorrectCurrentPassword")):(O=C.message)!=null&&O.toLowerCase().includes("already")?u(a("admin.settings.emailAlreadyInUse")):u(a("admin.settings.emailChangeFailed")):(p(!0),k(t),v(!0),n(""),o("")),x(!1)};return e.jsxs(q,{children:[e.jsxs(U,{children:[e.jsxs(_,{className:"flex items-center gap-2",children:[e.jsx(V,{className:"h-5 w-5"}),a("admin.settings.updateEmail")]}),e.jsx(H,{children:a("admin.settings.changeEmailDescription")})]}),e.jsx(F,{children:e.jsxs("form",{onSubmit:E,className:"space-y-4",children:[b&&e.jsxs(D,{className:"bg-primary/5 border-primary/20",children:[e.jsx(V,{className:"h-4 w-4 text-primary"}),e.jsxs(L,{className:"text-foreground",children:[e.jsxs("p",{className:"font-semibold mb-2",children:["📧 ",a("admin.settings.emailConfirmationSent")," ",e.jsx("strong",{children:S})]}),e.jsxs("p",{className:"text-sm mb-2",children:[a("admin.settings.emailStayLoggedIn")," (",e.jsx("strong",{children:s==null?void 0:s.email}),")"," ",a("admin.settings.emailStayLoggedInUntil")]}),e.jsxs("p",{className:"text-sm font-medium",children:["⚠️ ",a("admin.settings.emailAutoLogout")]})]})]}),R&&!b&&e.jsx(D,{className:"bg-green-50 border-green-200",children:e.jsx(L,{className:"text-green-800",children:a("admin.settings.emailChangeSent")})}),A&&e.jsx(D,{variant:"destructive",children:e.jsx(L,{children:A})}),e.jsx(D,{children:e.jsxs(L,{className:"text-sm space-y-2",children:[e.jsx("p",{className:"font-medium",children:a("admin.settings.emailChangeProcess")}),e.jsxs("ol",{className:"list-decimal list-inside space-y-1 ml-2",children:[e.jsx("li",{children:a("admin.settings.emailChangeStep1")}),e.jsx("li",{children:a("admin.settings.emailChangeStep2")}),e.jsx("li",{children:a("admin.settings.emailChangeStep3")}),e.jsx("li",{children:a("admin.settings.emailChangeStep4")})]}),e.jsx("p",{className:"text-muted-foreground italic mt-2",children:a("admin.settings.emailChangeWarning")})]})}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(j,{htmlFor:"current-email",children:a("admin.settings.currentEmail")}),e.jsx(N,{id:"current-email",type:"email",value:(s==null?void 0:s.email)??"",readOnly:!0,disabled:!0,className:"bg-muted"}),e.jsx("p",{className:"text-xs text-muted-foreground",children:a("admin.settings.currentEmailHelp")})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(j,{htmlFor:"new-email",children:a("admin.settings.newEmail")}),e.jsx(N,{id:"new-email",type:"email",value:t,onChange:w=>n(w.target.value),placeholder:a("admin.settings.newEmailPlaceholder"),required:!0})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(j,{htmlFor:"email-password",children:a("admin.settings.emailPasswordLabel")}),e.jsxs("div",{className:"relative",children:[e.jsx(N,{id:"email-password",type:m?"text":"password",value:c,onChange:w=>o(w.target.value),placeholder:a("admin.settings.emailPasswordPlaceholder"),autoComplete:"current-password",required:!0}),e.jsx(g,{type:"button",variant:"ghost",size:"sm",className:"absolute right-0 top-0 h-full px-3 py-2 hover:bg-transparent",onClick:()=>d(!m),children:m?e.jsx(I,{className:"h-4 w-4"}):e.jsx(T,{className:"h-4 w-4"})})]}),e.jsx("p",{className:"text-xs text-muted-foreground",children:a("admin.settings.emailPasswordHelp")})]}),e.jsx(g,{type:"submit",className:"w-full",disabled:f||!t||!c,children:f?e.jsxs("div",{className:"flex items-center space-x-2",children:[e.jsx("div",{className:"animate-spin rounded-full h-4 w-4 border-b-2 border-current"}),e.jsx("span",{children:a("admin.forms.processing")})]}):a("admin.settings.changeEmailButton")})]})})]})},Ce=()=>{const{changePassword:s}=J(),{t:r}=y(),[a,t]=i.useState(""),[n,c]=i.useState(""),[o,m]=i.useState(!1),[d,f]=i.useState(!1),[x,A]=i.useState(!1),[u,R]=i.useState(!1),[v,b]=i.useState(!0),{password:p,updatePassword:S,criteria:k,isPasswordValid:E}=xe(),w=l=>{S(l),b(l===n)},M=l=>{c(l),b(p===l)},C=async l=>{if(l.preventDefault(),m(!0),!a){h.error(r("admin.settings.currentPasswordRequired")),m(!1);return}if(p!==n){h.error(r("admin.settings.passwordsDoNotMatch")),m(!1);return}if(!E()){h.error(r("admin.settings.newPasswordRequired")),m(!1);return}const{error:P}=await s(a,p);P||(t(""),S(""),c(""),b(!0)),m(!1)};return e.jsxs(q,{children:[e.jsxs(U,{children:[e.jsxs(_,{className:"flex items-center gap-2",children:[e.jsx(pe,{className:"h-5 w-5"}),r("admin.settings.updatePassword")]}),e.jsx(H,{children:r("admin.settings.updatePasswordDescription")})]}),e.jsx(F,{children:e.jsxs("form",{onSubmit:C,className:"space-y-4",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(j,{htmlFor:"current-password",children:r("admin.settings.currentPassword")}),e.jsxs("div",{className:"relative",children:[e.jsx(N,{id:"current-password",type:d?"text":"password",value:a,onChange:l=>t(l.target.value),placeholder:"Enter your current password",autoComplete:"current-password",required:!0}),e.jsx(g,{type:"button",variant:"ghost",size:"sm",className:"absolute right-0 top-0 h-full px-3 py-2 hover:bg-transparent",onClick:()=>f(!d),children:d?e.jsx(I,{className:"h-4 w-4"}):e.jsx(T,{className:"h-4 w-4"})})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(j,{htmlFor:"new-password",children:r("admin.settings.newPassword")}),e.jsxs("div",{className:"relative",children:[e.jsx(N,{id:"new-password",type:x?"text":"password",value:p,onChange:l=>w(l.target.value),placeholder:"Enter a strong password",autoComplete:"new-password",required:!0}),e.jsx(g,{type:"button",variant:"ghost",size:"sm",className:"absolute right-0 top-0 h-full px-3 py-2 hover:bg-transparent",onClick:()=>A(!x),children:x?e.jsx(I,{className:"h-4 w-4"}):e.jsx(T,{className:"h-4 w-4"})})]}),e.jsx(ge,{password:p,criteria:k})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(j,{htmlFor:"confirm-new-password",children:r("admin.settings.confirmNewPassword")}),e.jsxs("div",{className:"relative",children:[e.jsx(N,{id:"confirm-new-password",type:u?"text":"password",value:n,onChange:l=>M(l.target.value),placeholder:"Confirm your new password",autoComplete:"new-password",className:!v&&n?"border-destructive":"",required:!0}),e.jsx(g,{type:"button",variant:"ghost",size:"sm",className:"absolute right-0 top-0 h-full px-3 py-2 hover:bg-transparent",onClick:()=>R(!u),children:u?e.jsx(I,{className:"h-4 w-4"}):e.jsx(T,{className:"h-4 w-4"})})]}),!v&&n&&e.jsx("p",{className:"text-sm text-destructive",children:r("admin.settings.passwordsDoNotMatch")})]}),e.jsx(g,{type:"submit",className:"w-full",disabled:o||!a||!p||!n||!v||!E(),children:o?e.jsxs("div",{className:"flex items-center space-x-2",children:[e.jsx("div",{className:"animate-spin rounded-full h-4 w-4 border-b-2 border-current"}),e.jsx("span",{children:r("admin.forms.processing")})]}):r("admin.settings.changePassword")})]})})]})},ye=()=>{const{t:s}=y(),[r,a]=i.useState(""),[t,n]=i.useState(!1),[c,o]=i.useState(!1);console.log("DeleteAccountSection rendered, t function:",typeof s),console.log("Sample translation test:",s("admin.deleteAccount.title"));const m=async()=>
1{if(r!=="DELETAR"){h.error(s("admin.deleteAccount.confirmErrorDesc"));return}n(!0);try{const{data:d,error:f}=await z.functions.invoke("delete-user-account");if(f)throw f;if(d!=null&&d.blocked){h.error(d.error),n(!1),o(!1);return}h.success(s("admin.deleteAccount.successDesc")),await z.auth.signOut(),setTimeout(()=>{window.location.href="/"},2e3)}catch(d){console.error("Error deleting account:",d),h.error(d.message||s("admin.deleteAccount.errorDesc"))}finally{n(!1),o(!1),a("")}};return e.jsx(q,{className:"border-destructive/20 bg-destructive/5",children:e.jsx(F,{className:"p-0",children:e.jsx(G,{type:"single",collapsible:!0,children:e.jsxs($,{value:"delete-account",className:"border-none",children:[e.jsx(K,{className:"px-6 pt-6 pb-[18px] hover:no-underline",children:e.jsxs("div",{className:"flex items-start gap-3 text-left",children:[e.jsx(B,{className:"h-5 w-5 text-destructive mt-0.5 flex-shrink-0"}),e.jsxs("div",{className:"space-y-1",children:[e.jsx("h3",{className:"text-destructive font-semibold",children:s("admin.deleteAccount.title")}),e.jsx("p",{className:"text-sm text-muted-foreground",children:s("admin.deleteAccount.de
1scription")})]})]})}),e.jsx(Q,{className:"px-6 pb-6",children:e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"bg-card border border-destructive/30 rounded-lg p-4",children:[e.jsx("h4",{className:"font-medium text-destructive mb-2",children:s("admin.deleteAccount.consequencesTitle")}),e.jsxs("ul",{className:"text-sm text-muted-foreground space-y-1 list-disc list-inside",children:[e.jsx("li",{children:s("admin.deleteAccount.consequence1")}),e.jsx("li",{children:s("admin.deleteAccount.consequence2")}),e.jsx("li",{children:s("admin.deleteAccount.consequence3")}),e.jsx("li",{children:s("admin.deleteAccount.consequence4")}),e.jsx("li",{children:s("admin.deleteAccount.consequence5")})]})]}),e.jsxs(Y,{open:c,onOpenChange:o,children:[e.jsx(Z,{asChild:!0,children:e.jsxs(g,{variant:"destructive",className:"w-full",children:[e.jsx(W,{className:"h-4 w-4 mr-2"}),s("admin.deleteAccount.button")]})}),e.jsxs(X,{className:"sm:max-w-[500px]",children:[e.jsxs(ee,{children:[e.jsxs(se,{className:"text-destructive flex items-center gap-2",children:[e.jsx(B,{className:"h-5 w-5"}),s("admin.deleteAccount.modalTitle")]}),e.jsxs(ae,{className:"space-y-4",children:[e.jsx("p",{children:s("admin.deleteAccount.modalDesc1")}),e.jsxs("div",{className:"bg-muted p-3 rounded-md",children:[e.jsxs("p",{className:"font-medium text-sm mb-2",children:[s("admin.deleteAccount.whatWillBeDeleted"),":"]}),e.jsxs("ul",{className:"text-xs text-muted-foreground space-y-1 list-disc list-inside",children:[e.jsx("li",{children:s("admin.deleteAccount.deleteItem1")}),e.jsx("li",{children:s("admin.deleteAccount.deleteItem2")}),e.jsx("li",{children:s("admin.deleteAccount.deleteItem3")}),e.jsx("li",{children:s("admin.deleteAccount.deleteItem4")}),e.jsx("li",{children:s("admin.deleteAccount.deleteItem5")})]})]}),e.jsx("p",{className:"text-destructive font-medium",children:s("admin.deleteAccount.modalDesc2")})]})]}),e.jsx("div",{className:"space-y-4",children:e.jsxs("div",{children:[e.jsx(j,{htmlFor:"confirm-delete",className:"text-sm font-medium",children:s("admin.deleteAccount.confirmLabel")}),e.jsx(N,{id:"confirm-delete",value:r,onChange:d=>a(d.target.value),placeholder:"DELETAR",className:"mt-1",disabled:t}),e.jsx("p",{className:"text-xs text-muted-foreground mt-1",children:s("admin.deleteAccount.confirmHint")})]})}),e.jsxs(te,{children:[e.jsx(ne,{disabled:t,children:s("admin.common.cancel")}),e.jsx(re,{onClick:m,disabled:t||r!=="DELETAR",className:"bg-destructive text-destructive-foreground hover:bg-destructive/90",children:t?e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"animate-spin rounded-full h-4 w-4 border-b-2 border-white mr-2"}),s("admin.deleteAccount.deleting")]}):e.jsxs(e.Fragment,{children:[e.jsx(W,{className:"h-4 w-4 mr-2"}),s("admin.deleteAccount.confirmButton")]})})]})]})]})]})})]})})})})},ze=()=>{const{t:s}=y(),{formData:r,loading:a,isAdmin:t,company:n,handleInputChange:c,handleSubmit:o}=le();return n?e.jsxs("div",{className:"space-y-6",children:[e.jsx(je,{title:s("admin.settings.account"),subtitle:s("admin.settings.accountDescription")}),e.jsx(be,{}),e.jsx(Ce,{}),e.jsxs("form",{onSubmit:o,className:"space-y-6",children:[e.jsx(ve,{formData:{preferred_language:r.preferred_language},onInputChange:c,disabled:!t}),t&&e.jsxs("div",{className:"grid grid-cols-1 sm:grid-cols-2 gap-3",children:[e.jsxs(g,{type:"button",variant:"outline",onClick:()=>window.history.back(),disabled:a,className:"w-full",children:[e.jsx(ie,{className:"h-4 w-4 mr-2"}),s("admin.settings.cancel")]}),e.jsx(g,{type:"submit",disabled:a,className:"w-full",children:a?e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"animate-spin rounded-full h-4 w-4 border-b-2 border-white mr-2"}),s("admin.settings.saving")]}):e.jsxs(e.Fragment,{children:[e.jsx(we,{className:"h-4 w-4 mr-2"}),s("admin.settings.save")]})})]})]}),e.jsx(ye,{})]}):e.jsx("div",{className:"flex items-center justify-center py-12",children:e.jsxs("div",{className:"text-center",children:[e.jsx(fe,{className:"h-16 w-16 mx-auto text-muted-foreground mb-4"}),e.jsx("h2",{className:"text-2xl font-semibold mb-2",children:s("admin.settings.companyNotFound")}),e.jsx("p",{className:"text-muted-foreground",children:s("admin.settings.couldNotLoad")})]})})};export{ze as AccountSettings};

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.