1import{j as e}from"./ui-vendor-7ksmbWQe.js";import{r as a}from"./react-vendor-LSUMIZ7H.js";import{t as _,l as T,j as d,D as B,w as H,ai as M,B as m,x as z,y as E,z as I,ad as P,C as n,e as o}from"./index-DWFe9eMF.js";import{D as R}from"./DisplayIdLink-DsiWoEfF.js";import{u as U}from"./i18n-vendor-Cq4PMOpV.js";import{H as y}from"./heart-p1kh5GbH.js";import{P as L}from"./plus-wVwOVnuZ.js";import{U as A}from"./users-2RT-GKgj.js";import{T as K}from"./trash-2-DHkDZxUq.js";import"./VerifiedBadge-BGB-7JMQ.js";import"./pipolyMonogram-BF6B0_Vg.js";function ee(){const{t}=U(),[j,b]=a.useState([]),[r,w]=a.useState(null),[f,C]=a.useState([]),[D,S]=a.useState(!0),[l,g]=a.useState(""),[k,x]=a.useState(!1),{user:h}=_(),{toast:i}=T(),p={payable:Number(h?.payable_balance)||0,pending:Number(h?.pending_balance)||0,employer:Number(h?.employer_balance)||0};a.useEffect(()=>{u()},[]);const u=async()=>{try{const s=await d.getFavoriteLists();b(s||[])}catch(s){i({title:t("toasts.error"),description:s.message,variant:"destructive"})}finally{S(!1)}},v=async s=>{w(s);try{const c=await d.getFavoriteListMembers(s.id);C(c||[])}catch(c){i({title:t("toasts.error"),description:c.message,variant:"destructive"})}},N=async()=>{if(l.trim())try{await d.createFavoriteList(l.trim()),i({title:t("toasts.listCreated"),description:t("toasts.listCreatedDesc")}),g(""),x(!1),u()}catch(s){i({title:t("toasts.error"),description:s.message,variant:"destructive"})}},F=async s=>{if(r)try{await d.removeFavoriteListMember(r.id,s),i({title:t("toasts.removed"),description:t("toasts.removedDesc")}),v(r),u()}catch(c){i({title:t("toasts.error"),description:c.message,variant:"destructive"})}};return e.jsxs("div",{className:"min-h-screen bg-background pb-20 md:pb-6",children:[e.jsx(B,{payableBalance:p.payable,pendingBalance:p.pending,employerBalance:p.employer}),e.jsxs("main",{className:"container mx-auto px-4 pt-24 md:pt-6 pb-8 space-y-6",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("div",{className:"p-3 bg-primary/10 rounded-full",children:e.jsx(y,{className:"h-6 w-6 text-primary"})}),e.jsxs("div",{children:[e.jsx("h1",{className:"text-2xl font-bold",children:t("favoriteLists.title")}),e.jsx("p",{className:"text-sm text-muted-foreground",children:t("favoriteLists.subtitle")})]})]}),e.jsxs(H,{open:k,onOpenChange:x,children:[e.jsx(M,{asChild:!0,children:e.jsxs(m,{size:"sm",children:[e.jsx(L,{className:"h-4 w-4 mr-1"})," ",t("favoriteLists.newList")]})}),e.jsxs(z,{children:[e.jsx(E,{children:e.jsx(I,{children:t("favoriteLists.createList")})}),e.jsx(P,{placeholder:t("favoriteLists.listNamePlaceholder"),value:l,onChange:s=>g(s.target.value),onKeyDown:s=>s.key==="Enter"&&N()}),e.jsx(m,{onClick:N,disabled:!l.trim(),children:t("favoriteLists.create")})]})]})]}),e.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-3 gap-4",children:[e.jsx("div",{className:"space-y-3",children:D?e.jsx("p",{className:"text-muted-foreground text-center py-8",children:t("favoriteLists.loading")}):j.length===0?e.jsx(n,{children:e.jsxs(o,{className:"py-8 text-center",children:[e.jsx(y,{className:"h-12 w-12 text-muted-foreground mx-auto mb-3"}),e.jsx("p",{className:"text-muted-foreground",children:t("favoriteLists.noLists")}),e.jsx("p",{className:"text-xs text-muted-foreground mt-1",children:t("favoriteLists.noListsDesc")}),e.jsxs(m,{variant:"outline",size:"sm",className:"mt-3",onClick:()=>x(!0),children:[e.jsx(L,{className:"h-3 w-3 mr-1"})," ",t("favoriteLists.createFirstList")]})]})}):j.map(s=>e.jsx(n,{className:`cursor-pointer transition-shadow hover:shadow-md ${r?.id===s.id?"ring-2 ring-primary":""}`,onClick:()=>v(s),children:e.jsxs(o,{className:"p-4",children:[e.jsx("p",{className:"font-semibold",children:s.name}),e.jsxs("p",{className:"text-xs text-muted-foreground",children:[e.jsx(A,{className:"h-3 w-3 inline mr-1"}),t("favoriteLists.members",{count:s.member_count})]})]})},s.id))}),e.jsx("div",{className:"md:col-span-2 space-y-3",children:r?e.jsxs(e.Fragment,{children:[e.jsx(n,{children:e.jsxs(o,{className:"p-4",children:[e.jsx("h2",{className:"font-semibold text-lg",children:r.name}),e.jsx("p",{className:"text-xs text-muted-foreground mt-1",children:t("favoriteLists.addWorkersHint")})]})}),f.length===0?e.jsx(n,{children:e.jsx(o,{className:"py-8 text-center text-muted-foreground",children:t("favoriteLists.noMembers")})}):f.map(s=>e.jsx(n,{children:e.jsxs(o,{className:"p-4 flex items-center justify-between",children:[e.jsxs("div",{children:[e.jsx("p",{className:"font-semibold",children:e.jsx(R,{displayId:s.display_id,children:s.name||s.display_id})}),e.jsxs("p",{className:"text-xs text-muted-foreground",children:[s.country," ⢠",t("favoriteLists.added")," ",new Date(s.added_at).toLocaleDateString()]})]}),e.jsx(m,{variant:"ghost",size:"sm",onClick:()=>F(s.id),children:e.jsx(K,{className:"h-4 w-4 text-destructive"})})]})},s.id))]}):e.jsx(n,{children:e.jsx(o,{className:"py-12 text-center text-muted-foreground",children:t("favoriteLists.selectList")})})})]})]})]})}export{ee 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.