From ea2e52937c7da046646af71910f87af67b457487 Mon Sep 17 00:00:00 2001 From: Bagasbanuna02 Date: Thu, 2 Jan 2025 12:28:37 +0800 Subject: [PATCH 1/2] chore(release): 1.2.37 --- CHANGELOG.md | 2 ++ package.json | 2 +- 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index c094971c..dd2aaac3 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,8 @@ All notable changes to this project will be documented in this file. See [commit-and-tag-version](https://github.com/absolute-version/commit-and-tag-version) for commit guidelines. +## [1.2.37](https://github.com/bipproduction/hipmi/compare/v1.2.36...v1.2.37) (2025-01-02) + ## [1.2.36](https://github.com/bipproduction/hipmi/compare/v1.2.35...v1.2.36) (2024-12-30) ## [1.2.35](https://github.com/bipproduction/hipmi/compare/v1.2.34...v1.2.35) (2024-12-27) diff --git a/package.json b/package.json index 273e1449..ff74e64c 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "hipmi", - "version": "1.2.36", + "version": "1.2.37", "private": true, "prisma": { "seed": "npx tsx prisma/seed.ts --yes" From d0def08ff6d9fa524f3ad40e5a457ecbda2f4011 Mon Sep 17 00:00:00 2001 From: Bagasbanuna02 Date: Thu, 2 Jan 2025 14:42:49 +0800 Subject: [PATCH 2/2] 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 --- src/app/api/collaboration/[id]/route.ts | 100 ++++-- src/app/api/collaboration/group/[id]/route.ts | 82 +++++ src/app/dev/colab/detail/group/[id]/page.tsx | 2 + .../dev/colab/detail/info-grup/[id]/page.tsx | 9 +- .../colab/detail/main_detail/[id]/page.tsx | 13 +- .../detail/proyek/partisipasi/[id]/layout.tsx | 4 +- .../detail/proyek/partisipasi/[id]/page.tsx | 13 +- .../colab/detail/proyek/saya/[id]/layout.tsx | 9 +- .../colab/detail/proyek/saya/[id]/page.tsx | 14 +- src/app/zCoba/skeleton/page.tsx | 24 +- .../component/comp_avatar_and_username.tsx | 2 +- .../comp_card_box_and_background.tsx | 14 + .../colab/_lib/api_collaboration.ts | 32 +- .../colab/component/detail/detail_data.tsx | 20 +- .../detail/list_partisipasi_user.tsx | 289 ++++++++++++------ .../colab/component/header_author_name.tsx | 10 +- .../colab/component/skeleton_view.tsx | 191 +++++++++++- src/app_modules/colab/create/index.tsx | 40 +-- src/app_modules/colab/detail/group/index.tsx | 33 +- .../colab/detail/info_grup/index.tsx | 104 ++++--- .../colab/detail/main_detail/index.tsx | 76 ++--- .../colab/detail/proyek/partisipasi/index.tsx | 68 +++-- .../colab/detail/proyek/saya/index.tsx | 248 +++++++++------ .../colab/detail/proyek/saya/layout.tsx | 6 +- .../fun_create_partisipan_by_user_id.ts | 28 +- .../colab/main/proyek/partisipasi.tsx | 9 +- 26 files changed, 981 insertions(+), 459 deletions(-) create mode 100644 src/app/api/collaboration/group/[id]/route.ts diff --git a/src/app/api/collaboration/[id]/route.ts b/src/app/api/collaboration/[id]/route.ts index 36f0f5e3..3abcd9ce 100644 --- a/src/app/api/collaboration/[id]/route.ts +++ b/src/app/api/collaboration/[id]/route.ts @@ -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 }, diff --git a/src/app/api/collaboration/group/[id]/route.ts b/src/app/api/collaboration/group/[id]/route.ts new file mode 100644 index 00000000..83b64866 --- /dev/null +++ b/src/app/api/collaboration/group/[id]/route.ts @@ -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 } + ); + } +} diff --git a/src/app/dev/colab/detail/group/[id]/page.tsx b/src/app/dev/colab/detail/group/[id]/page.tsx index d93ed4f9..ebd48b78 100644 --- a/src/app/dev/colab/detail/group/[id]/page.tsx +++ b/src/app/dev/colab/detail/group/[id]/page.tsx @@ -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); diff --git a/src/app/dev/colab/detail/info-grup/[id]/page.tsx b/src/app/dev/colab/detail/info-grup/[id]/page.tsx index 375df71c..d4001193 100644 --- a/src/app/dev/colab/detail/info-grup/[id]/page.tsx +++ b/src/app/dev/colab/detail/info-grup/[id]/page.tsx @@ -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 ( <> - + ); } diff --git a/src/app/dev/colab/detail/main_detail/[id]/page.tsx b/src/app/dev/colab/detail/main_detail/[id]/page.tsx index 8ef7f58f..5d8311ca 100644 --- a/src/app/dev/colab/detail/main_detail/[id]/page.tsx +++ b/src/app/dev/colab/detail/main_detail/[id]/page.tsx @@ -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 ( <> ); diff --git a/src/app/dev/colab/detail/proyek/partisipasi/[id]/layout.tsx b/src/app/dev/colab/detail/proyek/partisipasi/[id]/layout.tsx index 2d9fef0e..e7cdc81a 100644 --- a/src/app/dev/colab/detail/proyek/partisipasi/[id]/layout.tsx +++ b/src/app/dev/colab/detail/proyek/partisipasi/[id]/layout.tsx @@ -3,7 +3,9 @@ import { LayoutColab_DetailPartisipasiProyek } from "@/app_modules/colab"; export default async function Layout({ children }: { children: any }) { return ( <> - {children} + + {children} + ); } diff --git a/src/app/dev/colab/detail/proyek/partisipasi/[id]/page.tsx b/src/app/dev/colab/detail/proyek/partisipasi/[id]/page.tsx index 68b18d99..323e5439 100644 --- a/src/app/dev/colab/detail/proyek/partisipasi/[id]/page.tsx +++ b/src/app/dev/colab/detail/proyek/partisipasi/[id]/page.tsx @@ -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 ( <> - + ); } diff --git a/src/app/dev/colab/detail/proyek/saya/[id]/layout.tsx b/src/app/dev/colab/detail/proyek/saya/[id]/layout.tsx index d7c38cc1..1b84d85b 100644 --- a/src/app/dev/colab/detail/proyek/saya/[id]/layout.tsx +++ b/src/app/dev/colab/detail/proyek/saya/[id]/layout.tsx @@ -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 ( <> - - {children} - + {children} ); } diff --git a/src/app/dev/colab/detail/proyek/saya/[id]/page.tsx b/src/app/dev/colab/detail/proyek/saya/[id]/page.tsx index 2c5d724f..e1527440 100644 --- a/src/app/dev/colab/detail/proyek/saya/[id]/page.tsx +++ b/src/app/dev/colab/detail/proyek/saya/[id]/page.tsx @@ -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 ( <> - {/*
{JSON.stringify(listPartisipan, null,2)}
*/} - + ); } diff --git a/src/app/zCoba/skeleton/page.tsx b/src/app/zCoba/skeleton/page.tsx index 34e765b2..f16ec3cf 100644 --- a/src/app/zCoba/skeleton/page.tsx +++ b/src/app/zCoba/skeleton/page.tsx @@ -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() { > + + + + {Array.from(new Array(2)).map((e, i) => ( + + + + + + + + + ))} + + + + {/* @@ -23,9 +40,6 @@ export default function Voting_ComponentSkeletonViewPuh() { - {/* - - */}
@@ -54,7 +68,7 @@ export default function Voting_ComponentSkeletonViewPuh() { - + */} {/* diff --git a/src/app_modules/_global/component/comp_avatar_and_username.tsx b/src/app_modules/_global/component/comp_avatar_and_username.tsx index 22ffc8b8..97809b9b 100644 --- a/src/app_modules/_global/component/comp_avatar_and_username.tsx +++ b/src/app_modules/_global/component/comp_avatar_and_username.tsx @@ -63,7 +63,7 @@ export function ComponentGlobal_AvatarAndUsername({ onCheckProfile()} > diff --git a/src/app_modules/_global/component/comp_card_box_and_background.tsx b/src/app_modules/_global/component/comp_card_box_and_background.tsx index cee4c5f7..7d724c24 100644 --- a/src/app_modules/_global/component/comp_card_box_and_background.tsx +++ b/src/app_modules/_global/component/comp_card_box_and_background.tsx @@ -2,6 +2,20 @@ import { AccentColor, MainColor } from "@/app_modules/_global/color"; import { Card } from "@mantine/core"; import React from "react"; +/** + * ComponentGlobal_CardStyles + * + * A React component that renders a customizable card element. + * + * Props: + * - children (React.ReactNode): Content to be displayed inside the card. + * - backgroundColor (string, optional): Background color of the card. Defaults to AccentColor.darkblue. + * - border (string, optional): Border color of the card. Defaults to AccentColor.blue. + * - marginBottom (string | number, optional): Margin below the card. Defaults to "15px". + * - height (string | number, optional): Height of the card. Defaults to "auto". + * - color (string, optional): Text color inside the card. Defaults to MainColor.white. + * - onClickHandler (React.MouseEventHandler, optional): Function to handle click events on the card. + */ export function ComponentGlobal_CardStyles({ children, backgroundColor, diff --git a/src/app_modules/colab/_lib/api_collaboration.ts b/src/app_modules/colab/_lib/api_collaboration.ts index a2aaa791..1c6b0d26 100644 --- a/src/app_modules/colab/_lib/api_collaboration.ts +++ b/src/app_modules/colab/_lib/api_collaboration.ts @@ -11,7 +11,33 @@ export const apiGetAllCollaboration = async ({ return await respone.json().catch(() => null); }; -export const apiGetOneCollaborationById = async ({ id }: { id: string }) => { - const respone = await fetch(`/api/collaboration/${id}`); +export const apiGetOneCollaborationById = async ({ + id, + kategori, + page, +}: { + id: string; + kategori: "detail" | "list_partisipan" | "cek_partisipasi"; + page?: string; +}) => { + const respone = await fetch( + `/api/collaboration/${id}?kategori=${kategori}&page=${page}` + ); return await respone.json().catch(() => null); -}; \ No newline at end of file +}; + +export const apiGetDataGroupById = async ({ + id, + kategori, + page, +}: { + id: string; + kategori: "detail" | "info_group" + page?: string; +}) => { + const respone = await fetch( + `/api/collaboration/group/${id}?kategori=${kategori}&page=${page}` + ); + + return await respone.json().catch(() => null) +} \ No newline at end of file diff --git a/src/app_modules/colab/component/detail/detail_data.tsx b/src/app_modules/colab/component/detail/detail_data.tsx index 30158c00..e2f2f12a 100644 --- a/src/app_modules/colab/component/detail/detail_data.tsx +++ b/src/app_modules/colab/component/detail/detail_data.tsx @@ -19,15 +19,15 @@ export default function ComponentColab_DetailData({ - + Industri - : + : - + {data?.ProjectCollaborationMaster_Industri.name ? data.ProjectCollaborationMaster_Industri.name : "Industri"} @@ -37,31 +37,31 @@ export default function ComponentColab_DetailData({ - + Lokasi - : + : - + {data?.lokasi ? data.lokasi : " Lokasi dari proyek"} - + Tujuan proyek - {data?.purpose ? data?.purpose : "-"} + {data?.purpose ? data?.purpose : "-"} - + Keuntungan - {data?.benefit ? data?.benefit : "-"} + {data?.benefit ? data?.benefit : "-"} diff --git a/src/app_modules/colab/component/detail/list_partisipasi_user.tsx b/src/app_modules/colab/component/detail/list_partisipasi_user.tsx index a5eaaef3..eab27c28 100644 --- a/src/app_modules/colab/component/detail/list_partisipasi_user.tsx +++ b/src/app_modules/colab/component/detail/list_partisipasi_user.tsx @@ -4,9 +4,14 @@ import { AccentColor, MainColor, } from "@/app_modules/_global/color/color_pallet"; +import { ComponentGlobal_CardStyles } from "@/app_modules/_global/component"; import ComponentGlobal_InputCountDown from "@/app_modules/_global/component/input_countdown"; +import ComponentGlobal_IsEmptyData from "@/app_modules/_global/component/is_empty_data"; import { ComponentGlobal_NotifikasiBerhasil } from "@/app_modules/_global/notif_global/notifikasi_berhasil"; import { ComponentGlobal_NotifikasiGagal } from "@/app_modules/_global/notif_global/notifikasi_gagal"; +import notifikasiToUser_funCreate from "@/app_modules/notifikasi/fun/create/create_notif_to_user"; +import { clientLogger } from "@/util/clientLogger"; +import mqtt_client from "@/util/mqtt_client"; import { ActionIcon, Box, @@ -14,86 +19,219 @@ import { Center, Drawer, Group, - Paper, - ScrollArea, + Loader, Stack, Text, Textarea, Title, } from "@mantine/core"; -import { useDisclosure } from "@mantine/hooks"; +import { useDisclosure, useShallowEffect } from "@mantine/hooks"; import { IconX } from "@tabler/icons-react"; +import _ from "lodash"; +import { ScrollOnly } from "next-scroll-loader"; +import { useParams } from "next/navigation"; import { useState } from "react"; +import { apiGetOneCollaborationById } from "../../_lib/api_collaboration"; import colab_funCreatePartisipan from "../../fun/create/fun_create_partisipan_by_user_id"; -import colab_getListPartisipanByColabId from "../../fun/get/get_list_partisipan_by_id"; import { MODEL_COLLABORATION_PARTISIPASI } from "../../model/interface"; +import { Collaboration_SkeletonListPrtisipanIsUser } from "../skeleton_view"; import ComponentColab_AuthorNameOnListPartisipan from "./header_author_list_partisipan"; -import notifikasiToUser_funCreate from "@/app_modules/notifikasi/fun/create/create_notif_to_user"; -import mqtt_client from "@/util/mqtt_client"; -import { ComponentGlobal_CardStyles } from "@/app_modules/_global/component"; export default function ComponentColab_DetailListPartisipasiUser({ - listPartisipan, userLoginId, authorId, - colabId, - cekPartisipan, }: { - listPartisipan?: MODEL_COLLABORATION_PARTISIPASI[]; userLoginId?: string; authorId?: string; - colabId?: string; - cekPartisipan?: boolean; }) { - const [apply, setApply] = useState(false); - const [data, setData] = useState(listPartisipan); + const params = useParams<{ id: string }>(); + const [data, setData] = useState( + null + ); + const [isPartisipan, setCekPartisipan] = useState(null); + + const [activePage, setActivePage] = useState(1); const [opened, { open, close }] = useDisclosure(false); const [deskripsi, setDeskripsi] = useState(""); + const [isLoading, setIsLoading] = useState(false); - + useShallowEffect(() => { + onLoadDataPartisipan(); + }, []); - async function onJoin() { - const res = await colab_funCreatePartisipan( - colabId as any, - userLoginId as any, - deskripsi - ); - if (res.status === 201) { - const dataNotif = { - appId: res?.data?.ProjectCollaboration?.id, - userId: res?.data?.ProjectCollaboration?.userId, - pesan: res?.data?.ProjectCollaboration?.title, - status: "Partisipan Project", - kategoriApp: "COLLABORATION", - title: "Partisipan baru telah bergabung !", - }; - - const createNotifikasi = await notifikasiToUser_funCreate({ - data: dataNotif as any, + async function onLoadDataPartisipan() { + try { + const respone = await apiGetOneCollaborationById({ + id: params.id, + kategori: "list_partisipan", + page: `${activePage}`, }); - if (createNotifikasi.status === 201) { - mqtt_client.publish( - "USER", - JSON.stringify({ - userId: dataNotif.userId, - count: 1, - }) - ); + if (respone) { + setData(respone.data); } - - const resList = await colab_getListPartisipanByColabId(colabId as any); - setApply(true); - close(); - setData(resList as any); - ComponentGlobal_NotifikasiBerhasil(res.message); - } else { - ComponentGlobal_NotifikasiGagal(res.message); + } catch (error) { + clientLogger.error("Error get list partisipan", error); } } + useShallowEffect(() => { + onCheckPartisipasi(); + }, []); + + async function onCheckPartisipasi() { + try { + const respone = await apiGetOneCollaborationById({ + id: params.id, + kategori: "cek_partisipasi", + }); + + if (respone) { + setCekPartisipan(respone.data); + } + } catch (error) { + clientLogger.error("Error cek partisipasi", error); + } + } + + async function onJoin() { + try { + setIsLoading(true); + const res = await colab_funCreatePartisipan({ + id: params.id, + deskripsi: deskripsi, + }); + + if (res.status === 201) { + // const dataNotif = { + // appId: res?.data?.ProjectCollaboration?.id, + // userId: res?.data?.ProjectCollaboration?.userId, + // pesan: res?.data?.ProjectCollaboration?.title, + // status: "Partisipan Project", + // kategoriApp: "COLLABORATION", + // title: "Partisipan baru telah bergabung !", + // }; + + // const createNotifikasi = await notifikasiToUser_funCreate({ + // data: dataNotif as any, + // }); + + // if (createNotifikasi.status === 201) { + // mqtt_client.publish( + // "USER", + // JSON.stringify({ + // userId: dataNotif.userId, + // count: 1, + // }) + // ); + // } + + const respone = await apiGetOneCollaborationById({ + id: params.id, + kategori: "list_partisipan", + page: `${activePage}`, + }); + + if (respone) { + setData(respone.data); + } + + const cekPartisipan = await apiGetOneCollaborationById({ + id: params.id, + kategori: "cek_partisipasi", + }); + + if (cekPartisipan) { + setCekPartisipan(cekPartisipan); + } + + close(); + ComponentGlobal_NotifikasiBerhasil(res.message); + } else { + ComponentGlobal_NotifikasiGagal(res.message); + } + } catch (error) { + clientLogger.error("Error create partisipan", error); + } finally { + setIsLoading(false); + } + } + + if (_.isNull(data) || _.isNull(isPartisipan)) { + return ; + } + return ( <> + + {userLoginId !== authorId && ( +
+ +
+ )} + + {_.isEmpty(data) ? ( + + +
+ Partispasi User ({data?.length}) +
+ +
+
+ ) : ( + + +
+ Partispasi User ({data?.length}) +
{" "} + + ( +
+ +
+ )} + data={data} + setData={setData as any} + moreData={async () => { + const respone = await apiGetOneCollaborationById({ + id: params.id, + kategori: "list_partisipan", + page: `${activePage + 1}`, + }); + + setActivePage((val) => val + 1); + + return respone.data; + }} + > + {(item) => ( + + )} +
+
+
+
+ )} +
+ -
- ) : ( - "" - )} - - - -
- Partispasi User ({data?.length}) -
{" "} - - - - {data?.length === 0 ? ( -
- - Tidak ada partisipan - -
- ) : ( - data?.map((e, i) => ( - - - - )) - )} -
-
-
-
-
-
); } diff --git a/src/app_modules/colab/component/header_author_name.tsx b/src/app_modules/colab/component/header_author_name.tsx index 958bbeb3..315b34e4 100644 --- a/src/app_modules/colab/component/header_author_name.tsx +++ b/src/app_modules/colab/component/header_author_name.tsx @@ -3,6 +3,8 @@ import { ComponentGlobal_AvatarAndUsername } from "@/app_modules/_global/component"; import { Group, Stack, Text } from "@mantine/core"; import { useRouter } from "next/navigation"; +import moment from "moment"; +import "moment/locale/id"; export default function ComponentColab_AuthorNameOnHeader({ tglPublish, @@ -19,10 +21,8 @@ export default function ComponentColab_AuthorNameOnHeader({ component={ {tglPublish ? ( - - {new Intl.DateTimeFormat("id-ID", { - dateStyle: "medium", - }).format(tglPublish)} + + {moment(tglPublish).locale("id").format("ll")} ) : ( "" @@ -65,7 +65,7 @@ export default function ComponentColab_AuthorNameOnHeader({ {tglPublish ? ( - + {new Intl.DateTimeFormat("id-ID", { dateStyle: "medium" diff --git a/src/app_modules/colab/component/skeleton_view.tsx b/src/app_modules/colab/component/skeleton_view.tsx index 50078632..afa4f998 100644 --- a/src/app_modules/colab/component/skeleton_view.tsx +++ b/src/app_modules/colab/component/skeleton_view.tsx @@ -1,30 +1,38 @@ import { ComponentGlobal_CardStyles } from "@/app_modules/_global/component"; -import { Center, Grid, Skeleton, Stack } from "@mantine/core"; +import { Center, Grid, Group, Skeleton, Stack } from "@mantine/core"; export { - Collaboration_SkeletonCreate, Collaboration_SkeletonBeranda, + Collaboration_SkeletonCreate, + Collaboration_SkeletonDetail, + Collaboration_SkeletonDetailInfoGroup, Collaboration_SkeletonGrup, + Collaboration_SkeletonListPartisipan, + Collaboration_SkeletonListPrtisipanIsUser, }; function Collaboration_SkeletonCreate() { return ( <> - + - + - + - + + + + + - + @@ -94,9 +102,176 @@ function Collaboration_SkeletonGrup() { <> {Array.from(new Array(2)).map((e, i) => ( - + + + + + + + + ))} ); } + +function Collaboration_SkeletonDetail() { + return ( + <> + + + + + + + + + + +
+ +
+ + + + + + + + + + + + + + + + + + + + + + + +
+
+ + ); +} + +function Collaboration_SkeletonListPrtisipanIsUser() { + return ( + <> + + + +
+ +
+ + {Array.from(new Array(2)).map((e, i) => ( + + + + + + + + + ))} +
+
+
+ + ); +} + +function Collaboration_SkeletonListPartisipan() { + return ( + <> + +
+ +
+ + +
+ +
+ + {Array.from(new Array(2)).map((e, i) => ( + + + + + + + + + ))} +
+
+
+ + ); +} + +function Collaboration_SkeletonDetailInfoGroup() { + return ( + <> + + + +
+ +
+ + + + + + + + + + + + + + + + + + + + + + + + + +
+
+ + + + + + {Array.from(new Array(2)).map((e, i) => ( + + + + + + + + + ))} + + +
+ + ); +} diff --git a/src/app_modules/colab/create/index.tsx b/src/app_modules/colab/create/index.tsx index b28e3236..8123fca1 100644 --- a/src/app_modules/colab/create/index.tsx +++ b/src/app_modules/colab/create/index.tsx @@ -5,26 +5,22 @@ import ComponentGlobal_InputCountDown from "@/app_modules/_global/component/inpu import { ComponentGlobal_NotifikasiBerhasil } from "@/app_modules/_global/notif_global/notifikasi_berhasil"; import { ComponentGlobal_NotifikasiGagal } from "@/app_modules/_global/notif_global/notifikasi_gagal"; import { ComponentGlobal_NotifikasiPeringatan } from "@/app_modules/_global/notif_global/notifikasi_peringatan"; +import { clientLogger } from "@/util/clientLogger"; +import mqtt_client from "@/util/mqtt_client"; import { Button, - Center, Select, Stack, TextInput, - Textarea, - Loader, + Textarea } from "@mantine/core"; +import { useShallowEffect } from "@mantine/hooks"; import { useRouter } from "next/navigation"; import { useState } from "react"; +import { Collaboration_SkeletonCreate } from "../component"; +import { apiGetMasterCollaboration } from "../component/lib/api_collaboration"; import colab_funCreateProyek from "../fun/create/fun_create_proyek"; import { MODEL_COLLABORATION_MASTER } from "../model/interface"; -import mqtt_client from "@/util/mqtt_client"; -import { useHookstate } from "@hookstate/core"; -import { useGsCollabCreate } from "../global_state/state"; -import { useShallowEffect } from "@mantine/hooks"; -import { apiGetMasterCollaboration } from "../component/lib/api_collaboration"; -import { clientLogger } from "@/util/clientLogger"; -import { Collaboration_SkeletonCreate } from "../component"; export default function Colab_Create() { const [value, setValue] = useState({ @@ -103,7 +99,7 @@ export default function Colab_Create() { }} /> - {/*