upd: kataloh
deskripsi: - update api list portofolio No Issues
This commit is contained in:
@@ -8,9 +8,11 @@ export async function GET(request: Request) {
|
|||||||
let fixData
|
let fixData
|
||||||
const { searchParams } = new URL(request.url)
|
const { searchParams } = new URL(request.url)
|
||||||
const profile = searchParams.get("profile")
|
const profile = searchParams.get("profile")
|
||||||
|
const kategori_halaman = searchParams.get("cat")
|
||||||
const page = searchParams.get("page")
|
const page = searchParams.get("page")
|
||||||
|
const dataSkip = Number(page) * 10 - 10;
|
||||||
|
|
||||||
if (page == "profile") {
|
if (kategori_halaman == "profile") {
|
||||||
fixData = await prisma.portofolio.findMany({
|
fixData = await prisma.portofolio.findMany({
|
||||||
take: 2,
|
take: 2,
|
||||||
orderBy: {
|
orderBy: {
|
||||||
@@ -27,8 +29,10 @@ export async function GET(request: Request) {
|
|||||||
profileId: true,
|
profileId: true,
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
} else if (page == "portofolio") {
|
} else if (kategori_halaman == "portofolio") {
|
||||||
fixData = await prisma.portofolio.findMany({
|
fixData = await prisma.portofolio.findMany({
|
||||||
|
skip: dataSkip,
|
||||||
|
take: 10,
|
||||||
orderBy: {
|
orderBy: {
|
||||||
createdAt: "desc",
|
createdAt: "desc",
|
||||||
},
|
},
|
||||||
|
|||||||
@@ -1,17 +1,17 @@
|
|||||||
import { Portofolio_ViewListDetail } from "@/app_modules/katalog/portofolio";
|
import { ListDetailPortofolioNew } from "@/app_modules/katalog/portofolio";
|
||||||
import { portofolio_funGetAllDaftarByid } from "@/app_modules/katalog/portofolio/fun/get/get_all_portofolio";
|
|
||||||
|
|
||||||
export default async function Page({ params }: { params: { id: string } }) {
|
export default async function Page({ params }: { params: { id: string } }) {
|
||||||
const profileId = params.id;
|
// const profileId = params.id;
|
||||||
const dataPortofolio = await portofolio_funGetAllDaftarByid({
|
// const dataPortofolio = await portofolio_funGetAllDaftarByid({
|
||||||
profileId,
|
// profileId,
|
||||||
page: 1,
|
// page: 1,
|
||||||
});
|
// });
|
||||||
|
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<>
|
<>
|
||||||
<Portofolio_ViewListDetail dataPortofolio={dataPortofolio as any} profileId={profileId} />
|
{/* <Portofolio_ViewListDetail dataPortofolio={dataPortofolio as any} profileId={profileId} /> */}
|
||||||
|
<ListDetailPortofolioNew />
|
||||||
</>
|
</>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -10,6 +10,7 @@ import Portofolio_EditMedsosBisnis from "./edit/medsos/ui_edit_medsos";
|
|||||||
import LayoutPortofolio_EditDataBisnis from "./edit/data/layout";
|
import LayoutPortofolio_EditDataBisnis from "./edit/data/layout";
|
||||||
import LayoutPortofolio_EditLogoBisnis from "./edit/logo/layout";
|
import LayoutPortofolio_EditLogoBisnis from "./edit/logo/layout";
|
||||||
import LayoutPortofolio_EditMedsosBisnis from "./edit/medsos/layout";
|
import LayoutPortofolio_EditMedsosBisnis from "./edit/medsos/layout";
|
||||||
|
import ListDetailPortofolioNew from './view/list_detail_portofolio_new';
|
||||||
|
|
||||||
export {
|
export {
|
||||||
CreatePortofolio,
|
CreatePortofolio,
|
||||||
@@ -22,8 +23,9 @@ export {
|
|||||||
LayoutPortofolio_EditDataBisnis,
|
LayoutPortofolio_EditDataBisnis,
|
||||||
LayoutPortofolio_EditLogoBisnis,
|
LayoutPortofolio_EditLogoBisnis,
|
||||||
LayoutPortofolio_EditMedsosBisnis,
|
LayoutPortofolio_EditMedsosBisnis,
|
||||||
apiGetPortofolioByProfile
|
apiGetPortofolioByProfile,
|
||||||
};
|
};
|
||||||
export type { IListPortofolio };
|
export type { IListPortofolio };
|
||||||
export { Portofolio_ViewListDetail } from "./view/view_list_detail_portofolio";
|
export { Portofolio_ViewListDetail } from "./view/view_list_detail_portofolio";
|
||||||
|
export { ListDetailPortofolioNew }
|
||||||
|
|
||||||
|
|||||||
@@ -0,0 +1,59 @@
|
|||||||
|
import ComponentGlobal_Loader from "@/app_modules/_global/component/loader";
|
||||||
|
import { Box, Center } from "@mantine/core";
|
||||||
|
import { ScrollOnly } from "next-scroll-loader";
|
||||||
|
import { useState } from "react";
|
||||||
|
import { ComponentPortofolio_DaftarBoxView } from "../component/card_view_daftar";
|
||||||
|
import { portofolio_funGetAllDaftarByid } from "../fun/get/get_all_portofolio";
|
||||||
|
import { MODEL_PORTOFOLIO } from "../model/interface";
|
||||||
|
import { useParams } from "next/navigation";
|
||||||
|
import { useShallowEffect } from "@mantine/hooks";
|
||||||
|
import { apiGetPortofolioByProfile } from "../lib/api_portofolio";
|
||||||
|
|
||||||
|
export default function Portofolio_UiListDetailNew() {
|
||||||
|
const param = useParams<{ id: string }>()
|
||||||
|
const profileId = param.id
|
||||||
|
const [data, setData] = useState<MODEL_PORTOFOLIO[]>([])
|
||||||
|
const [activePage, setActivePage] = useState(1)
|
||||||
|
|
||||||
|
async function getPortofolio() {
|
||||||
|
try {
|
||||||
|
const response = await apiGetPortofolioByProfile(`?profile=${param.id}&cat=portofolio&page=1`)
|
||||||
|
if (response.success) {
|
||||||
|
setData(response.data);
|
||||||
|
}
|
||||||
|
} catch (error) {
|
||||||
|
console.error(error);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
useShallowEffect(() => {
|
||||||
|
getPortofolio()
|
||||||
|
}, []);
|
||||||
|
|
||||||
|
return <>
|
||||||
|
<Box py={5}>
|
||||||
|
<ScrollOnly
|
||||||
|
height="90vh"
|
||||||
|
renderLoading={() => (
|
||||||
|
<Center mt={"lg"}>
|
||||||
|
<ComponentGlobal_Loader />
|
||||||
|
</Center>
|
||||||
|
)}
|
||||||
|
data={data}
|
||||||
|
setData={setData}
|
||||||
|
moreData={async () => {
|
||||||
|
const loadData = await portofolio_funGetAllDaftarByid({
|
||||||
|
profileId,
|
||||||
|
page: activePage + 1,
|
||||||
|
});
|
||||||
|
setActivePage((val) => val + 1);
|
||||||
|
|
||||||
|
return loadData;
|
||||||
|
}}
|
||||||
|
>
|
||||||
|
{(item) => <ComponentPortofolio_DaftarBoxView data={item} />}
|
||||||
|
</ScrollOnly>
|
||||||
|
</Box>
|
||||||
|
</>;
|
||||||
|
}
|
||||||
@@ -0,0 +1,13 @@
|
|||||||
|
'use client'
|
||||||
|
import { UIGlobal_LayoutHeaderTamplate, UIGlobal_LayoutTamplate } from "@/app_modules/_global/ui";
|
||||||
|
import Portofolio_UiListDetailNew from "../ui/ui_list_detail_portofolio_new";
|
||||||
|
|
||||||
|
export default function ListDetailPortofolioNew() {
|
||||||
|
return (
|
||||||
|
<>
|
||||||
|
<UIGlobal_LayoutTamplate header={<UIGlobal_LayoutHeaderTamplate title="Daftar Portofolio" />} >
|
||||||
|
<Portofolio_UiListDetailNew />
|
||||||
|
</UIGlobal_LayoutTamplate>
|
||||||
|
</>
|
||||||
|
)
|
||||||
|
}
|
||||||
@@ -17,7 +17,7 @@ export default function ListPortofolioProfileNew() {
|
|||||||
async function getPortofolio() {
|
async function getPortofolio() {
|
||||||
try {
|
try {
|
||||||
setLoading(true)
|
setLoading(true)
|
||||||
const response = await apiGetPortofolioByProfile(`?profile=${param.id}&page=profile`)
|
const response = await apiGetPortofolioByProfile(`?profile=${param.id}&cat=profile`)
|
||||||
if (response.success) {
|
if (response.success) {
|
||||||
setDataPortofolio(response.data);
|
setDataPortofolio(response.data);
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user