Sindbad~EG File Manager
"use strict";(self.webpackChunk_minimal_material_kit_react=self.webpackChunk_minimal_material_kit_react||[]).push([[767],{6767:(e,s,i)=>{i.r(s),i.d(s,{default:()=>S});var n=i(5043),a=i(3216),l=i(9252),t=i(8911),o=i(5865),d=i(8977),r=i(8613),c=i(8903),u=i(7625),h=i(6446),m=i(5037),p=i(2812),v=i(1036),x=i(9554),b=i(9456),j=i(9588),f=i(2954),w=i(4535),g=i(5565),_=i(3417),y=i(579);const A={position:"absolute",top:"50%",left:"50%",transform:"translate(-50%, -50%)",width:400,bgcolor:"background.paper",border:"2px solid black",borderRadius:2,boxShadow:24,p:4},P=(0,w.Ay)("input")({clip:"rect(0 0 0 0)",clipPath:"inset(50%)",height:1,overflow:"hidden",position:"absolute",bottom:0,left:0,whiteSpace:"nowrap",width:1});function S(){const[e,s]=(0,n.useState)({}),[i,w]=(0,n.useState)("/assets/images/avatars/avatar_placeholder.png"),[S,C]=(0,n.useState)(!1),D=(0,a.Zp)(),R=(0,b.wA)(),{userInfo:k}=(0,b.d4)((e=>e.auth)),[I,W]=(0,n.useState)(!0),[U,V]=(0,n.useState)(!0),[N,B]=(0,n.useState)(!1),[E,L]=(0,n.useState)(!1),[M,Y]=(0,n.useState)(!1),z=async()=>{try{const i=await g.A.get("".concat(j.VY,"/user/get-user-profile/").concat(null===k||void 0===k?void 0:k.user_id));if(200===(null===i||void 0===i?void 0:i.status)){var e;let n=null===i||void 0===i||null===(e=i.data)||void 0===e?void 0:e.data[0];s(n),w(null!==n&&void 0!==n&&n.business_logo?"https://autocrm.infinitibizsol.com/images/"+(null===n||void 0===n?void 0:n.business_logo):"/assets/images/avatars/avatar_placeholder.png"),R((0,_.bu)(n))}}catch(i){v.oR.error("Error while getting details")}};(0,n.useEffect)((()=>{z()}),[]);const O=e=>{if(!e)return"";const s=e.replace(/\D/g,"");if(s.length>0){var i,n,a;return null===(i=s.match(/^(\d{0,3})(\d{0,3})(\d{0,4})$/))||void 0===i||null===(n=i.slice(1))||void 0===n||null===(a=n.filter(Boolean))||void 0===a?void 0:a.join("-")}return""};return(0,y.jsxs)(l.A,{children:[(0,y.jsxs)(t.A,{direction:"row",alignItems:"center",justifyContent:"space-between",children:[(0,y.jsx)(o.A,{variant:"h4",sx:{mb:5},children:"User Profile"}),(0,y.jsx)(d.A,{variant:"contained",onClick:()=>D("/dashboard/app",{replace:!0}),children:"Back To Dashboard"})]}),(0,y.jsxs)(t.A,{mb:5,children:[(0,y.jsx)("div",{className:"display-avatar",style:{marginRight:"15px"},children:(0,y.jsx)(r.A,{src:"object"===typeof i?URL.createObjectURL(i):i,alt:"autioneer_photo",sx:{width:120,height:120,margin:"5px auto"}})}),(0,y.jsx)("br",{}),(0,y.jsxs)("div",{style:{display:"flex",alignItems:"center",justifyContent:"center",gap:"10px"},children:[(0,y.jsxs)(d.A,{component:"label",variant:"contained",tabIndex:-1,startIcon:(0,y.jsx)(f.A,{}),children:["Upload file",(0,y.jsx)(P,{type:"file",accept:"image/*",onChange:e=>{const s=e.target.files[0];w(s)}})]}),(0,y.jsx)(p.A,{loading:M,component:"label",variant:"contained",onClick:async()=>{if("object"===typeof i){Y(!0);try{const s=new FormData;s.append("business_logo",i);const n=await g.A.patch("".concat(j.VY,"/user/update-business-logo"),s);var e;if(200===(null===n||void 0===n?void 0:n.status))v.oR.success("Logo updated successfully"),R((0,_.bu)({business_logo:null===n||void 0===n||null===(e=n.data)||void 0===e?void 0:e.business_logo}))}catch(a){var s,n;v.oR.error((null===a||void 0===a||null===(s=a.response)||void 0===s||null===(n=s.data)||void 0===n?void 0:n.message)||"Error while updating logo")}Y(!1)}else v.oR.warning("Please select a file")},children:"Update"})]})]}),(0,y.jsx)(m.lV,{onSubmit:async e=>{if(e)try{B(!0);const s=await g.A.patch("".concat(j.VY,"/user/update-user-profile"),e);console.log("Update profile:",s),200===(null===s||void 0===s?void 0:s.status)&&(v.oR.success("Profile updated successfully"),B(!1),z())}catch(s){B(!1)}else v.oR.error("Invalid data!")},initialValues:{user_id:null===e||void 0===e?void 0:e.user_id,firstname:null===e||void 0===e?void 0:e.firstname,lastname:null===e||void 0===e?void 0:e.lastname,business_name:null===e||void 0===e?void 0:e.business_name,mobile_no:null===e||void 0===e?void 0:e.mobile_no,business_phone:null===e||void 0===e?void 0:e.business_phone,business_email:null===e||void 0===e?void 0:e.business_email,business_address:null===e||void 0===e?void 0:e.business_address},validate:(e,s)=>{var i,n;const a={};var l;return l=e.business_email,/\S+@\S+\.\S+/.test(l)||(a.business_email="Invalid email address"),null!==e&&void 0!==e&&e.mobile_no&&12!==(null===e||void 0===e||null===(i=e.mobile_no)||void 0===i?void 0:i.length)&&(a.mobile_no="Invalid Mobile Number"),null!==e&&void 0!==e&&e.business_phone&&12!==(null===e||void 0===e||null===(n=e.business_phone)||void 0===n?void 0:n.length)&&(a.business_phone="Invalid business Phone"),a},render:e=>{let{handleSubmit:s,errors:i,form:n}=e;return(0,y.jsxs)("form",{onSubmit:s,children:[(0,y.jsxs)(c.Ay,{container:!0,spacing:4,children:[(0,y.jsx)(c.Ay,{item:!0,xs:6,children:(0,y.jsx)(m.D0,{fullWidth:!0,name:"firstname",children:e=>(0,y.jsx)(x.A,{label:"First Name",...e})})}),(0,y.jsx)(c.Ay,{item:!0,xs:6,children:(0,y.jsx)(m.D0,{fullWidth:!0,name:"lastname",children:e=>(0,y.jsx)(x.A,{label:"Last Name",...e})})}),(0,y.jsx)(c.Ay,{item:!0,xs:6,children:(0,y.jsx)(m.D0,{fullWidth:!0,name:"business_name",children:e=>(0,y.jsx)(x.A,{label:"Business Name",...e})})}),(0,y.jsx)(c.Ay,{item:!0,xs:6,children:(0,y.jsx)(m.D0,{fullWidth:!0,name:"business_email",children:e=>(0,y.jsx)(x.A,{label:"Email address",...e})})}),(0,y.jsx)(c.Ay,{item:!0,xs:6,mt:3,children:(0,y.jsx)(m.D0,{fullWidth:!0,name:"mobile_no",format:e=>O(e),children:e=>(0,y.jsx)(x.A,{label:"Mobile No",type:"text",...e})})}),(0,y.jsx)(c.Ay,{item:!0,xs:6,mt:3,children:(0,y.jsx)(m.D0,{fullWidth:!0,name:"business_phone",format:e=>O(e),children:e=>(0,y.jsx)(x.A,{label:"Business Phone",type:"text",...e})})}),(0,y.jsx)(c.Ay,{item:!0,xs:6,mt:3,children:(0,y.jsx)(m.D0,{fullWidth:!0,name:"business_address",children:e=>(0,y.jsx)(x.A,{label:"Business Address",...e})})}),(0,y.jsx)(c.Ay,{item:!0,xs:6,mt:3,children:(0,y.jsx)(d.A,{type:"button",variant:"outlined",onClick:()=>C(!0),children:"Change Password"})})]}),(0,y.jsx)(c.Ay,{container:!0,direction:"row",justifyContent:"center",alignItems:"center",m:4,children:(0,y.jsx)(p.A,{loading:N,size:"large",type:"submit",variant:"contained",children:"Update"})})]})}}),(0,y.jsx)(u.A,{open:S,onClose:()=>C(!1),"aria-labelledby":"modal-modal-title","aria-describedby":"modal-modal-description",children:(0,y.jsx)(h.A,{sx:A,children:(0,y.jsx)(m.lV,{onSubmit:async e=>{const{old_password:s,newPassword:i,confirmPassword:n}=e;if(i){if(i!==n)return void W(!1);L(!0),W(!0);try{const e=await g.A.patch("".concat(j.VY,"/user/update-password"),{newPassword:i,old_password:s,user_id:null===k||void 0===k?void 0:k.user_id});200===(null===e||void 0===e?void 0:e.status)&&(v.oR.success("Password updated successfully"),C(!1))}catch(a){v.oR.error(a.response.data.message||"Error while updating password")}L(!1)}else v.oR.warning("Password can never be empty.")},initialValues:{old_password:"",newPassword:"",confirmPassword:""},validate:e=>{const s={};return null!==e&&void 0!==e&&e.old_password||(s.old_password="Old Password is required"),s},render:e=>{let{handleSubmit:s,errors:i,form:n}=e;return(0,y.jsx)("form",{onSubmit:s,children:(0,y.jsxs)(c.Ay,{container:!0,spacing:4,children:[(0,y.jsx)(c.Ay,{item:!0,xs:12,children:(0,y.jsx)(m.D0,{fullWidth:!0,name:"old_password",children:e=>(0,y.jsx)(x.A,{label:"Old Password",type:"text",...e})})}),(0,y.jsx)(c.Ay,{item:!0,xs:12,children:(0,y.jsx)(m.D0,{fullWidth:!0,name:"newPassword",children:e=>(0,y.jsx)(x.A,{label:"New Password",type:"text",...e})})}),(0,y.jsxs)(c.Ay,{item:!0,xs:12,children:[(0,y.jsx)(m.D0,{fullWidth:!0,name:"confirmPassword",children:e=>(0,y.jsx)(x.A,{label:"Confirm Password",type:"text",...e})}),!I&&(0,y.jsx)(o.A,{variant:"body2",color:"red",children:"Passwords do not match"})]}),(0,y.jsx)(c.Ay,{item:!0,xs:12,children:(0,y.jsx)(p.A,{loading:E,type:"submit",variant:"contained",children:"Change Password"})})]})})}})})})]})}},2954:(e,s,i)=>{var n=i(4994);s.A=void 0;var a=n(i(39)),l=i(579);s.A=(0,a.default)((0,l.jsx)("path",{d:"M19.35 10.04C18.67 6.59 15.64 4 12 4 9.11 4 6.6 5.64 5.35 8.04 2.34 8.36 0 10.91 0 14c0 3.31 2.69 6 6 6h13c2.76 0 5-2.24 5-5 0-2.64-2.05-4.78-4.65-4.96M14 13v4h-4v-4H7l5-5 5 5z"}),"CloudUpload")}}]);
//# sourceMappingURL=767.a4a95a75.chunk.js.map
Sindbad File Manager Version 1.0, Coded By Sindbad EG ~ The Terrorists