1const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/index-P4ZdD-Xo.js","assets/index-DUvoU4cF.css"])))=>i.map(i=>d[i]); 2import{U as k,u as A,r as p,j as s,C as j,aQ as _,P as b,n as F,a3 as R,q as m,aO as E,L,aM as z,ct as M,af as U}from"./index-P4ZdD-Xo.js";import{f as I}from"./dateFormatter-DZXCGK8F.js";const $=()=>{const{id:l}=k(),u=A(),[n,h]=p.useState(null),[x,y]=p.useState([]),[d,f]=p.useState([]),[w,g]=p.useState(!0),[P,C]=p.useState(!1);if(p.useEffect(()=>{if(!l)return;(async()=>{try{g(!0);const r=await z({company_id:l}),t=Array.isArray(r)?r:r?.data??r?.products??[];y(t);try{const c=await M(l),a=c?.data?.company??c?.data??c?.company??c;if(a&&(a.company_name||a.name))h({...a,company_name:a.company_name||a.name,company_logo:a.company_logo_url||a.company_logo||a.logo,company_simple_hint:a.company_simple_hint||a.description,status:a.status});else throw new Error("No company data")}catch{const a=t[0]?.company;h(a?{id:a.id??l,company_name:a.company_name||a.name||"٠تجر",company_logo:a.company_logo_url||a.company_logo||a.logo,company_
2simple_hint:a.description||a.company_simple_hint||"",status:a.status||"approved"}:{id:l,company_name:"Ù
تجر",status:"approved"})}const{getProductReviews:i}=await U(async()=>{const{getProductReviews:c}=await import("./index-P4ZdD-Xo.js").then(a=>a.dM);return{getProductReviews:c}},__vite__mapDeps([0,1])),o=[];for(const c of t)try{const a=await i(c.id);(Array.isArray(a)?a:a?.data??[]).forEach(S=>o.push({...S,productName:c.name}))}catch{}f(o)}catch{C(!0)}finally{g(!1)}})()},[l]),w)return s.jsxs("div",{className:"cpub-loading",children:[s.jsx("div",{className:"cpub-spinner"}),s.jsx("p",{children:"جار٠تØÙ
ÙÙ Ø¨ÙØ§Ùات اÙÙ
تجر..."})]});if(P||!n)return s.jsxs("div",{className:"cpub-error",children:[s.jsx(j,{size:60}),s.jsx("h2",{children:"اÙÙ
تجر ØºÙØ± Ù
تاØ"}),s.jsx("p",{children:"تعذر تØÙ
ÙÙ Ø¨ÙØ§Ùات ÙØ°Ø§ اÙÙ
تجر. ÙØ±Ø¬Ù اÙÙ
ØØ§ÙÙØ© ÙØ§ØÙاÙ."}),s.jsxs("button",{onClick:()=>u(-1),children:[s.jsx(_,{})," Ø§ÙØ¹Ùدة ÙÙÙ
تجر"]})]});const N=b(n.company_logo),v=n.status==="approved";return s.jsxs("div",{className:"cpub-page",children:[s.jsx("div",{className:"cpub-back-bar",children:s.jsxs("button",{className:"cpub-back-btn",onClick:()=>u(-1),children:[s.jsx(_,{})," Ø§ÙØ¹Ùدة ÙÙÙ
تجر"]})}),s.jsx("section",{className:"cpub-hero",children:s.jsxs("div",{className:"cpub-hero-inner",children:[s.jsx("div",{className:"cpub-logo-wrap",children:N?s.jsx("img",{src:N,alt:n.company_name,className:"cpub-logo"}):s.jsx("div",{className:"cpub-logo-placeholder",children:s.jsx(j,{size:40})})}),s.jsxs("div",{className:"cpub-hero-info",children:[s.jsxs("div",{className:"cpub-name-row",children:[s.jsx("h1",{className:"cpub-name",children:n.company_name}),s.jsx("span",{className:`cpub-badge ${v?"approved":"pending"}`,children:v?s.jsxs(s.Fragment,{children:[s.jsx(F,{})," Ù
تجر Ù
عتÙ
د"]}):s.jsxs(s.Fragment,{children:[s.jsx(R,{})," ÙÙØ¯ اÙÙ
راجعة"]})})]}),n.company_category&&s.jsx("div",{className:"cpub-category-row",children:s.jsx("span",{className:"cpub-category-tag",children:n.company_category})}),n.company_simple_hint&&s.jsx("p",{className:"cpub-about",children:n.company_
2simple_hint}),s.jsxs("div",{className:"cpub-stats",children:[s.jsxs("div",{className:"cpub-stat",children:[s.jsx("strong",{children:x.length}),s.jsx("span",{children:"Ù
ÙØªØ¬"})]}),s.jsxs("div",{className:"cpub-stat",children:[s.jsx("strong",{children:d.length}),s.jsx("span",{children:"تÙÙÙÙ
"})]}),d.length>0&&s.jsxs("div",{className:"cpub-stat",children:[s.jsxs("div",{className:"cpub-avg-stars",children:[s.jsx(m,{fill:"var(--amber-500)",color:"var(--amber-500)"}),s.jsx("strong",{children:(d.reduce((e,r)=>e+(Number(r.rating)||0),0)/d.length).toFixed(1)})]}),s.jsx("span",{children:"Ù
ØªÙØ³Ø· Ø§ÙØªÙÙÙÙ
"})]})]})]})]})}),s.jsxs("section",{className:"cpub-section",children:[s.jsx("div",{className:"cpub-section-header",children:s.jsxs("h2",{className:"cpub-section-title",children:[s.jsx(E,{})," Ù
ÙØªØ¬Ø§Øª اÙÙ
تجر"]})}),x.length===0?s.jsxs("div",{className:"cpub-empty",children:[s.jsx(j,{size:48}),s.jsx("p",{children:"ÙØ§ ØªÙØ¬Ø¯ Ù
ÙØªØ¬Ø§Øª Ù
Ø¹Ø±ÙØ¶Ø© ØØ§ÙÙØ§Ù"})]}):s.jsx("div",{className:"cpub-products-grid",children:x.map(e=>{const r="https://placehold.co/300x220?text=Product",t=b(e.main_image_url||e.main_image)||r,i=Number(e.discount_price??0),o=Number(e.price??0),c=i>0?o-i:o;return s.jsxs(L,{to:"/store",className:"cpub-product-card",onClick:()=>u("/store"),children:[s.jsxs("div",{className:"cpub-product-img-wrap",children:[s.jsx("img",{src:t,alt:e.name,loading:"lazy",onError:a=>{a.currentTarget.src=r}}),i>0&&s.jsxs("span",{className:"cpub-discount-badge",children:["-",Math.round(i/o*100),"%"]})]}),s.jsxs("div",{className:"cpub-product-info",children:[s.jsx("h3",{className:"cpub-product-name",children:e.name}),s.jsxs("div",{className:"cpub-product-price",children:[s.jsxs("span",{className:"cpub-price-main",children:[c.toLocaleString()," ج.Ù
"]}),i>0&&s.jsx("span",{className:"cpub-price-old",children:o.toLocaleString()})]}),s.jsxs("div",{className:"cpub-product-rating",children:[[1,2,3,4,5].map(a=>s.jsx(m,{className:a<=Math.floor(e.rating??0)?"star-on":"star-off"},a)),s.jsxs("span",{children:["(",e.reviews_count??0,")"]})]})]})]},e.id)})})]}),d.length>0&&s.jsxs("section",{className:"cpub-section",children:[s.jsx("div",{className:"cpub-section-header",children:s.jsxs("h2",{className:"cpub-section-title",children:[s.jsx(m,{})," آراء Ø§ÙØ¹Ù
ÙØ§Ø¡"]})}),s.jsx("div",{className:"cpub-reviews-grid",children:d.map((e,r)=>s.jsxs("div",{className:"cpub-review-card",children:[s.jsxs("div",{className:"cpub-review-header",children:[s.jsx("div",{className:"cpub-reviewer-avatar",children:e.user_avatar?s.jsx("img",{src:b(e.user_avatar),alt:e.user_name}):(e.user_name||"Ù
").charAt(0).toUpperCase()}),s.jsxs("div",{className:"cpub-reviewer-info",children:[s.jsxs("div",{className:"cpub-reviewer-name-row",children:[s.jsx("strong",{children:e.user_name||"Ù
ستخدÙ
"}),s.jsx("span",{className:`cpub-reviewer-type ${e.user_type==="ØµÙØ§ÙعÙ"?"craftsman":"user"}`,children:e.user_type})]}),s.jsxs("div",{className:"cpub-review-meta-row",children:[s.jsx("div",{className:"cpub-review-stars",children:[1,2,3,4,5].map(t=>s.jsx(m,{className:t<=(Number(e.rating)||0)?"star-on":"star-off"},t))}),s.jsx("span",{className:"cpub-review-date",children:e.created_at?I(e.created_at):""})]})]})]}),e.comment&&s.jsxs("p",{className:"cpub-review-comment",children:['"',e.comment,'"']}),s.jsx("span",{className:"cpub-review-product-tag",children:e.productName})]},r))})]})]})};export{$ 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.