2 lines
13 KiB
JavaScript
2 lines
13 KiB
JavaScript
import{t as h,T as m,r as o,a as oe,Y as w,e as Ce,f as e,j as r,F as Ie,S as b,B as p,R as B,I as z,g as k,h as O,$ as H,k as Me,aU as q,aT as re,a0 as Fe,P as Te,u as Be,bU as ze}from"./index.ef35a7e7.js";import{M as ke}from"./MuiDialog.ba489843.js";import{G as n}from"./Grid.ba6e5a37.js";import{r as f,i as g,a as x}from"./jsx-runtime_commonjs-proxy.a0db3bf1.js";import{C as ne}from"./Card.cc6fb9c1.js";import"./DialogContent.e5ce391a.js";import"./DialogTitle.161ebb47.js";const Oe=h("header")(({theme:t})=>({display:"flex",alignItems:"center",padding:t.spacing(2),justifyContent:"space-between"})),V=h(m)(({theme:t})=>({...t.typography.h6,marginBottom:t.spacing(2),marginTop:t.spacing(2)})),qe=({title:t,openDialog:d,setOpenDialog:i,data:l})=>{o.exports.useState(!1),o.exports.useState(!0),oe();const c=l,u=!!c,[$,j]=o.exports.useState();console.log("usernya masuk",$),o.exports.useEffect(()=>{u&&w.get("/user/"+c).then(v=>{j(v.data)})},[c]);const Y=h(m)(({theme:v})=>({...v.typography.h4,boxShadow:"none",fontWeight:700,color:"#005B7F"}));console.log("currentUsers",$),console.log("data Id masuk",l);const _=Ce({}),{reset:S,watch:P,control:Z,setValue:J,setError:R,getValues:X,handleSubmit:a,formState:{isSubmitting:C}}=_;P(),o.exports.useEffect(()=>{d===!1&&S()},[d,S]);const I=async v=>{var ee,te;console.log("data",v);try{if(u){const y=await w.put("/reset-password/",v)}else{const y=await w.post("/reset-password",v)}S(),q(u?"Password Updated Successfully!":"Password Created Successfully!",{variant:"success"}),i(!1)}catch(y){if(y&&y.response.status===422)for(const[Re,ae]of Object.entries(y.response.data.errors))R(Re,{message:ae[0]}),q((ee=ae[0])!=null?ee:"Failed Processing Request",{variant:"error"});else q((te=y.message)!=null?te:"Failed Processing Request",{variant:"error"})}const Q=document==null?void 0:document.querySelector("ascent");Q!=null&&(Q.innerHTML="")},[M,we]=o.exports.useState(!1),[F,je]=o.exports.useState(!1),[T,Pe]=o.exports.useState(!1);return e(ke,{title:t,openDialog:d,setOpenDialog:i,content:(()=>r(Ie,{methods:_,onSubmit:a(I),children:[e(Oe,{children:e(Y,{children:"Ubah Kata Sandi"})}),e(b,{spacing:3,children:r(p,{sx:{width:"100%",typography:"body1",p:2},children:[r(n,{item:!0,xs:12,children:[e(V,{children:"Kata Sandi Lama "}),e(B,{name:"old_password",label:"Kata Sandi Lama",type:M?"text":"password",InputProps:{endAdornment:e(z,{position:"end",children:e(k,{onClick:()=>we(!M),edge:"end",children:e(O,{icon:M?"eva:eye-fill":"eva:eye-off-fill"})})})}})]}),r(n,{item:!0,xs:12,children:[e(V,{children:"Kata Sandi Baru "}),e(B,{name:"new_password",label:"Kata Sandi Baru",type:F?"text":"password",InputProps:{endAdornment:e(z,{position:"end",children:e(k,{onClick:()=>je(!F),edge:"end",children:e(O,{icon:F?"eva:eye-fill":"eva:eye-off-fill"})})})}})]}),r(n,{item:!0,xs:12,children:[e(V,{children:"Konfirmasi Kata Sandi "}),e(B,{name:"confirm_new_password",label:"Konfirmasi Kata Sandi",type:T?"text":"password",InputProps:{endAdornment:e(z,{position:"end",children:e(k,{onClick:()=>Pe(!T),edge:"end",children:e(O,{icon:T?"eva:eye-fill":"eva:eye-off-fill"})})})}})]}),e(p,{sx:{width:"100%",pt:5},children:e(b,{alignItems:"center",justifyContent:"end",direction:{xs:"column",md:"row"},children:r(b,{direction:"row",spacing:1,children:[e(H,{sx:{boxShadow:"none"},variant:"outlined",size:"medium",fullWidth:!0,onClick:()=>i(!1),children:"Batal"}),e(Me,{sx:{boxShadow:"0px 2px 4px rgba(0, 0, 0, 0.1)"},type:"submit",variant:"contained",size:"medium",fullWidth:!0,loading:C,children:"Simpan"})]})})})]})})]}))(),maxWidth:"sm"})},Ve=qe;var s={},L={};Object.defineProperty(L,"__esModule",{value:!0});L.default=Ke;const He=Object.prototype.toString,Le=Error.prototype.toString,De=RegExp.prototype.toString,Ee=typeof Symbol<"u"?Symbol.prototype.toString:()=>"",Ne=/^Symbol\((.*)\)(.*)$/;function Ue(t){return t!=+t?"NaN":t===0&&1/t<0?"-0":""+t}function ie(t,d=!1){if(t==null||t===!0||t===!1)return""+t;const i=typeof t;if(i==="number")return Ue(t);if(i==="string")return d?`"${t}"`:t;if(i==="function")return"[Function "+(t.name||"anonymous")+"]";if(i==="symbol")return Ee.call(t).replace(Ne,"Symbol($1)");const l=He.call(t).slice(8,-1);return l==="Date"?isNaN(t.getTime())?""+t:t.toISOString(t):l==="Error"||t instanceof Error?"["+Le.call(t)+"]":l==="RegExp"?De.call(t):null}function Ke(t,d){let i=ie(t,d);return i!==null?i:JSON.stringify(t,function(l,c){let u=ie(this[l],d);return u!==null?u:c},2)}Object.defineProperty(s,"__esModule",{value:!0});s.string=s.object=ue=s.number=s.mixed=s.default=s.date=s.boolean=s.array=void 0;var se=Ae(L);function Ae(t){return t&&t.__esModule?t:{default:t}}let le={default:"${path} is invalid",required:"${path} is a required field",oneOf:"${path} must be one of the following values: ${values}",notOneOf:"${path} must not be one of the following values: ${values}",notType:({path:t,type:d,value:i,originalValue:l})=>{let c=l!=null&&l!==i,u=`${t} must be a \`${d}\` type, but the final value was: \`${(0,se.default)(i,!0)}\``+(c?` (cast from the value \`${(0,se.default)(l,!0)}\`).`:".");return i===null&&(u+='\n If "null" is intended as an empty value be sure to mark the schema as `.nullable()`'),u},defined:"${path} must be defined"};s.mixed=le;let de={length:"${path} must be exactly ${length} characters",min:"${path} must be at least ${min} characters",max:"${path} must be at most ${max} characters",matches:'${path} must match the following: "${regex}"',email:"${path} must be a valid email",url:"${path} must be a valid URL",uuid:"${path} must be a valid UUID",trim:"${path} must be a trimmed string",lowercase:"${path} must be a lowercase string",uppercase:"${path} must be a upper case string"};s.string=de;let ce={min:"${path} must be greater than or equal to ${min}",max:"${path} must be less than or equal to ${max}",lessThan:"${path} must be less than ${less}",moreThan:"${path} must be greater than ${more}",positive:"${path} must be a positive number",negative:"${path} must be a negative number",integer:"${path} must be an integer"};var ue=s.number=ce;let pe={min:"${path} field must be later than ${min}",max:"${path} field must be at earlier than ${max}"};s.date=pe;let me={isValue:"${path} field must be ${value}"};s.boolean=me;let he={noUnknown:"${path} field has unspecified keys: ${unknown}"};s.object=he;let fe={min:"${path} field must have at least ${min} items",max:"${path} field must have less than or equal to ${max} items",length:"${path} must have ${length} items"};s.array=fe;var We=Object.assign(Object.create(null),{mixed:le,string:de,number:ce,date:pe,object:he,array:fe,boolean:me});s.default=We;var D={},Ge=g.exports;Object.defineProperty(D,"__esModule",{value:!0});var ge=D.default=void 0,Ye=Ge(f()),Ze=x,Je=(0,Ye.default)((0,Ze.jsx)("path",{d:"M19 3H5c-1.1 0-2 .9-2 2v14c0 1.1.9 2 2 2h14c1.1 0 2-.9 2-2V5c0-1.1-.9-2-2-2zm-7 3c1.93 0 3.5 1.57 3.5 3.5S13.93 13 12 13s-3.5-1.57-3.5-3.5S10.07 6 12 6zm7 13H5v-.23c0-.62.28-1.2.76-1.58C7.47 15.82 9.64 15 12 15s4.53.82 6.24 2.19c.48.38.76.97.76 1.58V19z"}),"AccountBox");ge=D.default=Je;var E={},Xe=g.exports;Object.defineProperty(E,"__esModule",{value:!0});var xe=E.default=void 0,Qe=Xe(f()),et=x,tt=(0,Qe.default)((0,et.jsx)("path",{d:"M12 12c2.21 0 4-1.79 4-4s-1.79-4-4-4-4 1.79-4 4 1.79 4 4 4zm0 2c-2.67 0-8 1.34-8 4v2h16v-2c0-2.66-5.33-4-8-4z"}),"Person");xe=E.default=tt;var N={},at=g.exports;Object.defineProperty(N,"__esModule",{value:!0});var ve=N.default=void 0,rt=at(f()),nt=x,it=(0,rt.default)((0,nt.jsx)("path",{d:"M20 7h-5V4c0-1.1-.9-2-2-2h-2c-1.1 0-2 .9-2 2v3H4c-1.1 0-2 .9-2 2v11c0 1.1.9 2 2 2h16c1.1 0 2-.9 2-2V9c0-1.1-.9-2-2-2zM9 12c.83 0 1.5.67 1.5 1.5S9.83 15 9 15s-1.5-.67-1.5-1.5S8.17 12 9 12zm3 6H6v-.75c0-1 2-1.5 3-1.5s3 .5 3 1.5V18zm1-9h-2V4h2v5zm5 7.5h-4V15h4v1.5zm0-3h-4V12h4v1.5z"}),"Badge");ve=N.default=it;var U={},st=g.exports;Object.defineProperty(U,"__esModule",{value:!0});var be=U.default=void 0,ot=st(f()),lt=x,dt=(0,ot.default)((0,lt.jsx)("path",{d:"M20.01 15.38c-1.23 0-2.42-.2-3.53-.56-.35-.12-.74-.03-1.01.24l-1.57 1.97c-2.83-1.35-5.48-3.9-6.89-6.83l1.95-1.66c.27-.28.35-.67.24-1.02-.37-1.11-.56-2.3-.56-3.53 0-.54-.45-.99-.99-.99H4.19C3.65 3 3 3.24 3 3.99 3 13.28 10.73 21 20.01 21c.71 0 .99-.63.99-1.18v-3.45c0-.54-.45-.99-.99-.99z"}),"Call");be=U.default=dt;var K={},ct=g.exports;Object.defineProperty(K,"__esModule",{value:!0});var ye=K.default=void 0,ut=ct(f()),pt=x,mt=(0,ut.default)((0,pt.jsx)("path",{d:"M20 4H4c-1.1 0-1.99.9-1.99 2L2 18c0 1.1.9 2 2 2h16c1.1 0 2-.9 2-2V6c0-1.1-.9-2-2-2zm0 4-8 5-8-5V6l8 5 8-5v2z"}),"Mail");ye=K.default=mt;var A={},ht=g.exports;Object.defineProperty(A,"__esModule",{value:!0});var $e=A.default=void 0,ft=ht(f()),gt=x,xt=(0,ft.default)((0,gt.jsx)("path",{d:"M18 8h-1V6c0-2.76-2.24-5-5-5S7 3.24 7 6v2H6c-1.1 0-2 .9-2 2v10c0 1.1.9 2 2 2h12c1.1 0 2-.9 2-2V10c0-1.1-.9-2-2-2zm-6 9c-1.1 0-2-.9-2-2s.9-2 2-2 2 .9 2 2-.9 2-2 2zm3.1-9H8.9V6c0-1.71 1.39-3.1 3.1-3.1 1.71 0 3.1 1.39 3.1 3.1v2z"}),"Lock");$e=A.default=xt;var W={},vt=g.exports;Object.defineProperty(W,"__esModule",{value:!0});var Se=W.default=void 0,bt=vt(f()),yt=x,$t=(0,bt.default)((0,yt.jsx)("path",{d:"M21 10h-8.35C11.83 7.67 9.61 6 7 6c-3.31 0-6 2.69-6 6s2.69 6 6 6c2.61 0 4.83-1.67 5.65-4H13l2 2 2-2 2 2 4-4.04L21 10zM7 15c-1.65 0-3-1.35-3-3s1.35-3 3-3 3 1.35 3 3-1.35 3-3 3z"}),"Key");Se=W.default=$t;var G={},St=g.exports;Object.defineProperty(G,"__esModule",{value:!0});var _e=G.default=void 0,_t=St(f()),wt=x,jt=(0,_t.default)((0,wt.jsx)("path",{d:"M5 5h7V3H5c-1.1 0-2 .9-2 2v14c0 1.1.9 2 2 2h7v-2H5V5zm16 7-4-4v3H9v2h8v3l4-4z"}),"LogoutTwoTone");_e=G.default=jt;function zt(){h("header")(({theme:a})=>({padding:a.spacing(5),display:"flex",alignItems:"center",justifyContent:"space-between"})),h(m)(({theme:a})=>({...a.typography.h3,marginBottom:a.spacing(1),marginTop:a.spacing(2),color:"#005B7F"}));const t=h(m)(({theme:a})=>({...a.typography.h6,marginBottom:a.spacing(2),marginTop:a.spacing(2),color:"#005B7F"})),d=oe();re(),Fe(),o.exports.useState(null),re(),h(Te)(({theme:a})=>({textAlign:"left"}));const i={color:"#005B7F",backgroundColor:"#FFFFFF",boxShadow:"0px 2px 4px rgba(0, 0, 0, 0.1)",borderRadius:"8px",flex:1,marginRight:3,padding:"13px",border:"2px solid #005B7F",fontSize:"15px",lineHeight:"16px",textTransform:"none","&:hover":{backgroundColor:"#005B7F",color:"#FFFFFF"}};function l(){const[a,C]=o.exports.useState([]);return o.exports.useEffect(()=>{w.get("/user").then(I=>{C(I.data)})},[]),o.exports.useMemo(()=>({id:a==null?void 0:a.id,email:a==null?void 0:a.email}),[a]),console.log("user",a),r("div",{children:[e(m,{variant:"h3",sx:{mb:5},children:"Profile"}),r(p,{position:"relative",mb:5,children:[e(p,{display:"flex",alignItems:"center",position:"relative",minHeight:"18.75rem",borderRadius:"xl",sx:{borderRadius:"20px"},children:e("img",{src:"/image/overlay.png",alt:"overlay",width:"100%",height:"100%",style:{borderTopLeftRadius:"20px",borderTopRightRadius:"20px"}})}),e(ne,{sx:{position:"relative",mt:-8,mx:3,py:2,px:2},children:r(n,{container:!0,spacing:3,alignItems:"center",sx:{p:3},children:[e(n,{item:!0,children:e(ze,{src:"https://minimal-assets-api.vercel.app/assets/images/avatars/avatar_5.jpg",alt:"Rayan Moran",sx:{width:100,height:100,ml:"4%"}})}),e(n,{item:!0,children:r(p,{height:"100%",mt:.5,lineHeight:1,sx:{ml:5},children:[e(m,{variant:"h4",fontWeight:"700",children:"Rayan Moran"}),e(m,{variant:"subtitle1",color:"text.secondary",children:"Super Admin"})]})}),e(n,{item:!0,xs:12,md:6,lg:4,sx:{ml:"auto"}})]})})]}),e(b,{spacing:3,children:r(n,{container:!0,spacing:3,children:[e(n,{item:!0,xs:12,md:6,children:r(p,{sx:{p:3},children:[e(n,{sx:{mt:5,ml:5,mb:2},children:e(p,{sx:{display:"flex",pb:2,borderBottom:"5px solid"},children:r(b,{spacing:2,justifyContent:"center",alignItems:"center",direction:"row",children:[e(ge,{}),e(m,{variant:"h4",sx:{ml:1},children:"Profil"})]})})}),e(p,{sx:{p:5},children:r(n,{container:!0,spacing:3,children:[r(n,{item:!0,xs:12,md:6,children:[r(n,{item:!0,xs:12,md:12,children:[r(t,{children:[e(xe,{})," ID"]}),e(c,{children:a!=null&&a.id?a==null?void 0:a.id:"-"})]}),r(n,{item:!0,xs:12,md:12,children:[r(t,{children:[e(ve,{})," Nama"]}),e(c,{children:"Perdi"})]})]}),r(n,{item:!0,xs:12,md:6,children:[r(n,{item:!0,xs:12,md:12,children:[r(t,{children:[e(be,{})," Telepon"]}),e(c,{children:"2131231231"})]}),r(n,{item:!0,xs:12,md:12,children:[r(t,{children:[e(ye,{})," Email"]}),e(c,{children:a!=null&&a.email?a==null?void 0:a.email:"-"})]})]})]})})]})}),r(n,{item:!0,xs:12,md:6,children:[r(p,{sx:{p:3},children:[e(n,{sx:{mt:5,ml:5,mb:2},children:e(p,{sx:{display:"flex",pb:2,borderBottom:"5px solid"},children:r(b,{spacing:2,justifyContent:"center",alignItems:"center",direction:"row",children:[e($e,{}),e(m,{variant:"h4",sx:{ml:1},children:"Keamanan"})]})})}),e(p,{sx:{p:5},children:e(n,{item:!0,xs:12,md:12,children:e("div",{style:{display:"flex",justifyContent:"Center"},children:e(H,{variant:"contained",sx:i,startIcon:e(Se,{}),onClick:()=>{J("edit"),Z(a.id)},children:"Ubah Kata Sandi"})})})})]}),e(p,{sx:{p:3},style:{display:"flex",justifyContent:"center"},children:r(H,{onClick:X,variant:"outlined",color:"error",children:[e(_e,{})," Logout"]})})]})]})})]})}const c=h(m)(({theme:a})=>({boxShadow:"none",fontWeight:700,color:"#000000"}));h(m)(({theme:a})=>({...a.typography.h5,boxShadow:"none",fontWeight:500,color:"#000000"}));const[u,$]=o.exports.useState(!1),[j,Y]=o.exports.useState(""),[_,S]=o.exports.useState(""),[P,Z]=o.exports.useState(ue),J=a=>{switch(a){case"edit":S(a),$(!0);break}},{logout:R}=Be(),X=()=>{R(),d("/auth/login")};return r(b,{children:[e(ne,{sx:{marginTop:"30px",p:5,boxShadow:"none"},children:e(l,{})}),_==="edit"&&e(Ve,{data:P,openDialog:u,setOpenDialog:$,title:{name:j,icon:"heroicons-solid:cash"}})]})}export{zt as default};
|