1(self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[6718],{50191:function(e,a,t){(window.__NEXT_P=window.__NEXT_P||[]).push(["/myAccount/edit-profile",function(){return t(71351)}])},71351:function(e,a,t){"use strict";t.r(a),t.d(a,{__N_SSP:function(){return b},default:function(){return edit_profile}});var i=t(85893),n=t(67294),l=t(61010),o=t.n(l),s=t(34998),r=t(29061),c=t(42668),d=t(86426),m=t(5379),u=t.n(m),h=t(25675),p=t.n(h),googleLogin=e=>{let{onSuccess:a,onError:t,auth:n,size:l}=e,o=(0,d.Nq)({onSuccess:async e=>{try{if(e.access_token){var i,l,o,s;let{data:c}=await r.Z.post("/api/middleware/linkEmail",{g_access_token:e.access_token},{headers:{token:n}});200==c.code?a({email:null==c?void 0:null===(o=c.data)||void 0===o?void 0:null===(l=o.updateData)||void 0===l?void 0:l.email}):412==c.code&&(null==c?void 0:null===(i=c.data)||void 0===i?void 0:i.errors)?t(null==c?void 0:null===(s=c.data)||void 0===s?void 0:s.errors[0].g_access_token):409==c.code||417==c.code?t(null==c?void 0:c.message):t("SomeThing Went wrong")}}catch(e){console.log("err",e),t("SomeThing Went wrong")}},onError:e=>{console.log(e),t("SomeThing Went wrong")}});return(0,i.jsxs)(i.Fragment,{children:["small"==l?(0,i.jsx)("button",{onClick:()=>o(),className:"jsx-b10133cb77b58ece s_logo",children:(0,i.jsx)(p(),{className:"img",src:"/images/googlelogin.svg",height:18,width:20,alt:"google login"})}):(0,i.jsxs)("button",{onClick:()=>o(),className:"jsx-b10133cb77b58ece l_logo",children:[(0,i.jsx)("span",{className:"jsx-b10133cb77b58ece",children:"Sign in with Google"}),(0,i.jsx)(p(),{className:"img",src:"/images/googlelogin.svg",height:14,width:18,alt:"google login"})]}),(0,i.jsx)(u(),{id:"b10133cb77b58ece",children:".l_logo.jsx-b10133cb77b58ece{background-color:white;display:-webkit-box;display:-webkit-flex;display:-moz-box;display:-ms-flexbox;display:flex;-webkit-box-align:center;-webkit-align-items:center;-moz-box-align:center;-ms-flex-align:center;align-items:center;border:1px solid black;cursor:pointer;width:auto;padding:0 20px;height:34px;-webkit-border-radius:40px;-moz-border-radius:40px;border-radius:40px;display:-webkit-box;display:-webkit-flex;display:-moz-box;display:-ms-flexbox;display:flex;-webkit-box-align:center;-webkit-align-items:center;-moz-box-align:center;-ms-flex-align:center;align-items:center;-webkit-box-pack:center;-webkit-justify-content:center;-moz-box-pack:center;-ms-flex-pack:center;justify-content:center}.s_logo.jsx-b10133cb77b58ece{background-color:transparent;display:-webkit-box;display:-webkit-flex;display:-moz-box;display:-ms-flexbox;display:flex;-webkit-box-align:center;-webkit-align-items:center;-moz-box-align:center;-ms-flex-align:center;align-items:center;border:1px solid black;cursor:pointer;width:40px;height:40px;-webkit-border-radius:40px;-moz-border-radius:40px;border-radius:40px;display:-webkit-box;display:-webkit-flex;display:-moz-box;display:-ms-flexbox;display:flex;-webkit-box-align:center;-webkit-align-items:center;-moz-box-align:center;-ms-flex-align:center;align-items:center;-webkit-box-pack:center;-webkit-justify-content:center;-moz-box-pack:center;-ms-flex-pack:center;justify-content:center}.l_logo.jsx-b10133cb77b58ece span.jsx-b10133cb77b58ece{padding-top:2px;font-size:13px!important;font-weight:400!important;margin-right:5px}.l_logo.jsx-b10133cb77b58ece .img.jsx-b10133cb77b58ece{width:18px;height:18px;margin-left:5px}.s_logo.jsx-b10133cb77b58ece .img.jsx-b10133cb77b58ece{width:18px;height:18px}"})]})},g=t(45007),x=t(95279),b=!0,edit_profile=function(e){var a,t,l,m,u;let[h,b]=(0,n.useState)(e.profileData),[f,j]=(0,n.useState)([]),[v,_]=(0,n.useState)([]),[y,w]=(0,n.useState)([]),[k,N]=(0,n.useState)(!1),[C,S]=(0,n.useState)(""),[D,z]=(0,n.useState)({}),H=(0,n.useRef)();(0,g.I0)();let uploadProfile=async a=>{try{let t=new FormData;t.append("profile_picture",a);let{data:i}=await r.Z.post("https://clm-api.jagran.com/api/v1/customer/upload/profile-picture",t,{headers:{Authorization:"Bearer "+e.auth,"Content-Type":"multipart/form-data"}});200==i.code&&b(e=>{var a,t;return{...e,profile_picture:null==i?void 0:null===(t=i.data)||void 0===t?void 0:null===(a=t.profileData)||void 0===a?void 0:a.profile_picture}})}catch(e){S("Something Went Wrong")}},onChangeHandler=e=>{var a;if("mobile_no"!=e.target.name||!(e.target.value.length>
1=11)){if("profile_picture"==e.target.name){uploadProfile(e.target.files[0]);return}if("radio-group"==e.target.name){b(a=>({...a,gender:e.target.value}));return}if("country"==e.target.name){getStateList(e.target.value),b(a=>({...a,country_id:e.target.value,state_id:"",city_id:""}));return}if("state"==e.target.name){P(e.target.value),b(a=>({...a,state_id:e.target.value,city_id:""}));return}if("city"==e.target.name){b(a=>({...a,city_id:e.target.value}));return}("first_name"!=e.target.name&&"last_name"!=e.target.name||!0!=(a=e.target.value,/\d/.test(a)))&&b(a=>({...a,[e.target.name]:e.target.value}))}},updateProfileHandler=async()=>{try{let a={date_of_birth:h.date_of_birth,first_name:h.first_name||"",last_name:h.last_name||"",gender:h.gender};h.country_id&&(a.country_id=String(h.country_id)),h.city_id&&(a.city_id=String(h.city_id)),h.state_id&&(a.state_id=String(h.state_id)),a.email&&!a.mobile_no&&delete a.mobile_no,!a.email&&a.mobile_no&&delete a.email;let{data:t}=await r.Z.post("/api/middleware/updateProfile",a,{headers:{token:e.auth}});if(200==t.code)window.location.href="/manage-profile";else if(412==t.code){let e=t.data.errors.reduce((e,a)=>{for(let t in a)e[t]=a[t];return e},{});z(e)}else S(t.message?t.message:"Something Went Wrong")}catch(e){S("Something Went Wrong")}},getCountryList=async()=>{try{let{data:a}=await (0,r.Z)("".concat("https://clm-api.jagran.com/","api/get-country"));if(200==a.code){var e;j((null==a?void 0:null===(e=a.data)||void 0===e?void 0:e.countryData)||[])}}catch(e){}},getStateList=async e=>{try{let{data:t}=await (0,r.Z)("".concat("https://clm-api.jagran.com/","api/get-state/").concat(e));if(200==t.code){var a;_((null==t?void 0:null===(a=t.data)||void 0===a?void 0:a.stateData)||[])}}catch(e){console.log(e)}},P=(0,n.useCallback)(async e=>{try{let{data:t}=await (0,r.Z)("".concat("https://clm-api.jagran.com/","api/get-city/").concat(h.country_id,"/").concat(e));if(200==t.code){var a;w((null==t?void 0:null===(a=t.data)||void 0===a?void 0:a.cityData)||[])}}catch(e){console.log(e)}},[h.country_id]);return(0,n.useEffect)(()=>{getCountryList(),h.country_name&&getStateList(h.country_id),h.state_name&&P(h.state_id)},[P,h.country_id,h.country_name,h.state_id,h.state_name]),(0,i.jsxs)(i.Fragment,{children:[(0,i.jsx)(x.Z,{query:e.query,profile:h,auth:e.auth,logoUrl:"/",ProfileDropdownWeb:!1,ProfileDropdownMobile:!0}),k&&(0,i.jsx)(c.Z,{showModal:k,token:e.auth,onCloseModal:()=>{window.location.reload(),N(!1)},onClose:()=>{N(!1)}}),(0,i.jsx)("div",{id:"mobile-root"}),(0,i.jsxs)("div",{className:o().myAccount,children:[(0,i.jsx)(s.Z,{query:e.query,auth:e.auth}),(0,i.jsx)("div",{className:o().mainContent,children:(0,i.jsxs)("div",{className:o().info,children:[(0,i.jsxs)("div",{className:o().userinfo,children:[(0,i.jsx)("input",{onChange:onChangeHandler,multiple:!1,ref:H,type:"file",hidden:!0,name:"profile_picture"}),(0,i.jsxs)("div",{className:o().profileCol,children:[(0,i.jsx)("div",{className:o().img,children:(0,i.jsxs)("figure",{onClick:()=>{H.current.click()},children:[(0,i.jsx)("button",{className:o().editphoto,children:(0,i.jsx)("svg",{children:(0,i.jsx)("use",{href:"#editphoto"})})}),h.profile_picture?(0,i.jsx)(p(),{loading:"lazy",width:100,height:100,src:h.profile_picture,alt:"Profile Picture"}):(0,i.jsx)(p(),{loading:"lazy",width:100,height:100,src:"/images/dummy-user.png",alt:"Dummy User"})]})}),(0,i.jsxs)("aside",{children:[(0,i.jsx)("p",{children:"Hello,"}),(0,i.jsxs)("h3",{className:o().name,children:[null==e?void 0:null===(a=e.profileData)||void 0===a?void 0:a.first_name," ",null==e?void 0:null===(t=e.profileData)||void 0===t?void 0:t.last_name]}),(0,i.jsx)("p",{className:o().email,children:null==e?void 0:null===(l=e.profileData)||void 0===l?void 0:l.email}),(null==e?void 0:null===(m=e.profileData)||void 0===m?void 0:m.member_since)&&(0,i.jsxs)("small",{className:o().join,children:["Joined since"," ",new Date(null==e?void 0:null===(u=e.profileData)||void 0===u?void 0:u.member_since).toLocaleDateString("en-Us",{year:"numeric",month:"long"})]})]})]})]}),(0,i.jsxs)("div",{className:"".concat(o().form," ").concat(o().info),children:[(0,i.jsx)("h3",{className:o().heading,children:"Login Information"}),(0,i.jsxs)("div",{className:o().inputGroupInline,children:[(0,i.jsxs)("label",{children:[h.email?"Email ID:":"Add Email"," "]}),h.email?(0,i.jsx)("h6",{children:h.email}):(0,i.jsx)(d.rg,{clientId:"247545486737-0f0plg20qounrs8k1qjbkdp0bd57trrb.apps.googleusercontent.com",children:(0,i.jsx)(googleLogin,{onSuccess:()=>{z({...D,email:null}),window.location.reload()},onError:e=>{z({...D,email:e})},auth:e.auth,size:"small"})})]}),D.email&&(0,i.jsx)("span",{className:"".concat(o().alert," ").concat(o().invalid),children:D.email}),(0,i.jsxs)("div",{className:o().inputGroupInline,children:[(0,i.jsx)("label",{children:"Mobile :"}),h.is_mobile_verified?(0,i.jsx)(i.Fragment,{children:(0,i.jsx)("h6",{children:h.mobile_no})}):(0,i.jsx)("h6",{children:(0,i.jsx)("button",{onClick:()=>N(!0),children:"+ Add your mobile number"})})]})]}),(0,i.jsxs)("div",{className:o().form,children:[(0,i.jsx)("h3",{className:o().heading,children:"Personal Information"}),(0,i.jsxs)("div",{className:o().inputGroup,children:[(0,i.jsxs)("label",{children:["First Name",(0,i.jsx)("small",{children:"*"})]}),(0,i.jsx)("input",{type:"text",name:"first_name",value:h.first_name,onChange:onChangeHandler}),D.first_name&&(0,i.jsx)("span",{className:"".concat(o().alert," ").concat(o().invalid),children:D.first_name})]}),(0,i.jsxs)("div",{className:o().inputGroup,children:[(0,i.jsxs)("label",{children:["Last Name",(0,i.jsx)("small",{children:"*"})]}),(0,i.jsx)("input",{type:"text",name:"last_name",value:h.last_name,onChange:onChangeHandler}),D.last_name&&(0,i.jsx)("span",{className:"".concat(o().alert," ").concat(o().invalid),children:D.last_name})]}),(0,i.jsxs)("div",{className:o().inputGroup,children:[(0,i.jsx)("label",{children:"Birthday"}),(0,i.jsx)("input",{type:"date",id:"birthday",name:"date_of_birth",value:h.date_of_birth||"",onChange:onChangeHandler,max:new Date().toISOString().split("T")[0]}),D.date_of_birth&&(0,i.jsx)("span",{className:"".concat(o().alert," ").concat(o().invalid),children:D.date_of_birth})]}),(0,i.jsxs)("div",{className:o().inputGroup,children:[(0,i.jsxs)("label",{children:["Gender",(0,i.jsx)("small",{children:"*"})]}),(0,i.jsxs)("div",{className:o().radio,children:[(0,i.jsx)("input",{type:"radio",id:"male",name:"radio-group",value:"male",checked:"male"===h.gender,onCh
1ange:onChangeHandler}),(0,i.jsx)("label",{htmlFor:"male",children:"Male"}),(0,i.jsx)("input",{type:"radio",id:"female",name:"radio-group",value:"female",checked:"female"===h.gender,onChange:onChangeHandler}),(0,i.jsx)("label",{htmlFor:"female",children:"Female"})]}),D.gender&&(0,i.jsx)("span",{className:"".concat(o().alert," ").concat(o().invalid),children:D.gender})]}),(0,i.jsxs)("div",{className:o().selectCountry,children:[(0,i.jsxs)("div",{className:o().inputGroup,children:[(0,i.jsx)("label",{children:"Country / Region"}),(0,i.jsxs)("select",{name:"country",onChange:onChangeHandler,value:h.country_id,children:[(0,i.jsx)("option",{value:"",title:"",children:"Select a country"}),f.map(e=>(0,i.jsx)("option",{value:e.id,title:e.name,children:e.name},e.id))]}),D.country_id&&(0,i.jsx)("span",{className:"".concat(o().alert," ").concat(o().invalid),children:D.country_id})]}),(0,i.jsxs)("div",{className:o().inputGroup,children:[(0,i.jsx)("label",{children:"State"}),(0,i.jsxs)("select",{name:"state",onChange:onChangeHandler,value:h.state_id,children:[(0,i.jsx)("option",{value:"",title:"",children:"Select a State"}),v.map(e=>(0,i.jsx)("option",{value:e.id,title:e.name,children:e.name},e.id))]}),D.state_id&&(0,i.jsx)("span",{className:"".concat(o().alert," ").concat(o().invalid),children:D.state_id})]}),(0,i.jsxs)("div",{className:o().inputGroup,children:[(0,i.jsx)("label",{children:"City"}),(0,i.jsxs)("select",{name:"city",onChange:onChangeHandler,value:h.city_id,children:[(0,i.jsx)("option",{value:"",title:"",children:"Select a city"}),y.map(e=>(0,i.jsx)("option",{value:e.id,title:e.name,children:e.name},e.id))]}),D.city_id&&(0,i.jsx)("span",{className:"".concat(o().alert," ").concat(o().invalid),children:D.city_id})]})]}),(0,i.jsx)("div",{className:o().ctaBtn,children:(0,i.jsx)("button",{onClick:updateProfileHandler,className:"".concat(o().button," ").concat(o().auto),children:"Save"})}),C&&(0,i.jsx)("div",{children:(0,i.jsx)("p",{className:"".concat(o().alert," ").concat(o().invalid),children:C})})]})]})})]})]})}}},function(e){e.O(0,[5675,3857,1101,5035,2668,243,9774,2888,179],function(){return e(e.s=50191)}),_N_E=e.O()}]);
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.