PageSourceSearch

https://en.b2b.cafe/assets/index-DP5jSmxA.js

js b2b.cafe collected 2026-09-24 14:36:10 UTC 9,951 bytes, 1 lines download raw bytes

1import{r as p,u as e,bh as H,bS as J,bT as Y,aW as G,am as Q}from"./vendor-DzWMmZj2.js";import{d as L,e as V}from"./vendor-tanstack-D-s8FawA.js";import{g as X}from"./index-icF_Tj8y.js";import{u as q,B as Z}from"./useTable-CFZmHKgO.js";import{x as A,L as ee,B as g,b as te}from"./index-B-ZZKIlh.js";import{u as U}from"./vendor-i18n-C7hD56hb.js";import"./vendor-socket-CdJ84v18.js";import"./vendor-phone-CDRp5aFf.js";const P=s=>{if(!s)return"—";const a=new Date(s*1e3),t=n=>String(n).padStart(2,"0");return"".concat(t(a.getDate()),".").concat(t(a.getMonth()+1),".").concat(String(a.getFullYear()).slice(-2)," • ").concat(t(a.getHours()),":").concat(t(a.getMinutes()))},se=s=>({id:"select",enableSorting:!1,header:()=>{const a=s.allIds.length>0&&s.allIds.every(n=>s.selected.has(n)),t=s.allIds.some(n=>s.selected.has(n))&&!a;return e.jsx(A,{checked:t?"indeterminate":a,onCheckedChange:s.toggleAll,"aria-label":"Выбрать всё"})},meta:{columnProps:{width:40},cellProps:{className:"flex items-center justify-center"},headerProps:{className:"flex items-center justify-center"}},cell:({row:a})=>{var o,m;const t=a.original,n=(o=t.id)!=null?o:-1;return e.jsx(A,{checked:s.selected.has(n),onCheckedChange:()=>s.toggleOne(n),"aria-label":"Выбрать ".concat((m=t.name)!=null?m:n)})}}),ae=s=>({accessorKey:"id",header:()=>e.jsx("span",{className:"text-sm text-muted-foreground whitespace-nowrap",children:s.t("stores.table.id")}),meta:{columnProps:{minWidth:90}},cell:({row:a})=>{var n;const t=a.original;return e.jsxs("div",{className:"flex flex-col gap-0.5",children:[e.jsxs("span",{className:"text-sm font-bold text-primary-black whitespace-nowrap",children:[s.t("stores.table.id")," ",(n=t.id)!=null?n:"—"]}),e.jsx("span",{className:"text-xs text-muted-foreground whitespace-nowrap",children:P(t.creationTime)})]})}}),ne=s=>({id:"name",accessorFn:a=>{var t;return(t=a.name)!=null?t:""},header:()=>e.jsx("span",{className:"text-sm text-muted-foreground",children:s.t("stores.table.name")}),meta:{columnProps:{minWidth:160}},cell:({row:a})=>{var n,o;const t=a.original;return e.jsxs("div",{className:"flex flex-col gap-0.5",children:[e.jsx("span",{className:"text-sm font-semibold text-primary-black",children:(n=t.name)!=null?n:"—"}),((o=t.distributor)==null?void 0:o.name)&&e.jsx("span",{className:"text-xs text-muted-foreground",children:t.distributor.name})]})}}),re=s=>({id:"managers",accessorFn:a=>{var t,n;return(n=(t=a.managers)==null?void 0:t.map(o=>o.name).join(", "))!=null?n:""},header:()=>e.jsx("span",{className:"text-sm text-muted-foreground",children:s.t("stores.table.manager")}),meta:{columnProps:{minWidth:180}},cell:({row:a})=>{var N;const n=(N=a.original.managers)!=null?N:[],o=2,m=n.slice(0,o),i=n.length-o;return e.jsxs("div",{className:"flex flex-col gap-0.5",children:[m.map(c=>e.jsx(ee,{to:"/users/one/".concat(c.id),className:"text-sm text-primary truncate max-w-[180px]",children:c.name},c.id)),i>0&&e.jsxs("span",{className:"text-xs text-muted-foreground",children:[s.t("stores.table.managers_more")," ",i]}),n.length===0&&e.jsx("span",{className:"text-sm text-muted-foreground",children:"—"})]})}}),oe=s=>({id:"countryLang",accessorFn:a=>{var t,n;return(n=(t=a.country)==null?void 0:t.name)!=null?n:""},header:()=>e.jsx("span",{className:"text-sm text-muted-foreground",children:s.t("stores.table.country_lang")}),meta:{columnProps:{minWidth:130}},cell:({row:a})=>{var n,o,m;const t=a.original;return e.jsxs("div",{className:"flex flex-col gap-0.5",children:[e.jsx("span",{className:"text-sm text-primary-black",children:(o=(n=t.country)==null?void 0:n.name)!=null?o:"—"}),((m=t.language)==null?void 0:m.name)&&e.jsx("span",{className:"text-xs text-muted-foreground",children:t.language.name})]})}}),le=s=>({id:"currency",accessorFn:a=>{var t,n;return(n=(t=a.currency)==null?void 0:t.name)!=null?n:""},header:()=>e.jsx("span",{className:"text-sm text-muted-foreground",children:s.t("stores.table.currency")}),meta:{columnProps:{minWidth:120}},cell:({row:a})=>{var n,o;const t=a.original;return e.jsx("span",{className:"text-sm text-primary-black",children:(o=(n=t.currency)==null?void 0:n.name)!=null?o:"—"})}}),ce=s=>({id:"priceUpdate",accessorFn:a=>{var t;return(t=a.priceUpdateTime)!=null?t:0},header:()=>e.jsx("span",{className:"text-sm text-muted-foreground whitespace-nowrap",children:s.t("stores.table.price_update")}),meta:{columnProps:{minWidth:130}},cell:({row:a})=>{const t=a.original;return e.jsx("span",{className:"text-sm text-primary-black whitespace-nowrap",children:P(t.priceUpdateTime)})}}),ie=s=>({id:"stockUpdate",accessorFn:a=>{var t;return(t=a.stockUpdateTime)!=null?t:0},header:()=>e.jsx("span",{className:"text-sm text-muted-foreground whitespace-nowrap",children:s.t("stores.table.stock_update")}),meta:{columnProps:{minWidth:130}},cell:({row:a})=>{const t=a.original;return e.jsx("span",{className:"text-sm text-primary-black whitespace-nowrap",children:P(t.stockUpdateTime)})}}),de=s=>({id:"actions",enableSorting:!1,header:()=>e.jsx("span",{className:"text-sm text-muted-foreground",children:s.t("stores.table.actions")}),meta:{columnProps:{minWidth:150},headerProps:{className:"justify-center"},cellProps:{className:"flex justify-center"}},cell:({row:a})=>{const t=a.original;return e.jsxs(g,{size:"sm",variant:"outline",className:"gap-1.5",onClick:n=>{n.stopPropagation(),s.onEdit(t.id)},children:[e.jsx(H,{className:"size-3.5"}),s.t("stores.table.edit")]})}}),me=({items:s,isLoading:a})=>{const{t}=U("stores"),n=L(),[o,m]=p.useState(new Set),i=p.useMemo(()=>s.flatMap(d=>d.id?[d.id]:[]),[s]),l={t,selected:o,allIds:i,toggleOne:d=>m(f=>{const j=new Set(f);
1return j.has(d)?j.delete(d):j.add(d),j}),toggleAll:()=>m(d=>i.every(f=>d.has(f))?new Set:new Set(i)),onEdit:d=>n({to:"/stores/one/$id",params:{id:String(d)}})},C=p.useMemo(()=>[se(l),ae(l),ne(l),re(l),oe(l),le(l),ce(l),ie(l),de(l)],[o,i,t]),{table:b,expandHandler:S,layout:v}=q({data:s,columns:C,enableSorting:!1});return e.jsx(Z,{mobileView:!1,table:b,isLoading:a,layout:v,expandHandler:S,empty:e.jsx("span",{className:"text-sm text-muted-foreground",children:"—"})})},{storesList:ue}=X(),F="stores_filters",xe=[25,50,100],pe=()=>{var s;try{return JSON.parse((s=localStorage.getItem(F))!=null?s:"{}")}catch(a){return{}}},he=s=>localStorage.setItem(F,JSON.stringify(s)),ge=()=>localStorage.removeItem(F),be=s=>Object.values(s).some(a=>a),O=(s,a,t)=>({offset:(a-1)*t,length:t,search:s.search||void 0}),fe=()=>{var T,z,E,I;const{t:s}=U("stores"),a=L(),t=V({strict:!1}),n=be(t)?t:pe(),[o,m]=p.useState([]),[i,N]=p.useState(0),[c,y]=p.useState(Number((T=n.page)!=null?T:"1")||1),[l,C]=p.useState(Number((z=n.length)!=null?z:"100")||100),[b,S]=p.useState((E=n.search)!=null?E:""),[v,d]=p.useState((I=n.search)!=null?I:""),f=p.useRef(!0),{isPending:j,mutateAsync:M}=te({mutationKey:["stores-list"],mutationFn:r=>ue(r),successFn:r=>{var h,u,_,W;m((u=(h=r==null?void 0:r.result)==null?void 0:h.items)!=null?u:[]),N((W=(_=r==null?void 0:r.result)==null?void 0:_.count)!=null?W:0)}}),k=(r,h,u)=>{he({...r,page:String(h),length:String(u)}),a({to:"/stores",search:{search:r.search,page:String(h)},replace:!0}),M(O(r,h,u))};p.useEffect(()=>{f.current&&(f.current=!1,M(O(n,c,l)))},[]);const $=()=>{d(b),y(1),k({search:b},1,l)},B=()=>{S(""),d(""),y(1),k({},1,l),ge()},w=r=>{y(r),k({search:v},r,l)},D=r=>{C(r),y(1),k({search:v},1,r)},x=Math.max(1,Math.ceil(i/l)),K=Math.min((c-1)*l+1,i),R=Math.min(c*l,i);return e.jsxs("div",{className:"flex flex-col gap-4",children:[e.jsxs("div",{className:"flex items-start justify-between gap-4",children:[e.jsxs("div",{children:[e.jsx("h1",{className:"text-conte-heading2 text-primary-black",children:s("stores.title")}),e.jsxs("div",{className:"flex items-center gap-2 mt-1",children:[e.jsx("span",{className:"text-sm text-muted-foreground",children:s("stores.filter.per_page")}),e.jsx("select",{value:l,onChange:r=>D(Number(r.target.value)),className:"text-sm border border-border rounded-md px-2 py-0.5 bg-background outline-none focus:border-primary",children:xe.map(r=>e.jsx("option",{value:r,children:r},r))})]}),i>0&&e.jsxs("p",{className:"text-xs text-muted-foreground mt-1",children:[s("stores.count_many",{count:i})," • ",s("stores.shown",{start:K,end:R})]})]}),e.jsxs("div",{className:"flex items-center gap-2 shrink-0",children:[e.jsxs(g,{size:"md",className:"gap-2",onClick:()=>a({to:"/stores/new"}),children:[e.jsx(J,{className:"size-4"}),s("stores.btn.add")]}),e.jsx(g,{size:"icon",variant:"outline",children:e.jsx(Y,{className:"size-4"})})]})]}),e.jsxs("div",{className:"bg-background rounded-xl border border-border overflow-hidden",children:[e.jsx("div",{className:"px-4 py-3 border-b border-border",children:e.jsxs("div",{className:"relative flex items-center",children:[e.jsx(G,{className:"absolute left-3 size-4 text-muted-foreground pointer-events-none"}),e.jsx("input",{type:"text",value:b,onChange:r=>S(r.target.value),onKeyDown:r=>r.key==="Enter"&&$(),placeholder:s("stores.filter.search_placeholder"),className:"w-full rounded-lg border border-border bg-background pl-9 pr-8 py-2 text-sm outline-none focus:border-primary"}),b&&e.jsx("button",{onClick:B,className:"absolute right-2.5 text-muted-foreground hover:text-primary-black",children:e.jsx(Q,{className:"size-4"})})]})}),e.jsx(me,{items:o,isLoading:j})]}),x>1&&e.jsxs("div",{className:"flex items-center justify-end gap-2",children:[e.jsx(g,{variant:"outline",size:"sm",disabled:c===1,onClick:()=>w(Math.max(1,c-1)),children:"←"}),Array.from({length:Math.min(x,5)},(r,h)=>{const u=c<=3?h+1:c+h-2;return u<1||u>x?null:e.jsx(g,{variant:u===c?"default":"outline",size:"sm",onClick:()=>w(u),children:u},u)}),x>5&&c<x-2&&e.jsx("span",{className:"text-sm text-muted-foreground",children:"..."}),x>5&&c<x-1&&e.jsx(g,{variant:"outline",size:"sm",onClick:()=>w(x),children:x}),e.jsx(g,{variant:"outline",size:"sm",disabled:c===x,onClick:()=>w(Math.min(x,c+1)),children:"→"})]})]})},Pe=fe;export{Pe as component};

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.