fixed no images problem and no cache in fetchCourses
This commit is contained in:
parent
a00cd857f1
commit
b6c5b15900
|
@ -47,12 +47,22 @@ const CoursesSilder = ({ courses }: { courses: CoursesProps[] }) => {
|
||||||
<div key={index} className=" bg-[#F6E8E9] h-auto pt-30 transition-all justify-items-center duration-20">
|
<div key={index} className=" bg-[#F6E8E9] h-auto pt-30 transition-all justify-items-center duration-20">
|
||||||
<div className="hidden lg:grid lg:grid-cols-2 w-full mb-28">
|
<div className="hidden lg:grid lg:grid-cols-2 w-full mb-28">
|
||||||
<div className="flex col-span-1 h-auto justify-self-end mr-20">
|
<div className="flex col-span-1 h-auto justify-self-end mr-20">
|
||||||
<img
|
{course.images.length > 0 ? (
|
||||||
src={`${process.env.NEXT_PUBLIC_IMAGE_URL}${course.images[0].image}`}
|
<img
|
||||||
alt="Course Image"
|
src={`${process.env.NEXT_PUBLIC_IMAGE_URL}${course.images[0].image}`}
|
||||||
className="w-[50vh] h-[70vh] object-cover object-center rounded-3xl shadow-md"
|
alt="Course Image"
|
||||||
style={{ aspectRatio: '1 / 1' }}
|
className="w-[50vh] h-[70vh] object-cover object-center rounded-3xl shadow-md"
|
||||||
/>
|
style={{ aspectRatio: '1 / 1' }}
|
||||||
|
/>
|
||||||
|
) : (
|
||||||
|
<img
|
||||||
|
src={"/images/piano1.jpg"}
|
||||||
|
alt="Course Image"
|
||||||
|
className="w-[50vh] h-[70vh] object-cover object-center rounded-3xl shadow-md"
|
||||||
|
style={{ aspectRatio: '1 / 1' }}
|
||||||
|
/>
|
||||||
|
)}
|
||||||
|
|
||||||
</div>
|
</div>
|
||||||
<div className="flex col-span-1 h-auto justify-start items-center ml-20">
|
<div className="flex col-span-1 h-auto justify-start items-center ml-20">
|
||||||
<div className="flex flex-col items-start w-[50vh]">
|
<div className="flex flex-col items-start w-[50vh]">
|
||||||
|
@ -76,11 +86,20 @@ const CoursesSilder = ({ courses }: { courses: CoursesProps[] }) => {
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div className=" relative w-[50vh] h-[70vh] max-sm:w-[85vw] max-sm:h-[60vh] mt-20 mb-28 overflow-hidden rounded-3xl shadow-md sm:block md:block lg:hidden xl:hidden 2xl:hidden mx-auto">
|
<div className=" relative w-[50vh] h-[70vh] max-sm:w-[85vw] max-sm:h-[60vh] mt-20 mb-28 overflow-hidden rounded-3xl shadow-md sm:block md:block lg:hidden xl:hidden 2xl:hidden mx-auto">
|
||||||
<img
|
{course.images.length > 0 ? (
|
||||||
src={`${process.env.NEXT_PUBLIC_IMAGE_URL}${course.images[0].image}`}
|
<img
|
||||||
alt="Course Image"
|
src={`${process.env.NEXT_PUBLIC_IMAGE_URL}${course.images[0].image}`}
|
||||||
className="absolute inset-0 w-full h-full object-cover object-center "
|
alt="Course Image"
|
||||||
/>
|
className="absolute inset-0 w-full h-full object-cover object-center "
|
||||||
|
/>
|
||||||
|
) : (
|
||||||
|
<img
|
||||||
|
src={"/images/piano1.jpg"}
|
||||||
|
alt="Course Image"
|
||||||
|
className="absolute inset-0 w-full h-full object-cover object-center "
|
||||||
|
/>
|
||||||
|
)}
|
||||||
|
|
||||||
<div className="absolute inset-0 flex flex-col items-center justify-center bg-black bg-opacity-50 text-white p-6">
|
<div className="absolute inset-0 flex flex-col items-center justify-center bg-black bg-opacity-50 text-white p-6">
|
||||||
<p className="text-2xl text-center mb-4">
|
<p className="text-2xl text-center mb-4">
|
||||||
{course.title}
|
{course.title}
|
||||||
|
@ -89,12 +108,12 @@ const CoursesSilder = ({ courses }: { courses: CoursesProps[] }) => {
|
||||||
{course.sort_description}
|
{course.sort_description}
|
||||||
</p>
|
</p>
|
||||||
<Link
|
<Link
|
||||||
href={`/courses/${course.id}`}
|
href={`/courses/${course.id}`}
|
||||||
className="flex items-center justify-center rounded-full bg-white h-12 w-28 text-sm text-black shadow-md shadow-gray-400/20 transition-all hover:shadow-lg hover:shadow-gray-500/40"
|
className="flex items-center justify-center rounded-full bg-white h-12 w-28 text-sm text-black shadow-md shadow-gray-400/20 transition-all hover:shadow-lg hover:shadow-gray-500/40"
|
||||||
data-ripple-light="true"
|
data-ripple-light="true"
|
||||||
>
|
>
|
||||||
{"了解更多"}
|
{"了解更多"}
|
||||||
</Link>
|
</Link>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
|
@ -92,7 +92,7 @@ export async function fetchCourses() {
|
||||||
console.log('Fetching from URL:', url);
|
console.log('Fetching from URL:', url);
|
||||||
|
|
||||||
try {
|
try {
|
||||||
const response = await fetch(url, { headers });
|
const response = await fetch(url, { headers, cache: 'no-store', next: { revalidate: 0 } });
|
||||||
|
|
||||||
|
|
||||||
const result = await response.json();
|
const result = await response.json();
|
||||||
|
@ -124,7 +124,10 @@ export async function fetchCourse(id: string) {
|
||||||
|
|
||||||
|
|
||||||
try {
|
try {
|
||||||
const response = await fetch(url, { headers });
|
const response = await fetch(url, {
|
||||||
|
headers, cache: 'no-store',
|
||||||
|
next: { revalidate: 0 }
|
||||||
|
});
|
||||||
|
|
||||||
|
|
||||||
var result: CoursesProps = await response.json();
|
var result: CoursesProps = await response.json();
|
||||||
|
|
Loading…
Reference in New Issue