PageSourceSearch

https://pricemate.info/_nuxt/Dt2rYvmD.js

js pricemate.info collected 2026-10-02 00:39:11 UTC 6,228 bytes, 1 lines download raw bytes

1import{f as V,ak as U,G as b,J as $,X as L,D as l,E as s,L as h,U as y,$ as B,O as i,S as d,V as E,Q as S,R as A,W as D,F as r}from"./YmqgnTXc.js";import{useAuth as F}from"./CRxV7opB.js";const I={class:"max-w-4xl mx-auto p-4 md:p-6"},M={key:0,class:"flex justify-center py-8"},N={key:1,class:"bg-red-100 border border-red-400 text-red-700 px-4 py-3 rounded mb-4"},R={key:2,class:"bg-green-100 border border-green-400 text-green-700 px-4 py-3 rounded mb-4"},q={class:"grid grid-cols-1 md:grid-cols-2 gap-6"},P={class:"space-y-2"},T={class:"space-y-2"},j={class:"flex items-center"},z={class:"space-y-2"},G={class:"grid grid-cols-1 md:grid-cols-2 gap-6"},J={class:"space-y-2"},O={class:"space-y-2"},Q={key:0,class:"space-y-4"},W={class:"grid grid-cols-1 md:grid-cols-2 gap-4"},X={class:"block text-sm font-medium text-gray-700"},Y=["onUpdate:modelValue"],H={class:"flex justify-end space-x-3"},K=["disabled"],Z={key:0},ee={key:1},re={__name:"[id]",setup(te){const v=V().public.apiBase,_=U(),c=L(),k=F(),x=_.params.id,n=b(null),a=b(!1),u=b(null),f=b(null),o=b({name:"",price:0,negotiable:!1,description:"",category_id:null,location:"",sellerContact:"",attributes:{}}),w=async()=>{var e;const m=localStorage.getItem("auth_token");try{a.value=!0,u.value=null;const t=await $fetch(`${v}/api/listings/${x}`,{headers:{Authorization:`Bearer ${m}`}});if(!t)throw new Error("Listing not found");n.value=t,o.value={name:t.name||"",price:t.price||0,negotiable:t.negotiable||!1,description:t.description||"",category_id:t.category_id||null,location:t.location||"",sellerContact:t.sellerContact||"",attributes:{}},t.attributes&&Array.isArray(t.attributes)&&(o.value.attributes=t.attributes.reduce((p,g)=>(g&&g.attribute_id&&(p[g.attribute_id]=g.value||""),p),{}))}catch(t){u.value=((e=t.data)==null?void 0:e.message)||t.message||"Failed to fetch listing",console.error("Error fetching listing:",t),c.push("/my-profile/dashboard/listings")}finally{a.value=!1}},C=async()=>{var e;const m=localStorage.getItem("auth_token");try{a.value=!0,u.value=null,await $fetch(`${v}/api/listings/${x}`,{method:"PUT",headers:{Authorization:`Bearer ${m}`},body:o.value}),f.value="Your changes have been submitted for approval",setTimeout(()=>{c.push("/my-profile/dashboard/listings")},2e3)}catch(t){u.value=((e=t.data)==null?void 0:e.message)||t.message||"Failed to update listing",console.error("Error updating listing:",t)}finally{a.value=!1}};return $(()=>{k.isLoggedIn.value?w():c.push("/auth/login")}),(m,e)=>(r(),l("div",I,[e[15]||(e[15]=s("h1",{class:"text-2xl font-bold mb-6"},"Edit Listing",-1)),a.value&&!n.value?(r(),l("div",M,[...e[7]||(e[7]=[s("div",{class:"animate-spin rounded-full h-12 w-12 border-t-2 border-b-2 border-blue-500"},null,-1)])])):u.value?(r(),l("div",N,y(u.value),1)):f.value?(r(),l("div",R,y(f.value),1)):n.value?(r(),l("form",{key:3,onSubmit:B(C,["prevent"]),class:"space-y-6"},[s("div",q,[s("div",P,[e[8]||(e[8]=s("label",{class:"block text-sm font-medium text-gray-700"},"Listing Name",-1)),i(s("input",{"onUpdate:modelValue":e[0]||(e[0]=t=>o.value.name=t),type:"text",class:"w-full px-3 py-2 border border-gray-300 rounded-md shadow-sm focus:outline-none focus:ring-blue-500 focus:border-blue-500",required:""},null,512),[[d,o.value.name]])]),s("div",T,[e[9]||(e[9]=s("label",{class:"block text-sm font-medium text-gray-700"},"Price",-1)),i(s("input",{"onUpdate:modelValue":e[1]||(e[1]=t=>o.value.price=t),type:"number",min:"0",step:"0.01",class:"w-full px-3 py-2 border border-gray-300 rounded-md shadow-sm focus:outline-none focus:ring-blue-500 focus:border-blue-500",required:""},null,512),[[d,o.value.price,void 0,{number:!0}]])])]),s("div",j,[i(s("input",{"onUpdate:modelValue":e[2]||(e[2]=t=>o.value.negotiable=t),type:"checkbox",id:"negotiable",class:"h-4 w-4 text-blue-600 focus:ring-blue-500 border-gray-300 rounded"},null,512),[[E,o.value.negotiable]]),e[10]||(e[10]=s("label",{for:"negotiable",class:"ml-2 block text-sm text-gray-700"},"Price is negotiable",-1))]),s("div",z,[e[11]||(e[11]=s("label",{class:"block text-sm font-medium text-gray-700"},"Description",-1)),i(s("textarea",{"onUpdate:modelValue":e[3]||(e[3]=t=>o.value.description=t),rows:"4",class:"w-full px-3 py-2 border border-gray-300 rounded-md shadow-sm focus:outline-none focus:ring-blue-500 focus:border-blue-500"},null,512),[[d,o.value.description]])]),s("div",G,[s("div",J,[e[12]||(e[12]=s("label",{class:"block text-sm font-medium text-gray-700"},"Location",-1)),i(s("input",{"onUpdate:modelValue":e[4]||(e[4]=t=>o.value.location=t),type:"text",class:"w-full px-3 py-2 border border-gray-300 rounded-md shadow-sm focus:outline-none focus:ring-blue-500 focus:border-blue-500"},null,512),[[d,o.value.location]])]),s("div",O,[e[13]||(e[13]=s("label",{class:"block text-sm font-medium text-gray-700"},"Contact Number",-1)),i(s("input",{"onUpdate:modelValue":e[5]||(e[5]=t=>o.value.sellerContact=t),type:"tel",class:"w-full px-3 py-2 border border-gray-300 rounded-md shadow-sm focus:outline-none focus:ring-blue-500 focus:border-blue-500",required:""},null,512),[[d,o.value.sellerContact]])])]),n.value.attributes&&n.value.attributes.length>0?(r(),l("div",Q,[e[14]||(e[14]=s("h3",{class:"text-lg font-medium"},"Attributes",-1)),s("div",W,[(r(!0),l(S,null,A(n.value.attributes,t=>(r(),l("div",{key:t.attribute_id,class:"space-y-2"},[s("label",X,y(t.name),1),i(s("input",{"onUpdate:modelValue":p=>o.value.attributes[t.attribute_id]=p,type:"text",class:"w-full px-3 py-2 border border-gray-300 rounded-md shadow-sm focus:outline-none focus:ring-blue-500 focus:border-blue-500"},null,8,Y),[[d,o.value.attributes[t.attribute_id]]])]))),128))])])):h("",!0),s("div",H,[s("button",{type:"button",onClick:e[6]||(e[6]=t=>D(c).push("/my-profile/dashboard/listings")),class:"px-4 py-2 border border-gray-300 rounded-md text-sm font-medium text-gray-700 hover:bg-gray-50"}," Cancel "),s("button",{type:"submit",class:"px-4 py-2 border border-transparent roun
1ded-md shadow-sm text-sm font-medium text-white bg-blue-600 hover:bg-blue-700 focus:outline-none focus:ring-2 focus:ring-offset-2 focus:ring-blue-500",disabled:a.value},[a.value?(r(),l("span",Z,"Submitting...")):(r(),l("span",ee,"Submit Changes"))],8,K)])],32)):h("",!0)]))}};export{re as default};

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.