PageSourceSearch

https://matters.group/assets/AccountSettings-DpKI52L6.js

js matters.group collected 2026-10-09 22:42:18 UTC 5,864 bytes, 6 lines download raw bytes

1import{c as L,K as S,M as k,q,r as o,j as e,S as F,N as I,a as c,b as d,d as u,e as m,f as h,B as C,P as Y,Q as _,T as U,V as H,Y as K,Z as B,_ as M,$ as O,a0 as Z,F as Q,s as i}from"./index-CISjGKDG.js";import{I as x}from"./input-DGwrk3E_.js";import{L as p}from"./label-BS3NzEI_.js";import{T as R}from"./triangle-alert-Cbo_viQI.js";import{T as V}from"./trash-2-BemfS7GG.js";/**
2 * @license lucide-react v0.462.0 - ISC
3 *
4 * This source code is licensed under the ISC license.
5 * See the LICENSE file in the root directory of this source tree.
6 */const $=L("Key",[["path",{d:"m15.5 7.5 2.3 2.3a1 1 0 0 0 1.4 0l2.1-2.1a1 1 0 0 0 0-1.4L19 4",key:"g0fldk"}],["path",{d:"m21 2-9.6 9.6",key:"1j0ho8"}],["circle",{cx:"7.5",cy:"15.5",r:"5.5",key:"yqb3hr"}]]),ee=()=>{const{user:a,signOut:A}=S(),g=k(),{toast:r}=q(),[l,f]=o.useState(""),[j,w]=o.useState(!1),[n,y]=o.useState(""),[v,N]=o.useState(""),[b,E]=o.useState(!1);if(!a)return g("/auth"),null;const T=async s=>{if(s.preventDefault(),n.length<6){r({title:"Password too short",description:"Password must be at least 6 characters long.",variant:"destructive"});return}if(n!==v){r({title:"Passwords don't match",description:"Please make sure both passwords match.",variant:"destructive"});return}E(!0);try{const{error:t}=await i.auth.updateUser({password:n});if(t)throw t;r({title:"Password updated",description:"Your password has been changed successfully."}),y(""),N("")}catch(t){r({title:"Error",description:t.message||"Failed to update password. Please try again.",variant:"destructive"})}finally{E(!1)}},P=async()=>{if(l!=="DELETE"){r({title:"Confirmation required",description:"Please type DELETE to confirm account deletion.",variant:"destructive"});return}w(!0);try{const{error:s}=await i.from("profiles").delete().eq("id",a.id);s&&console.error("Error deleting profile:",s);const{error:t}=await i.from("blog_posts").delete().eq("author_id",a.id);t&&console.error("Error deleting blog posts:",t);const{error:D}=await i.from("user_roles").delete().eq("user_id",a.id);D&&console.error("Error deleting user roles:",D),await A(),r({title:"Account deleted",description:"Your account and associated data have been deleted."}),g("/")}catch(s){console.error("Error deleting account:",s),r({title:"Error",description:"Failed to delete account. Please try again or contact support.",variant:"destructive"})}finally{w(!1)}};return e.jsxs("div",{className:"min-h-screen flex flex-col bg-background",children:[e.jsx(F,{title:"Account Settings | Hexline",description:"Manage your account settings and preferences."}),e.jsx(I,{}),e.jsx("main",{className:"flex-1 container mx-auto px-4 py-12",children:e.jsxs("div",{className:"max-w-2xl mx-auto",children:[e.jsx("h1",{className:"text-3xl font-bold mb-8",children:"Account Settings"}),e.jsxs(c,{className:"mb-6",children:[e.jsxs(d,{children:[e.jsx(u,{children:"Account Information"}),e.jsx(m,{children:"Your account details"})]}),e.jsx(h,{children:e.jsxs("div",{className:"space-y-2",children:[e.jsx("p",{className:"text-sm text-muted-foreground",children:"Email"}),e.jsx("p",{className:"font-medium",children:a.email})]})})]}),e.jsxs(c,{className:"mb-6",children:[e.jsxs(d,{children:[e.jsxs(u,{className:"flex items-center gap-2",children:[e.jsx($,{className:"h-5 w-5"}),"Change Password"]}),e.jsx(m,{children:"Update your account password"})]}),e.jsx(h,{children:e.jsxs("form",{onSubmit:T,className:"space-y-4",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(p,{htmlFor:"new-password",children:"New Password"}),e.jsx(x,{id:"new-password",type:"password",value:n,onChange:s=>y(s.target.value),placeholder:"Enter new password",minLength:6,required:!0})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(p,{htmlFor:"confirm-password",children:"Confirm New Password"}),e.jsx(x,{id:"confirm-password",type:"password",value:v,onChange:s=>N(s.target.value),placeholder:"Confirm new password",minLength:6,required:!0})]}),e.jsx(C,{type:"submit",disabled:b,children:b?"Updating...":"Update Password"})]})})]}),e.jsxs(c,{className:"border-destructive",children:[e.jsxs(d,{children:[e.jsxs(u,{className:"text-destructive flex items-center gap-2",children:[e.jsx(R,{className:"h-5 w-5"}),"Danger Zone"]}),e.jsx(m,{children:"Irreversible actions that affect your account"})]}),e.jsx(h,{children:e.jsxs("div",{className:"space-y-4",children:[e.jsx("p",{className:"text-sm text-muted-foreground",children:"Deleting your account will permanently remove all your data, including:"}),e.jsxs("ul",{className:"list-disc list-inside text-sm text-muted-foreground space-y-1",children:[e.jsx("li",{children:"Your profile information"}),e.jsx("li",{children:"All blog posts you've authored"}),e.jsx("li",{children:"Any assigned roles and permissions"})]}),e.jsx("p",{className:"text-sm font-medium text-destructive",children:"This action cannot be undone."}),e.jsxs(Y,{children:[e.jsx(_,{asChild:!0,children:e.jsxs(C,{variant:"destructive",className:"mt-4",children:[e.jsx(V,{className:"h-4 w-4 mr-2"}),"Delete Account"]})}
6),e.jsxs(U,{children:[e.jsxs(H,{children:[e.jsx(K,{children:"Are you absolutely sure?"}),e.jsxs(B,{className:"space-y-4",children:[e.jsx("p",{children:"This action cannot be undone. This will permanently delete your account and remove all associated data from our servers."}),e.jsxs("div",{className:"space-y-2",children:[e.jsxs(p,{htmlFor:"confirm-delete",children:["Type ",e.jsx("span",{className:"font-bold",children:"DELETE"})," to confirm"]}),e.jsx(x,{id:"confirm-delete",value:l,onChange:s=>f(s.target.value),placeholder:"Type DELETE to confirm"})]})]})]}),e.jsxs(M,{children:[e.jsx(O,{onClick:()=>f(""),children:"Cancel"}),e.jsx(Z,{onClick:P,disabled:l!=="DELETE"||j,className:"bg-destructive text-destructive-foreground hover:bg-destructive/90",children:j?"Deleting...":"Delete Account"})]})]})]})]})})]})]})}),e.jsx(Q,{})]})};export{ee as default};

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.