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