PageSourceSearch

https://nicholasalifa.lovable.app/assets/ProductDetail-C_oPqFGA.js

js nicholasalifa.lovable.app collected 2026-10-03 03:34:13 UTC 18,803 bytes, 11 lines download raw bytes

1import{c as K,r as i,j as e,_ as $,B as h,I as P,av as R,C as ae,V as te,al as re,aB as ie,at as le,au as ne,f as ce,m as D,L as k,ap as oe,F as M,l as de,aA as F,Z,ai as J,aC as G,k as C,d as T,aw as me,a3 as W}from"./index-DVnvwKss.js";import{L as v}from"./label-Bnts9xf-.js";import{R as xe,a as U}from"./radio-group-CnAp_H84.js";import{S as l}from"./skeleton-0-5UMlgj.js";import{u as ue}from"./useBookChapters-NN7kv-xk.js";import{u as he}from"./useReadingProgress-DvH52rCB.js";import{B as pe}from"./Breadcrumbs-B1zdw0pZ.js";import{T as ge}from"./textarea-C2P6Vfod.js";import{a as je,b as Q,c as fe,S as Y}from"./useProductReviews-BzoTRBx9.js";import{R as X}from"./RatingSummary-Cnuj92Lo.js";import{P as ee}from"./package-CWCtnPMe.js";import{M as ve}from"./map-pin-Bn7e5Vt0.js";import{G as Ne}from"./graduation-cap-B6HRXtd7.js";import"./house-BKAT5qfs.js";import"./star-DgJGUcrD.js";/**
2 * @license lucide-react v0.462.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 ye=K("CirclePlay",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["polygon",{points:"10 8 16 12 10 16 10 8",key:"1cimsy"}]]);/**
7 * @license lucide-react v0.462.0 - ISC
8 *
9 * This source code is licensed under the ISC license.
10 * See the LICENSE file in the root directory of this source tree.
11 */const be=K("MessageSquare",[["path",{d:"M21 15a2 2 0 0 1-2 2H7l-4 4V5a2 2 0 0 1 2-2h14a2 2 0 0 1 2 2z",key:"1lielz"}]]);function we({releaseDate:m}){const[s,N]=i.useState(null),[p,g]=i.useState(!1);if(i.useEffect(()=>{const o=()=>{const x=new Date(m).getTime(),u=new Date().getTime(),d=x-u;return d<=0?(g(!0),null):{days:Math.floor(d/864e5),hours:Math.floor(d%864e5/36e5),minutes:Math.floor(d%36e5/6e4),seconds:Math.floor(d%6e4/1e3)}};N(o());const t=setInterval(()=>{const x=o();x===null&&clearInterval(t),N(x)},1e3);return()=>clearInterval(t)},[m]),p)return e.jsx("div",{className:"bg-green-50 dark:bg-green-950/20 border border-green-200 dark:border-green-800 p-4 rounded-lg",children:e.jsxs("div",{className:"flex items-center gap-2 text-green-700 dark:text-green-400",children:[e.jsx($,{className:"w-5 h-5"}),e.jsx("span",{className:"font-medium",children:"Now Available!"})]})});if(!s)return null;const c=({value:o,label:t})=>e.jsxs("div",{className:"flex flex-col items-center",children:[e.jsx("div",{className:"bg-foreground text-background font-heading text-2xl sm:text-3xl font-bold w-14 sm:w-16 h-14 sm:h-16 flex items-center justify-center rounded-lg",children:o.toString().padStart(2,"0")}),e.jsx("span",{className:"text-xs text-muted-foreground mt-1 uppercase tracking-wider",children:t})]});return e.jsxs("div",{className:"bg-amber-50 dark:bg-amber-950/20 border border-amber-200 dark:border-amber-800 p-5 rounded-lg",children:[e.jsxs("div",{className:"flex items-center gap-2 text-amber-700 dark:text-amber-400 mb-4",children:[e.jsx($,{className:"w-5 h-5"}),e.jsx("span",{className:"font-medium",children:"Releases In"})]}),e.jsxs("div",{className:"flex items-center justify-center gap-2 sm:gap-3",children:[e.jsx(c,{value:s.days,label:"Days"}),e.jsx("span",{className:"text-2xl font-bold text-muted-foreground pb-5",children:":"}),e.jsx(c,{value:s.hours,label:"Hours"}),e.jsx("span",{className:"text-2xl font-bold text-muted-foreground pb-5",children:":"}),e.jsx(c,{value:s.minutes,label:"Mins"}),e.jsx("span",{className:"text-2xl font-bold text-muted-foreground pb-5",children:":"}),e.jsx(c,{value:s.seconds,label:"Secs"})]}),e.jsx("p",{className:"text-sm text-amber-600 dark:text-amber-500 mt-4 text-center",children:"Pre-order now to secure your copy"})]})}function _e({productId:m}){const{data:s,isLoading:N}=je(m),{data:p}=Q(m),g=fe(),[c,o]=i.useState(!1),[t,x]=i.useState(0),[u,d]=i.useState(""),[j,y]=i.useState(""),[b,f]=i.useState(""),[w,_]=i.useState(""),n=a=>{a.preventDefault(),t!==0&&(!u.trim()||!j.trim()||g.mutate({product_id:m,rating:t,reviewer_name:u.trim(),reviewer_email:j.trim(),title:b.trim()||void 0,content:w.trim()||void 0},{onSuccess:()=>{o(!1),x(0),d(""),y(""),f(""),_("")}}))};return e.jsxs("section",{className:"mt-16 max-w-3xl",children:[e.jsxs("div",{className:"flex items-center justify-between mb-6",children:[e.jsx("h2",{className:"font-heading text-2xl",children:"Reviews"}),!c&&e.jsxs(h,{variant:"outline",onClick:()=>o(!0),children:[e.jsx(be,{className:"w-4 h-4 mr-2"}),"Write a Review"]})]}),p&&p.review_count>0&&e.jsx("div",{className:"mb-8",children:e.jsx(X,{averageRating:p.average_rating,reviewCount:p.review_count})}),c&&e.jsxs("form",{onSubmit:n,className:"bg-secondary/50 p-6 mb-8 space-y-4 border border-border",children:[e.jsx("h3",{className:"font-heading text-lg",children:"Write Your Review"}),e.jsxs("div",{children:[e.jsx(v,{children:"Rating *"}),e.jsx("div",{className:"mt-1",children:e.jsx(Y,{rating:t,size:"lg",interactive:!0,onRatingChange:x})})]}),e.jsxs("div",{className:"grid sm:grid-cols-2 gap-4",children:[e.jsxs("div",{children:[e.jsx(v,{htmlFor:"reviewer-name",children:"Name *"}),e.jsx(P,{id:"reviewer-name",value:u,onChange:a=>d(a.target.value),required:!0,maxLength:100})]}),e.jsxs("div",{children:[e.jsx(v,{htmlFor:"reviewer-email",children:"Email *"}),e.jsx(P,{id:"reviewer-email",type:"email",value:j,onChange:a=>y(a.target.value),required:!0,maxLength:255,placeholder:"Used to verify purchase"})]})]}),e.jsxs("div",{children:[e.jsx(v,{htmlFor:"review-title",children:"Title (optional)"}),e.jsx(P,{id:"review-title",value:b,onChange:a=>f(a.target.value),maxLength:200,placeholder:"Summarize your experience"})]}),e.jsxs("div",{children:[e.jsx(v,{htmlFor:"review-content",children:"Review (optional)"}),e.jsx(ge,{id:"review-content",value:w,onChange:a=>_(a.target.value),maxLength:2e3,rows:4,placeholder:"Share your thoughts about this product..."})]}),e.jsxs("div",{className:"flex gap-3",children:[e.jsx(h,{type:"submit",disabled:t===0||g.isPending,children:g.isPending?"Submitting...":"Submit Review"}),e.jsx(h,{type:"button",variant:"ghost",onClick:()=>o(!1),children:"Cancel"})]}),e.jsx("p",{className:"text-xs text-muted-foreground",children:`Reviews are moderated before appearing. If your email matches a purchase, you'll get a "Verified Buyer" badge.`})]}),N?e.jsx("p",{className:"text-muted-foreground",children:"Loading reviews..."}):s&&s.length>0?e.jsx("div",{className:"space-y-6",children:s.map(a=>e.jsxs("div",{className:"border-b border-border pb-6 last:border-0",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 mb-1",children:[e.jsx(Y,{rating:a.rating,size:"sm"}),a.order_id&&e.jsxs(R,{variant:"secondary",className:"text-xs gap-1",children:[e.jsx(ae,{className:"w-3 h-3"}),"Verified Buyer"]})]}),a.title&&e.jsx("h4",{className:"font-medium",children:a.title})]}),e.jsx("span",{className:"text-xs text-muted-foreground",children:te(new Date(a.created_at),"MMM d, yyyy")})]}),a.content&&e.jsx("p",{className:"text-sm text-muted-foreground mb-2",children:a.content}),e.jsxs("p",{className:"text-xs text-muted-foreground",children:["— ",a.reviewer_name]})]},a.id))}):!c&&e.jsx("p",{className:"text-muted-foreground",children:"No reviews yet. Be the first to share your thoughts!"})]})}const ke={book:T,course:Ne,event:Z,digital:J,physical:ee},q={book:"Book",course:"Course",event:"Event",digital:"Digital Product",physical:"Physical Product"};function Se(){return e.jsxs(e.Fragment,{children:[e.jsx(D,{}),e.jsx("main",{className:"min-h-screen py-24",children:e.jsxs("div",{className:"container-wide",children:[e.jsxs("div",{className:"flex items-center gap-2 mb-8",children:[e.jsx(l,{className:"h-4 w-12"}),e.jsx(l,{className:"h-4 w-4"}),e.jsx(l,{className:"h-4 w-24"})]}),e.jsxs("div",{className:"grid lg:grid-cols-2 gap-12",children:[e.jsx(l,{className:"aspect-square w-full rounded-none"}),e.jsxs("div",{className:"space-y-6",children:[e.jsx("div",{className:"flex gap-2",children:e.jsx(l,{className:"h-6 w-20 rounded-full"})}),e.jsx(l,{className:"h-10 w-3/4"}),e.jsx(l,{className:"h-5 w-full"}),e.jsx(l,{className:"h-5 w-2/3"}),e.jsx(F,{}),e.jsx(l,{className:"h-12 w-32"}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(l,{className:"h-4 w-40"}),e.jsx(l,{className:"h-4 w-36"})]}),e.jsx(l,{className:"h-12 w-full rounded-md"})]})]})]})}),e.jsx(M,{})]})}function Oe(){const{slug:m}=re(),{data:s,isLoading:N,error:p}=ie(m||""),{addItem:g,items:c}=le(),{openCart:o}=ne(),{formatPrice:t,currencySymbol:x,toDisplayValue:u,toKobo:d}=ce(),{data:j}=ue((s==null?void 0:s.id)||""),{lastReadChapter:y,overallProgress:b}=he(m||"",(j==null?void 0:j.length)||0),{data:f}=Q((s==null?void 0:s.id)||""),[w,_]=i.useState(""),[n,a]=i.useState("digital"),[L,z]=i.useState(null);i.useEffect(()=>{s&&s.allow_pay_what_you_want&&_(u(s.price).toString()),s!=null&&s.cover_image_url&&z(s.cover_image_url)},[s,u]);
11const E=s?[s.cover_image_url,...s.gallery_images||[]].filter(Boolean):[],se=()=>{if(s){const r=s.has_multiple_formats?n:void 0;if(s.allow_pay_what_you_want){const B=d(parseFloat(w)),H=s.min_price||0;if(isNaN(B)||B<H){W.error(`Minimum price is ${t(H)}`);return}g(s,1,B,r)}else g(s,1,void 0,r);const S=r==="hardcopy"?" (Hardcopy)":r==="digital"?" (Digital)":"";W.success(`${s.title}${S} added to cart`,{action:{label:"View Cart",onClick:o}})}},A=s&&c.some(r=>s.has_multiple_formats?r.product.id===s.id&&r.format===n:r.product.id===s.id),O=()=>s?s.has_multiple_formats&&n==="hardcopy"&&s.hardcopy_price||s.price:0,I=()=>s?s.has_multiple_formats&&n==="hardcopy"?s.hardcopy_stock_quantity!==null&&s.hardcopy_stock_quantity<=0:s.stock_quantity!==null&&s.stock_quantity<=0:!1;if(N)return e.jsx(Se,{});if(p||!s)return e.jsxs(e.Fragment,{children:[e.jsx(D,{}),e.jsxs("div",{className:"min-h-screen flex flex-col items-center justify-center animate-fade-in",children:[e.jsx("div",{className:"inline-flex items-center justify-center w-20 h-20 rounded-full bg-muted mb-6",children:e.jsx(ee,{className:"w-10 h-10 text-muted-foreground/50"})}),e.jsx("h1",{className:"font-heading text-2xl mb-2",children:"Product Not Found"}),e.jsx("p",{className:"text-muted-foreground mb-6",children:"This product may have been removed or doesn't exist."}),e.jsx(k,{to:"/store",children:e.jsxs(h,{children:[e.jsx(oe,{className:"mr-2 h-4 w-4"}),"Back to Store"]})})]}),e.jsx(M,{})]});const V=ke[s.product_type];return e.jsxs(e.Fragment,{children:[e.jsx(de,{title:s.title,description:s.description||`${s.title} - Available now in the store.`,image:s.og_image_url||s.cover_image_url||void 0,url:`/store/${s.slug}`,type:"product",product:{price:O(),currency:"NGN",availability:s.is_preorder?"preorder":I()?"oos":"instock"}}),e.jsx(D,{}),e.jsx("main",{className:"min-h-screen py-24",children:e.jsxs("div",{className:"container-wide animate-fade-in",children:[e.jsx(pe,{items:[{label:"Store",href:"/store"},{label:s.title}],className:"mb-8"}),e.jsxs("div",{className:"grid lg:grid-cols-2 gap-12",children:[e.jsxs("div",{className:"space-y-3",children:[e.jsxs("div",{className:"aspect-square bg-secondary relative overflow-hidden border-2 border-border",children:[L||s.cover_image_url?e.jsx("img",{src:L||s.cover_image_url,alt:`${s.title} — ${q[s.product_type]} product image`,className:"w-full h-full object-cover"}):e.jsx("div",{className:"w-full h-full flex items-center justify-center",children:e.jsx(V,{className:"w-24 h-24 text-muted-foreground/40"})}),I()&&e.jsx("div",{className:"absolute inset-0 bg-background/80 flex items-center justify-center",children:e.jsx(R,{variant:"destructive",className:"text-lg px-4 py-2",children:"Out of Stock"})}),s.is_preorder&&e.jsxs(R,{className:"absolute top-3 right-3 bg-amber-500 text-white",children:[e.jsx($,{className:"w-3 h-3 mr-1"}),"Pre-Order"]})]}),E.length>1&&e.jsx("div",{className:"flex gap-2 overflow-x-auto pb-1",children:E.map((r,S)=>e.jsx("button",{onClick:()=>z(r),className:`shrink-0 w-16 h-16 border-2 overflow-hidden transition-colors ${L===r?"border-primary":"border-border hover:border-muted-foreground"}`,children:e.jsx("img",{src:r,alt:`${s.title} - image ${S+1}`,className:"w-full h-full object-cover"})},S))})]}),e.jsxs("div",{className:"space-y-6",children:[e.jsxs("div",{children:[e.jsxs(R,{variant:"secondary",className:"mb-4",children:[e.jsx(V,{className:"w-3 h-3 mr-1"}),q[s.product_type]]}),e.jsx("h1",{className:"font-heading text-3xl lg:text-4xl mb-3",children:s.title}),f&&f.review_count>0&&e.jsx(X,{averageRating:f.average_rating,reviewCount:f.review_count,className:"mb-4"}),s.description&&e.jsx("p",{className:"text-lg text-muted-foreground leading-relaxed",children:s.description})]}),e.jsx(F,{}),s.is_preorder&&s.preorder_release_date&&e.jsx(we,{releaseDate:s.preorder_release_date}),s.product_type==="event"&&e.jsxs("div",{className:"bg-accent/30 border border-accent rounded-lg p-4 space-y-2",children:[s.event_date&&e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(Z,{className:"w-4 h-4 text-primary"}),e.jsx("span",{children:new Date(s.event_date).toLocaleDateString("en-US",{weekday:"long",year:"numeric",month:"long",day:"numeric"})})]}),s.event_location&&e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(ve,{className:"w-4 h-4 text-primary"}),e.jsx("span",{children:s.event_location})]})]}),s.has_multiple_formats&&e.jsxs("div",{className:"space-y-4",children:[e.jsx(v,{className:"text-base font-medium",children:"Choose Format"}),e.jsxs(xe,{value:n,onValueChange:r=>a(r),className:"space-y-3",children:[e.jsxs("label",{className:`flex items-start space-x-3 p-4 rounded-lg border-2 cursor-pointer transition-all ${n==="digital"?"border-primary bg-primary/5 shadow-sm":"border-border hover:border-muted-foreground"}`,children:[e.jsx(U,{value:"digital",id:"format-digital",className:"mt-1"}),e.jsxs("div",{className:"flex-1",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx("span",{className:"font-medium",children:"Digital Copy"}),e.jsx("span",{className:"font-heading text-lg text-primary",children:t(s.price)})]}),e.jsxs("div",{className:"flex items-center gap-1 text-sm text-muted-foreground mt-1",children:[e.jsx(J,{className:"w-3 h-3"}),"Instant download after payment"]})]})]}),e.jsxs("label",{className:`flex items-start space-x-3 p-4 rounded-lg border-2 cursor-pointer transition-all ${n==="hardcopy"?"border-primary bg-primary/5 shadow-sm":"border-border hover:border-muted-foreground"}`,children:[e.jsx(U,{value:"hardcopy",id:"format-hardcopy",className:"mt-1"}),e.jsxs("div",{className:"flex-1",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx("span",{className:"font-medium",children:"Hardcopy"}),e.jsx("span",{className:"font-heading text-lg text-primary",children:t(s.hardcopy_price||s.price)})]}),e.jsxs("div",{className:"flex items-center gap-1 text-sm text-muted-foreground mt-1",children:[e.jsx(G,{className:"w-3 h-3"}),"Physical book shipped to you"]}),s.hardcopy_stock_quantity!==null&&s.hardcopy_stock_quantity>0&&e.jsxs("div",{className:"text-xs text-muted-foreground mt-1",children:[s.hardcopy_stock_quantity," in stock"]})]})]})]})]}),!s.has_multiple_formats&&(s.allow_pay_what_you_want?e.jsxs("div",{className:"space-y-4 bg-accent/30 border border-accent p-5 rounded-lg",children:[e.jsxs("div",{children:[e.jsx(v,{htmlFor:"custom-price",className:"text-base font-medium",children:"Pay What You Want"}),e.jsxs("p",{className:"text-sm text-muted-foreground mt-1",children:["Enter the amount you'd like to pay",s.min_price&&s.min_price>0&&e.jsxs("span",{children:[" (minimum ",t(s.min_price),")"]})]})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("span",{className:"text-lg font-medium",children:x}),e.jsx(P,{id:"custom-price",type:"number",min:u(s.min_price||0),step:"0.01",value:w,onChange:r=>_(r.target.value),className:"text-2xl font-heading h-12 w-40",placeholder:"Amount"})]}),e.jsxs("p",{className:"text-sm text-muted-foreground",children:["Suggested price: ",t(s.price)]})]}):e.jsxs("div",{className:"flex items-baseline gap-3",children:[e.jsx("span",{className:"font-heading text-4xl text-primary",children:t(O())}),s.compare_at_price&&s.compare_at_price>s.price&&e.jsx("span",{className:"text-xl text-muted-foreground line-through",children:t(s.compare_at_price)})]})),e.jsxs("div",{className:"space-y-2",children:[!s.has_multiple_formats&&!s.requires_shipping&&e.jsxs("div",{className:"flex items-center gap-2 text-sm text-muted-foreground",children:[e.jsx(C,{className:"w-4 h-4 text-green-600"}),"Instant digital delivery"]}),n==="digital"&&s.has_multiple_formats&&e.jsxs("div",{className:"flex items-center gap-2 text-sm text-muted-foreground",children:[e.jsx(C,{className:"w-4 h-4 text-green-600"}),"Instant digital delivery"]}),n==="hardcopy"&&s.has_multiple_formats&&e.jsxs("div",{className:"flex items-center gap-2 text-sm text-muted-foreground",children:[e.jsx(G,{className:"w-4 h-4 text-primary"}),"Shipping required"]}),!s.has_multiple_formats&&s.stock_quantity!==null&&s.stock_quantity>0&&e.jsxs("div",{className:"flex items-center gap-2 text-sm text-muted-foreground",children:[e.jsx(C,{className:"w-4 h-4 text-green-600"}),s.stock_quantity," in stock"]})]}),s.read_online_enabled&&e.jsx("div",{className:"space-y-2",children:y?e.jsxs(e.Fragment,{children:[e.jsx(k,{to:`/read/${s.slug}/${y}`,children:e.jsxs(h,{size:"lg",className:"w-full",children:[e.jsx(ye,{className:"mr-2 h-5 w-5"}),"Continue Reading",b>0&&e.jsxs("span",{className:"ml-2 text-xs opacity-80",children:["(",b,"% complete)"]})]})}),e.jsx(k,{to:`/read/${s.slug}`,children:e.jsxs(h,{variant:"outline",size:"lg",className:"w-full",children:[e.jsx(T,{className:"mr-2 h-5 w-5"}),"Start from Beginning"]})})]}):e.jsx(k,{to:`/read/${s.slug}`,children:e.jsxs(h,{variant:"outline",size:"lg",className:"w-full",children:[e.jsx(T,{className:"mr-2 h-5 w-5"}),"Read Online Free"]})})}),e.jsxs("div",{className:"space-y-3 pt-2",children:[e.jsx(h,{size:"lg",className:"w-full text-base h-12",onClick:se,disabled:I(),children:A?e.jsxs(e.Fragment,{children:[e.jsx(C,{className:"mr-2 h-5 w-5"}),"Added to Cart"]}):e.jsxs(e.Fragment,{children:[e.jsx(me,{className:"mr-2 h-5 w-5"}),s.is_preorder?"Pre-Order Now":"Add to Cart"]})}),A&&e.jsx(k,{to:"/checkout",className:"block",children:e.jsx(h,{variant:"outline",size:"lg",className:"w-full",children:"Proceed to Checkout"})})]})]})]}),s.content&&e.jsxs("div",{className:"mt-20",children:[e.jsx(F,{className:"mb-12"}),e.jsxs("div",{className:"max-w-3xl",children:[e.jsxs("h2",{className:"font-heading text-2xl mb-6",children:["About This ",q[s.product_type]]}),e.jsx("div",{className:"prose prose-lg max-w-none",dangerouslySetInnerHTML:{__html:s.content}})]})]}),e.jsxs("div",{className:"mt-16",children:[e.jsx(F,{className:"mb-12"}),e.jsx(_e,{productId:s.id})]})]})}),e.jsx(M,{})]})}
11export{Oe 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.