PageSourceSearch

https://buildslot.ai/assets/ReviewsManager-CYDgKrlr.js

js buildslot.ai collected 2026-10-05 12:13:41 UTC 6,956 bytes, 6 lines download raw bytes

1import{q as k,u as w,r as N,s as T,v as S,x as f,m as e,p as m,M as A,w as j,k as b,B as g}from"./index-CpSGH3si.js";import{C as n,a as r,b as y,c as v}from"./card--3jAFIY6.js";import{T as M}from"./textarea-DnsCXU4p.js";import{S as q}from"./skeleton-D7CKVNpx.js";import{m as B}from"./proxy-DFy_m_5J.js";import{U as D}from"./user-DdcnLghC.js";import{C as L}from"./circle-check-big-BfTSBK82.js";import{T as z}from"./thumbs-up-G2A7N3ku.js";import{L as F}from"./loader-circle-CZ4nBqpt.js";/**
2 * @license lucide-react v0.475.0 - ISC
3 *
4 * This source code is licensed under the ISC license.
5 * See the LICENSE file in the root directory of this source tree.
6 */const P=[["polyline",{points:"9 17 4 12 9 7",key:"hvgpf2"}],["path",{d:"M20 18v-2a4 4 0 0 0-4-4H4",key:"5vmcpk"}]],Q=k("Reply",P);function G({contractorId:c,contractor:l}){var u;const _=w(),[R,x]=N.useState(null),[o,h]=N.useState(""),{data:t,isLoading:C}=T({queryKey:["contractor-reviews",c],queryFn:()=>f.entities.Review.filter({contractor_id:c},"-created_date"),enabled:!!c}),p=S({mutationFn:({reviewId:s,response:a})=>f.entities.Review.update(s,{contractor_response:a,contractor_response_date:new Date().toISOString()}),onSuccess:()=>{_.invalidateQueries({queryKey:["contractor-reviews",c]}),x(null),h("")}});if(C)return e.jsx("div",{className:"space-y-4",children:[...Array(3)].map((s,a)=>e.jsx(q,{className:"h-48 rounded-xl"},a))});const d=(t==null?void 0:t.filter(s=>!s.contractor_response))||[];return t!=null&&t.filter(s=>s.contractor_response),e.jsxs("div",{className:"space-y-6",children:[e.jsxs("div",{className:"grid grid-cols-2 md:grid-cols-4 gap-4",children:[e.jsx(n,{children:e.jsxs(r,{className:"p-4 text-center",children:[e.jsx("div",{className:"text-3xl font-bold text-slate-900",children:((u=l==null?void 0:l.rating)==null?void 0:u.toFixed(1))||"0.0"}),e.jsx("div",{className:"flex items-center justify-center gap-1 mt-1",children:[...Array(5)].map((s,a)=>e.jsx(m,{className:`w-3 h-3 ${a<Math.round((l==null?void 0:l.rating)||0)?"text-amber-500 fill-amber-500":"text-slate-200"}`},a))}),e.jsx("p",{className:"text-xs text-slate-500 mt-1",children:"Average Rating"})]})}),e.jsx(n,{children:e.jsxs(r,{className:"p-4 text-center",children:[e.jsx("div",{className:"text-3xl font-bold text-slate-900",children:(t==null?void 0:t.length)||0}),e.jsx("p",{className:"text-xs text-slate-500 mt-1",children:"Total Reviews"})]})}),e.jsx(n,{children:e.jsxs(r,{className:"p-4 text-center",children:[e.jsx("div",{className:"text-3xl font-bold text-amber-600",children:d.length}),e.jsx("p",{className:"text-xs text-slate-500 mt-1",children:"Awaiting Response"})]})}),e.jsx(n,{children:e.jsxs(r,{className:"p-4 text-center",children:[e.jsxs("div",{className:"text-3xl font-bold text-green-600",children:[t!=null&&t.length?Math.round(t.filter(s=>s.would_recommend).length/t.length*100):0,"%"]}),e.jsx("p",{className:"text-xs text-slate-500 mt-1",children:"Would Recommend"})]})})]}),d.length>0&&e.jsxs(n,{className:"border-amber-200 bg-amber-50/30",children:[e.jsx(y,{children:e.jsxs(v,{className:"flex items-center gap-2 text-lg",children:[e.jsx(A,{className:"w-5 h-5 text-amber-600"}),"Reviews Awaiting Your Response",e.jsx(j,{className:"bg-amber-100 text-amber-700",children:d.length})]})}),e.jsx(r,{className:"space-y-4",children:d.map(s=>e.jsxs(B.div,{initial:{opacity:0}
6,animate:{opacity:1},className:"p-4 bg-white rounded-lg border border-slate-200",children:[e.jsxs("div",{className:"flex items-start justify-between mb-3",children:[e.jsxs("div",{className:"flex items-start gap-3",children:[e.jsx("div",{className:"w-10 h-10 rounded-full bg-slate-100 flex items-center justify-center",children:e.jsx(D,{className:"w-5 h-5 text-slate-400"})}),e.jsxs("div",{children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("p",{className:"font-medium text-slate-900",children:s.reviewer_name}),s.is_verified_purchase&&e.jsxs(j,{variant:"secondary",className:"text-xs bg-green-100 text-green-700",children:[e.jsx(L,{className:"w-3 h-3 mr-1"}),"Verified"]})]}),e.jsx("p",{className:"text-sm text-slate-500",children:b(new Date(s.created_date),{addSuffix:!0})})]})]}),e.jsx("div",{className:"flex items-center gap-1",children:[...Array(5)].map((a,i)=>e.jsx(m,{className:`w-4 h-4 ${i<s.rating?"text-amber-500 fill-amber-500":"text-slate-200"}`},i))})]}),s.title&&e.jsx("h4",{className:"font-medium text-slate-900 mb-1",children:s.title}),e.jsx("p",{className:"text-slate-600 text-sm",children:s.comment}),s.would_recommend&&e.jsxs("div",{className:"mt-2 flex items-center gap-1 text-green-600 text-sm",children:[e.jsx(z,{className:"w-3 h-3"}),e.jsx("span",{children:"Would recommend"})]}),R===s.id?e.jsxs("div",{className:"mt-4 space-y-3",children:[e.jsx(M,{value:o,onChange:a=>h(a.target.value),placeholder:"Thank your customer and address their feedback...",rows:3}),e.jsxs("div",{className:"flex gap-2",children:[e.jsx(g,{size:"sm",onClick:()=>p.mutate({reviewId:s.id,response:o}),disabled:!o.trim()||p.isPending,className:"bg-green-600 hover:bg-green-700",children:p.isPending?e.jsx(F,{className:"w-4 h-4 animate-spin"}):"Post Response"}),e.jsx(g,{size:"sm",variant:"outline",onClick:()=>{x(null),h("")},children:"Cancel"})]})]}):e.jsxs(g,{variant:"outline",size:"sm",className:"mt-4",onClick:()=>x(s.id),children:[e.jsx(Q,{className:"w-4 h-4 mr-1"}),"Respond"]})]},s.id))})]}),e.jsxs(n,{children:[e.jsx(y,{children:e.jsx(v,{className:"text-lg",children:"All Reviews"})}),e.jsx(r,{children:t!=null&&t.length?e.jsx("div",{className:"space-y-4",children:t.map(s=>e.jsxs("div",{className:"p-4 bg-slate-50 rounded-lg",children:[e.jsxs("div",{className:"flex items-start justify-between mb-2",children:[e.jsxs("div",{children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("p",{className:"font-medium text-slate-900",children:s.reviewer_name}),s.is_verified_purchase&&e.jsx(j,{variant:"secondary",className:"text-xs bg-green-100 text-green-700",children:"Verified"})]}),e.jsx("p",{className:"text-sm text-slate-500",children:b(new Date(s.created_date),{addSuffix:!0})})]}),e.jsx("div",{className:"flex items-center gap-1",children:[...Array(5)].map((a,i)=>e.jsx(m,{className:`w-4 h-4 ${i<s.rating?"text-amber-500 fill-amber-500":"text-slate-200"}`},i))})]}),e.jsx("p",{className:"text-slate-600 text-sm",children:s.comment}),s.contractor_response&&e.jsxs("div",{className:"mt-3 p-3 bg-white rounded border-l-4 border-green-500",children:[e.jsx("p",{className:"text-xs text-green-600 font-medium mb-1",children:"Your Response"}),e.jsx("p",{className:"text-sm text-slate-600",children:s.contractor_response})]})]},s.id))}):e.jsxs("div",{className:"text-center py-8",children:[e.jsx(m,{className:"w-12 h-12 text-slate-300 mx-auto mb-4"}),e.jsx("h3",{className:"text-lg font-medium text-slate-900 mb-2",children:"No reviews yet"}),e.jsx("p",{className:"text-slate-500",children:"Reviews will appear here as customers leave feedback."})]})})]})]})}export{G 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.