perbaikan(kolaborasi): memperbaiki bug modul kolaborasi dan tingkatkan komponen UI
Deskripsi: - Perbaikan endpoint API dan routing kolaborasi - Pembaruan tampilan grup kolaborasi dan partisipasi proyek - Peningkatan komponen skeleton loading - Perbaikan tampilan komponen avatar dan username - Refaktor layout pembuatan dan detail kolaborasi
This commit is contained in:
@@ -1,4 +1,5 @@
|
||||
import { prisma } from "@/app/lib";
|
||||
import { funGetUserIdByToken } from "@/app_modules/_global/fun/get";
|
||||
import backendLogger from "@/util/backendLogger";
|
||||
import { NextResponse } from "next/server";
|
||||
|
||||
@@ -11,36 +12,87 @@ export async function GET(
|
||||
try {
|
||||
let fixData;
|
||||
const { id } = context.params;
|
||||
const { searchParams } = new URL(request.url);
|
||||
const kategori = searchParams.get("kategori");
|
||||
const page = searchParams.get("page");
|
||||
const takeData = 10;
|
||||
const dataSkip = Number(page) * takeData - takeData;
|
||||
|
||||
// Buatkan api untuk list partisipasi
|
||||
|
||||
fixData = await prisma.projectCollaboration.findFirst({
|
||||
where: {
|
||||
id: id,
|
||||
},
|
||||
select: {
|
||||
id: true,
|
||||
isActive: true,
|
||||
title: true,
|
||||
lokasi: true,
|
||||
purpose: true,
|
||||
benefit: true,
|
||||
createdAt: true,
|
||||
// jumlah_partisipan: true,
|
||||
Author: {
|
||||
select: {
|
||||
id: true,
|
||||
Profile: true,
|
||||
const userLoginId = await funGetUserIdByToken();
|
||||
|
||||
if (userLoginId == null) {
|
||||
return NextResponse.json(
|
||||
{
|
||||
success: false,
|
||||
message: "Gagal mendapatkan data, user id tidak ada",
|
||||
},
|
||||
{ status: 500 }
|
||||
);
|
||||
}
|
||||
|
||||
if (kategori == "detail") {
|
||||
fixData = await prisma.projectCollaboration.findFirst({
|
||||
where: {
|
||||
id: id,
|
||||
},
|
||||
select: {
|
||||
id: true,
|
||||
isActive: true,
|
||||
title: true,
|
||||
lokasi: true,
|
||||
purpose: true,
|
||||
benefit: true,
|
||||
createdAt: true,
|
||||
// jumlah_partisipan: true,
|
||||
Author: {
|
||||
select: {
|
||||
id: true,
|
||||
Profile: true,
|
||||
},
|
||||
},
|
||||
ProjectCollaborationMaster_Industri: true,
|
||||
ProjectCollaboration_Partisipasi: {
|
||||
where: {
|
||||
isActive: true,
|
||||
},
|
||||
},
|
||||
},
|
||||
ProjectCollaborationMaster_Industri: true,
|
||||
ProjectCollaboration_Partisipasi: {
|
||||
where: {
|
||||
isActive: true,
|
||||
},
|
||||
});
|
||||
} else if (kategori == "list_partisipan") {
|
||||
fixData = await prisma.projectCollaboration_Partisipasi.findMany({
|
||||
take: takeData,
|
||||
skip: dataSkip,
|
||||
where: {
|
||||
projectCollaborationId: id,
|
||||
isActive: true,
|
||||
},
|
||||
},
|
||||
});
|
||||
select: {
|
||||
id: true,
|
||||
User: {
|
||||
select: {
|
||||
id: true,
|
||||
Profile: true,
|
||||
},
|
||||
},
|
||||
deskripsi_diri: true,
|
||||
},
|
||||
});
|
||||
} else if (kategori == "cek_partisipasi") {
|
||||
const cek = await prisma.projectCollaboration_Partisipasi.findFirst({
|
||||
where: {
|
||||
projectCollaborationId: id,
|
||||
userId: userLoginId,
|
||||
},
|
||||
});
|
||||
|
||||
if (cek === null) {
|
||||
fixData = false;
|
||||
} else {
|
||||
fixData = true;
|
||||
}
|
||||
}
|
||||
|
||||
return NextResponse.json(
|
||||
{ success: true, message: "Berhasil mendapatkan data", data: fixData },
|
||||
|
||||
82
src/app/api/collaboration/group/[id]/route.ts
Normal file
82
src/app/api/collaboration/group/[id]/route.ts
Normal file
@@ -0,0 +1,82 @@
|
||||
import { prisma } from "@/app/lib";
|
||||
import backendLogger from "@/util/backendLogger";
|
||||
import { NextResponse } from "next/server";
|
||||
|
||||
export const dynamic = "force-dynamic";
|
||||
|
||||
export async function GET(
|
||||
request: Request,
|
||||
context: { params: { id: string } }
|
||||
) {
|
||||
try {
|
||||
let fixData;
|
||||
const { id } = context.params;
|
||||
const { searchParams } = new URL(request.url);
|
||||
const kategori = searchParams.get("kategori");
|
||||
const page = searchParams.get("page");
|
||||
const takeData = 10;
|
||||
const skipData = Number(page) * takeData - takeData;
|
||||
|
||||
// data room { id, grup_name}
|
||||
if (kategori == "detail") {
|
||||
fixData = await prisma.projectCollaboration_RoomChat.findFirst({
|
||||
where: {
|
||||
id: id,
|
||||
},
|
||||
select: {
|
||||
id: true,
|
||||
name: true,
|
||||
},
|
||||
});
|
||||
} else if (kategori == "info_group") {
|
||||
fixData = await prisma.projectCollaboration_RoomChat.findFirst({
|
||||
where: {
|
||||
id: id,
|
||||
},
|
||||
select: {
|
||||
id: true,
|
||||
name: true,
|
||||
ProjectCollaboration: {
|
||||
select: {
|
||||
id: true,
|
||||
isActive: true,
|
||||
title: true,
|
||||
lokasi: true,
|
||||
purpose: true,
|
||||
benefit: true,
|
||||
createdAt: true,
|
||||
ProjectCollaborationMaster_Industri: true,
|
||||
},
|
||||
},
|
||||
ProjectCollaboration_AnggotaRoomChat: {
|
||||
select: {
|
||||
User: {
|
||||
select: {
|
||||
id: true,
|
||||
Profile: {
|
||||
select: {
|
||||
id: true,
|
||||
name: true,
|
||||
imageId: true,
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
});
|
||||
}
|
||||
|
||||
return NextResponse.json(
|
||||
{ success: true, message: "Berhasil mendapatkan data", data: fixData },
|
||||
{ status: 200 }
|
||||
);
|
||||
} catch (error) {
|
||||
backendLogger.error("Gagal mendapatkan data", error);
|
||||
return NextResponse.json(
|
||||
{ success: false, message: "Gagal mendapatkan data" },
|
||||
{ status: 500 }
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -15,6 +15,8 @@ export default async function Page({ params }: { params: { id: string } }) {
|
||||
"ProjectCollaboration",
|
||||
"ProjectCollaboration_AnggotaRoomChat",
|
||||
]);
|
||||
|
||||
|
||||
let listMsg = await colab_getMessageByRoomId({ roomId: roomId, page: 1 });
|
||||
const dataUserLogin = await user_getOneByUserId(userLoginId as string);
|
||||
|
||||
|
||||
@@ -1,14 +1,9 @@
|
||||
import prisma from "@/app/lib/prisma";
|
||||
import { Colab_DetailInfoGrup } from "@/app_modules/colab";
|
||||
import colab_getListAnggotaByRoomId from "@/app_modules/colab/fun/get/room_chat/get_list_anggota_by_room_id";
|
||||
|
||||
export default async function Page({ params }: { params: { id: string } }) {
|
||||
let roomId = params.id;
|
||||
const dataRoom = await colab_getListAnggotaByRoomId(roomId);
|
||||
|
||||
export default async function Page() {
|
||||
return (
|
||||
<>
|
||||
<Colab_DetailInfoGrup dataRoom={dataRoom as any} />
|
||||
<Colab_DetailInfoGrup />
|
||||
</>
|
||||
);
|
||||
}
|
||||
|
||||
@@ -1,24 +1,13 @@
|
||||
import { funGetUserIdByToken } from "@/app_modules/_global/fun/get";
|
||||
import { Colab_MainDetail } from "@/app_modules/colab";
|
||||
import colab_funCekPartisipasiById from "@/app_modules/colab/fun/get/cek_partisipasi_by_user_id";
|
||||
import colab_getListPartisipanByColabId from "@/app_modules/colab/fun/get/get_list_partisipan_by_id";
|
||||
import colab_getOneCollaborationById from "@/app_modules/colab/fun/get/get_one_by_id";
|
||||
|
||||
export default async function Page({ params }: { params: { id: string } }) {
|
||||
let colabId = params.id;
|
||||
export default async function Page() {
|
||||
const userLoginId = await funGetUserIdByToken();
|
||||
|
||||
const dataColab = await colab_getOneCollaborationById(colabId);
|
||||
const listPartisipan = await colab_getListPartisipanByColabId(colabId);
|
||||
const cekPartisipan = await colab_funCekPartisipasiById(colabId);
|
||||
|
||||
return (
|
||||
<>
|
||||
<Colab_MainDetail
|
||||
dataColab={{} as any}
|
||||
userLoginId={userLoginId as string}
|
||||
listPartisipan={listPartisipan as any}
|
||||
cekPartisipan={cekPartisipan}
|
||||
/>
|
||||
</>
|
||||
);
|
||||
|
||||
@@ -3,7 +3,9 @@ import { LayoutColab_DetailPartisipasiProyek } from "@/app_modules/colab";
|
||||
export default async function Layout({ children }: { children: any }) {
|
||||
return (
|
||||
<>
|
||||
<LayoutColab_DetailPartisipasiProyek>{children}</LayoutColab_DetailPartisipasiProyek>
|
||||
<LayoutColab_DetailPartisipasiProyek>
|
||||
{children}
|
||||
</LayoutColab_DetailPartisipasiProyek>
|
||||
</>
|
||||
);
|
||||
}
|
||||
|
||||
@@ -1,18 +1,9 @@
|
||||
import { Colab_DetailPartisipasiProyek } from "@/app_modules/colab";
|
||||
import colab_getListPartisipanByColabId from "@/app_modules/colab/fun/get/get_list_partisipan_by_id";
|
||||
import colab_getOneCollaborationById from "@/app_modules/colab/fun/get/get_one_by_id";
|
||||
|
||||
export default async function Page({params}: {params: {id: string}}) {
|
||||
const colabId = params.id
|
||||
const dataColab = await colab_getOneCollaborationById(colabId)
|
||||
const listPartisipan = await colab_getListPartisipanByColabId(colabId)
|
||||
|
||||
export default async function Page() {
|
||||
return (
|
||||
<>
|
||||
<Colab_DetailPartisipasiProyek
|
||||
dataColab={dataColab as any}
|
||||
listPartisipan={listPartisipan as any}
|
||||
/>
|
||||
<Colab_DetailPartisipasiProyek />
|
||||
</>
|
||||
);
|
||||
}
|
||||
|
||||
@@ -3,19 +3,12 @@ import React from "react";
|
||||
|
||||
export default async function Layout({
|
||||
children,
|
||||
params,
|
||||
}: {
|
||||
children: React.ReactNode;
|
||||
params: { id: string };
|
||||
}) {
|
||||
let colabId = params.id;
|
||||
|
||||
|
||||
return (
|
||||
<>
|
||||
<LayoutColab_DetailProyekSaya colabId={colabId}>
|
||||
{children}
|
||||
</LayoutColab_DetailProyekSaya>
|
||||
<LayoutColab_DetailProyekSaya>{children}</LayoutColab_DetailProyekSaya>
|
||||
</>
|
||||
);
|
||||
}
|
||||
|
||||
@@ -1,19 +1,9 @@
|
||||
import { Colab_DetailProyekSaya } from "@/app_modules/colab";
|
||||
import colab_getListPartisipanByColabId from "@/app_modules/colab/fun/get/get_list_partisipan_by_id";
|
||||
import colab_getOneCollaborationById from "@/app_modules/colab/fun/get/get_one_by_id";
|
||||
|
||||
export default async function Page({ params }: { params: { id: string } }) {
|
||||
const colabId = params.id;
|
||||
const dataColab = await colab_getOneCollaborationById(colabId);
|
||||
const listPartisipan = await colab_getListPartisipanByColabId(colabId);
|
||||
|
||||
export default async function Page() {
|
||||
return (
|
||||
<>
|
||||
{/* <pre>{JSON.stringify(listPartisipan, null,2)}</pre> */}
|
||||
<Colab_DetailProyekSaya
|
||||
dataColab={dataColab as any}
|
||||
listPartisipan={listPartisipan as any}
|
||||
/>
|
||||
<Colab_DetailProyekSaya />
|
||||
</>
|
||||
);
|
||||
}
|
||||
|
||||
@@ -5,7 +5,7 @@ import {
|
||||
UIGlobal_LayoutHeaderTamplate,
|
||||
UIGlobal_LayoutTamplate,
|
||||
} from "@/app_modules/_global/ui";
|
||||
import { Center, Grid, Group, Skeleton, Stack } from "@mantine/core";
|
||||
import { Grid, Skeleton, Stack } from "@mantine/core";
|
||||
|
||||
export default function Voting_ComponentSkeletonViewPuh() {
|
||||
return (
|
||||
@@ -15,6 +15,23 @@ export default function Voting_ComponentSkeletonViewPuh() {
|
||||
>
|
||||
<Stack>
|
||||
<ComponentGlobal_CardStyles marginBottom={"0"}>
|
||||
<Stack>
|
||||
<Skeleton h={20} w={100} />
|
||||
|
||||
{Array.from(new Array(2)).map((e, i) => (
|
||||
<Grid align="center" gutter={"md"} key={i}>
|
||||
<Grid.Col span={"content"}>
|
||||
<Skeleton circle height={40} />
|
||||
</Grid.Col>
|
||||
<Grid.Col span={3}>
|
||||
<Skeleton height={20} w={150} />
|
||||
</Grid.Col>
|
||||
</Grid>
|
||||
))}
|
||||
</Stack>
|
||||
</ComponentGlobal_CardStyles>
|
||||
|
||||
{/* <ComponentGlobal_CardStyles marginBottom={"0"}>
|
||||
<Stack spacing={"xl"}>
|
||||
<Grid align="center" gutter={"md"}>
|
||||
<Grid.Col span={"content"}>
|
||||
@@ -23,9 +40,6 @@ export default function Voting_ComponentSkeletonViewPuh() {
|
||||
<Grid.Col span={3}>
|
||||
<Skeleton height={20} w={150} />
|
||||
</Grid.Col>
|
||||
{/* <Grid.Col span={3} offset={3}>
|
||||
<Skeleton height={20} w={150} />
|
||||
</Grid.Col> */}
|
||||
</Grid>
|
||||
<Center>
|
||||
<Skeleton height={15} w={200} />
|
||||
@@ -54,7 +68,7 @@ export default function Voting_ComponentSkeletonViewPuh() {
|
||||
<Skeleton height={15} w={100} />
|
||||
<Skeleton height={15} w={"100%"} />
|
||||
</Stack>
|
||||
</ComponentGlobal_CardStyles>
|
||||
</ComponentGlobal_CardStyles> */}
|
||||
|
||||
{/* <ComponentGlobal_CardStyles>
|
||||
<Stack>
|
||||
|
||||
Reference in New Issue
Block a user