(self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[9211],{1842:(e,t,s)=>{Promise.resolve().then(s.bind(s,6889))},5731:(e,t,s)=>{"use strict";s.d(t,{A:()=>a,F:()=>r});class o{getToken(){return localStorage.getItem("auth_token")}async request(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},s={"Content-Type":"application/json",Accept:"application/json"},o=this.getToken();o&&(s.Authorization="Bearer ".concat(o));let r="".concat(this.baseUrl).concat(e);try{let e=await fetch(r,{...t,headers:s});if(console.log("API Response status:",e.status,"for URL:",r),!e.ok){let t=await e.json().catch(()=>({message:"Request failed"}));if(console.error("API Error:",t),422===e.status)throw{response:{status:422,data:t}};if(401===e.status)throw localStorage.removeItem("auth_token"),localStorage.removeItem("auth_user"),{response:{status:401,data:t}};throw Error(t.message||"HTTP error! status: ".concat(e.status))}let o=await e.json();return console.log("API Response data:",o),o}catch(e){throw console.error("API request failed:",e),e}}async get(e){return console.log("API GET request to:","".concat(this.baseUrl).concat(e)),this.request(e,{method:"GET"})}async post(e,t){return this.request(e,{method:"POST",body:t?JSON.stringify(t):void 0})}async put(e,t){return this.request(e,{method:"PUT",body:t?JSON.stringify(t):void 0})}async patch(e,t){return this.request(e,{method:"PATCH",body:t?JSON.stringify(t):void 0})}async delete(e,t){return this.request(e,{method:"DELETE",body:t?JSON.stringify(t):void 0})}constructor(e){this.baseUrl=e}}let r=new o("http://localhost:8000/api"),a=r},6889:(e,t,s)=>{"use strict";s.r(t),s.d(t,{default:()=>n});var o=s(5155),r=s(2115),a=s(5731);function n(){let[e,t]=(0,r.useState)(""),[s,n]=(0,r.useState)(null),[l,c]=(0,r.useState)(null),[i,d]=(0,r.useState)(!1),u=async()=>{if(e){d(!0),c(null),n(null);try{console.log("Testing API call to:","/products/".concat(e));let t=await a.F.get("/products/".concat(e));console.log("Raw API response:",t),n(t)}catch(e){console.error("API Error:",e),c(e instanceof Error?e.message:"Unknown error")}finally{d(!1)}}};return(0,o.jsxs)("div",{className:"container mx-auto p-8",children:[(0,o.jsx)("h1",{className:"text-2xl font-bold mb-6",children:"API Debug Tool"}),(0,o.jsxs)("div",{className:"space-y-4",children:[(0,o.jsxs)("div",{children:[(0,o.jsx)("label",{className:"block text-sm font-medium mb-2",children:"Product Slug:"}),(0,o.jsx)("input",{type:"text",value:e,onChange:e=>t(e.target.value),className:"border border-gray-300 rounded px-3 py-2 w-full max-w-md",placeholder:"Enter product slug"})]}),(0,o.jsx)("button",{onClick:u,disabled:i||!e,className:"bg-blue-500 text-white px-4 py-2 rounded disabled:opacity-50",children:i?"Testing...":"Test API Call"})]}),l&&(0,o.jsxs)("div",{className:"mt-6 p-4 bg-red-100 border border-red-400 rounded",children:[(0,o.jsx)("h3",{className:"font-bold text-red-800",children:"Error:"}),(0,o.jsx)("p",{className:"text-red-700",children:l})]}),s&&(0,o.jsxs)("div",{className:"mt-6",children:[(0,o.jsx)("h3",{className:"font-bold mb-2",children:"API Response:"}),(0,o.jsx)("pre",{className:"bg-gray-100 p-4 rounded overflow-auto text-sm",children:JSON.stringify(s,null,2)})]})]})}}},e=>{var t=t=>e(e.s=t);e.O(0,[8441,1684,7358],()=>t(1842)),_N_E=e.O()}]);