PageSourceSearch

https://www.trouwassistent.nl/assets/AdminOrders-D9meo6_9.js

js trouwassistent.nl collected 2026-09-24 14:25:58 UTC 6,021 bytes, 1 lines download raw bytes

1import{j as e}from"./ui-CYi4GrVi.js";import{a as s}from"./react-vendor-CG7WfdSN.js";import{u as r,T as a,a as t,b as l,c as n,d,e as i}from"./table-Dni0kan0.js";import{s as o,k as c,B as p}from"./index-iEuQkT4g.js";import{I as h}from"./input-D19wRQsy.js";import{S as m,a as x,b as u,c as g,d as j}from"./select-DGMTmxRf.js";import{S as y}from"./skeleton-B6QodLIn.js";import{A as _,a as f}from"./alert-BsDNiuWy.js";import{D as b,a as v,b as N,c as w,d as A}from"./dialog-B04CrDt8.js";import{S}from"./search-CyVLK_r3.js";import{M as k}from"./map-pin-I54QfZ5Q.js";import"./supabase-BrKiwD5U.js";import"./charts-ChniAfy4.js";import"./chevron-up-CnuaC_y6.js";import"./check-DOMrFRp9.js";import"./x-DgJiIU8E.js";const C={pending:"In afwachting",confirmed:"Bevestigd",shipped:"Verzonden",delivered:"Geleverd",cancelled:"Geannuleerd"},L={pending:"bg-yellow-50 text-yellow-700 border-yellow-200",confirmed:"bg-blue-50 text-blue-700 border-blue-200",shipped:"bg-purple-50 text-purple-700 border-purple-200",delivered:"bg-green-50 text-green-700 border-green-200",cancelled:"bg-red-50 text-red-700 border-red-200"};function q(){const[q,B]=s.useState("all"),{data:z,isLoading:D,error:F}=function(e){return r({queryKey:["admin","orders",e],queryFn:async()=>{let s=o.from("shop_orders").select("\n          id,\n          ordered_at,\n          status,\n          seller_approved,\n          quantity,\n          unit_price,\n          total_amount,\n          shipping_address,\n          shop_products (\n            title,\n            category,\n            shop!shop_id(name)\n          )\n        ").order("ordered_at",{ascending:!1});e&&"all"!==e&&(s=s.eq("status",e));const{data:r,error:a}=await s;if(a)throw a;return(r??[]).map(e=>{const s=Array.isArray(e.shop_products)?e.shop_products[0]:e.shop_products;return{id:e.id,ordered_at:e.ordered_at,status:e.status,seller_approved:e.seller_approved,quantity:e.quantity,unit_price:e.unit_price,total_amount:e.total_amount,shipping_address:e.shipping_address,product_title:s?.title??null,product_category:s?.category??null,seller_name:(Array.isArray(s?.shop)?s.shop[0]:s?.shop)?.name??null}})},staleTime:6e4,retry:!1})}(q),[V,G]=s.useState(""),[M,T]=s.useState(null),I=s.useMemo(()=>{if(!z||!V)return z??[];const e=V.toLowerCase();return z.filter(s=>s.seller_name?.toLowerCase().includes(e)||s.product_title?.toLowerCase().includes(e)||s.shipping_address?.name?.toLowerCase().includes(e))},[z,V]);return e.jsxs("div",{className:"space-y-6",children:[e.jsxs("div",{children:[e.jsx("h1",{className:"text-2xl font-bold text-gray-900",children:"Bestellingen"}),e.jsx("p",{className:"text-sm text-gray-500 mt-1",children:"Alle shop-bestellingen platform-breed."})]}),e.jsxs("div",{className:"flex flex-col sm:flex-row gap-3",children:[e.jsxs("div",{className:"relative flex-1",children:[e.jsx(S,{className:"absolute left-3 top-1/2 -translate-y-1/2 h-4 w-4 text-gray-400"}),e.jsx(h,{placeholder:"Zoek op verkoper, product of klant...",value:V,onChange:e=>G(e.target.value),className:"pl-9"})]}),e.jsxs(m,{value:q,onValueChange:e=>B(e),children:[e.jsx(x,{className:"w-full sm:w-48",children:e.jsx(u,{placeholder:"Alle statussen"})}),e.jsxs(g,{children:[e.jsx(j,{value:"all",children:"Alle statussen"}),Object.keys(C).map(s=>e.jsx(j,{value:s,children:C[s]},s))]})]})]}),e.jsx("div",{className:"bg-white rounded-lg border shadow-sm overflow-hidden",children:F?e.jsx(_,{className:"m-4 bg-red-50 border-red-200",children:e.jsx(f,{className:"text-red-700",children:"Fout bij laden van bestellingen. Controleer de RLS-policies in Supabase."})}):D?e.jsx("div",{className:"p-4 space-y-2",children:Array.from({length:6}).map((s,r)=>e.jsx(y,{className:"h-12 w-full"},r))}):e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"px-4 py-2 border-b bg-gray-50 text-xs text-gray-500",children:[I.length," bestelling",1!==I.length?"en":""]}),e.jsx("div",{className:"overflow-x-auto",children:e.jsxs(a,{children:[e.jsx(t,{children:e.jsxs(l,{children:[e.jsx(n,{children:"Datum"}),e.jsx(n,{children:"Product"}),e.jsx(n,{children:"Verkoper"}),e.jsx(n,{children:"Klant"}),e.jsx(n,{className:"text-right",children:"Aantal"}),e.jsx(n,{className:"text-right",children:"Bedrag"}),e.jsx(n,{children:"Status"}),e.jsx(n,{})]})}),e.jsx(d,{children:0===I.length?e.jsx(l,{children:e.jsx(i,{colSpan:8,className:"text-center text-gray-400 py-8",children:"Geen bestellingen gevonden"})}):I.map(s=>{return e.jsxs(l,{children:[e.jsx(i,{className:"text-gray-600 whitespace-nowrap",children:(r=s.ordered_at,new Date(r).toLocaleDateString("nl-NL",{day:"numeric",month:"short",year:"numeric"}))}),e.jsx(i,{className:"font-medium",children:s.product_title??"—"}),e.jsx(i,{className:"text-gray-600",children:s.seller_name??"—"}),e.jsx(i,{className:"text-gray-600",children:s.shipping_address?.name??"—"}),e.jsx(i,{className:"text-right",children:s.quantity}),e.jsxs(i,{className:"text-right font-medium",children:["€",s.total_amount.toFixed(2)]}),e.jsx(i,{children:e.jsx(c,{variant:"outline",className:L[s.status],children:C[s.status]})}),e.jsx(i,{children:s.shipping_address&&e.jsx(p,{variant:"ghost",size:"sm",className:"h-7 px-2 text-gray-400 hover:text-gray-700",onClick:()=>T(s),children:e.jsx(k,{className:"h-3.5 w-3.5"})})})]},s.id);var r})})]})})]})}),e.jsx(b,{open:!!M,onOpenChange:()=>T(null),children:e.jsxs(v,{className:"max-w-sm",children:[e.jsxs(N,{children:[e.jsx(w,{children:"Bezorgadres"}),e.jsx(A,{className:"sr-only",children:"Bezorgadres van de geselecteerde bestelling."})]}),M&&e.jsxs("div",{className:"space-y-1 text-sm text-gray-700",children:[M.shipping_address?.name&&e.jsx("p",{className:"font-medium",children:M.shipping_address.name}),M.shipping_address?.street&&e.jsx("p",{children:M.shipping_address.street}),(M.shipping_address?.postal_code||M.shipping_address?.city)&&e.jsxs("p",{children:[M.shipping_address.postal_code," ",M.shipping_address.city]}),M.shipping_address?.country&&e.jsx("p",{className:"text-gray-500",children:M.shipping_address.country})]})]})})]})}export{q 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.