update
This commit is contained in:
parent
130dcc44fd
commit
b8af83fe38
|
|
@ -305,13 +305,13 @@ export default function DetailContent() {
|
|||
close();
|
||||
}
|
||||
|
||||
if (!articleDetail?.files || articleDetail.files.length === 0) {
|
||||
return (
|
||||
<div className="w-full h-[400px] bg-gray-100 flex items-center justify-center rounded-lg">
|
||||
<p className="text-gray-400 text-sm">Gambar tidak tersedia</p>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
// if (!articleDetail?.files || articleDetail.files.length === 0) {
|
||||
// return (
|
||||
// <div className="w-full h-[400px] bg-gray-100 flex items-center justify-center rounded-lg">
|
||||
// <p className="text-gray-400 text-sm">Gambar tidak tersedia</p>
|
||||
// </div>
|
||||
// );
|
||||
// }
|
||||
|
||||
return (
|
||||
<>
|
||||
|
|
@ -363,11 +363,16 @@ export default function DetailContent() {
|
|||
</div>
|
||||
|
||||
<div className="w-full h-auto mb-6">
|
||||
{/* Gambar utama */}
|
||||
{articleDetail?.files && articleDetail.files.length > 0 ? (
|
||||
<>
|
||||
{/* Gambar utama */}
|
||||
<div className="w-full">
|
||||
<Image
|
||||
src={articleDetail.files[selectedIndex].fileUrl}
|
||||
alt={articleDetail.files[selectedIndex].fileAlt || "Berita"}
|
||||
src={articleDetail.files[selectedIndex]?.fileUrl}
|
||||
alt={
|
||||
articleDetail.files[selectedIndex]?.fileAlt || "Berita"
|
||||
}
|
||||
width={800}
|
||||
height={400}
|
||||
className="rounded-lg w-full object-cover"
|
||||
|
|
@ -378,7 +383,7 @@ export default function DetailContent() {
|
|||
<div className="flex gap-2 mt-3 overflow-x-auto">
|
||||
{articleDetail.files.map((file: any, index: number) => (
|
||||
<button
|
||||
key={file.id || index}
|
||||
key={file?.id || index}
|
||||
onClick={() => setSelectedIndex(index)}
|
||||
className={`border-2 rounded-lg overflow-hidden ${
|
||||
selectedIndex === index
|
||||
|
|
@ -387,8 +392,8 @@ export default function DetailContent() {
|
|||
}`}
|
||||
>
|
||||
<Image
|
||||
src={file.fileUrl}
|
||||
alt={file.fileAlt || "Thumbnail"}
|
||||
src={file?.fileUrl}
|
||||
alt={file?.fileAlt || "Thumbnail"}
|
||||
width={100}
|
||||
height={80}
|
||||
className="object-cover"
|
||||
|
|
@ -396,6 +401,13 @@ export default function DetailContent() {
|
|||
</button>
|
||||
))}
|
||||
</div>
|
||||
</>
|
||||
) : (
|
||||
// Jika file kosong/null tapi tetap render data lainnya
|
||||
<div className="w-full h-[400px] bg-gray-100 flex items-center justify-center rounded-lg">
|
||||
<p className="text-gray-400 text-sm">Gambar tidak tersedia</p>
|
||||
</div>
|
||||
)}
|
||||
|
||||
{/* Slug */}
|
||||
<p className="text-sm text-gray-500 mt-2 text-end">
|
||||
|
|
|
|||
Loading…
Reference in New Issue