fix:tbn & inp media update

This commit is contained in:
Rama Priyanto 2025-08-21 09:57:58 +07:00
commit 6ef70c03c1
2 changed files with 45 additions and 16 deletions

View File

@ -42,7 +42,8 @@ export default function MedolUpdate() {
getTbnUpdate();
}
if (selectedTab === "inp" && inpUpdate?.length < 1) {
getInpUpdate();
// getInpUpdate();
getTbnUpdate();
}
}, [selectedTab]);
@ -53,7 +54,28 @@ export default function MedolUpdate() {
async function getTbnUpdate() {
const res = await topNewsTbn();
setTbnUpdate(res?.data?.data);
console.log("tbn data", res?.data?.data);
const tempTbn: any = [];
const tempINP: any = [];
for (const element of res?.data?.data) {
if (
element.website.name.includes("Tribratanews") ||
element.website.name.includes("Tribrata News")
) {
if (tempTbn.length <= 10) {
tempTbn.push(element);
}
}
if (element.website.name.includes("INP")) {
if (tempINP.length <= 10) {
tempINP.push(element);
}
}
}
setTbnUpdate(tempTbn);
setInpUpdate(tempINP);
}
async function getInpUpdate() {
const headers = {
@ -62,8 +84,8 @@ export default function MedolUpdate() {
const resLog = await inpLogin(headers);
const res = await topNewsInp(resLog?.data?.access_token);
// setInpUpdate(res?.data);
setInpUpdate(res?.data?.data);
setInpUpdate(res?.data?.data);
// getDataImage(res?.data);
}
@ -173,7 +195,13 @@ export default function MedolUpdate() {
key={newsItem?.title}
className="hover:shadow-xl hover:opacity-90"
>
<Link href={newsItem?.pageUrl} target="_blank">
<Link
href={newsItem?.pageUrl.replace(
"mediahub.polri.go.id/image",
"mediahub.polri.go.id/in/image"
)}
target="_blank"
>
<Card
isPressable
shadow="sm"
@ -195,7 +223,7 @@ export default function MedolUpdate() {
{formatDate(newsItem?.createdAt)}
</p>
<b className="text-sm">
{textEllipsis(newsItem?.title, 50)}
{textEllipsis(newsItem?.title, 120)}
</b>
</CardFooter>
</Card>
@ -288,7 +316,7 @@ export default function MedolUpdate() {
{formatDate(newsItem?.date)}
</p>
<b className="text-sm">
{textEllipsis(newsItem?.title, 50)}
{textEllipsis(newsItem?.title, 120)}
</b>
</CardFooter>
</Card>
@ -358,7 +386,8 @@ export default function MedolUpdate() {
className="hover:shadow-xl hover:opacity-90"
>
<Link
href={`https://inp.polri.go.id/artikel/${newsItem?.slug}`}
// href={`https://inp.polri.go.id/artikel/${newsItem?.slug}`}
href={newsItem.source_url}
target="_blank"
>
<Card
@ -369,19 +398,19 @@ export default function MedolUpdate() {
<CardBody className="overflow-visible p-0">
<Image
alt="thumnail"
classNames={{
wrapper: "!w-full !max-w-full",
img: "!w-full",
}}
className="object-cover !h-[20vh] w-full"
src={newsItem?.thumbnail}
className="object-cover !h-[20vh]"
src={newsItem?.image}
// src={newsItem?.thumbnail}
/>
</CardBody>
<CardFooter className="flex flex-col items-start text-left">
{/* {newsItem?.created_at} */}
<p className="text-xs">{newsItem?.created_at}</p>
<p className="text-xs">
{" "}
{formatDate(newsItem?.date)}
</p>
<b className="text-sm">
{textEllipsis(newsItem?.judul, 50)}
{textEllipsis(newsItem?.title, 120)}
</b>
</CardFooter>
</Card>

View File

@ -92,7 +92,7 @@ export async function topNewsTbn() {
"content-type": "application/json",
};
return await tbnGetNews(
`/public/articles?page=1&limit=10&order_by=terkini&source=tbnews`,
`/public/articles?page=1&limit=50&order_by=terkini&source=tbnews`,
headers
);
}