PageSourceSearch

https://bbcc.ai/build/assets/AIUserSettings-Cjcf0MfY.js

js bbcc.ai collected 2026-10-05 12:12:48 UTC 15,501 bytes, 14 lines download raw bytes

1import{u as U,r as l,j as e,H as G}from"./app-DP13319Q.js";import{D as W}from"./DraggableMenu-Bk7Spryo.js";import{M as H}from"./react-tooltip.min-DW3XhwOj.js";/* empty css            */import"./index-CtyZ6W6U.js";import"./index-DQkUn08L.js";function Q({settings:T,user:c}){const{auth:_,tooltips:L={}}=U().props,[f,F]=l.useState("profile"),[p,R]=l.useState(T.guest_ai_enabled),[u,x]=l.useState(!1),[o,s]=l.useState(null),[m,E]=l.useState({name:c.name,email:c.email}),[y,g]=l.useState(c.avatar||null),[k,b]=l.useState(!1),v=l.useRef(null),[i,j]=l.useState({current_password:"",new_password:"",new_password_confirmation:""}),N=t=>{E({...m,[t.target.name]:t.target.value})},M=async t=>{var S,P,A;const r=(S=t.target.files)==null?void 0:S[0];if(!r)return;if(!["image/jpeg","image/png","image/jpg","image/gif","image/webp","image/bmp"].includes(r.type)){s({type:"error",text:"Please upload a valid image file (JPEG, PNG, GIF, WEBP, or BMP)"}),setTimeout(()=>s(null),3e3);return}if(r.size>100*1024*1024){s({type:"error",text:"Image size must be less than 100MB"}),setTimeout(()=>s(null),3e3);return}const n=new FileReader;n.onloadend=()=>{g(n.result)},n.readAsDataURL(r);const d=new FormData;d.append("avatar",r),d.append("name",m.name),d.append("email",m.email),b(!0),s(null);try{const h=await(await fetch("/ai/user-settings/update-profile",{method:"POST",headers:{"X-CSRF-TOKEN":((P=document.querySelector('meta[name="csrf-token"]'))==null?void 0:P.getAttribute("content"))||"","X-Requested-With":"XMLHttpRequest"},body:d})).json();h.success?((A=h.user)!=null&&A.avatar&&g(h.user.avatar),s({type:"success",text:"Profile updated successfully"}),setTimeout(()=>s(null),3e3)):(s({type:"error",text:h.message||"Failed to update avatar"}),setTimeout(()=>s(null),3e3),g(c.avatar||null))}catch(C){console.error("Error uploading avatar:",C),s({type:"error",text:"An error occurred. Please try again."}),setTimeout(()=>s(null),3e3),g(c.avatar||null)}finally{b(!1)}},q=async()=>{var t;if(confirm("Are you sure you want to remove your avatar?")){b(!0);try{const a=await(await fetch("/ai/user-settings/remove-avatar",{method:"DELETE",headers:{"X-CSRF-TOKEN":((t=document.querySelector('meta[name="csrf-token"]'))==null?void 0:t.getAttribute("content"))||"","X-Requested-With":"XMLHttpRequest"}})).json();a.success?(g(null),s({type:"success",text:"Avatar removed successfully"}),setTimeout(()=>s(null),3e3)):(s({type:"error",text:a.message||"Failed to remove avatar"}),setTimeout(()=>s(null),3e3))}catch(r){console.error("Error removing avatar:",r),s({type:"error",text:"An error occurred. Please try again."}),setTimeout(()=>s(null),3e3)}finally{b(!1)}}},I=async t=>{var r;t.preventDefault(),x(!0),s(null);try{const a=new FormData;a.append("name",m.name),a.append("email",m.email);const d=await(await fetch("/ai/user-settings/update-profile",{method:"POST",headers:{"X-CSRF-TOKEN":((r=document.querySelector('meta[name="csrf-token"]'))==null?void 0:r.getAttribute("content"))||"","X-Requested-With":"XMLHttpRequest"},body:a})).json();d.success?(s({type:"success",text:d.message||"Profile updated successfully"}),setTimeout(()=>s(null),3e3)):s({type:"error",text:d.message||"Failed to update profile"})}catch(a){console.error("Error updating profile:",a),s({type:"error",text:"An error occurred. Please try again."})}finally{x(!1)}},w=t=>{j({...i,[t.target.name]:t.target.value})},X=async t=>{var r;if(t.preventDefault(),i.new_password!==i.new_password_confirmation){s({type:"error",text:"New passwords do not match"}),setTimeout(()=>s(null),3e3);return}if(i.new_password.length<8){s({type:"error",text:"New password must be at least 8 characters"}),setTimeout(()=>s(null),3e3);return}x(!0),s(null);try{const n=await(await fetch("/ai/user-settings/update-password",{method:"POST",headers:{"Content-Type":"application/json","X-CSRF-TOKEN":((r=document.querySelector('meta[name="csrf-token"]'))==null?void 0:r.getAttribute("content"))||"","X-Requested-With":"XMLHttpRequest"},body:JSON.stringify(i)})).json();n.success?(s({type:"success",text:n.message||"Password updated successfully"}),j({current_password:"",new_password:"",new_password_confirmation:""}),setTimeout(()=>s(null),3e3)):s({type:"error",text:n.message||"Failed to update password"})}catch(a){console.error("Error updating password:",a),s({type:"error",text:"An error occurred. Please try again."})}finally{x(!1)}},D=async()=>{var r;const t=!p;x(!0),s(null);try{const n=await(await fetch("/ai/user-settings/update",{method:"POST",headers:{"Content-Type":"application/json","X-CSRF-TOKEN":((r=document.querySelector('meta[name="csrf-token"]'))==null?void 0:r.getAttribute("content"))||"","X-Requested-With":"XMLHttpRequest"},body:JSON.stringify({guest_ai_enabled:t})})).json();n.success?(R(t),s({type:"success",text:n.message||"Settings updated successfully"}),setTimeout(()=>s(null),3e3)):s({type:"error",text:n.message||"Failed to update settings"})}catch(a){console.error("Error updating settings:",a),s({type:"error",text:"An error occurred. Please try again."})}finally{x(!1)}},O=[{id:"profile",label:"Profile",icon:"👤"},{id:"password",label:"Change Password",icon:"🔒"},{id:"settings",label:"Settings",icon:"⚙️"}];return e.jsxs(e.Fragment,{children:[e.jsx(G,{title:"Account Settings"}),e.jsx(H,{id:"main-tooltip",place:"top",className:"!bg-gray-900 !text-white !text-xs !px-3 !py-2 !rounded-lg !z-[100] !shadow-xl",effect:"solid"}),e.jsx(W,{auth:_}),e.jsx("div",{className:"flex min-h-screen flex-col bg-[#FCFCFC] text-slate-800",children:e.jsx("div",{className:"flex-1 w-full flex",children:e.jsx("main",{className:"flex-1 min-h-screen overflow-y-auto",children:e.jsxs("div",{className:"flex flex-col px-4 pt-1 pb-1",children:[e.jsx("h1",{className:"text-3xl font-bold text-gray-900 mb-2",children:"Account Settings"}),e.jsx("p",{className:"text-gray-600 mb-8",children:"Manage your account preferences and security"}),e.jsx("div",{className:"border-b border-gray-200 mb-6",children:e.jsx("nav",{className:"-mb-px flex space-x-8",children:O.map(t=>e.jsxs("button",{onClick:()=>F(t.id),className:`
2                                                py-4 px-1 border-b-2 font-medium text-sm transition-colors
3                                                ${f===t.id?"border-[#22c55e] text-[#22c55e]":"border-transparent text-gray-500 hover:text-gray-700 hover:border-gray-300"}
4                                            `,children:[e.jsx("span",{className:"mr-2",children:t.icon}),t.label]},t.id))})}),e.jsxs("div",{className:"mt-6",children:[f==="profile"&&e.jsxs("div",{className:"bg-white rounded-2xl shadow-sm border border-gray-200 overflow-hidden",children:[e.jsxs("div",{className:"px-6 py-4 border-b border-gray-200 bg-gray-50",children:[e.jsx("h2",{className:"text-lg font-semibold text-gray-900",children:"Profile Information"}),e.jsx("p",{className:"text-sm text-gray-500 mt-1",children:"Update your account information and avatar"})]}),e.jsxs("form",{onSubmit:I,className:"p-6 space-y-6",children:[e.jsxs("div",{className:"flex flex-col sm:flex-row items-center sm:items-start space-y-4 sm:sp
4ace-y-0 sm:space-x-6",children:[e.jsxs("div",{className:"relative flex-shrink-0",children:[y?e.jsx("img",{src:y,alt:"Avatar",className:"w-24 h-24 rounded-full object-cover border-2 border-gray-200",onError:()=>g(null)}):e.jsx("div",{className:"w-24 h-24 rounded-full bg-gradient-to-br from-[#22c55e] to-[#16a34a] flex items-center justify-center text-white text-3xl font-semibold",children:c.name.charAt(0).toUpperCase()}),k&&e.jsx("div",{className:"absolute inset-0 bg-black bg-opacity-50 rounded-full flex items-center justify-center",children:e.jsx("div",{className:"animate-spin rounded-full h-6 w-6 border-b-2 border-white"})})]}),e.jsxs("div",{className:"flex flex-col items-center sm:items-start space-y-3",children:[e.jsxs("div",{className:"flex flex-wrap justify-center sm:justify-start gap-2",children:[e.jsx("button",{type:"button",onClick:()=>{var t;return(t=v.current)==null?void 0:t.click()},className:"px-4 py-2 text-sm font-medium text-white bg-[#22c55e] rounded-lg hover:bg-[#16a34a] transition-colors whitespace-nowrap",children:"Change Avatar"}),y&&e.jsx("button",{type:"button",onClick:q,className:"px-4 py-2 text-sm font-medium text-gray-700 bg-gray-100 rounded-lg hover:bg-gray-200 transition-colors",children:"Remove"})]}),e.jsx("p",{className:"text-xs text-gray-500 text-center sm:text-left max-w-[200px] sm:max-w-none",children:"JPG, GIF, PNG, WEBP, or BMP. Max size 100MB."})]}),e.jsx("input",{ref:v,type:"file",accept:"image/jpeg,image/png,image/jpg,image/gif,image/webp,image/bmp",onChange:M,className:"hidden"})]}),e.jsxs("div",{children:[e.jsx("label",{className:"block text-sm font-medium text-gray-700 mb-2",children:"Full Name"}),e.jsx("input",{type:"text",name:"name",value:m.name,onChange:N,className:"w-full px-3 py-2 border border-gray-300 rounded-lg focus:outline-none focus:ring-2 focus:ring-[#22c55e] focus:border-transparent",required:!0})]}),e.jsxs("div",{children:[e.jsx("label",{className:"block text-sm font-medium text-gray-700 mb-2",children:"Email Address"}),e.jsx("input",{type:"email",name:"email",value:m.email,onChange:N,className:"w-full px-3 py-2 border border-gray-300 rounded-lg focus:outline-none focus:ring-2 focus:ring-[#22c55e] focus:border-transparent",required:!0})]}),e.jsx("div",{className:"pt-4 border-t border-gray-200",children:e.jsxs("p",{className:"text-sm text-gray-500",children:["Member since: ",new Date(c.created_at).toLocaleDateString()]})}),o&&o.type!=="error"&&e.jsx("div",{className:`p-3 rounded-lg text-sm ${o.type==="success"?"bg-green-50 text-green-700 border border-green-200":"bg-red-50 text-red-700 border border-red-200"}`,children:o.text}),e.jsx("div",{className:"flex justify-end",children:e.jsx("button",{type:"submit",disabled:u,className:"px-6 py-2 bg-[#22c55e] text-white font-medium rounded-lg hover:bg-[#16a34a] transition-colors disabled:opacity-50 disabled:cursor-not-allowed",children:u?"Saving...":"Save Changes"})})]})]}),f==="password"&&e.jsxs("div",{className:"bg-white rounded-2xl shadow-sm border border-gray-200 overflow-hidden",children:[e.jsxs("div",{className:"px-6 py-4 border-b border-gray-200 bg-gray-50",children:[e.jsx("h2",{className:"text-lg font-semibold text-gray-900",children:"Change Password"}),e.jsx("p",{className:"text-sm text-gray-500 mt-1",children:"Update your password to keep your account secure"})]}),e.jsxs("form",{onSubmit:X,className:"p-6 space-y-6",children:[e.jsxs("div",{children:[e.jsx("label",{className:"block text-sm font-medium text-gray-700 mb-2",children:"Current Password"}),e.jsx("input",{type:"password",name:"current_password",value:i.current_password,onChange:w,className:"w-full px-3 py-2 border border-gray-300 rounded-lg focus:outline-none focus:ring-2 focus:ring-[#22c55e] focus:border-transparent",required:!0})]}),e.jsxs("div",{children:[e.jsx("label",{className:"block text-sm font-medium text-gray-700 mb-2",children:"New Password"}),e.jsx("input",{type:"password",name:"new_password",value:i.new_password,onChange:w,className:"w-full px-3 py-2 border border-gray-300 rounded-lg focus:outline-none focus:ring-2 focus:ring-[#22c55e] focus:border-transparent",required:!0}),e.jsx("p",{className:"text-xs text-gray-500 mt-1",children:"Minimum 8 characters"})]}),e.jsxs("div",{children:[e.jsx("label",{className:"block text-sm font-medium text-gray-700 mb-2",children:"Confirm New Password"}),e.jsx("input",{type:"password",name:"new_password_confirmation",value:i.new_password_confirmation,onChange:w,className:"w-full px-3 py-2 border border-gray-300 rounded-lg focus:outline-none focus:ring-2 focus:ring-[#22c55e] focus:border-transparent",required:!0})]}),o&&e.jsx("div",{className:`p-3 rounded-lg text-sm ${o.type==="success"?"bg-green-50 text-green-700 border border-green-200":"bg-red-50 text-red-700 border border-red-200"}`,children:o.text}),e.jsx("div",{className:"flex justify-end",children:e.jsx("button",{type:"submit",disabled:u,className:"px-6 py-2 bg-[#22c55e] text-white font-medium rounded-lg hover:bg-[#16a34a] transition-colors disabled:opacity-50 disabled:cursor-not-allowed",children:u?"Updating...":"Update Password"})})]})]}),f==="settings"&&e.jsxs("div",{className:"bg-white rounded-2xl shadow-sm border border-gray-200 overflow-hidden",children:[e.jsxs("div",{className:"px-6 py-4 border-b border-gray-200 bg-gray-50",children:[e.jsx("h2",{className:"text-lg font-semibold text-gray-900",children:"AI Settings"}),e.jsx("p",{className:"text-sm text-gray-500 mt-1",children:"Manage your AI preferences and permissions"})]}),e.jsxs("div",{className:"p-6",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{className:"flex-1",children:[e.jsx("h3",{className:"text-base font-medium text-gray-900",children:"Allow guest users to use AI"}),e.jsx("p",{className:"text-sm text-gray-500 mt-1",children:"When enabled, non-logged-in users can access AI features. When disabled, only authenticated users can use AI."})]}),e.jsx("div",{className:"ml-4",children:e.jsx("button",{onClick:D,disabled:u,className:`
5                                                            relative inline-flex h-6 w-11 items-center rounded-full 
6                                                            transition-colors focus:outline-none focus:ring-2 
7                                                            focus:ring-[#22c55e] focus:ring-offset-2
8                                                            ${p?"bg-[#22c55e]":"bg-gray-300"}
9                                                            ${u?"opacity-50 cursor-not-allowed":"cursor-pointer"}
10                                                        `,role:"switch","aria-checked":p,children:e.jsx("span",{className:`
11                                                                inline-block h-4 w-4 transform rounded-full 
12                                                                bg-white shadow-lg transition-transform
13                                                                ${p?"translate-x-6":"translate-x-1"}
14                                                            `})})})]}),e.jsxs("div",{className:"mt-4 flex items-center",children:[e.jsx("div",{className:`w-2 h-2 rounded-full ${p?"bg-[#22c55e]":"bg-gray-400"} mr-2`}),e.jsxs("span",{className:"text-sm text-gray-600",children:["Guest AI is currently ",e.jsx("span",{className:"font-semibold",children:p?"enabled":"disabled"})]})]}),o&&e.jsx("div",{className:`mt-4 p-3 rounded-lg text-sm ${o.type==="success"?"bg-green-50 text-green-700 border border-green-200":"bg-red-50 text-red-700 border border-red-200"}`,children:o.text}),u&&e.jsxs("div",{className:"mt-4 flex items-center text-sm text-gray-500",children:[e.jsx("div",{className:"animate-spin rounded-full h-4 w-4 border-b-2 border-[#22c55e] mr-2"}),"Saving..."]})]}),e.jsx("div",{className:"px-6 py-4 border-t border-gray-200 bg-gray-50",children:e.jsxs("div",{className:"flex",children:[e.jsx("svg",{className:"h-5 w-5 text-blue-400 flex-shrink-0",xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 20 20",fill:"currentColor",children:e.jsx("path",{fillRule:"evenodd",d:"M18 10a8 8 0 11-16 0 8 8 0 0116 0zm-7-4a1 1 0 11-2 0 1 1 0 012 0zM9 9a1 1 0 000 2v3a1 1 0 001 1h1a1 1 0 100-2v-3a1 1 0 00-1-1H9z",clipRule:"evenodd"})}),e.jsxs("p",{className:"ml-3 text-sm text-blue-700",children:[e.jsx("span",{className:"font-medium",children:"Note:"})," More AI settings will be added here in the future."]})]})})]})]})]})})})})]})}export{Q 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.