fix:inp api, home
This commit is contained in:
parent
b38b20e881
commit
c00f4094ef
|
|
@ -68,7 +68,7 @@ export default function HeaderNews() {
|
|||
}}
|
||||
>
|
||||
{article?.map((newsItem: any, index: number) => (
|
||||
<SwiperSlide key={newsItem.id + index}>
|
||||
<SwiperSlide key={newsItem?.id}>
|
||||
<Card isFooterBlurred radius="lg" className="border-none">
|
||||
<Image
|
||||
width={1920}
|
||||
|
|
@ -116,7 +116,7 @@ export default function HeaderNews() {
|
|||
{article?.map((data: any, index: number) => (
|
||||
<div
|
||||
className="text-xs text-left m-2 p-2 dark:bg-[#1E1616] bg-white rounded-md flex flex-row gap-2"
|
||||
key={data.id + index}
|
||||
key={data?.id}
|
||||
>
|
||||
<Image
|
||||
height={480}
|
||||
|
|
@ -132,7 +132,6 @@ export default function HeaderNews() {
|
|||
<div>
|
||||
<Link
|
||||
href={`/news/detail/${data?.id}-${data?.slug}`}
|
||||
key={data?.id}
|
||||
className="lg:hidden"
|
||||
>
|
||||
{textEllipsis(data.title, 40)}
|
||||
|
|
@ -198,7 +197,7 @@ export default function HeaderNews() {
|
|||
}}
|
||||
>
|
||||
{article?.map((newsItem: any, index: number) => (
|
||||
<SwiperSlide key={newsItem.id + index} className="h-[67vh]">
|
||||
<SwiperSlide key={newsItem?.id} className="h-[67vh]">
|
||||
<Card
|
||||
isFooterBlurred
|
||||
radius="lg"
|
||||
|
|
@ -273,7 +272,7 @@ export default function HeaderNews() {
|
|||
<ScrollShadow hideScrollBar className=" h-[54vh]">
|
||||
{article?.map((list: any, index: number) => (
|
||||
<div
|
||||
key={list.id + index}
|
||||
key={list?.id}
|
||||
className="text-xs text-left m-2 p-2 dark:bg-[#1E1616] bg-white rounded-md"
|
||||
>
|
||||
<Link href={`news/detail/${list?.id}`}>
|
||||
|
|
|
|||
|
|
@ -17,6 +17,7 @@ import { topNewsMediahub } from "@/service/medol-news-update";
|
|||
import Link from "next/link";
|
||||
import {
|
||||
getImageInp,
|
||||
inpLogin,
|
||||
topNewsInp,
|
||||
topNewsTbn,
|
||||
} from "@/service/third-party-service";
|
||||
|
|
@ -54,9 +55,16 @@ export default function MedolUpdate() {
|
|||
setTbnUpdate(res?.data?.data);
|
||||
}
|
||||
async function getInpUpdate() {
|
||||
const res = await topNewsInp();
|
||||
const headers = {
|
||||
"content-type": "application/json",
|
||||
};
|
||||
const resLog = await inpLogin(headers);
|
||||
const res = await topNewsInp(resLog?.data?.access_token);
|
||||
// setInpUpdate(res?.data);
|
||||
getDataImage(res?.data);
|
||||
setInpUpdate(res?.data?.data);
|
||||
console.log("reelog", res?.data?.data);
|
||||
|
||||
// getDataImage(res?.data);
|
||||
}
|
||||
|
||||
async function getDataImage(data: any) {
|
||||
|
|
@ -260,8 +268,11 @@ export default function MedolUpdate() {
|
|||
}}
|
||||
>
|
||||
{inpUpdate?.map((newsItem: any) => (
|
||||
<SwiperSlide key={newsItem?.id}>
|
||||
<Link href={newsItem?.link} target="_blank">
|
||||
<SwiperSlide key={newsItem?.slug}>
|
||||
<Link
|
||||
href={`https://inp.polri.go.id/artikel/${newsItem?.slug}`}
|
||||
target="_blank"
|
||||
>
|
||||
<Card
|
||||
isPressable
|
||||
shadow="sm"
|
||||
|
|
@ -273,12 +284,12 @@ export default function MedolUpdate() {
|
|||
width="300%"
|
||||
alt="tes"
|
||||
className="object-cover !h-[30vh]"
|
||||
src={newsItem.image}
|
||||
src={newsItem?.thumbnail}
|
||||
/>
|
||||
</CardBody>
|
||||
<CardFooter className="flex flex-col items-start text-left">
|
||||
{convertDateFormatNoTime(newsItem?.date)}
|
||||
<b className="">{newsItem?.title?.rendered}</b>
|
||||
{newsItem?.created_at}
|
||||
<b className="">{newsItem?.judul}</b>
|
||||
</CardFooter>
|
||||
</Card>
|
||||
</Link>
|
||||
|
|
|
|||
|
|
@ -58,6 +58,35 @@ async function inpGetNews(pathUrl: any, headers: any) {
|
|||
};
|
||||
}
|
||||
}
|
||||
export async function inpLogin(headers: any) {
|
||||
const response = await inpInstance
|
||||
.post(
|
||||
"/login",
|
||||
{
|
||||
email: "api@inp.humas.polri.go.id",
|
||||
password: "@Inp2024",
|
||||
},
|
||||
{ headers }
|
||||
)
|
||||
.catch(function (error: any) {
|
||||
console.log(error, "inp");
|
||||
return error.response;
|
||||
});
|
||||
console.log("Response base svc : ", response);
|
||||
if (response?.status == 200 || response?.status == 201) {
|
||||
return {
|
||||
error: false,
|
||||
message: "success",
|
||||
data: response?.data,
|
||||
};
|
||||
} else {
|
||||
return {
|
||||
error: true,
|
||||
message: response?.data?.message || response?.data || null,
|
||||
data: null,
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
export async function topNewsTbn() {
|
||||
const headers = {
|
||||
|
|
@ -68,11 +97,20 @@ export async function topNewsTbn() {
|
|||
headers
|
||||
);
|
||||
}
|
||||
export async function topNewsInp() {
|
||||
export async function loginInp() {
|
||||
const headers = {
|
||||
"content-type": "application/json",
|
||||
};
|
||||
// return await inpGetNews(`/media`, headers);
|
||||
return await inpGetNews(`/login`, headers);
|
||||
}
|
||||
|
||||
export async function topNewsInp(token: any) {
|
||||
const headers = {
|
||||
"content-type": "application/json",
|
||||
Authorization: `Bearer ${token}`,
|
||||
};
|
||||
// return await inpGetNews(`/media`, headers);
|
||||
return await inpGetNews(`/artikel/data?per_page=10&page=1`, headers);
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue