bugfix
All checks were successful
Build & Push Docker Image / docker (push) Successful in 1m52s

This commit is contained in:
Ahmed Darrazi 2025-12-19 17:24:10 +01:00
parent 4e7fdb046d
commit 2055484a87
10 changed files with 64 additions and 36 deletions

View File

@ -18,6 +18,7 @@ const CourseCard1 = ({ course, viewType = 'grid', className, wishlists }: Props)
const { user } = props.auth;
const { translate } = props;
const { button, frontend, common } = translate;
const showWishlist = props.system.fields?.show_student_wishlist !== false;
const isWishlisted = wishlists?.find((wishlist) => wishlist.course_id === course.id);
const currency = systemCurrency(props.system.fields['selling_currency']);
@ -55,7 +56,7 @@ const CourseCard1 = ({ course, viewType = 'grid', className, wishlists }: Props)
</Link>
</div>
{wishlists && (
{wishlists && showWishlist && (
<TooltipProvider delayDuration={0}>
<Tooltip>
<TooltipTrigger className="absolute top-3 right-3 z-10 opacity-0 group-hover:opacity-100">

View File

@ -17,6 +17,7 @@ const CourseCard2 = ({ course, className, wishlists }: Props) => {
const { props } = usePage<SharedData>();
const { user } = props.auth;
const { button, common, frontend } = props.translate;
const showWishlist = props.system.fields?.show_student_wishlist !== false;
const isWishlisted = wishlists?.find((wishlist) => wishlist.course_id === course.id);
const currency = systemCurrency(props.system.fields['selling_currency']);
@ -52,7 +53,7 @@ const CourseCard2 = ({ course, className, wishlists }: Props) => {
</div>
</Link>
{wishlists && (
{wishlists && showWishlist && (
<TooltipProvider delayDuration={0}>
<Tooltip>
<TooltipTrigger className="absolute top-2 right-2 z-10">

View File

@ -17,6 +17,7 @@ const CourseCard6 = ({ course, type = 'grid', className, wishlists }: Props) =>
const { props } = usePage<SharedData>();
const { user } = props.auth;
const { button, common, frontend } = props.translate;
const showWishlist = props.system.fields?.show_student_wishlist !== false;
const isWishlisted = wishlists?.find((wishlist) => wishlist.course_id === course.id);
const currency = systemCurrency(props.system.fields['selling_currency']);
@ -54,7 +55,7 @@ const CourseCard6 = ({ course, type = 'grid', className, wishlists }: Props) =>
</Link>
</div>
{wishlists && (
{wishlists && showWishlist && (
<TooltipProvider delayDuration={0}>
<Tooltip>
<TooltipTrigger className="absolute top-2 right-2 z-10">

View File

@ -20,6 +20,7 @@ const ExamCard1 = ({ exam, variant = 'default', viewType = 'grid', onAddToCart,
const { props } = usePage<SharedData>();
const { translate } = props;
const { common } = translate;
const showWishlist = props.system.fields?.show_student_wishlist !== false;
const isCompact = variant === 'compact';
const examUrl = route('exams.details', { slug: exam.slug, id: exam.id });
@ -97,7 +98,7 @@ const ExamCard1 = ({ exam, variant = 'default', viewType = 'grid', onAddToCart,
</div>
<div className="flex items-center gap-2">
{onAddToWishlist && (
{showWishlist && onAddToWishlist && (
<Button
variant="outline"
size="icon"

View File

@ -21,6 +21,7 @@ const IntroNavbar = () => {
const navbar = getPageSection(page, 'navbar');
const user = auth.user;
const showWishlist = props.system.fields?.show_student_wishlist !== false;
const [isSticky, setIsSticky] = useState(false);
const [isMenuOpen, setIsMenuOpen] = useState(false);
@ -105,7 +106,7 @@ const IntroNavbar = () => {
)}
{(user.role === 'student' || user.role === 'instructor') &&
studentMenuItems.map(({ id, name, Icon, slug }) => (
getStudentMenuItems(showWishlist).map(({ id, name, Icon, slug }) => (
<DropdownMenuItem
key={id}
className="cursor-pointer px-3"
@ -216,19 +217,23 @@ const IntroNavbar = () => {
);
};
const studentMenuItems = [
const getStudentMenuItems = (showWishlist: boolean) => [
{
id: nanoid(),
name: 'My Courses',
slug: 'courses',
Icon: GraduationCap,
},
{
id: nanoid(),
name: 'Wishlist',
slug: 'wishlist',
Icon: Heart,
},
...(showWishlist
? [
{
id: nanoid(),
name: 'Wishlist',
slug: 'wishlist',
Icon: Heart,
},
]
: []),
{
id: nanoid(),
name: 'My Profile',

View File

@ -21,6 +21,7 @@ const LandingNavbar = () => {
const navbar = getPageSection(page, 'navbar');
const user = auth.user;
const showWishlist = props.system.fields?.show_student_wishlist !== false;
const [isSticky, setIsSticky] = useState(false);
const [isMenuOpen, setIsMenuOpen] = useState(false);
@ -97,7 +98,7 @@ const LandingNavbar = () => {
)}
{(user.role === 'student' || user.role === 'instructor') &&
studentMenuItems.map(({ id, name, Icon, slug }) => (
getStudentMenuItems(showWishlist).map(({ id, name, Icon, slug }) => (
<DropdownMenuItem
key={id}
className="cursor-pointer px-3"
@ -205,19 +206,23 @@ const LandingNavbar = () => {
);
};
const studentMenuItems = [
const getStudentMenuItems = (showWishlist: boolean) => [
{
id: nanoid(),
name: 'My Courses',
slug: 'courses',
Icon: GraduationCap,
},
{
id: nanoid(),
name: 'Wishlist',
slug: 'wishlist',
Icon: Heart,
},
...(showWishlist
? [
{
id: nanoid(),
name: 'Wishlist',
slug: 'wishlist',
Icon: Heart,
},
]
: []),
{
id: nanoid(),
name: 'My Profile',

View File

@ -5,6 +5,7 @@ import { RadioGroup, RadioGroupItem } from '@/components/ui/radio-group';
import { CoursePlayerProps } from '@/types/page';
import { usePage } from '@inertiajs/react';
import { format, parseISO } from 'date-fns';
import { de } from 'date-fns/locale';
import jsPDF from 'jspdf';
import { Award, Calendar, Download, FileImage, FileText } from 'lucide-react';
import { useRef, useState } from 'react';
@ -17,7 +18,9 @@ const Certificate = () => {
const courseName = props.course.title;
const studentName = props.auth.user.name;
const completionDate = format(parseISO(props.watchHistory.completion_date), 'MMM d, yyyy');
const completionDate = props.watchHistory?.completion_date
? format(parseISO(props.watchHistory.completion_date), 'dd. MMMM yyyy', { locale: de })
: '';
const [downloadFormat, setDownloadFormat] = useState('png');
const certificateRef = useRef<HTMLDivElement>(null);
const dimensions = { width: 900, height: 600 }; // Standard

View File

@ -17,6 +17,7 @@ const Navbar = () => {
const { translate } = props;
const { button } = translate;
const user = props.auth.user;
const showWishlist = props.system.fields?.show_student_wishlist !== false;
return (
<header className="bg-primary dark:bg-primary-dark text-primary-foreground dark:text-primary sticky top-0 z-50 h-[60px]">
@ -61,7 +62,7 @@ const Navbar = () => {
)}
{(user.role === 'student' || user.role === 'instructor') &&
getStudentMenuItems(button).map(({ id, name, Icon, slug }) => (
getStudentMenuItems(button, showWishlist).map(({ id, name, Icon, slug }) => (
<DropdownMenuItem
key={id}
className="cursor-pointer px-3"
@ -95,19 +96,23 @@ const Navbar = () => {
);
};
const getStudentMenuItems = (button: any) => [
const getStudentMenuItems = (button: any, showWishlist: boolean) => [
{
id: nanoid(),
name: button.my_courses,
slug: 'courses',
Icon: GraduationCap,
},
{
id: nanoid(),
name: button.wishlist,
slug: 'wishlist',
Icon: Heart,
},
...(showWishlist
? [
{
id: nanoid(),
name: button.wishlist,
slug: 'wishlist',
Icon: Heart,
},
]
: []),
{
id: nanoid(),
name: button.profile,

View File

@ -70,8 +70,9 @@ const EnrollmentButton = ({ auth, course }: { auth: Auth; course: Course }) => {
};
const EnrollOrPlayerButton = () => {
const { auth, course, enrollment, watchHistory, approvalStatus, wishlists, translate } = usePage<CourseDetailsProps>().props;
const { auth, course, enrollment, watchHistory, approvalStatus, wishlists, translate, system } = usePage<CourseDetailsProps>().props;
const { frontend } = translate;
const showWishlist = system.fields?.show_student_wishlist !== false;
// Compute access conditions - improves readability
const isEnrolled = !!enrollment;
@ -97,9 +98,11 @@ const EnrollOrPlayerButton = () => {
} else {
return (
<>
<Button className="w-full px-1 sm:px-3" variant="outline" size="lg" onClick={handleWishlist}>
{isWishlisted ? frontend.remove_from_wishlist : frontend.add_to_wishlist}
</Button>
{showWishlist && (
<Button className="w-full px-1 sm:px-3" variant="outline" size="lg" onClick={handleWishlist}>
{isWishlisted ? frontend.remove_from_wishlist : frontend.add_to_wishlist}
</Button>
)}
<EnrollmentButton auth={auth} course={course} />
</>

View File

@ -10,6 +10,7 @@ const CoursePreview = () => {
const { auth, exam, system, wishlist, enrollment, translate } = usePage<ExamPreviewProps>().props;
const { frontend } = translate;
const currency = systemCurrency(system.fields['selling_currency']);
const showWishlist = system.fields?.show_student_wishlist !== false;
const handleWishlist = () => {
if (wishlist) {
@ -75,9 +76,11 @@ const CoursePreview = () => {
)}
</h2>
<Button className="w-full px-1 sm:px-3" variant="outline" size="lg" onClick={handleWishlist}>
{wishlist ? frontend.remove_from_wishlist : frontend.add_to_wishlist}
</Button>
{showWishlist && (
<Button className="w-full px-1 sm:px-3" variant="outline" size="lg" onClick={handleWishlist}>
{wishlist ? frontend.remove_from_wishlist : frontend.add_to_wishlist}
</Button>
)}
{exam.pricing_type === 'free' ? (
<Button size="lg" className="w-full" onClick={() => enrollmentHandler(exam)}>