1import{ay as re,j as e,bR as ce,bt as de,bq as oe,dw as xe,c8 as pe,bg as me,g as i,az as W,dx as ue,b8 as _}from"./vendor-B15GE7q_.js";import{B as Q,as as z,at as he,au as J,av as fe,aw as A,ax as V,ay as E,az as F,aA as I,aB as ge,aC as je,aD as ve}from"./index-C82LlEg8.js";import{a as Ne}from"./professional-DHWgfCpa.js";function ye({item:t}){var c;const l=re();return e.jsxs("div",{className:"border border-[#d9d9d9] border-solid flex flex-col gap-[80px] overflow-clip px-[20px] py-[15px] relative rounded-[8px] bg-white",children:[e.jsxs("div",{className:"flex flex-col gap-[20px]",children:[e.jsx("div",{className:"flex justify-end",children:e.jsx(be,{item:t})}),e.jsxs("div",{className:"flex flex-col gap-[2px]",children:[e.jsx("h3",{className:"font-sans text-[16px] font-semibold leading-[24px] text-black",children:t.name}),e.jsxs("div",{className:"flex gap-[12px]",children:[t.cropVarietyName&&e.jsx("span",{className:"bg-[#dde6ff] flex h-[35px] items-center justify-center px-[12px] py-[5px] rounded-[4px] text-[14px] font-semibold leading-[20px] text-[#403cf5]",children:t.cropVarietyName}),t.grade&&e.jsx("span",{className:"bg-[#f1eeee] flex h-[35px] items-center justify-center px-[12px] py-[5px] rounded-[4px] text-[14px] font-semibold leading-[20px] text-black",children:t.grade})]})]}),e.jsxs("div",{className:"flex flex-col gap-[4px]",children:[e.jsxs("div",{className:"flex items-start gap-[5px]",children:[e.jsx("div",{className:"flex items-center justify-center rounded-[6px] p-[5px]",children:e.jsx(ce,{className:"h-[16px] w-[16px] text-gray-500"})}),e.jsxs("span",{className:"flex-1 py-[2px] text-[14px] font-semibold leading-[20px] text-[#666]",children:[t.name," ",t.cropVarietyName?`- ${t.cropVarietyName}`:""," ",t.grade?`- ${t.grade}`:""]})]}),e.jsxs("div",{className:"flex items-start gap-[5px]",children:[e.jsx("div",{className:"flex items-center justify-center rounded-[6px] p-[5px]",children:e.jsx(de,{className:"h-[16px] w-[16px] text-gray-500"})}),e.jsx("span",{className:"flex-1 py-[2px] text-[14px] font-semibold leading-[20px] text-[#666]",children:((c=t==null?void 0:t.farmerActor)==null?void 0:c.name)||(t==null?void 0:t.ownerName)||"Unknown Farmer"})]}),e.jsxs("div",{className:"flex items-start gap-[5px]",children:[e.jsx("div",{className:"flex items-center justify-center rounded-[6px] p-[5px]",children:e.jsx(oe,{className:"h-[16px] w-[16px] text-gray-500"})}),e.jsx("span",{className:"flex-1 py-[2px] text-[14px] font-semibold leading-[20px] text-[#666]",children:(t==null?void 0:t.storageName)||"Unknown Location"})]}),e.jsxs("div",{className:"flex items-start gap-[5px]",children:[e.jsx("div",{className:"flex items-center justify-center rounded-[6px] p-[5px]",children:e.jsx(xe,{className:"h-[16px] w-[16px] text-gray-500"})}),e.jsx("span",{className:"flex-1 py-[2px] text-[14px] font-semibold leading-[20px] text-[#666]",children:t.currentQuantity?`${t.currentQuantity} ${t.baseUnit||"kgs"}`:"N/A"})]})]})]}),e.jsx("div",{className:"h-px w-full bg-[#e6e6e6]"}),e.jsx("div",{className:"flex flex-col gap-[8px]",children:e.jsxs("div",{className:"flex items-center justify-between w-full",children:[e.jsxs("div",{children:[e.jsx("div",{className:"text-[14px] font-semibold leading-[20px] text-black",children:t.indicativePrice?`${t.indicativePrice} RWF/${t.baseUnit||"kg"}`:"Price not set"}),e.jsx("div",{className:"text-[12px] font-normal leading-[16px] text-[#808080]",children:"Indicative price"})]}),e.jsx(Q,{onClick:()=>l(`/public-inventory-details/${t.id}`),className:"flex items-center gap-[5px] rounded-[6px] bg-[#099773] px-[12px] py-[10px] text-white hover:bg-[#088566]",children:e.jsx("span",{className:"text-[14px] font-semibold leading-[20px]",children:"View details"})})]})})]})}function be({item:t}){const l=(t.verificationStatus||"").toUpperCase();return l==="UNVERIFIED"?e.jsxs("span",{className:"inline-flex items-center gap-1 rounded-[4px] bg-red-50 px-2.5 py-1 text-[11px] font-medium leading-4 text-red-700 ring-1 ring-red-200",children:[e.jsx(pe,{className:"h-3 w-3"}),"Unverified"]}):l==="VERIFIED"?e.jsxs("span",{className:"bg-[#e0f8e8] flex h-[35px] items-center justify-center gap-[5px] px-[12px] py-[5px] rounded-[4px]",children:[e.jsx(me,{className:"h-[16px] w-[16px] text-[#298d4f]"}),e.jsx("span",{className:"text-[14px] font-semibold leading-[20px] text-[#298d4f]",children:"Verified"})]}):e.jsx("span",{className:"flex items-center justify-center gap-[5px] rounded-[4px] bg-gray-100 px-[12px] py-[5px] text-gray-700",children:e.jsx("span",{className:"text-[14px] font-semibold leading-[20px]",children:t.verificationStatus||"Pending"})})}function X({open:t,onClose:l,cropTypes:c=[],unitTypes:n=[],unitMap:f={},onApply:v}){const[d,y]=i.useState(null),[S,T]=i.useState(""),[b,U]=i.useState([]),[w,C]=i.useState(""),[g,$]=i.useState("");console.log(c);function N(s){U(m=>m.includes(s)?m.filter(P=>P!==s):[...m,s])}return t?e.jsxs("div",{className:"border border-[#d9d9d9] border-solid w-full lg:w-64 roun
1ded-[2px] bg-white px-[20px] py-[10px] flex flex-col gap-[20px]",children:[e.jsxs("div",{className:"mb-4 flex items-center justify-between",children:[e.jsx("h4",{className:"text-[16px] font-bold leading-[24px] text-black",children:"Filter Options"}),e.jsx(Q,{onClick:l,className:"rounded-md px-2 py-1 text-xs text-gray-500 hover:text-gray-700 lg:hidden",children:"â"})]}),e.jsxs("section",{className:"space-y-5",children:[e.jsxs("div",{children:[e.jsx("p",{className:"mb-2 text-[14px] font-semibold text-[#666]",children:"CROP TYPE"}),e.jsx("div",{className:"max-h-40 space-y-2 overflow-y-auto pr-1",children:c.map(s=>e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(z,{id:`crop-${s==null?void 0:s.id}`,checked:(d==null?void 0:d.id)===s.id,onCheckedChange:m=>y(m?s:null)}),e.jsx("label",{htmlFor:`crop-${s==null?void 0:s.id}`,className:"text-sm text-gray-700 cursor-pointer select-none",children:s==null?void 0:s.name})]},(s==null?void 0:s.id)||(s==null?void 0:s.code)||(s==null?void 0:s.name)))})]}),e.jsxs("div",{children:[e.jsx("p",{className:"mb-2 text-xs font-medium text-gray-500",children:"Verification status"}),[{value:"VERIFIED",name:"Verified"},{value:"UNVERIFIED",name:"Unverified"}].map(s=>e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(z,{id:`ver-${s.value}`,checked:S===s.value,onCheckedChange:m=>T(m?s.value:"")}),e.jsx("label",{htmlFor:`ver-${s.value}`,className:"text-sm text-gray-700 cursor-pointer select-none",children:s.name})]},s.value))]}),e.jsxs("div",{children:[e.jsx("p",{className:"mb-2 text-xs font-medium text-gray-500",children:"Unit of measurement"}),e.jsx("div",{className:"max-h-40 overflow-y-auto pr-1",children:n.map(s=>e.jsxs("div",{className:"mt-2 flex items-center gap-2",children:[e.jsx(z,{id:`uom-${(s==null?void 0:s.id)||(s==null?void 0:s.name)}`,checked:b.includes(s==null?void 0:s.name),onCheckedChange:()=>N(s==null?void 0:s.name)}),e.jsx("label",{htmlFor:`uom-${(s==null?void 0:s.id)||(s==null?void 0:s.name)}`,className:"text-sm text-gray-700 cursor-pointer select-none",children:s==null?void 0:s.name})]},(s==null?void 0:s.id)||(s==null?void 0:s.name)))})]}),e.jsxs("div",{children:[e.jsx("p",{className:"mb-2 text-xs font-medium text-gray-500",children:"Quantity range"}),e.jsxs("div",{className:"grid grid-cols-2 gap-2",children:[e.jsx("input",{value:w,onChange:s=>C(s.target.value),type:"number",placeholder:"Min",className:"w-full rounded-[6px] border border-input px-3 py-2 text-sm focus:border-teal-600 focus:ring-teal-600"}),e.jsx("input",{value:g,onChange:s=>$(s.target.value),type:"number",placeholder:"Max",className:"w-full rounded-[6px] border border-input px-3 py-2 text-sm focus:border-teal-600 focus:ring-teal-600"})]}),e.jsx(Q,{onClick:()=>{v({commodityId:(d==null?void 0:d.id)||(d==null?void 0:d.code)||"",verificationStatus:S||"",baseUnit:f[b[0]]||b[0]||"",minQuantity:w||"",maxQuantity:g||""})},className:"flex mt-3 w-full items-center gap-[5px] rounded-[6px] bg-[#099773] px-[12px] py-[10px] text-white hover:bg-[#088566]",children:"Apply Filter"})]})]})]}):null}async function Se(){const t=await ge();return((t==null?void 0:t.items)||(t==null?void 0:t.content)||t||[]).map(c=>({id:c.id??c.code??c.value,title:c.title??c.name??c.label})).filter(c=>c.id&&c.title)}async function we(t){if(!t)return[];const l=await je(t);return((l==null?void 0:l.items)||(l==null?void 0:l.content)||l||[]).map(n=>({id:n.id??n.code??n.value,title:n.title??n.name??n.label})).filter(n=>n.id&&n.title)}async function Ce(t){if(!t)return[];const l=await ve(t);return((l==null?void 0:l.items)||(l==null?void 0:l.content)||l||[]).map(n=>({id:n.id??n.code??n.value,title:n.title??n.name??n.label})).filter(n=>n.id&&n.title)}const Z={Kilogram:"Kilogram","Kilogram (Kg)":"Kilogram",Gram:"Gram",Grams:"Gram",Ton:"Ton",Tonnes:"Ton",Liter:"Liter",Liters:"Liter",Pieces:"Piece"};function Ue(){const[t,l]=i.useState("my"),[c,n]=i.useState(""),[f,v]=i.useState(!1),[d,y]=i.useState({commodityId:"",verificationStatus:"",baseUnit:"",minQuantity:"",maxQuantity:"",province:"",district:"",sector:"",query:"",seasonId:""}),[S,T]=i.useState([]),[b,U]=i.useState([]),[w,C]=i.useState([]),[g,$]=i.useState(""),[N,s]=i.useState(""),[m,P]=i.useState(""),[L,M]=i.useState(0),[D]=i.useState(50),[B,K]=i.useState(!1),[k,ee]=i.useState([]),[O,se]=i.useState(0),[h,te]=i.useState("All"),[G,ae]=i.useState([]),[H,ie]=i.useState([]);i.useEffect(()=>{(async()=>{var a;try{const[{items:o=[]}={},{items:x=[]}={}]=await Promise.all([he.list({page:1,size:100,sort:"name,asc"}).catch(()=>({})),(a=J)!=null&&a.list?J.list({page:1,size:100,sort:"name,asc"}).catch(()=>({})):Promise.resolve({})]);ae(o||[]),ie(x||[])}catch{W.error("Could not load filters")}try{T(await Se())}catch{}})()},[]),i.useEffect(()=>{(async()=>
1{if(U([]),s(""),C([]),P(""),!!g)try{U(await we(g))}catch{}})()},[g]),i.useEffect(()=>{(async()=>{if(C([]),P(""),!!N)try{C(await Ce(N))}catch{}})()},[N]);const R=()=>{var p,u,r;const a=((p=S.find(j=>String(j.id)===String(g)))==null?void 0:p.title)||"",o=((u=b.find(j=>String(j.id)===String(N)))==null?void 0:u.title)||"",x=((r=w.find(j=>String(j.id)===String(m)))==null?void 0:r.title)||"";return{provinceName:a,districtName:o,sectorName:x}};i.useEffect(()=>{let a=!1;return(async()=>{var o,x,p;K(!0);try{const u={page:L,size:D,mode:t==="my"?"MY":"OTHERS",commodityId:d.commodityId||void 0,verificationStatus:d.verificationStatus||void 0,baseUnit:d.baseUnit||void 0,minQuantity:d.minQuantity||void 0,maxQuantity:d.maxQuantity||void 0,province:d.province||void 0,district:d.district||void 0,sector:d.sector||void 0,query:d.query||void 0,seasonId:d.seasonId||void 0},r=await Ne(u),j=Array.isArray(r)?r:(r==null?void 0:r.data)||((o=r==null?void 0:r.data)==null?void 0:o.content)||(r==null?void 0:r.items)||[];a||(ee(j),se(((x=r==null?void 0:r.meta)==null?void 0:x.total)??((p=r==null?void 0:r.meta)==null?void 0:p.totalElements)??(r==null?void 0:r.totalElements)??j.length??0))}catch{a||W.error("Failed to load public listings")}finally{a||K(!1)}})(),()=>{a=!0}},[L,D,d,t]);const le=i.useMemo(()=>{const a=new Set(k.map(o=>o.seasonName||o.season).filter(Boolean));return Array.from(a).sort().reverse()},[k]),q=i.useMemo(()=>h&&h!=="All"?k.filter(a=>(a.seasonName||a.season)===h):k,[k,h]),Y=O===0?0:L*D+1,ne=Y+q.length-1;return e.jsx("div",{className:"min-h-screen bg-[#F3F4F6]",children:e.jsxs("div",{className:"space-y-[10px]",children:[e.jsx(fe,{title:"Public Listing",module:"Home",feature:"Public Listing"}),e.jsx("div",{className:"bg-white rounded p-4",children:e.jsxs("div",{className:"flex flex-col gap-3 sm:flex-row sm:items-end sm:justify-between",children:[e.jsxs("div",{children:[e.jsxs("p",{className:"text-sm font-semibold text-gray-900",children:["My Published Listings ",h!=="All"?`â ${h}`:""]}),e.jsxs("p",{className:"mt-1 text-xs text-gray-500",children:["See and manage all inventories open to buyers ",h!=="All"?`in ${h}`:""]})]}),e.jsx("div",{className:"w-40",children:e.jsxs(A,{value:h,onValueChange:te,children:[e.jsx(V,{children:e.jsx(E,{placeholder:"Select Season"})}),e.jsxs(F,{children:[e.jsx(I,{value:"All",children:"All Seasons"}),le.map(a=>e.jsx(I,{value:a,children:a},a))]})]})})]})}),e.jsx("div",{className:"mx-auto",children:e.jsx("div",{className:"mt-4 rounded-lg border border-[#d9d9d9] border-solid bg-white",children:e.jsxs("div",{className:"px-6 pb-6 pt-4",children:[e.jsxs("div",{className:"mt-4 grid grid-cols-1 gap-3 sm:grid-cols-2 lg:grid-cols-4 xl:grid-cols-7",children:[e.jsx("div",{className:"sm:col-span-1",children:e.jsxs("button",{onClick:()=>v(a=>!a),className:"inline-flex w-full items-center justify-center gap-2 rounded-md border border-input bg-white px-3 py-2 text-sm hover:border-teal-600",children:[e.jsx(ue,{className:"h-4 w-4"}),f?"Hide filter":"Filter"]})}),e.jsx("div",{className:"sm:col-span-2",children:e.jsxs("div",{className:"relative",children:[e.jsx("input",{value:c,onChange:a=>n(a.target.value),className:"w-full rounded-md border border-input bg-white py-2 pl-9 pr-3 text-sm placeholder:text-gray-400 focus:border-teal-600 focus:ring-teal-600",placeholder:"Search"}),e.jsx(_,{className:"pointer-events-none absolute left-2.5 top-2.5 h-4 w-4 text-gray-400"})]})}),e.jsx("div",{className:"sm:col-span-1",children:e.jsxs(A,{value:g||void 0,onValueChange:$,children:[e.jsx(V,{className:"w-full",children:e.jsx(E,{placeholder:"Province"})}),e.jsx(F,{children:S.map(a=>e.jsx(I,{value:String(a.id),children:a.title},a.id))})]})}),e.jsx("div",{className:"sm:col-span-1",children:e.jsxs(A,{value:N||void 0,onValueChange:s,children:[e.jsx(V,{className:"w-full",children:e.jsx(E,{placeholder:"District"})}),e.jsx(F,{children:b.map(a=>e.jsx(I,{value:String(a.id),children:a.title},a.id))})]})}),e.jsx("div",{className:"sm:col-span-1",children:e.jsxs(A,{value:m||void 0,onValueChange:P,children:[e.jsx(V,{className:"w-full",children:e.jsx(E,{placeholder:"Sector"})}),e.jsx(F,{children:w.map(a=>e.jsx(I,{value:String(a.id),children:a.title},a.id))})]})}),e.jsx("div",{className:"sm:col-span-1",children:e.jsxs(Q,{className:"flex items-center justify-center w-full gap-[5px] rounded-[6px] bg-[#099773] px-[12px] py-[10px] text-white hover:bg-[#088566] h-[44px]",onClick:()=>{const{provinceName:a,districtName:o,sectorName:x}=R();y(p=>({...p,province:a,district:o,sector:x,query:c||""})),M(0)},children:[e.jsx(_,{className:"h-4 w-4"}),e.jsx("span",{className:"text-[14px] font-semibold leading-[20px]",children:"Search"})]})})]}),e.jsxs("div",{className:"mt-5 lg:flex lg:items-start lg:gap-6",children:[f&&e.jsx("div",{className:"mb-4 lg:mb-0",children:e.jsx(X,{open:f,onClose:()=>v(!1),cropTypes:G,unitTypes:H,unitMap:Z,onApply:a=>{const{provinceName:o,districtName:x,sectorName:p}=R();y(u=>({...u,...a})),y(u=>({...u,...a,province:o,district:x,sector:p,query:c||""})),M(0)}})}),e.jsxs("div",{className:"flex-1",children:[e.jsxs("div",{className:`grid grid-cols-1 gap-5 md:grid-cols-2 ${f?"lg:grid-cols-2":"lg:grid-cols-3"}`,children:[q.map(a=>e.jsx(ye,{item:a},a.id)),!B&&q.length===0&&e.jsx("p",{className:"col-span-full text-center text-sm text-gray-500",children:"No listings found."})]}),e.jsx("div",{className:"mt-6 flex items-center justify-between text-xs text-gray-500",children:e.jsxs("span",{children:["Showing ",Y,"-",ne," of ",O," results"]})}),B&&e.jsxs("div",{className:"mt-8 text-center",children:[e.jsx("div",{className:"animate-spin h-8 w-8 border-4 border-[#099773] border-t-transparent roun
1ded-full mx-auto mb-4"}),e.jsx("p",{className:"text-[#666] text-sm",children:"Loading public listings..."})]})]})]})]})})}),f&&e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"fixed inset-0 z-30 bg-black/30 lg:hidden",onClick:()=>v(!1)}),e.jsx("div",{className:"fixed inset-y-0 left-0 z-40 w-80 bg-white p-4 shadow-xl lg:hidden",children:e.jsx(X,{open:f,onClose:()=>v(!1),cropTypes:G,unitTypes:H,unitMap:Z,onApply:a=>{const{provinceName:o,districtName:x,sectorName:p}=R();y(u=>({...u,...a,province:o,district:x,sector:p,query:c||""})),M(0),v(!1)}})})]})]})})}export{Ue 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.