PageSourceSearch

https://app.primecarers.co.uk/assets/ReviewPage-KRwM1Lqj.js

js primecarers.co.uk collected 2026-09-29 09:14:55 UTC 8,499 bytes, 1 lines download raw bytes

1import{r as i,j as e,L as N,ac as $}from"./index-BlJVdQjU.js";import{C as M}from"./check-circle-ziUaPqya.js";import{P as T}from"./PublicSiteHeader-BUJ6F-Hv.js";import{g as q}from"./api-BArn4UC8.js";import{g as A,s as Y}from"./api-DJffamfS.js";import{z as D}from"./App-UKDK7pVK.js";function O({value:n,onChange:t}){const[r,o]=i.useState(0),d=r||n;return e.jsx("div",{className:"flex items-center gap-1",role:"group","aria-label":"Star rating",children:[1,2,3,4,5].map(l=>e.jsx("button",{type:"button",onClick:()=>t(l),onMouseEnter:()=>o(l),onMouseLeave:()=>o(0),"aria-label":`${l} star${l>1?"s":""}`,className:"focus:outline-none",children:e.jsx($,{className:`h-8 w-8 transition-colors ${l<=d?"fill-darkamber text-darkamber":"fill-transparent text-pebble hover:text-darkamber"}`})},l))})}function z({profile:n}){var d;const t=n==null?void 0:n.profile,r=t?`${t.forename} ${t.surname_initial}`:"Your carer",o=t==null?void 0:t.picture_url;return e.jsxs("div",{className:"flex items-center gap-4 mb-6",children:[o?e.jsx("img",{src:o,alt:r,className:"h-16 w-16 rounded-full object-cover border-2 border-white shadow"}):e.jsx("div",{className:"h-16 w-16 rounded-full bg-lightgray flex items-center justify-center border-2 border-white shadow",children:e.jsx("span",{className:"text-2xl text-pebble",children:((d=t==null?void 0:t.forename)==null?void 0:d.charAt(0))||"?"})}),e.jsxs("div",{children:[e.jsx("p",{className:"text-sm text-granite",children:"Leave a review for"}),e.jsx("p",{className:"text-lg font-bold text-dark",children:r})]})]})}const H="Thanks — your review has been sent for a quick check by our team and will appear once approved.";function G(n){var o;const t=n;if((t==null?void 0:t.status)!==400)return null;const r=t.serverMessage??(typeof((o=t.body)==null?void 0:o.error)=="string"?t.body.error:void 0);return r&&r.trim()?r:null}function U({carerName:n,pending:t}){return e.jsxs("div",{className:"flex flex-col items-center text-center gap-4 py-8",children:[e.jsx(M,{className:"h-14 w-14 text-forestgreen"}),e.jsx("h1",{className:"text-2xl font-bold text-dark",children:"Thank you for your review!"}),t?e.jsx("p",{className:"text-granite max-w-sm",children:H}):e.jsxs("p",{className:"text-granite max-w-sm",children:["Your review for ",e.jsx("strong",{children:n})," has been submitted. It will be visible on their profile shortly."]})]})}function V({state:n}){const t={invalid:{title:"Invalid review link",body:"This review link is not valid. Please check the link and try again."},expired:{title:"Review link has expired",body:"This review link has expired. Please contact the carer for a new link."},used:{title:"Review already submitted",body:"A review has already been submitted using this link."},error:{title:"Something went wrong",body:"We were unable to load this page. Please try again later."}},{title:r,body:o}=t[n];return e.jsxs("div",{className:"flex flex-col items-center text-center gap-3 py-8",children:[e.jsx("h1",{className:"text-2xl font-bold text-dark",children:r}),e.jsx("p",{className:"text-granite max-w-sm",children:o})]})}function Z(){const{token:n}=D(),[t,r]=i.useState("loading"),[o,d]=i.useState(null),[l,k]=i.useState(null),[x,S]=i.useState(5),[h,P]=i.useState(""),[f,b]=i.useState(""),[v,C]=i.useState(""),[g,E]=i.useState(""),[j,F]=i.useState(""),[w,m]=i.useState(null),[p,y]=i.useState(!1),[I,L]=i.useState(!1);i.useEffect(()=>{if(!n){r("invalid");return}let a=!1;return A(n).then(s=>{if(!a)return d(s),b(s.forename||""),q(s.carer_id).then(c=>{a||k(c)}).catch(()=>{})}).then(()=>{a||r("form")}).catch(s=>{if(a)return;const c=s==null?void 0:s.status;if(c===404)r("invalid");else if(c===410){const u=((s==null?void 0:s.message)??"").toLowerCase();r(u.includes("already")||u.includes("used")?"used":"expired")}else r("error")}),()=>{a=!0}},[n]);const R=l!=null&&l.profile?`${l.profile.forename} ${l.profile.surname_initial}`:"your carer",_=async a=>{if(a.preventDefault(),m(null),x<1||x>5){m("Please select a star rating.");return}if(!h.trim()){m("Please write your review.");return}if(!f.trim()){m("Please enter your first name.");return}if(!g.trim()){m("Please enter your email address.");return}y(!0);try{const s={content:h.trim(),rating:x,email:g.trim(),forename:f.trim(),surname:v.trim(),phone:j.trim()||void 0},c=await Y(n,s);L((c==null?void 0:c.moderation_status)==="pending"),r("success")}catch(s){const c=s==null?void 0:s.status,u=((s==null?void 0:s.message)??"").toLowerCase();c===410&&(u.includes("already")||u.includes("used"))?r("success"):c===410?r("expired"):m(G(s)??"Something went wrong. Please try again.")}finally{y(!1)}};return e.jsxs("div",{className:"min-h-screen bg-whitegray",children:[e.jsx(T,{}),e.jsxs("main",{className:"max-w-xl mx-auto px-4 py-10",children:[t==="loading"&&e.jsx("div",{className:"flex items-center justify-center py-16",children:e.jsx(N,{className:"h-8 w-8 animate-spin text-forestgreen"})}),t==="success"&&e.jsx(U,{carerName:R,pending:I}),(t==="invalid"||t==="expired"||t==="used"||t==="error")&&e.jsx(V,{state:t}),t==="form"&&e.jsxs("div",{className:"bg-white rounded-xl border border-lightgraydark p-6 shadow-card",children:[e.jsx(z,{profile:l}),e.jsx("h1",{className:"text-xl font-bold text-dark mb-1",children:"Leave a review"}),e.jsx("p",{className:"text-sm text-granite mb-6",children:"Share your experience to help others find great c
1are."}),e.jsxs("form",{onSubmit:_,noValidate:!0,className:"space-y-5",children:[e.jsxs("div",{children:[e.jsxs("label",{className:"block text-sm font-medium text-dark mb-2",children:["Your rating ",e.jsx("span",{className:"text-red-500",children:"*"})]}),e.jsx(O,{value:x,onChange:S})]}),e.jsxs("div",{children:[e.jsxs("label",{htmlFor:"review-content",className:"block text-sm font-medium text-dark mb-1",children:["Your review ",e.jsx("span",{className:"text-red-500",children:"*"})]}),e.jsx("textarea",{id:"review-content",value:h,onChange:a=>P(a.target.value),rows:5,placeholder:"Please keep your feedback honest but polite and give as much detail as possible to help other users.",className:"w-full rounded-lg border border-lightgraydark px-3 py-2 text-sm text-dark placeholder-pebble focus:outline-none focus:ring-2 focus:ring-forestgreen resize-none",required:!0})]}),e.jsxs("div",{className:"grid grid-cols-2 gap-3",children:[e.jsxs("div",{children:[e.jsxs("label",{htmlFor:"review-forename",className:"block text-sm font-medium text-dark mb-1",children:["First name ",e.jsx("span",{className:"text-red-500",children:"*"})]}),e.jsx("input",{id:"review-forename",type:"text",value:f,onChange:a=>b(a.target.value),className:"w-full rounded-lg border border-lightgraydark px-3 py-2 text-sm text-dark placeholder-pebble focus:outline-none focus:ring-2 focus:ring-forestgreen",required:!0})]}),e.jsxs("div",{children:[e.jsx("label",{htmlFor:"review-surname",className:"block text-sm font-medium text-dark mb-1",children:"Last name"}),e.jsx("input",{id:"review-surname",type:"text",value:v,onChange:a=>C(a.target.value),className:"w-full rounded-lg border border-lightgraydark px-3 py-2 text-sm text-dark placeholder-pebble focus:outline-none focus:ring-2 focus:ring-forestgreen"})]})]}),e.jsxs("div",{children:[e.jsxs("label",{htmlFor:"review-email",className:"block text-sm font-medium text-dark mb-1",children:["Email address ",e.jsx("span",{className:"text-red-500",children:"*"})]}),e.jsx("input",{id:"review-email",type:"email",value:g,onChange:a=>E(a.target.value),className:"w-full rounded-lg border border-lightgraydark px-3 py-2 text-sm text-dark placeholder-pebble focus:outline-none focus:ring-2 focus:ring-forestgreen",required:!0})]}),e.jsxs("div",{children:[e.jsxs("label",{htmlFor:"review-phone",className:"block text-sm font-medium text-dark mb-1",children:["Phone number"," ",e.jsx("span",{className:"text-pebble font-normal",children:"(optional)"})]}),e.jsx("input",{id:"review-phone",type:"tel",value:j,onChange:a=>F(a.target.value),className:"w-full rounded-lg border border-lightgraydark px-3 py-2 text-sm text-dark placeholder-pebble focus:outline-none focus:ring-2 focus:ring-forestgreen"})]}),w&&e.jsx("p",{className:"text-sm text-red-600",children:w}),e.jsxs("button",{type:"submit",disabled:p,className:"w-full flex items-center justify-center gap-2 rounded-lg bg-forestgreen px-4 py-3 text-sm font-semibold text-white hover:bg-darkgreen disabled:opacity-60 disabled:cursor-not-allowed transition-colors",children:[p&&e.jsx(N,{className:"h-4 w-4 animate-spin"}),p?"Submitting…":"Submit review"]})]})]})]})]})}export{Z as ReviewPage};

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.