|
|
@@ -1,11 +1,6 @@
|
|
|
import { getTranslations, setRequestLocale } from "next-intl/server";
|
|
|
import { Link } from "@/i18n/navigation";
|
|
|
-import {
|
|
|
- fetchCourses,
|
|
|
- getCourseBySlug,
|
|
|
- shouldShowBuyButton,
|
|
|
- type Course,
|
|
|
-} from "@/data/courses";
|
|
|
+import { fetchCourses, getCourseBySlug, shouldShowBuyButton } from "@/data/courses";
|
|
|
import { CourseVideosListClient } from "@/app/[locale]/courses/[slug]/videos-list-client";
|
|
|
import { CourseFilesListClient } from "@/app/[locale]/courses/[slug]/files-list-client";
|
|
|
import { CourseBuyButton } from "@/components/course-buy-button";
|
|
|
@@ -17,10 +12,6 @@ type DetailProps = {
|
|
|
searchParams: SearchParams;
|
|
|
};
|
|
|
|
|
|
-function shouldShowFreeBadge(course: Course): boolean {
|
|
|
- return course.category === "trial" && course.price === 0;
|
|
|
-}
|
|
|
-
|
|
|
export default async function CourseDetailPage({ params, searchParams }: DetailProps) {
|
|
|
const { locale, slug } = await params;
|
|
|
const query = await searchParams;
|
|
|
@@ -32,7 +23,6 @@ export default async function CourseDetailPage({ params, searchParams }: DetailP
|
|
|
const isStrategy = course?.category === "strategy" || query?.cat === "strategy";
|
|
|
|
|
|
const t = await getTranslations("courses");
|
|
|
- const tn = await getTranslations("nav");
|
|
|
|
|
|
return (
|
|
|
<div className="relative min-h-screen bg-[#f6f8fb] font-sans">
|
|
|
@@ -47,57 +37,13 @@ export default async function CourseDetailPage({ params, searchParams }: DetailP
|
|
|
>
|
|
|
← {t("title")}
|
|
|
</Link>
|
|
|
- {course ? (
|
|
|
- <div className="mt-6">
|
|
|
- <span className="inline-flex rounded-full border border-[#b89458]/30 bg-[#b89458]/10 px-3 py-1 text-xs font-semibold tracking-wider text-[#f3deae]">
|
|
|
- {tn(`categories.${course.category}` as "categories.trial")}
|
|
|
- </span>
|
|
|
- <h1 className="font-serif mt-4 text-3xl font-bold tracking-wide text-white md:text-4xl">
|
|
|
- {course.title}
|
|
|
- </h1>
|
|
|
- </div>
|
|
|
- ) : (
|
|
|
- <h1 className="font-serif mt-6 text-3xl font-bold text-white md:text-4xl">
|
|
|
- {isStrategy ? t("fileListTitle") : t("videoListTitle")}
|
|
|
- </h1>
|
|
|
- )}
|
|
|
+ <h1 className="font-serif mt-6 text-3xl font-bold text-white md:text-4xl">
|
|
|
+ {isStrategy ? t("fileListTitle") : t("videoListTitle")}
|
|
|
+ </h1>
|
|
|
</div>
|
|
|
</div>
|
|
|
|
|
|
<div className="site-container relative z-10 section-block-compact -mt-6">
|
|
|
- {course ? (
|
|
|
- <div className="rounded-[2rem] border border-white/80 bg-white/70 p-6 shadow-xl backdrop-blur-xl">
|
|
|
- <div
|
|
|
- className={`h-48 w-full overflow-hidden rounded-2xl bg-slate-100 md:h-64 ${
|
|
|
- course.coverUrl ? "" : course.coverGradient
|
|
|
- }`}
|
|
|
- style={
|
|
|
- course.coverUrl
|
|
|
- ? { backgroundImage: `url(${course.coverUrl})`, backgroundSize: "cover", backgroundPosition: "center" }
|
|
|
- : undefined
|
|
|
- }
|
|
|
- />
|
|
|
- <p className="mt-8 text-lg leading-relaxed text-slate-600 px-2">{course.subtitle}</p>
|
|
|
-
|
|
|
- <div className="mt-8 flex flex-col gap-4 border-t border-slate-200/60 pt-6 px-2 sm:flex-row sm:items-center sm:justify-between">
|
|
|
- <p className="text-[12px] font-semibold tracking-widest text-slate-400">
|
|
|
- {t("lessons", { count: course.lessonCount })}
|
|
|
- </p>
|
|
|
- {!shouldShowFreeBadge(course) ? (
|
|
|
- <div className="flex items-baseline gap-1.5 rounded-full bg-[#fdfaf4] px-5 py-2.5 shadow-sm ring-1 ring-[#e8d2a6]">
|
|
|
- <span className="text-3xl font-bold text-[#8c6b36] md:text-4xl">${course.price}</span>
|
|
|
- <span className="text-sm font-bold text-[#b89458]">{course.currency}</span>
|
|
|
- </div>
|
|
|
- ) : (
|
|
|
- <span className="inline-flex rounded-full bg-emerald-50 px-5 py-2 text-base font-bold text-emerald-600 ring-1 ring-emerald-200">
|
|
|
- {t("free")}
|
|
|
- </span>
|
|
|
- )}
|
|
|
- </div>
|
|
|
- </div>
|
|
|
- ) : null}
|
|
|
-
|
|
|
- {/* 下方的视频或文件列表沿用原有逻辑 */}
|
|
|
<div className="mt-8">
|
|
|
{isStrategy ? (
|
|
|
<CourseFilesListClient goodsId={goodsId} allHref="/courses" allLabel={t("filterAll")} />
|