Merge pull request #172 from bipproduction/amalia/09-des-24
Amalia/09 des 24
This commit is contained in:
67
src/app/api/new/forum/route.ts
Normal file
67
src/app/api/new/forum/route.ts
Normal file
@@ -0,0 +1,67 @@
|
|||||||
|
import { prisma } from "@/app/lib"
|
||||||
|
import { NextResponse } from "next/server";
|
||||||
|
export const dynamic = "force-dynamic";
|
||||||
|
|
||||||
|
// GET ALL DATA PORTOFOLIO BY PROFILE ID
|
||||||
|
export async function GET(request: Request) {
|
||||||
|
try {
|
||||||
|
const { searchParams } = new URL(request.url)
|
||||||
|
const page = searchParams.get("page")
|
||||||
|
const search = searchParams.get("search")
|
||||||
|
const dataSkip = Number(page) * 5 - 5;
|
||||||
|
|
||||||
|
const data = await prisma.forum_Posting.findMany({
|
||||||
|
take: 5,
|
||||||
|
skip: dataSkip,
|
||||||
|
orderBy: {
|
||||||
|
createdAt: "desc",
|
||||||
|
},
|
||||||
|
where: {
|
||||||
|
isActive: true,
|
||||||
|
diskusi: {
|
||||||
|
mode: "insensitive",
|
||||||
|
contains: (search == undefined || search == "null") ? "" : search,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
select: {
|
||||||
|
id: true,
|
||||||
|
diskusi: true,
|
||||||
|
createdAt: true,
|
||||||
|
isActive: true,
|
||||||
|
authorId: true,
|
||||||
|
Author: {
|
||||||
|
select: {
|
||||||
|
id: true,
|
||||||
|
username: true,
|
||||||
|
Profile: {
|
||||||
|
select: {
|
||||||
|
id: true,
|
||||||
|
name: true,
|
||||||
|
imageId: true,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
Forum_Komentar: {
|
||||||
|
where: {
|
||||||
|
isActive: true,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
ForumMaster_StatusPosting: {
|
||||||
|
select: {
|
||||||
|
id: true,
|
||||||
|
status: true,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
forumMaster_StatusPostingId: true,
|
||||||
|
},
|
||||||
|
});
|
||||||
|
|
||||||
|
return NextResponse.json({ success: true, message: "Berhasil mendapatkan data", data }, { status: 200 });
|
||||||
|
|
||||||
|
}
|
||||||
|
catch (error) {
|
||||||
|
console.error(error);
|
||||||
|
return NextResponse.json({ success: false, message: "Gagal mendapatkan data, coba lagi nanti ", reason: (error as Error).message, }, { status: 500 });
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -89,7 +89,7 @@ export default function DrawerKatalogNew({ opened, close, userRoleId, userId }:
|
|||||||
))}
|
))}
|
||||||
|
|
||||||
<Component_ButtonLogout userId={userId} />
|
<Component_ButtonLogout userId={userId} />
|
||||||
{userRoleId != "1" && (
|
{userRoleId != "1" && userRoleId != "" && (
|
||||||
<Stack align="center" spacing={"xs"}>
|
<Stack align="center" spacing={"xs"}>
|
||||||
<ActionIcon
|
<ActionIcon
|
||||||
variant="transparent"
|
variant="transparent"
|
||||||
|
|||||||
@@ -15,9 +15,11 @@ export default function LayoutKatalogNew({ children }: { children: any }) {
|
|||||||
const [userRoleId, setUserRoleId] = useState("")
|
const [userRoleId, setUserRoleId] = useState("")
|
||||||
const [userLoginId, setUserLoginId] = useState("")
|
const [userLoginId, setUserLoginId] = useState("")
|
||||||
const [opened, { open, close }] = useDisclosure()
|
const [opened, { open, close }] = useDisclosure()
|
||||||
|
const [loading, setLoading] = useState(true);
|
||||||
|
|
||||||
async function getProfile() {
|
async function getProfile() {
|
||||||
try {
|
try {
|
||||||
|
setLoading(true)
|
||||||
const response = await apiGetUserProfile(`?profile=${param.id}`)
|
const response = await apiGetUserProfile(`?profile=${param.id}`)
|
||||||
const response2 = await funGetUserIdByToken()
|
const response2 = await funGetUserIdByToken()
|
||||||
if (response.success) {
|
if (response.success) {
|
||||||
@@ -27,6 +29,8 @@ export default function LayoutKatalogNew({ children }: { children: any }) {
|
|||||||
}
|
}
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.error(error);
|
console.error(error);
|
||||||
|
} finally {
|
||||||
|
setLoading(false)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -41,12 +45,14 @@ export default function LayoutKatalogNew({ children }: { children: any }) {
|
|||||||
<UIGlobal_LayoutHeaderTamplate
|
<UIGlobal_LayoutHeaderTamplate
|
||||||
title="KATALOG"
|
title="KATALOG"
|
||||||
customButtonRight={
|
customButtonRight={
|
||||||
authorId !== userLoginId ? (
|
loading ?
|
||||||
<ActionIcon disabled variant="transparent"></ActionIcon>
|
<ActionIcon disabled variant="transparent"></ActionIcon> :
|
||||||
) : (
|
authorId == userLoginId ? (
|
||||||
<ActionIcon c="white" variant="transparent" onClick={() => open()}>
|
<ActionIcon c="white" variant="transparent" onClick={() => open()}>
|
||||||
<IconDotsVertical />
|
<IconDotsVertical />
|
||||||
</ActionIcon>
|
</ActionIcon>
|
||||||
|
) : (
|
||||||
|
<ActionIcon disabled variant="transparent"></ActionIcon>
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
/>
|
/>
|
||||||
|
|||||||
@@ -2,7 +2,7 @@
|
|||||||
import { APIs } from "@/app/lib";
|
import { APIs } from "@/app/lib";
|
||||||
import { AccentColor } from "@/app_modules/_global/color/color_pallet";
|
import { AccentColor } from "@/app_modules/_global/color/color_pallet";
|
||||||
import ComponentGlobal_IsEmptyData from "@/app_modules/_global/component/is_empty_data";
|
import ComponentGlobal_IsEmptyData from "@/app_modules/_global/component/is_empty_data";
|
||||||
import { Avatar, Stack } from "@mantine/core";
|
import { Avatar, Loader, Stack } from "@mantine/core";
|
||||||
import { useShallowEffect } from "@mantine/hooks";
|
import { useShallowEffect } from "@mantine/hooks";
|
||||||
import "mapbox-gl/dist/mapbox-gl.css";
|
import "mapbox-gl/dist/mapbox-gl.css";
|
||||||
import { useState } from "react";
|
import { useState } from "react";
|
||||||
@@ -44,7 +44,10 @@ export function UiMap_MapBoxViewNew({ mapboxToken, }: { mapboxToken: string }) {
|
|||||||
<Stack style={{ borderRadius: "10px" }}>
|
<Stack style={{ borderRadius: "10px" }}>
|
||||||
{
|
{
|
||||||
loading ?
|
loading ?
|
||||||
<></> :
|
<Stack align="center" spacing="sm">
|
||||||
|
<Loader color="gray" variant="dots" />
|
||||||
|
</Stack>
|
||||||
|
:
|
||||||
<Map
|
<Map
|
||||||
mapboxAccessToken={mapboxToken}
|
mapboxAccessToken={mapboxToken}
|
||||||
mapStyle={"mapbox://styles/mapbox/streets-v11"}
|
mapStyle={"mapbox://styles/mapbox/streets-v11"}
|
||||||
|
|||||||
Reference in New Issue
Block a user