Bloc A - Code mort: - Suppression Studio (components, views, features) - Suppression gamification + services mock (projectService, storageService, gamificationService) - Mise à jour Sidebar, Navbar, locales Bloc B - Frontend: - Suppression modal.tsx deprecated, Modal.stories (doublon Dialog) - Feature flags: PLAYLIST_SEARCH, PLAYLIST_RECOMMENDATIONS, ROLE_MANAGEMENT = true - Suppression 19 tests orphelins, retrait exclusions vitest.config Bloc C - Backend: - Extraction routes_auth.go depuis router.go Bloc D - Rust: - Suppression security_legacy.rs (code mort, patterns déjà dans security/)
1 line
12 KiB
JavaScript
1 line
12 KiB
JavaScript
import{a as r,j as e}from"./vendor-react-yWUy5XPk.js";import{u as k,B as n,l as D,i as P,E as R,C as x}from"./index-CYK_b1Uz.js";import{Z as C,X as A,x as T,y as H,z as L,B as F,g as I,P as w,D as y,F as $,T as g,a as z,U,m as M}from"./vendor-icons-DJFb1Tiw.js";import{m as B}from"./marketplaceService-DWfxNVms.js";import{c as S}from"./commerceService-bs-xd9qB.js";import"./vendor-CveO81sn.js";import"./vendor-security-DsrNJhpn.js";import"./vendor-router-BNNHboN9.js";import"./vendor-tanstack-kPY9uK0s.js";import"./vendor-http-Cz8wfb0q.js";import"./vendor-utils-DtoSyhX2.js";import"./vendor-motion-B3XPS3Jc.js";import"./vendor-i18n-CMcqpBLz.js";const O=({products:o,onClose:i,onStart:j})=>{const{addToast:u}=k(),[a,h]=r.useState([]),[d,p]=r.useState(20),[l,b]=r.useState(24),v=t=>{h(c=>c.includes(t)?c.filter(m=>m!==t):[...c,t])},f=()=>{if(a.length===0){u("Select at least one product","error");return}j({productIds:a,discount:d,duration:l}),i()};return e.jsxs("div",{className:"fixed inset-0 z-[var(--sumi-z-modal)] flex items-center justify-center p-4",children:[e.jsx("div",{className:"absolute inset-0 bg-background/90 backdrop-blur-sm",onClick:i}),e.jsxs("div",{className:"relative w-full max-w-2xl bg-muted border border-border rounded-xl shadow-2xl animate-scaleIn overflow-hidden flex flex-col max-h-layout-modal",children:[e.jsxs("div",{className:"p-4 border-b border-border bg-card flex justify-between items-center",children:[e.jsxs("h3",{className:"font-bold text-foreground flex items-center gap-2",children:[e.jsx(C,{className:"w-5 h-5 text-warning"})," Start Flash Sale"]}),e.jsx("button",{onClick:i,children:e.jsx(A,{className:"w-5 h-5 text-muted-foreground hover:text-foreground"})})]}),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-muted-foreground uppercase mb-2",children:"Discount Percentage"}),e.jsxs("div",{className:"relative",children:[e.jsx(T,{className:"absolute left-3 top-1/2 -translate-y-1/2 w-4 h-4 text-muted-foreground"}),e.jsx("input",{type:"number",className:"w-full bg-background border border-border rounded pl-10 pr-4 py-2 text-foreground focus:border-warning outline-none focus-visible:ring-2 focus-visible:ring-ring",value:d,onChange:t=>p(Number(t.target.value)),min:5,max:90})]})]}),e.jsxs("div",{children:[e.jsx("label",{className:"block text-xs font-bold text-muted-foreground uppercase mb-2",children:"Duration (Hours)"}),e.jsxs("div",{className:"relative",children:[e.jsx(H,{className:"absolute left-3 top-1/2 -translate-y-1/2 w-4 h-4 text-muted-foreground"}),e.jsxs("select",{className:"w-full bg-background border border-border rounded pl-10 pr-4 py-2 text-foreground focus:border-warning outline-none focus-visible:ring-2 focus-visible:ring-ring appearance-none",value:l,onChange:t=>b(Number(t.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-warning/10 border border-warning/30 p-4 rounded-lg",children:[e.jsx("h4",{className:"text-warning font-bold text-sm mb-1",children:"Impact Summary"}),e.jsxs("p",{className:"text-xs text-foreground",children:["Applying a"," ",e.jsxs("span",{className:"font-bold text-foreground",children:[d,"%"]})," ","discount to"," ",e.jsx("span",{className:"font-bold text-foreground",children:a.length})," ","products. Sale ends in ",l," 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-muted-foreground uppercase",children:"Select Products"}),e.jsx("button",{className:"text-xs text-primary hover:underline",onClick:()=>h(a.length===o.length?[]:o.map(t=>t.id)),children:a.length===o.length?"Deselect All":"Select All"})]}),e.jsx("div",{className:"flex-1 overflow-y-auto custom-scrollbar border border-border rounded-lg bg-background p-2 space-y-1",children:o.map(t=>e.jsxs("div",{className:`flex items-center gap-4 p-2 rounded cursor-pointer transition-colors ${a.includes(t.id)?"bg-warning/10 border border-warning/30":"hover:bg-card border border-transparent"}`,onClick:()=>v(t.id),children:[e.jsx("div",{className:`text-muted-foreground ${a.includes(t.id)?"text-warning":""}`,children:a.includes(t.id)?e.jsx(L,{className:"w-4 h-4"}):e.jsx(F,{className:"w-4 h-4"})}),e.jsx("img",{src:t.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-foreground truncate",children:t.title}),e.jsxs("div",{className:"text-xs text-muted-foreground",children:["$",t.price]})]})]},t.id))})]})]}),e.jsxs("div",{className:"p-4 border-t border-border bg-card flex justify-end gap-4",children:[e.jsx(n,{variant:"ghost",onClick:i,children:"Cancel"}),e.jsx(n,{variant:"glass",onClick:f,className:"border-warning text-warning hover:bg-warning/10",children:"Launch Sale"})]})]})]})},te=({onCreateProduct:o})=>{const{addToast:i}=k(),[j,u]=r.useState(!1),[a,h]=r.useState([]),[d,p]=r.useState([]),[l,b]=r.useState({}),[v,f]=r.useState(!0),[t,c]=r.useState(null),m=r.useCallback(async()=>{f(!0),c(null);try{const[s,N,E]=await Promise.all([B.listProducts({seller_id:"me"}),S.getSales(),S.getSellerStats()]);h(s.products||[]),p(N),b(E)}catch(s){D.error("Error loading seller dashboard data",{error:s instanceof Error?s.message:String(s),stack:s instanceof Error?s.stack:void 0}),c(s instanceof Error?s:new Error(String(s)))}finally{f(!1)}},[]);return r.useEffect(()=>{m()},[m]),v?e.jsx("div",{className:"flex justify-center py-24",children:e.jsx(I,{className:"w-10 h-10 text-muted-foreground animate-spin"})}):t?e.jsx("div",{className:"pb-20",children:e.jsx(P,{error:t,onRetry:m,title:"Failed to load seller dashboard",context:{action:"loading",resource:"seller dashboard"},variant:"card"})}):a.length===0&&d.length===0?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-heading font-bold text-foreground mb-2",children:"SELLER DASHBOARD"}),e.jsx("p",{className:"text-muted-foreground font-mono text-sm",children:"Manage your products, sales, and analytics."})]}),e.jsx(n,{variant:"primary",icon:e.jsx(w,{className:"w-4 h-4"}),onClick:o,children:"CREATE PRODUCT"})]}),e.jsx(R,{icon:e.jsx(y,{className:"w-full h-full"}),title:"No products yet",description:"Create your first product to start selling and see your dashboard stats.",action:{label:"Create Product",onClick:o},size:"lg",className:"min-h-96"})]}):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-heading font-bold text-foreground mb-2",children:"SELLER DASHBOARD"}),e.jsx("p",{className:"text-muted-foreground 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(C,{className:"w-4 h-4"}),onClick:()=>u(!0),children:"FLASH SALE"}),e.jsx(n,{variant:"primary",icon:e.jsx(w,{className:"w-4 h-4"}),onClick:o,children:"CREATE PRODUCT"})]})]}),e.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 lg:grid-cols-4 gap-6",children:[e.jsxs(x,{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-warning"})}),e.jsx("div",{className:"text-muted-foreground text-xs font-bold uppercase mb-1",children:"Total Revenue"}),e.jsxs("div",{className:"text-3xl font-mono font-bold text-foreground mb-2",children:["$",l.revenue?.toLocaleString()]}),e.jsxs("div",{className:"text-xs text-success flex items-center gap-1",children:[e.jsx(g,{className:"w-3 h-3"})," +12.5% this month"]})]}),e.jsxs(x,{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(y,{className:"w-16 h-16 text-muted-foreground"})}),e.jsx("div",{className:"text-muted-foreground text-xs font-bold uppercase mb-1",children:"Total Sales"}),e.jsx("div",{className:"text-3xl font-mono font-bold text-foreground mb-2",children:l.sales}),e.jsxs("div",{className:"text-xs text-success flex items-center gap-1",children:[e.jsx(g,{className:"w-3 h-3"})," +5.0% this month"]})]}),e.jsxs(x,{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(z,{className:"w-16 h-16 text-destructive"})}),e.jsx("div",{className:"text-muted-foreground text-xs font-bold uppercase mb-1",children:"Page Views"}),e.jsx("div",{className:"text-3xl font-mono font-bold text-foreground mb-2",children:l.views>1e3?`${(l.views/1e3).toFixed(1)}K`:l.views}),e.jsxs("div",{className:"text-xs text-destructive flex items-center gap-1",children:[e.jsx(g,{className:"w-3 h-3 rotate-180"})," -2.4% this month"]})]}),e.jsxs(x,{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(U,{className:"w-16 h-16 text-foreground"})}),e.jsx("div",{className:"text-muted-foreground text-xs font-bold uppercase mb-1",children:"Conversion Rate"}),e.jsxs("div",{className:"text-3xl font-mono font-bold text-foreground mb-2",children:[l.conversion,"%"]}),e.jsxs("div",{className:"text-xs text-success flex items-center gap-1",children:[e.jsx(g,{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(x,{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-foreground",children:"Top Products"}),e.jsx(n,{variant:"ghost",size:"sm",children:"View All"})]}),e.jsx("div",{className:"space-y-4",children:a.map((s,N)=>e.jsxs("div",{className:"flex items-center gap-4 p-4 bg-card rounded-lg border border-transparent hover:border-border transition-all",children:[e.jsx("div",{className:"w-8 text-center font-mono text-muted-foreground",children:N+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-foreground truncate",children:s.title}),e.jsxs("div",{className:"text-xs text-muted-foreground",children:[s.reviewCount," reviews • ",s.rating," stars"]})]}),e.jsxs("div",{className:"text-right",children:[e.jsxs("div",{className:"font-bold text-foreground",children:["$",s.price]}),e.jsxs("div",{className:"text-xs text-muted-foreground",children:[Math.floor(Math.random()*100)," sales"]})]}),e.jsx(n,{variant:"ghost",size:"icon",className:"h-8 w-8",children:e.jsx(M,{className:"w-4 h-4"})})]},s.id))})]})}),e.jsx("div",{children:e.jsxs(x,{variant:"default",className:"h-full",children:[e.jsx("h3",{className:"font-bold text-foreground 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-muted"}),d.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-muted border border-success rounded-full flex items-center justify-center",children:e.jsx("div",{className:"w-2 h-2 bg-success rounded-full"})}),e.jsx("div",{className:"text-sm text-foreground font-bold",children:s.product}),e.jsxs("div",{className:"text-xs text-muted-foreground flex justify-between mt-1",children:[e.jsx("span",{children:s.buyer}),e.jsxs("span",{children:["$",s.amount]})]}),e.jsx("div",{className:"text-xs text-muted-foreground mt-1",children:s.date})]},s.id))]})]})})]}),j&&e.jsx(O,{products:a,onClose:()=>u(!1),onStart:s=>i(`Flash Sale started for ${s.productIds.length} products!`,"success")})]})};export{te as SellerDashboardView};
|