PageSourceSearch

https://console.quidkey.com/assets/merchants.index-CNoANDCp.js

js quidkey.com collected 2026-09-24 13:41:06 UTC 13,210 bytes, 1 lines download raw bytes

1import{j as e,N as D,X as ee,n as x,a3 as te,a4 as ae,a6 as se,a7 as F,cJ as ne,a as re,b as ie,bW as le,r as h,k as P,ax as ce,H as oe,ay as de,B as R,aA as me,aK as ue,aB as he,aY as xe}from"./main-To_L_1y0.js";import{S as pe}from"./searchable-select-DeEfeDDN.js";import{M as fe}from"./merchant-upsert-dialog-B9lfV0d7.js";import{S as ge}from"./search-filter-iEqsnA97.js";import{a as je,b as ve,c as be,T as Ne}from"./tooltip-CXfpieVi.js";import{S as ye}from"./switch-Cs1R8cqt.js";import{M as we}from"./merchant-archive-DoMz4ttj.js";import{u as z}from"./use-persistent-state-DTMD2Ji-.js";import{P as Ce}from"./plus-Dmm6tEsW.js";import"./select-popover-bPkr3rzV.js";import"./search-DPk_MPSb.js";import"./useMutation-B7FocJ-g.js";import"./input-DYzx90jl.js";import"./label-DhPWvjid.js";import"./country-configs-C_iyeFGO.js";import"./use-dismiss-on-outside-Bo3-8DrW.js";const Se={not_started:{label:"Not started",className:"bg-muted text-foreground"},in_progress:{label:"In progress",className:"bg-amber-500 text-white"},ready:{label:"Ready",className:"bg-blue-500 text-white"},active:{label:"Verified",className:"bg-emerald-600 text-white"}};function Ae({status:t}){const s=Se[t];return e.jsx("span",{className:x("inline-flex items-center rounded-md px-2 py-0.5",s.className),children:s.label})}function U({onboarding:t}){return t?e.jsxs(je,{children:[e.jsx(ve,{asChild:!0,children:e.jsx("button",{type:"button",className:"cursor-default rounded-md focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring","aria-label":`Onboarding: ${t.status}. Show checklist`,onClick:s=>s.stopPropagation(),children:e.jsx(Ae,{status:t.status})})}),e.jsx(be,{className:"max-w-[240px] p-2",children:e.jsx("ul",{className:"space-y-1",children:t.checklist.map(s=>e.jsxs("li",{className:"flex items-center gap-1.5",children:[s.complete?e.jsx(D,{className:"h-3 w-3 shrink-0 text-green-400"}):e.jsx(ee,{className:"h-3 w-3 shrink-0 text-red-400"}),e.jsx("span",{className:x(!s.complete&&"font-medium"),children:s.label})]},s.key))})})]}):e.jsx("span",{className:"text-muted-foreground",children:"—"})}const E={status:"all",onboarding:"all"};function ke(t){return t.status!=="all"||t.onboarding!=="all"}function I(t){const s=t.onboarding?.status;return s==="ready"||s==="active"}function Le(t,s){return!(s.status!=="all"&&t.activation_status!==s.status||s.onboarding==="complete"&&!I(t)||s.onboarding==="incomplete"&&I(t))}function O({allLabel:t,options:s,value:n,onChange:m}){const d=n!=="all",f=d?s.find(l=>l.value===n)?.label??t:t;return e.jsxs(te,{value:n,onValueChange:l=>m(l),children:[e.jsx(ae,{className:x("h-9 w-[130px]",d&&"border-primary text-foreground"),"aria-label":t,children:e.jsx("span",{className:"truncate",children:f})}),e.jsxs(se,{children:[e.jsx(F,{value:"all",children:"All"}),s.map(l=>e.jsx(F,{value:l.value,children:l.label},l.value))]})]})}function Me({filters:t,onChange:s}){return e.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[e.jsx(O,{allLabel:"Status",value:t.status,onChange:n=>s({...t,status:n}),options:[{value:"active",label:"Active"},{value:"inactive",label:"Inactive"}]}),e.jsx(O,{allLabel:"Onboarding",value:t.onboarding,onChange:n=>s({...t,onboarding:n}),options:[{value:"incomplete",label:"Incomplete"},{value:"complete",label:"Complete"}]})]})}function Je(){const{partner_id:t,create:s}=ne.useSearch(),n=re(),{can:m,currentContext:d}=ie(),f=le(),l=m("merchants:view-archived"),[C,$]=z("merchants.showArchived",!1),o=d?.type==="partner",B=o?d?.id:void 0,g=!o,S=m("merchants:create"),K=!!s&&S,[j,N]=h.useState(""),[v,A]=z("merchants.filters",E),i=P({...ce(),enabled:g}),u=Array.isArray(i.data)?i.data:[],k=o?void 0:t,y=o||!!t,r=P({...de(k,l&&C),enabled:y,placeholderData:oe}),p=Array.isArray(r.data)?r.data:[],b=h.useMemo(()=>{const a=j.toLowerCase().trim();return p.filter(c=>{if(!Le(c,v))return!1;if(!a)return!0;const Y=(c.brand_name??"").toLowerCase(),G=(c.id??"").toLowerCase(),Z=(c.uri??"").toLowerCase();return Y.includes(a)||G.includes(a)||Z.includes(a)})}
1,[p,j,v]),L=j.trim()!==""||ke(v);h.useEffect(()=>{N("")},[k,o]),h.useEffect(()=>{if(!g||t||i.isLoading||i.isError||!Array.isArray(u)||u.length===0)return;const a=u.find(c=>String(c?.name??"").trim().toLowerCase()==="merchant portal")??u.find(c=>String(c?.email??"").trim().toLowerCase()==="[email protected]");a?.id&&n({to:"/merchants",search:{partner_id:a.id,create:void 0},replace:!0})},[g,t,i.isLoading,i.isError,i.data]);const M=u.find(a=>a.id===t),q=a=>{n({to:"/merchants",search:{partner_id:a||void 0,create:void 0}})};function H(){n({to:"/merchants",search:{partner_id:t,create:!0}})}function J(){n({to:"/merchants",search:{partner_id:t,create:void 0}})}const _=a=>{n({to:"/merchants/$merchantId",params:{merchantId:a},search:c=>({partner_id:c.partner_id??void 0})})},W=a=>_(a.original.id),X=h.useMemo(()=>[{accessorKey:"brand_name",header:"Merchant",size:320,minSize:280,cell:({row:a})=>e.jsxs("div",{className:x("whitespace-nowrap",a.original.archived&&"opacity-60"),children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("span",{className:"font-medium",children:a.original.brand_name??"Merchant"}),a.original.archived?e.jsx("span",{className:"inline-flex items-center rounded-full bg-muted px-2 py-0.5 text-xs font-medium text-muted-foreground",children:"Archived"}):null]}),e.jsx(Q,{value:a.original.id})]})},{accessorKey:"uri",header:"URL",size:220,minSize:180,cell:({row:a})=>e.jsx("div",{className:"text-muted-foreground whitespace-nowrap",children:a.original.uri??"—"})},{accessorKey:"activation_status",header:"Status",size:120,minSize:110,cell:({row:a})=>a.original.activation_status?e.jsx(V,{label:a.original.activation_status}):e.jsx("span",{children:"—"})},{accessorKey:"onboarding",header:"Onboarding",size:120,minSize:110,enableSorting:!1,cell:({row:a})=>e.jsx(U,{onboarding:a.original.onboarding})},...f?[{id:"actions",header:"",size:56,minSize:56,enableSorting:!1,cell:({row:a})=>e.jsx("div",{className:"flex justify-end",children:e.jsx(we,{merchantId:a.original.id,merchantName:a.original.brand_name??"this merchant",archived:a.original.archived??!1,canVerify:a.original.onboarding?.status==="ready"})})}]:[]],[f]),T=r.isError?e.jsxs("div",{className:"text-center py-8",children:[e.jsx("p",{className:"text-destructive mb-2",children:"Failed to load merchants"}),e.jsx("button",{type:"button",onClick:()=>r.refetch(),className:"text-sm underline hover:no-underline",children:"Retry"})]}):L&&p.length>0?e.jsx(w,{type:"no-results",onClearSearch:()=>{N(""),A(E)}}):e.jsx(w,{type:"no-merchants"});return e.jsx(Ne,{delayDuration:150,children:e.jsxs("div",{className:"flex flex-col h-full min-h-0",children:[e.jsxs("div",{className:"flex items-start justify-between gap-4 mb-4",children:[e.jsxs("div",{children:[e.jsx("h1",{className:"text-3xl font-bold tracking-tight",children:"Merchants"}),e.jsx("p",{className:"text-muted-foreground mt-1",children:o?"View and manage your partner merchants.":"View and manage merchants across all partners."})]}),S?e.jsx(R,{type:"button",onClick:H,"aria-label":"Create merchant",disabled:!o&&(!t||i.isLoading||i.isError),title:!o&&!t?"Select a partner first":void 0,children:e.jsxs("span",{className:"inline-flex items-center gap-2",children:["Create ",e.jsx(Ce,{className:"h-4 w-4"})]})}):null]}),g?e.jsx("div",{className:"mb-4",children:i.isLoading?e.jsx("div",{className:"text-sm text-muted-foreground",children:"Loading partners…"}):i.isError?e.jsxs("div",{className:"text-sm text-destructive",children:["Failed to load partners."," ",e.jsx("button",{type:"button",onClick:()=>i.refetch(),className:"underline hover:no-underline",children:"Retry"})]}):e.jsx(pe,{className:"w-full sm:w-[220px]",value:t??"",onValueChange:a=>q(a||void 0),placeholder:"Select a partner…",searchPlaceholder:"Search partners…",emptyMessage:"No partners found.",options:u.map(a=>({value:a.id,label:a.name||a.email||a.id}))})}):null,y&&!r.isLoading&&!r.isError?e.jsxs("div",{className:"mb-3 flex flex-col gap-2",children:[e.jsxs("div",{className:"flex flex-col gap-2 sm:flex-row sm:items-center sm:justify-between",children:[e.jsx(Me,{filters:v,onChange:A}),e.jsx(ge,{value:j,onChange:N,placeholder:"Search by name, ID, or URL...",className:"w-full sm:w-[280px]"})]}),e.jsxs("div",{className:"flex items-center justify-between gap-2",children:[e.jsx("div",{className:"text-sm text-muted-foreground",children:L?e.jsxs(e.Fragment,{children:[b.length," of ",p.length," merchant(s)"]}):e.jsxs(e.Fragment,{children:[p.length," merchant(s)"," ",o?`for ${d?.name||"your partner"}`:t?`for ${M?.name||M?.email||"selected partner"}`:"across all partners"]})}),e.jsxs("div",{className:"flex items-center gap-3",children:[l?e.jsxs("label",{className:"flex items-center gap-2 text-xs text-muted-foreground",children:[e.jsx(ye,{checked:C,onCheckedChange:$,"aria-label":"Show archived merchants"}),"Show archived"]}):null,r.dataUpdatedAt?e.jsxs("span",{className:"text-xs text-muted-foreground",children:["Updated ",new Date(r.dataUpdatedAt).toLocaleTimeString()]}):null,e.jsxs(R,{type:"button",variant:"outline",size:"sm",onClick:()=>r.refetch(),disabled:r.isFetching,"aria-label":"Refresh merchants",children:[e.jsx(me,{className:x("h-4 w-4",r.isFetching&&"animate-spin")}),e.jsx("span",{className:"ml-2 hidden sm:inline",children:"Refresh"})]})]})]})]}):null,e.jsx("div",{className:"flex-1 min-h-0",children:y?e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"md:hidden",children:r.isLoading?e.jsx("div",{className:"py-8",children:e.jsx(ue,{title:"Loading merchants…"})}):b.length===0?T:e.jsx("ul",{className:"space-y-2",children:b.map(a=>e.jsx("li",{children:e.jsx(_e,{merchant:a,onOpen:()=>_(a.id)})},a.id))})}),e.jsx("div",{className:"hidden h-full md:block",children:e.jsx(he,{columns:X,data:b,isLoading:r.isLoading,emptyState:T,onRowClick:W,getRowId:a=>a.id,className:"h-full"})})]}):e.jsx(w,{type:"no-partner"})}),e.jsx(fe,{mode:"create",open:K,onOpenChange:a=>a?null:J(),initialPartnerId:B??t})]})})}function w({type:t,onClearSearch:s}
1){return t==="no-partner"?e.jsx("div",{className:"flex items-center justify-center h-full",children:e.jsxs("div",{className:"text-center text-muted-foreground",children:[e.jsx("p",{className:"text-lg font-medium mb-1",children:"Select a partner"}),e.jsx("p",{className:"text-sm",children:"Choose a partner from the dropdown to view their merchants."})]})}):t==="no-results"?e.jsx("div",{className:"flex items-center justify-center py-8",children:e.jsxs("div",{className:"text-center text-muted-foreground",children:[e.jsx("p",{className:"text-lg font-medium mb-1",children:"No matching merchants"}),e.jsxs("p",{className:"text-sm",children:["No merchants match your search or filters."," ",s&&e.jsx("button",{type:"button",onClick:s,className:"text-primary underline hover:no-underline",children:"Clear search & filters"})]})]})}):e.jsx("div",{className:"flex items-center justify-center",children:e.jsxs("div",{className:"text-center text-muted-foreground",children:[e.jsx("p",{className:"text-lg font-medium mb-1",children:"No merchants found"}),e.jsx("p",{className:"text-sm",children:"This partner has no merchants yet."})]})})}function _e({merchant:t,onOpen:s}){return e.jsxs("div",{className:x("relative rounded-lg border p-4 transition-colors hover:bg-muted/50 focus-within:ring-2 focus-within:ring-ring",t.archived&&"opacity-60"),children:[e.jsx("button",{type:"button",onClick:s,"aria-label":`Open ${t.brand_name??"merchant"}`,className:"absolute inset-0 z-0 rounded-lg focus:outline-none"}),e.jsxs("div",{className:"pointer-events-none relative z-10 flex items-start justify-between gap-3",children:[e.jsxs("div",{className:"min-w-0",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("span",{className:"font-medium truncate",children:t.brand_name??"Merchant"}),t.archived?e.jsx("span",{className:"inline-flex items-center rounded-full bg-muted px-2 py-0.5 text-xs font-medium text-muted-foreground",children:"Archived"}):null]}),e.jsx("div",{className:"pointer-events-auto mt-0.5 inline-flex",children:e.jsx(Q,{value:t.id})})]}),e.jsxs("div",{className:"pointer-events-auto flex shrink-0 flex-col items-end gap-1",children:[t.activation_status?e.jsx(V,{label:t.activation_status}):null,e.jsx(U,{onboarding:t.onboarding})]})]}),t.uri?e.jsx("div",{className:"pointer-events-none relative z-10 mt-2 truncate text-sm text-muted-foreground",children:t.uri}):null]})}function Q({value:t}){const[s,n]=h.useState(!1),m=async d=>{d.stopPropagation(),await navigator.clipboard.writeText(t),n(!0),setTimeout(()=>n(!1),2e3)};return e.jsxs("button",{type:"button",onClick:m,className:"group inline-flex items-center gap-1 font-mono text-xs text-muted-foreground hover:text-primary transition-colors",title:"Click to copy",children:[e.jsx("span",{children:t}),s?e.jsx(D,{className:"h-3 w-3 text-green-500 shrink-0"}):e.jsx(xe,{className:"h-3 w-3 opacity-0 group-hover:opacity-50 transition-opacity shrink-0"})]})}function V({label:t}){const s=t.trim().toLowerCase()==="active";return e.jsx("span",{className:`inline-flex items-center rounded-md px-2 py-0.5 capitalize ${s?"bg-emerald-600 text-white":"bg-muted text-foreground"}`,children:t})}export{Je 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.