1import{K as e,Z as t,m as n,s as r,t as i}from"./jsx-runtime-DQzIIyUr.js";import{t as a}from"./lib-BdUqZw-t.js";import{t as o}from"./seo-Bcm6Z8zA.js";import{u as s}from"./serverCalls-DUwxBaCV.js";import{c}from"./Buttons-tMz8fMKo.js";import{t as l}from"./Icons-fFZyZav0.js";var u=t(e(),1),d=i(),f=({params:e})=>o({title:`Survey Results`,description:`See how your domain name survey votes ranked.`,path:`/survey/${e.surveyId??``}/results`,noIndex:!0}),p=r(()=>{let{surveyId:e}=n(),[t,r]=(0,u.useState)(null),[i,o]=(0,u.useState)(null),[f,p]=(0,u.useState)(!0);if((0,u.useEffect)(()=>{(async()=>{if(!e){o(`Survey ID is missing`),p(!1);return}try{p(!0),o(null),r(await s(e))}catch(e){o(`Failed to load survey results. Please try again later.`),console.error(`Error fetching survey:`,e)}finally{p(!1)}})()},[e]),f)return(0,d.jsxs)(`div`,{className:`flex flex-col w-full max-w-2xl mx-auto min-h-[100dvh] items-center justify-center`,children:[(0,d.jsx)(`div`,{className:`animate-spin rounded-full h-12 w-12 border-b-2 border-primary`}),(0,d.jsx)(`p`,{className:`mt-4 text-gray-600`,children:`Loading results...`})]});if(i)return(0,d.jsxs)(`div`,{className:`flex flex-col w-full max-w-2xl mx-auto min-h-[100dvh] items-center justify-center`,children:[(0,d.jsx)(`div`,{className:`text-red-500 mb-4`,children:i}),(0,d.jsx)(`button`,{onClick:()=>window.location.reload(),className:`pill-button primary-action-button`,children:`Try Again`})]});if(!t)return(0,d.jsx)(`div`,{className:`flex flex-col w-full max-w-2xl mx-auto min-h-[100dvh] items-center justify-center`,children:(0,d.jsx)(`p`,{className:`text-gray-600`,children:`No survey results found.`})});let m=[...t.results].sort((e,t)=>t.averageRating-e.averageRating);return(0,d.jsxs)(`div`,{className:`flex flex-col w-full max-w-2xl mx-auto min-h-[100dvh] space-y-6 px-4 py-8`,children:[(0,d.jsx)(`div`,{className:`flex justify-between items-center`,children:(0,d.jsx)(`h2`,{children:`Survey Results`})}),(0,d.jsx)(`div`,{className:`bg-white rounded-lg shadow-md p-6`,children:(0,d.jsx)(`div`,{className:`space-y-4`,children:m.map((e,t)=>(0,d.jsxs)(`div`,{className:`flex items-center justify-between p-4 bg-gray-50 rounded-lg hover:bg-gray-100 transition-colors`,children:[(0,d.jsxs)(`div`,{className:`flex items-center gap-4`,children:[(0,d.jsxs)(`span`,{className:`text-lg font-semibold text-gray-500 w-8`,children:[`#`,t+1]}),(0,d.jsx)(`span`,{className:`text-lg font-medium`,children:e.domain})]}),(0,d.jsxs)(`div`,{className:`flex items-center gap-4`,children:[(0,d.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,d.jsx)(`span`,{className:`text-sm text-gray-500`,children:`Rating:`}),(0,d.jsx)(`span`,{className:`font-semibold`,children:e.averageRating.toFixed(1)})]}),(0,d.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,d.jsx)(`span`,{className:`text-sm text-gray-500`,children:`Votes:`}),(0,d.jsx)(`span`,{className:`font-semibold`,children:e.voteCount})]})]})]},e.domain))})}),(0,d.jsxs)(`div`,{className:`flex flex-row justify-center gap-4`,children:[e&&(0,d.jsx)(c,{surveyCode:e}),(0,d.jsxs)(a,{className:`pill-button primary-action-button flex items-center gap-2`,to:`/`,children:[`Create New Survey`,l.enter]})]})]})});export{p as default,f as meta};
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.