lms/public/build/assets/course-card-1-CTs0r98c.js
2025-12-15 12:26:23 +01:00

2 lines
3.5 KiB
JavaScript

import{u as N,j as s,L as x,aB as v,be as _,k as C,w,e as h}from"./vendor-BKmmeuxg.js";import{B as p}from"./button-BpNwv2aE.js";import{C as y,a as k,b as F,e as z}from"./card-D9_SJYq6.js";import{T as B,a as D,b as E,c as H}from"./tooltip-BsX7Z6vz.js";import{s as L,c as a,e as P}from"./utils-DxSsnXxD.js";const U=({course:e,viewType:l="grid",className:f,wishlists:r})=>{const{props:n}=N(),{user:o}=n.auth,{translate:g}=n,{button:j,frontend:d,common:m}=g,i=r==null?void 0:r.find(c=>c.course_id===e.id),t=L(n.system.fields.selling_currency),u=()=>{i?h.delete(route("course-wishlists.destroy",{id:i.id})):h.post(route("course-wishlists.store",{user_id:o==null?void 0:o.id,course_id:e.id}))};return s.jsxs(y,{className:a("group p-0",l==="list"&&"sm:flex sm:w-full sm:flex-row sm:justify-between",f),children:[s.jsx(k,{className:"p-0",children:s.jsxs("div",{className:"relative",children:[s.jsx("div",{className:a("p-2 pb-0",l==="list"&&"pb-2"),children:s.jsx(x,{href:route("course.details",{slug:e.slug,id:e.id}),children:s.jsx("div",{className:a("relative h-[190px] overflow-hidden rounded-lg",l==="list"&&"sm:w-[260px]"),children:s.jsx("img",{src:e.thumbnail||"/assets/images/blank-image.jpg",alt:e.title,className:"h-full w-full object-cover transition-transform duration-300 hover:scale-105",onError:c=>{const b=c.target;b.src="/assets/images/blank-image.jpg"}})})})}),r&&s.jsx(B,{delayDuration:0,children:s.jsxs(D,{children:[s.jsx(E,{className:"absolute top-3 right-3 z-10 opacity-0 group-hover:opacity-100",children:s.jsx(p,{size:"icon",variant:"ghost",className:"bg-white/80 hover:bg-white",onClick:u,children:s.jsx(v,{className:a("h-4 w-4",i&&"text-red-500")})})}),s.jsx(H,{children:s.jsxs("p",{children:[" ",i?d.remove_from_wishlist:d.add_to_wishlist]})})]})})]})}),s.jsxs("div",{className:a(l==="list"&&"flex w-[calc(100%-272px)] flex-col justify-between"),children:[s.jsxs(F,{className:a("p-4",l==="list"&&"h-full"),children:[s.jsxs("div",{className:"text-secondary-foreground mb-1 flex items-center gap-1.5 text-xs",children:[s.jsx(_,{className:"h-3 w-3"}),s.jsxs("span",{children:[e.enrollments_count||0," ",e.enrollments_count?` ${m.students}`:` ${d.student}`]}),s.jsx(C,{className:"ml-2 h-3 w-3"}),s.jsx("span",{children:P(e,"readable")})]}),s.jsxs(x,{className:a("space-y-3",l==="list"&&"sm:flex sm:h-full sm:flex-col sm:justify-between sm:py-4"),href:route("course.details",{slug:e.slug,id:e.id}),children:[s.jsx("p",{className:"hover:text-secondary-foreground font-semibold",children:e.title}),s.jsxs("p",{className:"text-muted-foreground flex items-center gap-1.5 text-sm",children:[s.jsx(w,{className:"h-3.5 w-3.5 fill-amber-400 text-amber-400"}),s.jsx("span",{children:e.average_rating?Number(e.average_rating).toFixed(2):"0.00"}),s.jsxs("span",{children:["(",e.reviews_count||0," ",m.reviews,")"]})]})]})]}),s.jsxs(z,{className:"flex w-full items-center justify-between p-4 pt-0",children:[s.jsx("p",{className:"capitalize",children:e.pricing_type==="free"?m.free:e.discount?s.jsxs(s.Fragment,{children:[s.jsxs("span",{className:"font-semibold",children:[t==null?void 0:t.symbol,e.discount_price]}),s.jsxs("span",{className:"text-muted-foreground ml-2 text-sm font-medium line-through",children:[t==null?void 0:t.symbol,e.price]})]}):s.jsx(s.Fragment,{children:s.jsxs("span",{className:"font-semibold",children:[t==null?void 0:t.symbol,e.price]})})}),s.jsx(p,{asChild:!0,variant:"outline",className:"border-secondary-light hover:bg-background hover:border-primary px-2.5",children:s.jsx(x,{href:route("course.details",{slug:e.slug,id:e.id}),children:j.learn_more})})]})]})]})};export{U as C};