PageSourceSearch

https://pshly.ai/assets/SitemapHealthCheck-CJKgzAgT.js

js pshly.ai collected 2026-10-05 12:31:55 UTC 7,950 bytes, 1 lines download raw bytes

1import{r as n,j as e}from"./react-D19kjoWR.js";import{s as y}from"./index-BiYpVMri.js";import{B as z}from"./button-Bre_tcdc.js";import{C as i}from"./card-BTf3o4Lt.js";import{B as p}from"./badge-B-XOr41f.js";import{u as w}from"./i18n-DVr-wOFn.js";import{l as U,a3 as $,by as v,R as I,L as E,u as h,o as u,a6 as k,bI as F,T as L}from"./icons-CAxi34Mu.js";import"./utils-pO556hdz.js";import"./radix-deHfsk72.js";import"./supabase-D-vHfFRB.js";import"./tanstack-i-tV8heQ.js";import"./router-DCTWe34i.js";function J({connection:d}){const{t:r}=w(),[c,g]=n.useState(!1),[s,f]=n.useState(null),[j,b]=n.useState(null),[l,C]=n.useState(!0);n.useEffect(()=>{(async()=>{const{data:a}=await y.from("sitemap_scan_results").select("*").eq("connection_id",d.id).order("scanned_at",{ascending:!1}).limit(1).maybeSingle();a&&f({success:!0,sitemapUrl:a.sitemap_url||"",sitemapFound:a.sitemap_found,isIndex:a.is_index,totalUrls:a.total_urls,checkedUrls:a.checked_urls,brokenUrls:a.broken_urls,missingProducts:a.missing_products,missingCollections:a.missing_collections,totalProducts:a.total_products,totalCollections:a.total_collections,issues:a.issues||[],scannedAt:a.scanned_at,scanSource:a.scan_source}),C(!1)})()},[d.id]),n.useEffect(()=>{!l&&!s&&N()},[l]);const N=n.useCallback(async()=>{g(!0),b(null);try{const{data:t,error:a}=await y.functions.invoke("sitemap-health-check",{body:{connectionId:d.id}});if(a)throw a;if(t!=null&&t.error)throw new Error(t.error);f({...t,scannedAt:new Date().toISOString(),scanSource:"manual"})}catch(t){b(t.message||"Scan failed")}finally{g(!1)}},[d.id]),_=t=>t==="error"?e.jsx(h,{size:14,className:"text-destructive shrink-0"}):t==="warning"?e.jsx(L,{size:14,className:"text-amber-500 shrink-0"}):e.jsx(u,{size:14,className:"text-primary shrink-0"}),S=t=>new Date(t).toLocaleDateString(void 0,{day:"numeric",month:"short",year:"numeric",hour:"2-digit",minute:"2-digit"}),o=(s==null?void 0:s.issues.length)??0,m=(s==null?void 0:s.issues.filter(t=>t.severity==="error").length)??0,x=(s==null?void 0:s.issues.filter(t=>t.severity==="warning").length)??0;return e.jsxs("div",{className:"space-y-6",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{children:[e.jsxs("h2",{className:"text-lg font-semibold text-foreground flex items-center gap-2",children:[e.jsx(U,{size:20,className:"text-primary"}),r("dashboard.sitemap.title")]}),e.jsx("p",{className:"text-sm text-muted-foreground mt-0.5",children:r("dashboard.sitemap.subtitle")})]}),e.jsxs("div",{className:"flex items-center gap-3",children:[(s==null?void 0:s.scannedAt)&&e.jsxs("div",{className:"hidden sm:flex items-center gap-1.5 text-xs text-muted-foreground",children:[e.jsx($,{size:12}),e.jsx("span",{children:S(s.scannedAt)}),s.scanSource==="cron"&&e.jsxs(p,{variant:"secondary",className:"text-[10px] gap-1",children:[e.jsx(v,{size:9}),r("dashboard.sitemap.auto")]})]}),e.jsxs(z,{onClick:N,disabled:c,variant:"outline",size:"sm",className:"gap-2",children:[e.jsx(I,{size:14,className:c?"animate-spin":""}),r(c?"dashboard.sitemap.scanning":"dashboard.sitemap.rescan")]})]})]}),e.jsx(i,{className:"p-3 bg-muted/50 border-border",children:e.jsxs("div",{className:"flex items-center gap-2 text-xs text-muted-foreground",children:[e.jsx(v,{size:14,className:"text-primary shrink-0"}),e.jsx("span",{children:r("dashboard.sitemap.cronInfo")})]})}),(c||l)&&!s&&e.jsxs(i,{className:"p-8 flex flex-col items-center justify-center gap-3",children:[e.jsx(E,{className:"animate-spin text-primary",size:28}),e.jsxs("p",{className:"text-sm text-muted-foreground",children:[r("dashboard.sitemap.scanning"),"..."]})]}),j&&!c&&e.jsx(i,{className:"p-6 border-destructive/30 bg-destructive/5",children:e.jsxs("div",{className:"flex items-start gap-3",children:[e.jsx(h,{size:18,className:"text-destructive shrink-0 mt-0.5"}),e.jsxs("div",{children:[e.jsx("p",{className:"font-medium text-destructive text-sm",children:r("dashboard.sitemap.error")}),e.jsx("p",{className:"text-xs text-muted-foreground mt-1",children:j})]})]})}),s&&e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"grid grid-cols-2 sm:grid-cols-4 gap-3",children:[e.jsxs(i,{className:"p-4 text-center",children:[e.jsx("p",{className:"text-2xl font-bold text-foreground",children:s.totalUrls.toLocaleStr
1ing()}),e.jsx("p",{className:"text-xs text-muted-foreground mt-1",children:r("dashboard.sitemap.urlsInSitemap")})]}),e.jsxs(i,{className:`p-4 text-center ${s.brokenUrls>0?"border-destructive/30":""}`,children:[e.jsx("p",{className:`text-2xl font-bold ${s.brokenUrls>0?"text-destructive":"text-primary"}`,children:s.brokenUrls}),e.jsx("p",{className:"text-xs text-muted-foreground mt-1",children:r("dashboard.sitemap.brokenLinks")})]}),e.jsxs(i,{className:`p-4 text-center ${s.missingProducts>0?"border-amber-300/50":""}`,children:[e.jsx("p",{className:`text-2xl font-bold ${s.missingProducts>0?"text-amber-500":"text-primary"}`,children:s.missingProducts}),e.jsx("p",{className:"text-xs text-muted-foreground mt-1",children:r("dashboard.sitemap.missingProducts")})]}),e.jsxs(i,{className:`p-4 text-center ${s.missingCollections>0?"border-amber-300/50":""}`,children:[e.jsx("p",{className:`text-2xl font-bold ${s.missingCollections>0?"text-amber-500":"text-primary"}`,children:s.missingCollections}),e.jsx("p",{className:"text-xs text-muted-foreground mt-1",children:r("dashboard.sitemap.missingCollections")})]})]}),e.jsxs(i,{className:"p-4",children:[e.jsxs("div",{className:"flex items-center gap-2 text-sm",children:[s.sitemapFound?e.jsx(u,{size:14,className:"text-primary"}):e.jsx(h,{size:14,className:"text-destructive"}),e.jsxs("span",{className:"text-muted-foreground",children:[r("dashboard.sitemap.source"),":"]}),e.jsxs("a",{href:s.sitemapUrl,target:"_blank",rel:"noopener noreferrer",className:"text-primary hover:underline flex items-center gap-1 font-mono text-xs truncate",children:[s.sitemapUrl,e.jsx(k,{size:10})]}),s.isIndex&&e.jsx(p,{variant:"secondary",className:"text-[10px]",children:"Sitemap Index"})]}),s.sitemapFound&&e.jsx("p",{className:"text-xs text-muted-foreground mt-2",children:r("dashboard.sitemap.checkedSample",{checked:s.checkedUrls,total:s.totalUrls})})]}),e.jsx(i,{className:`p-4 ${o===0?"border-primary/30 bg-primary/5":""}`,children:e.jsx("div",{className:"flex items-center gap-3",children:o===0?e.jsxs(e.Fragment,{children:[e.jsx(u,{size:22,className:"text-primary"}),e.jsxs("div",{children:[e.jsx("p",{className:"font-semibold text-foreground text-sm",children:r("dashboard.sitemap.healthy")}),e.jsx("p",{className:"text-xs text-muted-foreground",children:r("dashboard.sitemap.healthyDesc")})]})]}):e.jsxs(e.Fragment,{children:[e.jsx(F,{size:22,className:"text-amber-500"}),e.jsxs("div",{children:[e.jsx("p",{className:"font-semibold text-foreground text-sm",children:r("dashboard.sitemap.issuesFound",{count:o})}),e.jsxs("p",{className:"text-xs text-muted-foreground",children:[m>0&&`${m} ${r("dashboard.sitemap.errors")}`,m>0&&x>0&&", ",x>0&&`${x} ${r("dashboard.sitemap.warnings")}`]})]})]})})}),o>0&&e.jsx(i,{className:"divide-y divide-border",children:s.issues.map((t,a)=>e.jsxs("div",{className:"flex items-start gap-3 p-3 hover:bg-muted/50 transition-colors",children:[_(t.severity),e.jsxs("div",{className:"min-w-0 flex-1",children:[e.jsx("p",{className:"text-sm text-foreground",children:t.message}),t.url&&e.jsxs("a",{href:t.url,target:"_blank",rel:"noopener noreferrer",className:"text-xs text-muted-foreground hover:text-primary flex items-center gap-1 mt-0.5 truncate",children:[t.url,e.jsx(k,{size:9})]})]}),e.jsx(p,{variant:t.severity==="error"?"destructive":t.severity==="warning"?"outline":"secondary",className:"text-[10px] shrink-0",children:t.type==="missing_product"?r("dashboard.sitemap.typeProduct"):t.type==="missing_collection"?r("dashboard.sitemap.typeCollection"):t.type==="broken_link"?r("dashboard.sitemap.typeBroken"):r("dashboard.sitemap.typeStructure")})]},a))})]})]})}export{J as SitemapHealthCheck};

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.