Intergrasi to API

Deskripsi:
- Fix server action collaboration to API
This commit is contained in:
2024-12-30 17:41:19 +08:00
parent 9515c041ad
commit b5861f4383
25 changed files with 660 additions and 145 deletions

View File

@@ -2,29 +2,51 @@
import { RouterColab } from "@/app/lib/router_hipmi/router_colab";
import ComponentGlobal_IsEmptyData from "@/app_modules/_global/component/is_empty_data";
import { clientLogger } from "@/util/clientLogger";
import { Box, Center, Loader } from "@mantine/core";
import { useShallowEffect } from "@mantine/hooks";
import _ from "lodash";
import { ScrollOnly } from "next-scroll-loader";
import { useState } from "react";
import { apiGetAllCollaboration } from "../../_lib/api_collaboration";
import { ComponentColab_CardProyekSaya } from "../../component/card_view/card_proyek_saya";
import colab_getListAllProyekSayaByAuthorId from "../../fun/get/pasrtisipan/get_list_proyek_saya_by_author_id";
import { Collaboration_SkeletonBeranda } from "../../component/skeleton_view";
import { MODEL_COLLABORATION } from "../../model/interface";
export default function Colab_ProyekSaya({
listProyekSaya,
}: {
listProyekSaya: MODEL_COLLABORATION[];
}) {
const [data, setData] = useState(listProyekSaya);
export default function Colab_ProyekSaya() {
const [data, setData] = useState<MODEL_COLLABORATION[] | null>(null);
const [activePage, setActivePage] = useState(1);
useShallowEffect(() => {
onLoadData();
}, []);
async function onLoadData() {
try {
const respone = await apiGetAllCollaboration({
kategori: "proyeksaya",
page: `${activePage}`,
});
if (respone) {
setData(respone.data);
}
} catch (error) {
clientLogger.error("Error get proyeksaya", error);
}
}
if (_.isNull(data)) {
return <Collaboration_SkeletonBeranda />;
}
return (
<>
{_.isEmpty(data) ? (
<ComponentGlobal_IsEmptyData />
) : (
// --- Main component --- //
<Box >
<Box>
<ScrollOnly
height="73vh"
renderLoading={() => (
@@ -33,14 +55,16 @@ export default function Colab_ProyekSaya({
</Center>
)}
data={data}
setData={setData}
setData={setData as any}
moreData={async () => {
const loadData = await colab_getListAllProyekSayaByAuthorId({
page: activePage + 1,
const respone = await apiGetAllCollaboration({
kategori: "proyeksaya",
page: `${activePage + 1}`,
});
setActivePage((val) => val + 1);
return loadData;
return respone.data;
}}
>
{(item) => (