PageSourceSearch

https://famliya.com/assets/MyProducts-DdygVBUb.js

js famliya.com collected 2026-10-07 00:39:13 UTC 7,126 bytes, 1 lines download raw bytes

1import{a as e,j as t}from"./react-vendor-CqHsZQT_.js";import{u as s,a as r}from"./redux-vendor-BfZbvXSg.js";import{I as a}from"./index.es-Com0I2Rl.js";import{b as o,$ as i}from"./module-BEkV5TVA.js";import{al as l,a as n,am as d,B as c,Z as m,an as p}from"./index-D014Qzp9.js";import{E as u}from"./EmptyProducts-Kf-zeDMJ.js";import{E as x}from"./EclipseMenu-uXFjMgse.js";import{f as h}from"./countryCurrency-BavGR93w.js";import{p as j,a as f}from"./productFlow-DHTheAyK.js";import{a as g}from"./CustomAvatar-CZHY18KB.js";import{a as b}from"./router-vendor-C4JZIx9V.js";import{A as y}from"./arrow-left-Bgm_LAoH.js";import{P as v}from"./Landing-CQAMz9wD.js";import{S as N}from"./search-CGIj9Ao4.js";import"./axios-vendor-Dos3PyFQ.js";import"./wrench-wwiHgNeK.js";import"./cn-DAcdz4in.js";import"./usePostOptions-DzFaP85u.js";import"./hooks-6eFa8m4S.js";import"./useShare-DmdjfZqu.js";import"./route-utils-B17bakVU.js";import"./ButtonTag-D808n9_D.js";import"./WarningModal-DF4Bu3jw.js";import"./iconBase-aaPXk6vE.js";import"./stripe-vendor-rb60VU3P.js";import"./api.esm-DY1U_RAb.js";import"./componentbase.esm-8EHr-s2O.js";import"./index-ClQ24ry2.js";import"./index-orf1FMJT.js";import"./InputTag-BfRUe3OX.js";import"./index-CkL0ACTb.js";import"./AddReportModal-Ct9DWOjm.js";import"./index.esm-D_Gzbkxm.js";import"./BaseModal-C_xkJMqE.js";import"./DeleteConfirmationModal-Cqv8su8m.js";import"./triangle-alert-Dax54eMU.js";import"./ellipsis-CIsPq-bf.js";import"./analytics-DAqqt3cq.js";const w="#34A853",k=["All","Active","Sold out","Paused"];function P({item:e,userData:s,onEdit:r,onDelete:a,onClick:o}){var i;const l=Number(e.salePrice)>0&&Number(e.salePrice)<Number(e.price),n=l?e.salePrice:e.price,d=e.trackStock&&Number(e.quantity)<=0,c="paused"===e.status?"Paused":"draft"===e.status?"Draft":"Active",m="Active"===c?"bg-emerald-50 text-emerald-700":"bg-gray-100 text-gray-600";return t.jsxs("div",{role:"button",tabIndex:0,onClick:o,onKeyDown:e=>"Enter"===e.key&&o(),className:"flex gap-3 p-3 rounded-2xl border border-gray-200 bg-white cursor-pointer",children:[t.jsx("img",{src:null==(i=e.media)?void 0:i[0],alt:e.title,className:"w-[72px] h-[72px] shrink-0 rounded-xl object-cover bg-gray-100"}),t.jsxs("div",{className:"flex-1 min-w-0",children:[t.jsxs("div",{className:"flex items-start justify-between gap-2",children:[t.jsx("p",{className:"font-medium text-[15px] text-gray-900 truncate pr-1",children:e.title}),t.jsx("div",{"data-no-navigate":!0,onClick:e=>e.stopPropagation(),children:t.jsx(x,{item:e,type:"product",isOwner:!0,userData:s,showBookmark:!1,showShare:!1,showReport:!1,showDelete:!0,onEdit:()=>r(e),onDelete:()=>a(e._id),iconSize:18,menuPosition:"right-0 top-6",deleteConfirmTitle:"Delete Product",deleteConfirmMessage:"Are you sure you want to delete this product? This action cannot be undone.",deleteConfirmType:"product"})})]}),t.jsxs("div",{className:"flex items-baseline gap-2 mt-0.5",children:[t.jsx("span",{className:"font-bold text-[15px] text-gray-900",children:h({...e,price:n})}),l&&t.jsx("span",{className:"text-[13px] text-gray-400 line-through",children:h(e)})]}),t.jsxs("div",{className:"flex flex-wrap gap-2 mt-2",children:[t.jsx("span",{className:`px-2.5 py-0.5 rounded-md text-[12px] font-medium ${m}`,children:c}),e.trackStock&&(d?t.jsx("span",{className:"px-2.5 py-0.5 rounded-md text-[12px] font-medium bg-red-50 text-red-600",children:"Out of stock"}):t.jsxs("span",{className:"px-2.5 py-0.5 rounded-md text-[12px] font-medium bg-emerald-50 text-emerald-700",children:[e.quantity," in stock"]}))]})]})]})}const C=()=>{const x=s(),h=b(),{currentProfile:C}=g(),{userData:D}=r(e=>e.user),{allProducts:S,currentPage:E,totalPages:A,hasNextPage:T,pagination:M,loading:_}=r(e=>e.marketPlace),[z,B]=e.useState(""),[F,I]=e.useState(""),[O,$]=e.useState("All"),[L,R]=e.useState([]),W=e.useRef(!1),q=(null==M?void 0:M.totalDocs)??L.length,G=L.length>0,H=!!F;e.useEffect(()=>{const e=setTimeout(()=>I(z.trim()),300);return()=>clearTimeout(e)},[z]),e.useEffect(()=>{_||W.current||R(S.length>0?S:[])},[S,_]);const Y=()=>{h("/business-page/addproduct?step=1")},Z=e=>{x(m()),x(p(j(e))),h(f(e))},K=e.useCallback(async(e=!1)=>{const t=null==C?void 0:C._id;if(t)try{W.current=e;const s=await x(l({refId:t,refName:"business",limit:16,page:e?E+1:1,...F&&{search:F}}));e&&l.fulfilled.match(s)&&R(e=>
1[...e,...s.payload.data||[]])}finally{W.current=!1}},[x,F,E,null==C?void 0:C._id]);e.useEffect(()=>{(null==C?void 0:C._id)&&(R([]),K(!1))},[F,null==C?void 0:C._id]);const X=e.useCallback(()=>{E<A&&!_&&K(!0)},[E,A,_,K]),J=async e=>{try{200===(await n.delete(d(e))).status&&(c.success("Product deleted successfully"),R(t=>t.filter(t=>t._id!==e)),K(!1))}catch{c.error("Failed to delete product")}};return t.jsxs("div",{className:"flex flex-col w-full min-h-full bg-white  m-4 rounded-2xl",children:[t.jsx("header",{className:"sticky top-0 z-20 bg-white px-4 pt-3 pb-2",children:t.jsxs("div",{className:"flex items-center gap-3",children:[t.jsx("button",{type:"button",onClick:()=>h(-1),className:"p-1 -ml-1","aria-label":"Back",children:t.jsx(y,{size:22})}),t.jsx("h1",{className:"text-[17px] font-bold leading-tight",children:"My Products"})]})}),t.jsxs("div",{className:"px-4 pt-1 pb-3",children:[t.jsxs("div",{className:"flex items-center justify-between mb-3",children:[t.jsxs("p",{className:"text-[13px] text-gray-400",children:[q," listed"]}),t.jsx("button",{type:"button",onClick:Y,className:"w-11 h-11 rounded-full flex items-center justify-center text-white shadow-md",style:{background:w},"aria-label":"Add product",children:t.jsx(v,{size:22,strokeWidth:2.5})})]}),t.jsxs("div",{className:"relative mb-3",children:[t.jsx(N,{size:18,className:"absolute left-4 top-1/2 -translate-y-1/2 text-gray-400 pointer-events-none"}),t.jsx("input",{type:"search",value:z,onChange:e=>B(e.target.value),placeholder:"Search products...",className:"w-full rounded-full bg-gray-100 py-3 pl-11 pr-4 text-[15px] outline-none placeholder:text-gray-400"})]}),t.jsx("div",{className:"flex gap-2 overflow-x-auto no-scrollbar",children:k.map(e=>{const s=O===e;return t.jsx("button",{type:"button",onClick:()=>$(e),className:"shrink-0 px-4 py-1.5 rounded-full text-[13px] font-medium "+(s?"bg-[#111827] text-white":"bg-gray-100 text-gray-600"),children:e},e)})})]}),_&&0===L.length?t.jsx("div",{className:"flex justify-center items-center h-64",children:t.jsx(o,{strokeColor:w,width:"30"})}):G?t.jsx("div",{id:"scrollableDiv",className:"flex-1 no-scrollbar px-4 pb-8",style:{overflowY:"auto"},children:t.jsx(a,{dataLength:L.length,next:X,hasMore:T,loader:t.jsx("div",{className:"flex justify-center items-center py-8",children:t.jsx(i,{height:40,width:40,color:w,ariaLabel:"loading"})}),scrollableTarget:"scrollableDiv",scrollThreshold:.9,children:t.jsx("div",{className:"  grid grid-cols-1 md:grid-cols-3  gap-3 pb-8",children:L.map(e=>t.jsx(P,{item:e,userData:D,onEdit:Z,onDelete:J,onClick:()=>h(`/business-page/product/${e.slug||e._id}`)},e._id))})})}):H?t.jsx("p",{className:"text-center text-gray-400 text-sm py-16",children:"No products match your search"}):t.jsx(u,{onClick:Y,isOwner:!0})]})};export{C 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.