veza/apps/web/dist_verification/assets/SellerDashboardView-ymVO9IBa.js
2026-02-07 20:36:48 +01:00

1 line
11 KiB
JavaScript

import{a as l,j as e}from"./vendor-react-YMhRUmcb.js";import{m as N,B as n,C as r,l as y}from"./index-D2uzyr9g.js";import{aZ as k,X as S,b9 as C,aq as D,aO as P,aP as E,g as A,aa as H,D as T,aC as u,ba as L,aM as R,w as $,a0 as F}from"./vendor-icons-DINCNwpk.js";import{m as I}from"./marketplaceService-BwlLR1ZR.js";import{c as g}from"./commerceService-bs-xd9qB.js";import"./vendor-fFnFILYR.js";import"./vendor-router-DX94Iu-2.js";import"./vendor-tanstack-CoFNL2zy.js";import"./vendor-utils-4BWoYre8.js";const M=({products:d,onClose:i,onStart:j})=>{const{addToast:x}=N(),[a,m]=l.useState([]),[c,p]=l.useState(20),[o,v]=l.useState(24),f=s=>{m(t=>t.includes(s)?t.filter(b=>b!==s):[...t,s])},h=()=>{if(a.length===0){x("Select at least one product","error");return}j({productIds:a,discount:c,duration:o}),i()};return e.jsxs("div",{className:"fixed inset-0 z-[100] flex items-center justify-center p-4",children:[e.jsx("div",{className:"absolute inset-0 bg-kodo-void/90 backdrop-blur-sm",onClick:i}),e.jsxs("div",{className:"relative w-full max-w-2xl bg-kodo-graphite border border-kodo-steel rounded-xl shadow-2xl animate-scaleIn overflow-hidden flex flex-col max-h-[85vh]",children:[e.jsxs("div",{className:"p-4 border-b border-kodo-steel bg-kodo-ink flex justify-between items-center",children:[e.jsxs("h3",{className:"font-bold text-white flex items-center gap-2",children:[e.jsx(k,{className:"w-5 h-5 text-kodo-gold"})," Start Flash Sale"]}),e.jsx("button",{onClick:i,children:e.jsx(S,{className:"w-5 h-5 text-kodo-content-dim hover:text-white"})})]}),e.jsxs("div",{className:"p-6 flex flex-col md:flex-row gap-6 flex-1 overflow-hidden",children:[e.jsxs("div",{className:"w-full md:w-1/2 space-y-6",children:[e.jsxs("div",{children:[e.jsx("label",{className:"block text-xs font-bold text-kodo-content-dim uppercase mb-2",children:"Discount Percentage"}),e.jsxs("div",{className:"relative",children:[e.jsx(C,{className:"absolute left-3 top-1/2 -translate-y-1/2 w-4 h-4 text-kodo-content-dim"}),e.jsx("input",{type:"number",className:"w-full bg-kodo-void border border-kodo-steel rounded pl-10 pr-4 py-2 text-white focus:border-kodo-gold outline-none",value:c,onChange:s=>p(Number(s.target.value)),min:5,max:90})]})]}),e.jsxs("div",{children:[e.jsx("label",{className:"block text-xs font-bold text-kodo-content-dim uppercase mb-2",children:"Duration (Hours)"}),e.jsxs("div",{className:"relative",children:[e.jsx(D,{className:"absolute left-3 top-1/2 -translate-y-1/2 w-4 h-4 text-kodo-content-dim"}),e.jsxs("select",{className:"w-full bg-kodo-void border border-kodo-steel rounded pl-10 pr-4 py-2 text-white focus:border-kodo-gold outline-none appearance-none",value:o,onChange:s=>v(Number(s.target.value)),children:[e.jsx("option",{value:1,children:"1 Hour"}),e.jsx("option",{value:6,children:"6 Hours"}),e.jsx("option",{value:12,children:"12 Hours"}),e.jsx("option",{value:24,children:"24 Hours"}),e.jsx("option",{value:48,children:"48 Hours"}),e.jsx("option",{value:72,children:"3 Days"})]})]})]}),e.jsxs("div",{className:"bg-kodo-gold/10 border border-kodo-gold/30 p-4 rounded-lg",children:[e.jsx("h4",{className:"text-kodo-gold font-bold text-sm mb-1",children:"Impact Summary"}),e.jsxs("p",{className:"text-xs text-kodo-text-main",children:["Applying a"," ",e.jsxs("span",{className:"font-bold text-white",children:[c,"%"]})," ","discount to"," ",e.jsx("span",{className:"font-bold text-white",children:a.length})," ","products. Sale ends in ",o," hours."]})]})]}),e.jsxs("div",{className:"w-full md:w-1/2 flex flex-col",children:[e.jsxs("div",{className:"flex justify-between items-center mb-2",children:[e.jsx("label",{className:"block text-xs font-bold text-kodo-content-dim uppercase",children:"Select Products"}),e.jsx("button",{className:"text-xs text-kodo-cyan hover:underline",onClick:()=>m(a.length===d.length?[]:d.map(s=>s.id)),children:a.length===d.length?"Deselect All":"Select All"})]}),e.jsx("div",{className:"flex-1 overflow-y-auto custom-scrollbar border border-kodo-steel rounded-lg bg-kodo-void p-2 space-y-1",children:d.map(s=>e.jsxs("div",{className:`flex items-center gap-4 p-2 rounded cursor-pointer transition-colors ${a.includes(s.id)?"bg-kodo-gold/10 border border-kodo-gold/30":"hover:bg-kodo-ink border border-transparent"}`,onClick:()=>f(s.id),children:[e.jsx("div",{className:`text-kodo-content-dim ${a.includes(s.id)?"text-kodo-gold":""}`,children:a.includes(s.id)?e.jsx(P,{className:"w-4 h-4"}):e.jsx(E,{className:"w-4 h-4"})}),e.jsx("img",{src:s.coverUrl,className:"w-8 h-8 rounded object-cover"}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx("div",{className:"text-sm font-bold text-white truncate",children:s.title}),e.jsxs("div",{className:"text-xs text-kodo-content-dim",children:["$",s.price]})]})]},s.id))})]})]}),e.jsxs("div",{className:"p-4 border-t border-kodo-steel bg-kodo-ink flex justify-end gap-4",children:[e.jsx(n,{variant:"ghost",onClick:i,children:"Cancel"}),e.jsx(n,{variant:"glass",onClick:h,className:"border-kodo-gold text-kodo-gold hover:bg-kodo-gold/10",children:"Launch Sale"})]})]})]})},_=({onCreateProduct:d})=>{const{addToast:i}=N(),[j,x]=l.useState(!1),[a,m]=l.useState([]),[c,p]=l.useState([]),[o,v]=l.useState({}),[f,h]=l.useState(!0);return l.useEffect(()=>{(async()=>{h(!0);try{const[t,b,w]=await Promise.all([I.listProducts({seller_id:"me"}),g.getSales(),g.getSellerStats()]);m(t.products||[]),p(b),v(w)}catch(t){y.error("Error loading seller dashboard data",{error:t instanceof Error?t.message:String(t),stack:t instanceof Error?t.stack:void 0})}finally{h(!1)}})()},[]),f?e.jsx("div",{className:"flex justify-center py-24",children:e.jsx(A,{className:"w-10 h-10 text-kodo-steel animate-spin"})}):e.jsxs("div",{className:"animate-fadeIn space-y-8 pb-20",children:[e.jsxs("div",{className:"flex flex-col md:flex-row justify-between items-end gap-4",children:[e.jsxs("div",{children:[e.jsx("h2",{className:"text-2xl font-display font-bold text-white mb-2",children:"SELLER DASHBOARD"}),e.jsx("p",{className:"text-kodo-content-dim font-mono text-sm",children:"Manage your products, sales, and analytics."})]}),e.jsxs("div",{className:"flex gap-4",children:[e.jsx(n,{variant:"glass",icon:e.jsx(k,{className:"w-4 h-4"}),onClick:()=>x(!0),children:"FLASH SALE"}),e.jsx(n,{variant:"primary",icon:e.jsx(H,{className:"w-4 h-4"}),onClick:d,children:"CREATE PRODUCT"})]})]}),e.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 lg:grid-cols-4 gap-6",children:[e.jsxs(r,{variant:"default",className:"p-6 relative overflow-hidden group",children:[e.jsx("div",{className:"absolute right-0 top-0 p-4 opacity-10 group-hover:opacity-20 transition-opacity",children:e.jsx(T,{className:"w-16 h-16 text-kodo-gold"})}),e.jsx("div",{className:"text-kodo-content-dim text-xs font-bold uppercase mb-1",children:"Total Revenue"}),e.jsxs("div",{className:"text-3xl font-mono font-bold text-white mb-2",children:["$",o.revenue?.toLocaleString()]}),e.jsxs("div",{className:"text-xs text-kodo-lime flex items-center gap-1",children:[e.jsx(u,{className:"w-3 h-3"})," +12.5% this month"]})]}),e.jsxs(r,{variant:"default",className:"p-6 relative overflow-hidden group",children:[e.jsx("div",{className:"absolute right-0 top-0 p-4 opacity-10 group-hover:opacity-20 transition-opacity",children:e.jsx(L,{className:"w-16 h-16 text-kodo-steel"})}),e.jsx("div",{className:"text-kodo-content-dim text-xs font-bold uppercase mb-1",children:"Total Sales"}),e.jsx("div",{className:"text-3xl font-mono font-bold text-white mb-2",children:o.sales}),e.jsxs("div",{className:"text-xs text-kodo-lime flex items-center gap-1",children:[e.jsx(u,{className:"w-3 h-3"})," +5.0% this month"]})]}),e.jsxs(r,{variant:"default",className:"p-6 relative overflow-hidden group",children:[e.jsx("div",{className:"absolute right-0 top-0 p-4 opacity-10 group-hover:opacity-20 transition-opacity",children:e.jsx(R,{className:"w-16 h-16 text-kodo-magenta"})}),e.jsx("div",{className:"text-kodo-content-dim text-xs font-bold uppercase mb-1",children:"Page Views"}),e.jsx("div",{className:"text-3xl font-mono font-bold text-white mb-2",children:o.views>1e3?`${(o.views/1e3).toFixed(1)}K`:o.views}),e.jsxs("div",{className:"text-xs text-kodo-red flex items-center gap-1",children:[e.jsx(u,{className:"w-3 h-3 rotate-180"})," -2.4% this month"]})]}),e.jsxs(r,{variant:"default",className:"p-6 relative overflow-hidden group",children:[e.jsx("div",{className:"absolute right-0 top-0 p-4 opacity-10 group-hover:opacity-20 transition-opacity",children:e.jsx($,{className:"w-16 h-16 text-white"})}),e.jsx("div",{className:"text-kodo-content-dim text-xs font-bold uppercase mb-1",children:"Conversion Rate"}),e.jsxs("div",{className:"text-3xl font-mono font-bold text-white mb-2",children:[o.conversion,"%"]}),e.jsxs("div",{className:"text-xs text-kodo-lime flex items-center gap-1",children:[e.jsx(u,{className:"w-3 h-3"})," +0.8% this month"]})]})]}),e.jsxs("div",{className:"grid grid-cols-1 lg:grid-cols-3 gap-8",children:[e.jsx("div",{className:"lg:col-span-2",children:e.jsxs(r,{variant:"default",className:"h-full",children:[e.jsxs("div",{className:"flex justify-between items-center mb-6",children:[e.jsx("h3",{className:"font-bold text-white",children:"Top Products"}),e.jsx(n,{variant:"ghost",size:"sm",children:"View All"})]}),e.jsx("div",{className:"space-y-4",children:a.map((s,t)=>e.jsxs("div",{className:"flex items-center gap-4 p-4 bg-kodo-ink rounded-lg border border-transparent hover:border-kodo-steel transition-all",children:[e.jsx("div",{className:"w-8 text-center font-mono text-kodo-content-dim",children:t+1}),e.jsx("img",{src:s.coverUrl,className:"w-12 h-12 rounded object-cover"}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx("div",{className:"font-bold text-white truncate",children:s.title}),e.jsxs("div",{className:"text-xs text-kodo-content-dim",children:[s.reviewCount," reviews • ",s.rating," stars"]})]}),e.jsxs("div",{className:"text-right",children:[e.jsxs("div",{className:"font-bold text-white",children:["$",s.price]}),e.jsxs("div",{className:"text-xs text-kodo-steel",children:[Math.floor(Math.random()*100)," sales"]})]}),e.jsx(n,{variant:"ghost",size:"icon",className:"h-8 w-8",children:e.jsx(F,{className:"w-4 h-4"})})]},s.id))})]})}),e.jsx("div",{children:e.jsxs(r,{variant:"default",className:"h-full",children:[e.jsx("h3",{className:"font-bold text-white mb-6",children:"Recent Sales"}),e.jsxs("div",{className:"space-y-4 relative",children:[e.jsx("div",{className:"absolute left-2.5 top-2 bottom-2 w-px bg-kodo-steel"}),c.map(s=>e.jsxs("div",{className:"relative pl-8",children:[e.jsx("div",{className:"absolute left-0 top-1.5 w-5 h-5 bg-kodo-graphite border border-kodo-lime rounded-full flex items-center justify-center",children:e.jsx("div",{className:"w-2 h-2 bg-kodo-lime rounded-full"})}),e.jsx("div",{className:"text-sm text-white font-bold",children:s.product}),e.jsxs("div",{className:"text-xs text-kodo-content-dim flex justify-between mt-1",children:[e.jsx("span",{children:s.buyer}),e.jsxs("span",{children:["$",s.amount]})]}),e.jsx("div",{className:"text-[10px] text-kodo-content-dim mt-1",children:s.date})]},s.id))]})]})})]}),j&&e.jsx(M,{products:a,onClose:()=>x(!1),onStart:s=>i(`Flash Sale started for ${s.productIds.length} products!`,"success")})]})};export{_ as SellerDashboardView};