diff --git a/components/form/login.tsx b/components/form/login.tsx index 60763df..b403f0b 100644 --- a/components/form/login.tsx +++ b/components/form/login.tsx @@ -232,9 +232,9 @@ export default function Login() { {isFirstLogin ? (
-
+
Submit @@ -486,7 +486,7 @@ export default function Login() {

Belum ada artikel.

; + } return (
-
+
{/* Kiri - berita utama */} -
+
{articles[0].title}
- {articles[0].categories[0]?.title || "Uncategorized"} + {articles[0]?.categories?.[0]?.title || "Uncategorized"} -

{articles[0].title}

+

{articles[0]?.title}

- {articles[0].createdByName}{" "} + + {articles[0]?.createdByName} + {" "} •{" "} - {new Date(articles[0].createdAt).toLocaleDateString("id-ID", { - day: "numeric", - month: "long", - year: "numeric", - })} + {articles[0]?.createdAt && + new Date(articles[0].createdAt).toLocaleDateString("id-ID", { + day: "numeric", + month: "long", + year: "numeric", + })}

@@ -74,67 +79,84 @@ export default function HeaderNews() {
{/* Atas: 2 berita kecil */}
- {articles.slice(1, 3).map((item) => ( -
- {item.title} -
-
- - {item.categories[0]?.title || "Uncategorized"} - -

- {item.title} -

-

- {item.createdByName}{" "} - •{" "} - {new Date(item.createdAt).toLocaleDateString("id-ID", { - day: "numeric", - month: "short", - year: "numeric", - })} -

-
-
- ))} + {[articles[1], articles[2]].map( + (item, idx) => + item && ( +
+ {item.title +
+
+ + {item.categories?.[0]?.title || "Uncategorized"} + +

+ {item.title} +

+

+ + {item.createdByName} + {" "} + •{" "} + {item.createdAt && + new Date(item.createdAt).toLocaleDateString("id-ID", { + day: "numeric", + month: "short", + year: "numeric", + })} +

+
+
+ ) + )}
{/* Bawah: 1 berita besar */} -
- {articles[3].title} -
-
- - {articles[3].categories[0]?.title || "Uncategorized"} - -

- {articles[3].title} -

-

- - {articles[3].createdByName} - {" "} - •{" "} - {new Date(articles[3].createdAt).toLocaleDateString("id-ID", { - day: "numeric", - month: "long", - year: "numeric", - })} -

+ {articles[3] && ( +
+ {articles[3]?.title +
+
+ + {articles[3]?.categories?.[0]?.title || "Uncategorized"} + +

+ {articles[3]?.title} +

+

+ + {articles[3]?.createdByName} + {" "} + •{" "} + {articles[3]?.createdAt && + new Date(articles[3].createdAt).toLocaleDateString( + "id-ID", + { + day: "numeric", + month: "long", + year: "numeric", + } + )} +

+
-
+ )}
+ + {/* Banner bawah */}
error.response); @@ -35,7 +35,11 @@ export async function httpGetInterceptor(pathUrl: any) { } } -export async function httpPostInterceptor(pathUrl: any, data: any, headers?: any) { +export async function httpPostInterceptor( + pathUrl: any, + data: any, + headers?: any +) { const resCsrf = await getCsrfToken(); const csrfToken = resCsrf?.data?.csrf_token; @@ -67,7 +71,11 @@ export async function httpPostInterceptor(pathUrl: any, data: any, headers?: any } } -export async function httpPutInterceptor(pathUrl: any, data: any, headers?: any) { +export async function httpPutInterceptor( + pathUrl: any, + data: any, + headers?: any +) { const resCsrf = await getCsrfToken(); const csrfToken = resCsrf?.data?.csrf_token; @@ -99,7 +107,7 @@ export async function httpPutInterceptor(pathUrl: any, data: any, headers?: any) } export async function httpDeleteInterceptor(pathUrl: any, headers?: any) { - const resCsrf = await getCsrfToken(); + const resCsrf = await getCsrfToken(); const csrfToken = resCsrf?.data?.csrf_token; const mergedHeaders = {