(self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[8575],{9898:function(e,a,r){Promise.resolve().then(r.bind(r,4968))},4968:function(e,a,r){"use strict";r.r(a),r.d(a,{default:function(){return u}});var t=r(7437),s=r(2265),n=r(8706),l=r(9376);function u(){let{id:e}=(0,l.useParams)(),a=(0,n.T)(),[r,u]=(0,s.useState)(null),[o,i]=(0,s.useState)(!0),[d,c]=(0,s.useState)(!1),[m,f]=(0,s.useState)("");async function g(t){if(t.preventDefault(),r){c(!0),f("");try{let t=await fetch("/api/customers/".concat(e,"/profile"),{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify(r)}),s=await t.json();s.success?f(a("profile_updated",{defaultValue:"Profili u perditesua me sukses."})):f(s.message||a("error",{defaultValue:"Gabim."}))}catch(e){f(a("generic_error",{defaultValue:"Ndodhi nje gabim."}))}finally{c(!1)}}}return((0,s.useEffect)(()=>{fetch("/api/customers/".concat(e,"/profile")).then(e=>e.json()).then(e=>{e.success&&u(e.data)}).finally(()=>i(!1))},[e]),o)?(0,t.jsx)("div",{className:"text-gray-500",children:a("loading",{defaultValue:"Duke ngarkuar..."})}):r?(0,t.jsxs)("div",{children:[(0,t.jsx)("h1",{className:"text-2xl font-bold mb-6",children:a("my_profile",{defaultValue:"Profili Im"})}),m&&(0,t.jsx)("div",{className:"bg-green-50 text-green-600 p-3 rounded-lg mb-4 text-sm",children:m}),(0,t.jsxs)("form",{onSubmit:g,className:"bg-white rounded-xl p-6 shadow-sm space-y-4",children:[(0,t.jsxs)("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-4",children:[(0,t.jsxs)("div",{children:[(0,t.jsx)("label",{className:"block text-sm font-medium text-gray-700 mb-1",children:a("name",{defaultValue:"Emri"})}),(0,t.jsx)("input",{type:"text",value:r.name,onChange:e=>u({...r,name:e.target.value}),className:"w-full border border-gray-300 rounded-lg px-4 py-2 focus:ring-2 focus:ring-orange-500 focus:border-transparent outline-none"})]}),(0,t.jsxs)("div",{children:[(0,t.jsx)("label",{className:"block text-sm font-medium text-gray-700 mb-1",children:a("surname",{defaultValue:"Mbiemri"})}),(0,t.jsx)("input",{type:"text",value:r.surname,onChange:e=>u({...r,surname:e.target.value}),className:"w-full border border-gray-300 rounded-lg px-4 py-2 focus:ring-2 focus:ring-orange-500 focus:border-transparent outline-none"})]})]}),(0,t.jsxs)("div",{children:[(0,t.jsx)("label",{className:"block text-sm font-medium text-gray-700 mb-1",children:"Email"}),(0,t.jsx)("input",{type:"email",value:r.email,disabled:!0,className:"w-full border border-gray-200 rounded-lg px-4 py-2 bg-gray-50 text-gray-500"})]}),(0,t.jsxs)("div",{children:[(0,t.jsx)("label",{className:"block text-sm font-medium text-gray-700 mb-1",children:a("phone",{defaultValue:"Telefoni"})}),(0,t.jsxs)("div",{className:"flex gap-2",children:[(0,t.jsx)("input",{type:"text",value:r.phonePrefix,disabled:!0,className:"w-20 border border-gray-200 rounded-lg px-3 py-2 bg-gray-50 text-gray-500"}),(0,t.jsx)("input",{type:"tel",value:r.phone,onChange:e=>u({...r,phone:e.target.value}),className:"flex-1 border border-gray-300 rounded-lg px-4 py-2 focus:ring-2 focus:ring-orange-500 focus:border-transparent outline-none"})]})]}),(0,t.jsxs)("div",{children:[(0,t.jsx)("label",{className:"block text-sm font-medium text-gray-700 mb-1",children:a("date_of_birth",{defaultValue:"Datelindja"})}),(0,t.jsx)("input",{type:"date",value:r.dateOfBirth,onChange:e=>u({...r,dateOfBirth:e.target.value}),className:"w-full border border-gray-300 rounded-lg px-4 py-2 focus:ring-2 focus:ring-orange-500 focus:border-transparent outline-none"})]}),(0,t.jsx)("button",{type:"submit",disabled:d,className:"bg-orange-500 hover:bg-orange-600 disabled:bg-orange-300 text-white font-semibold px-6 py-3 rounded-lg transition-colors",children:d?a("saving",{defaultValue:"Duke ruajtur..."}):a("save",{defaultValue:"Ruaj"})})]})]}):(0,t.jsx)("div",{className:"text-gray-500",children:a("error",{defaultValue:"Gabim ne ngarkimin e te dhenave."})})}},9376:function(e,a,r){"use strict";var t=r(5475);r.o(t,"useParams")&&r.d(a,{useParams:function(){return t.useParams}}),r.o(t,"usePathname")&&r.d(a,{usePathname:function(){return t.usePathname}}),r.o(t,"useRouter")&&r.d(a,{useRouter:function(){return t.useRouter}}),r.o(t,"useSearchParams")&&r.d(a,{useSearchParams:function(){return t.useSearchParams}})}},function(e){e.O(0,[8706,2971,2117,1744],function(){return e(e.s=9898)}),_N_E=e.O()}]);