Project Collaboration
## feat - Buat proyek baru - Tampilan list data pada beranda - Partisipasi user lain ### No issuee
This commit is contained in:
@@ -734,7 +734,7 @@ model ProjectCollaboration {
|
||||
title String
|
||||
lokasi String
|
||||
purpose String @db.Text
|
||||
benefit String @db.Text
|
||||
benefit String? @db.Text
|
||||
|
||||
ProjectCollaborationMaster_Industri ProjectCollaborationMaster_Industri? @relation(fields: [projectCollaborationMaster_IndustriId], references: [id])
|
||||
projectCollaborationMaster_IndustriId Int?
|
||||
|
||||
@@ -1,13 +1,25 @@
|
||||
import { Colab_MainDetail } from "@/app_modules/colab";
|
||||
import colab_funCekPartisipasiById from "@/app_modules/colab/fun/get/cek_partisipasi_by_user_id";
|
||||
import colab_getListPartisipanById from "@/app_modules/colab/fun/get/get_list_partisipan_by_id";
|
||||
import colab_getOneCollaborationById from "@/app_modules/colab/fun/get/get_one_by_id";
|
||||
import { User_getUserId } from "@/app_modules/fun_global/get_user_token";
|
||||
|
||||
export default async function Page({ params }: { params: { id: string } }) {
|
||||
let colabId = params.id
|
||||
const userLoginId = await User_getUserId()
|
||||
let colabId = params.id;
|
||||
const userLoginId = await User_getUserId();
|
||||
const dataColab = await colab_getOneCollaborationById(colabId);
|
||||
const listPartisipan = await colab_getListPartisipanById(colabId)
|
||||
const cekPartisipan = await colab_funCekPartisipasiById(colabId)
|
||||
|
||||
|
||||
return (
|
||||
<>
|
||||
<Colab_MainDetail />
|
||||
<Colab_MainDetail
|
||||
dataColab={dataColab as any}
|
||||
userLoginId={userLoginId}
|
||||
listPartisipan={listPartisipan as any}
|
||||
cekPartisipan={cekPartisipan}
|
||||
/>
|
||||
</>
|
||||
);
|
||||
}
|
||||
|
||||
@@ -1,7 +1,12 @@
|
||||
import { Colab_Beranda } from "@/app_modules/colab";
|
||||
import colab_getListAllProyek from "@/app_modules/colab/fun/get/get_list_all_proyek";
|
||||
|
||||
export default async function Page() {
|
||||
return<>
|
||||
<Colab_Beranda/>
|
||||
</>
|
||||
const listData = await colab_getListAllProyek()
|
||||
|
||||
return (
|
||||
<>
|
||||
<Colab_Beranda listData={listData as any} />
|
||||
</>
|
||||
);
|
||||
}
|
||||
@@ -6,13 +6,16 @@ import { ComponentGlobal_NotifikasiPeringatan } from "@/app_modules/component_gl
|
||||
import { Card, Center, Title, Stack, Grid, Text } from "@mantine/core";
|
||||
import { useRouter } from "next/navigation";
|
||||
import { useState } from "react";
|
||||
import { MODEL_COLLABORATION } from "../../model/interface";
|
||||
|
||||
export default function ComponentColab_CardSectionData({
|
||||
colabId,
|
||||
path,
|
||||
data,
|
||||
}: {
|
||||
colabId?: any;
|
||||
path?: any;
|
||||
data?: MODEL_COLLABORATION;
|
||||
}) {
|
||||
const router = useRouter();
|
||||
|
||||
@@ -30,7 +33,7 @@ export default function ComponentColab_CardSectionData({
|
||||
>
|
||||
<Center px={"md"} mb={"lg"}>
|
||||
<Title order={5} lineClamp={1}>
|
||||
Judul Proyek{" "}
|
||||
{data?.title ? data.title : "Judul Proyek"}
|
||||
</Title>
|
||||
</Center>
|
||||
<Stack spacing={"xs"}>
|
||||
@@ -44,7 +47,11 @@ export default function ComponentColab_CardSectionData({
|
||||
<Text fz={"xs"}>:</Text>
|
||||
</Grid.Col>
|
||||
<Grid.Col span={"auto"}>
|
||||
<Text fz={"xs"}>Industri</Text>
|
||||
<Text fz={"xs"} lineClamp={1}>
|
||||
{data?.ProjectCollaborationMaster_Industri.name
|
||||
? data?.ProjectCollaborationMaster_Industri?.name
|
||||
: "Industri"}
|
||||
</Text>
|
||||
</Grid.Col>
|
||||
</Grid>
|
||||
|
||||
@@ -59,7 +66,7 @@ export default function ComponentColab_CardSectionData({
|
||||
</Grid.Col>
|
||||
<Grid.Col span={"auto"}>
|
||||
<Text fz={"xs"} lineClamp={1}>
|
||||
Lokasi dari proyek{" "}
|
||||
{data?.lokasi ? data?.lokasi : "Lokasi dari proyek"}
|
||||
</Text>
|
||||
</Grid.Col>
|
||||
</Grid>
|
||||
@@ -69,10 +76,9 @@ export default function ComponentColab_CardSectionData({
|
||||
Tujuan proyek
|
||||
</Text>
|
||||
<Text lineClamp={3} fz={"xs"}>
|
||||
Lorem ipsum dolor sit amet consectetur adipisicing elit. Nam
|
||||
repudiandae nostrum temporibus velit possimus, voluptate inventore
|
||||
recusandae hic ipsa praesentium deserunt, fuga asperiores
|
||||
doloremque amet incidunt explicabo ea eius earum.
|
||||
{data?.purpose
|
||||
? data?.purpose
|
||||
: "Lorem ipsum dolor sit amet, consectetur adipisicing elit. Maiores odio nihil in animi expedita, suscipit excepturi pariatur totam esse officiis enim cumque. Quidem, facere aliquam. Sunt laboriosam incidunt iste amet"}
|
||||
</Text>
|
||||
</Stack>
|
||||
</Stack>
|
||||
|
||||
@@ -20,13 +20,13 @@ export default function ComponentColab_CardSectionHeaderAuthorName({
|
||||
authorName?: string;
|
||||
tglPublish?: Date;
|
||||
isPembatas?: boolean;
|
||||
jumlah_partisipan?: number;
|
||||
jumlah_partisipan?: any[]
|
||||
}) {
|
||||
const router = useRouter();
|
||||
|
||||
return (
|
||||
<>
|
||||
<Card.Section px={"md"} pb={"md"}>
|
||||
<Card.Section px={"md"}>
|
||||
<Stack spacing={"xs"}>
|
||||
<Grid>
|
||||
<Grid.Col
|
||||
@@ -60,11 +60,13 @@ export default function ComponentColab_CardSectionHeaderAuthorName({
|
||||
</Grid.Col>
|
||||
<Grid.Col span={"content"}>
|
||||
<Stack justify="center" h={"100%"}>
|
||||
<Text c={"gray"} fz={"xs"}>
|
||||
{jumlah_partisipan
|
||||
? jumlah_partisipan + " " + "partisipan"
|
||||
: 0 + " " + "partisipan"}
|
||||
</Text>
|
||||
{tglPublish ? (
|
||||
<Text c={"gray"} fz={"xs"}>
|
||||
{new Intl.DateTimeFormat("id-ID").format(tglPublish)}
|
||||
</Text>
|
||||
) : (
|
||||
""
|
||||
)}
|
||||
</Stack>
|
||||
</Grid.Col>
|
||||
</Grid>
|
||||
|
||||
@@ -0,0 +1,34 @@
|
||||
"use client";
|
||||
|
||||
import { Stack, Divider, Center, Text, Grid, Card } from "@mantine/core";
|
||||
import { IconUsersGroup } from "@tabler/icons-react";
|
||||
|
||||
export default function ComponentColab_JumlahPartisipan({
|
||||
jumlah,
|
||||
}: {
|
||||
jumlah?: any[];
|
||||
}) {
|
||||
return (
|
||||
<>
|
||||
<Card.Section px={"md"}>
|
||||
<Stack>
|
||||
<Divider />
|
||||
<Center>
|
||||
<Grid>
|
||||
<Grid.Col span={"content"}>
|
||||
<Text c={"gray"} fz={"xs"} fw={"bold"}>
|
||||
{jumlah?.length ? jumlah?.length : 0}
|
||||
</Text>
|
||||
</Grid.Col>
|
||||
<Grid.Col span={"auto"}>
|
||||
<Text c={"gray"} fz={"xs"} fw={"bold"}>
|
||||
Partisipan
|
||||
</Text>
|
||||
</Grid.Col>
|
||||
</Grid>
|
||||
</Center>
|
||||
</Stack>
|
||||
</Card.Section>
|
||||
</>
|
||||
);
|
||||
}
|
||||
@@ -1,28 +0,0 @@
|
||||
"use client";
|
||||
|
||||
import { Stack, Divider, Center, Text, Grid } from "@mantine/core";
|
||||
import { IconUsersGroup } from "@tabler/icons-react";
|
||||
|
||||
export default function ComponentColab_JumlahPartisipan() {
|
||||
return (
|
||||
<>
|
||||
<Stack>
|
||||
<Divider />
|
||||
<Center>
|
||||
<Grid >
|
||||
<Grid.Col span={"content"}>
|
||||
<Text c={"gray"} fz={"xs"} fw={"bold"}>
|
||||
12
|
||||
</Text>
|
||||
</Grid.Col>
|
||||
<Grid.Col span={"auto"}>
|
||||
<Text c={"gray"} fz={"xs"} fw={"bold"}>
|
||||
Partisipan
|
||||
</Text>
|
||||
</Grid.Col>
|
||||
</Grid>
|
||||
</Center>
|
||||
</Stack>
|
||||
</>
|
||||
);
|
||||
}
|
||||
@@ -1,15 +1,20 @@
|
||||
"use client"
|
||||
"use client";
|
||||
|
||||
import { Stack, Box, Center, Title, Grid, Text } from "@mantine/core";
|
||||
import ComponentColab_AuthorNameOnHeader from "../header_author_name";
|
||||
import { MODEL_COLLABORATION } from "../../model/interface";
|
||||
|
||||
export default function ComponentColab_DetailData() {
|
||||
export default function ComponentColab_DetailData({
|
||||
data,
|
||||
}: {
|
||||
data?: MODEL_COLLABORATION;
|
||||
}) {
|
||||
return (
|
||||
<>
|
||||
<Stack>
|
||||
<Box>
|
||||
<Center px={"md"} mb={"lg"} >
|
||||
<Title order={4}>Judul Proyek </Title>
|
||||
<Center px={"md"} mb={"lg"}>
|
||||
<Title order={4}>{data?.title ? data.title : "Judul Proyek"}</Title>
|
||||
</Center>
|
||||
<Stack spacing={"sm"}>
|
||||
<Grid>
|
||||
@@ -22,7 +27,11 @@ export default function ComponentColab_DetailData() {
|
||||
<Text fz={"sm"}>:</Text>
|
||||
</Grid.Col>
|
||||
<Grid.Col span={"auto"}>
|
||||
<Text fz={"sm"}>Industri</Text>
|
||||
<Text fz={"sm"}>
|
||||
{data?.ProjectCollaborationMaster_Industri.name
|
||||
? data.ProjectCollaborationMaster_Industri.name
|
||||
: "Industri"}
|
||||
</Text>
|
||||
</Grid.Col>
|
||||
</Grid>
|
||||
|
||||
@@ -37,7 +46,7 @@ export default function ComponentColab_DetailData() {
|
||||
</Grid.Col>
|
||||
<Grid.Col span={"auto"}>
|
||||
<Text fz={"sm"} lineClamp={1}>
|
||||
Lokasi dari proyek{" "}
|
||||
{data?.lokasi ? data.lokasi : " Lokasi dari proyek"}
|
||||
</Text>
|
||||
</Grid.Col>
|
||||
</Grid>
|
||||
@@ -46,22 +55,14 @@ export default function ComponentColab_DetailData() {
|
||||
<Text fw={"bold"} fz={"sm"}>
|
||||
Tujuan proyek
|
||||
</Text>
|
||||
<Text fz={"sm"}>
|
||||
Lorem ipsum dolor sit amet consectetur adipisicing elit. Nam
|
||||
repudiandae nostrum temporibus velit possimus, voluptate
|
||||
inventore recusandae hic ipsa praesentium deserunt, fuga
|
||||
asperiores doloremque amet incidunt explicabo ea eius earum.
|
||||
</Text>
|
||||
<Text fz={"sm"}>{data?.purpose ? data?.purpose : "-"}</Text>
|
||||
</Stack>
|
||||
<Stack spacing={5}>
|
||||
<Text fw={"bold"} fz={"sm"}>
|
||||
Keutungan
|
||||
</Text>
|
||||
<Text fz={"sm"}>
|
||||
Lorem ipsum dolor sit amet consectetur adipisicing elit. Nam
|
||||
repudiandae nostrum temporibus velit possimus, voluptate
|
||||
inventore recusandae hic ipsa praesentium deserunt, fuga
|
||||
asperiores doloremque amet incidunt explicabo ea eius earum.
|
||||
{data?.benefit ? data?.benefit : "-"}
|
||||
</Text>
|
||||
</Stack>
|
||||
</Stack>
|
||||
@@ -69,4 +70,4 @@ export default function ComponentColab_DetailData() {
|
||||
</Stack>
|
||||
</>
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,29 +1,113 @@
|
||||
"use client"
|
||||
"use client";
|
||||
|
||||
import { Paper, Center, Title, ScrollArea, Box, Stack } from "@mantine/core";
|
||||
import {
|
||||
Paper,
|
||||
Center,
|
||||
Title,
|
||||
ScrollArea,
|
||||
Box,
|
||||
Stack,
|
||||
Text,
|
||||
Divider,
|
||||
Button,
|
||||
} from "@mantine/core";
|
||||
import ComponentColab_AuthorNameOnHeader from "../header_author_name";
|
||||
import {
|
||||
MODEL_COLLABORATION_MASTER,
|
||||
MODEL_COLLABORATION_PARTISIPASI,
|
||||
} from "../../model/interface";
|
||||
import _ from "lodash";
|
||||
import { useState } from "react";
|
||||
import colab_funCreatePartisipan from "../../fun/create/fun_create_partisipan_by_user_id";
|
||||
import colab_getListPartisipanById from "../../fun/get/get_list_partisipan_by_id";
|
||||
import { ComponentGlobal_NotifikasiBerhasil } from "@/app_modules/component_global/notif_global/notifikasi_berhasil";
|
||||
import { ComponentGlobal_NotifikasiGagal } from "@/app_modules/component_global/notif_global/notifikasi_gagal";
|
||||
|
||||
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);
|
||||
|
||||
async function onJoin() {
|
||||
await colab_funCreatePartisipan(colabId as any, userLoginId as any).then(
|
||||
async (res) => {
|
||||
if (res.status === 201) {
|
||||
await colab_getListPartisipanById(colabId as any).then((val) => {
|
||||
setApply(true);
|
||||
setData(val as any);
|
||||
ComponentGlobal_NotifikasiBerhasil(res.message);
|
||||
});
|
||||
} else {
|
||||
ComponentGlobal_NotifikasiGagal(res.message);
|
||||
}
|
||||
}
|
||||
);
|
||||
}
|
||||
|
||||
export default function ComponentColab_DetailListPartisipasiUser() {
|
||||
return (
|
||||
<>
|
||||
<Paper withBorder p={"md"}>
|
||||
<Center mb={"xl"}>
|
||||
<Title order={4}>Partispasi User (12)</Title>
|
||||
</Center>{" "}
|
||||
<ScrollArea h={400}>
|
||||
<Box h={400}>
|
||||
<Stack>
|
||||
{Array(10)
|
||||
.fill(0)
|
||||
.map((e, i) => (
|
||||
<Box key={i}>
|
||||
<ComponentColab_AuthorNameOnHeader isPembatas={true} />
|
||||
</Box>
|
||||
))}
|
||||
</Stack>
|
||||
</Box>
|
||||
</ScrollArea>
|
||||
</Paper>
|
||||
{/* <pre>{JSON.stringify(data, null, 2)}</pre> */}
|
||||
<Stack>
|
||||
{userLoginId !== authorId ? (
|
||||
<Center>
|
||||
<Button
|
||||
radius={"xl"}
|
||||
disabled={cekPartisipan ? true : false}
|
||||
color={cekPartisipan ? "green" : "blue"}
|
||||
onClick={() => {
|
||||
onJoin();
|
||||
}}
|
||||
>
|
||||
{cekPartisipan ? "Telah Berpartisipasi" : "Partisipasi"}
|
||||
</Button>
|
||||
</Center>
|
||||
) : (
|
||||
""
|
||||
)}
|
||||
|
||||
<Paper withBorder p={"md"}>
|
||||
<Stack spacing={"xl"}>
|
||||
<Center>
|
||||
<Title order={5}>Partispasi User ({data?.length})</Title>
|
||||
</Center>{" "}
|
||||
<ScrollArea h={data?.length === 0 ? 30 : 400}>
|
||||
<Box>
|
||||
<Stack>
|
||||
{data?.length === 0 ? (
|
||||
<Center>
|
||||
<Text fz={"xs"} fw={"bold"} c={"gray"}>
|
||||
Tidak ada partisipan
|
||||
</Text>
|
||||
</Center>
|
||||
) : (
|
||||
data?.map((e, i) => (
|
||||
<Box key={i}>
|
||||
<ComponentColab_AuthorNameOnHeader
|
||||
isPembatas={true}
|
||||
authorName={e?.User.Profile.name}
|
||||
imagesId={e?.User?.Profile?.imagesId}
|
||||
profileId={e?.User?.Profile?.id}
|
||||
/>
|
||||
</Box>
|
||||
))
|
||||
)}
|
||||
</Stack>
|
||||
</Box>
|
||||
</ScrollArea>
|
||||
</Stack>
|
||||
</Paper>
|
||||
</Stack>
|
||||
</>
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -4,10 +4,15 @@ import { RouterColab } from "@/app/lib/router_hipmi/router_colab";
|
||||
import { Button, Select, Stack, TextInput, Textarea } from "@mantine/core";
|
||||
import { useRouter } from "next/navigation";
|
||||
import { useState } from "react";
|
||||
import { MODEL_COLLABORATION_MASTER } from "../model/interface";
|
||||
import {
|
||||
MODEL_COLLABORATION,
|
||||
MODEL_COLLABORATION_MASTER,
|
||||
} from "../model/interface";
|
||||
import colab_funCreateProyek from "../fun/create/fun_create_proyek";
|
||||
import { ComponentGlobal_NotifikasiBerhasil } from "@/app_modules/component_global/notif_global/notifikasi_berhasil";
|
||||
import { ComponentGlobal_NotifikasiGagal } from "@/app_modules/component_global/notif_global/notifikasi_gagal";
|
||||
import _ from "lodash";
|
||||
import { ComponentGlobal_NotifikasiPeringatan } from "@/app_modules/component_global/notif_global/notifikasi_peringatan";
|
||||
|
||||
export default function Colab_Create({
|
||||
listIndustri,
|
||||
@@ -80,7 +85,6 @@ export default function Colab_Create({
|
||||
<Textarea
|
||||
label="Keuntungan "
|
||||
placeholder="Masukan keuntungan dalam proyek"
|
||||
withAsterisk
|
||||
minRows={5}
|
||||
onChange={(val) => {
|
||||
setValue({
|
||||
@@ -89,7 +93,7 @@ export default function Colab_Create({
|
||||
});
|
||||
}}
|
||||
/>
|
||||
<ButtonAction value={value} />
|
||||
<ButtonAction value={value as any} />
|
||||
</Stack>
|
||||
</>
|
||||
);
|
||||
@@ -100,13 +104,22 @@ function ButtonAction({ value }: { value: any }) {
|
||||
const [loading, setLoading] = useState(false);
|
||||
|
||||
async function onSave() {
|
||||
if (value.title === "")
|
||||
return ComponentGlobal_NotifikasiPeringatan("Lengkapi Data");
|
||||
if (value.lokasi === "")
|
||||
return ComponentGlobal_NotifikasiPeringatan("Lengkapi Data");
|
||||
if (value.purpose === "")
|
||||
return ComponentGlobal_NotifikasiPeringatan("Lengkapi Data");
|
||||
if (value.projectCollaborationMaster_IndustriId === 0)
|
||||
return ComponentGlobal_NotifikasiPeringatan("Pilih Industri");
|
||||
|
||||
await colab_funCreateProyek(value).then((res) => {
|
||||
if (res.status === 201) {
|
||||
setLoading(true);
|
||||
router.back();
|
||||
ComponentGlobal_NotifikasiBerhasil(res.message);
|
||||
} else {
|
||||
ComponentGlobal_NotifikasiGagal(res.message)
|
||||
ComponentGlobal_NotifikasiGagal(res.message);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@@ -17,15 +17,36 @@ import { useState } from "react";
|
||||
import ComponentColab_ButtonPartisipasi from "../../component/detail/button_partisipasi";
|
||||
import ComponentColab_DetailListPartisipasiUser from "../../component/detail/list_partisipasi_user";
|
||||
import ComponentColab_DetailData from "../../component/detail/detail_data";
|
||||
import { MODEL_COLLABORATION } from "../../model/interface";
|
||||
|
||||
export default function Colab_MainDetail() {
|
||||
export default function Colab_MainDetail({
|
||||
dataColab,
|
||||
userLoginId,
|
||||
listPartisipan,
|
||||
cekPartisipan,
|
||||
}: {
|
||||
dataColab?: MODEL_COLLABORATION;
|
||||
userLoginId?: string;
|
||||
listPartisipan?: any[];
|
||||
cekPartisipan: boolean
|
||||
}) {
|
||||
return (
|
||||
<>
|
||||
<Stack px={5} spacing={"lg"}>
|
||||
<ComponentColab_AuthorNameOnHeader tglPublish={new Date}/>
|
||||
<ComponentColab_DetailData />
|
||||
<ComponentColab_ButtonPartisipasi />
|
||||
<ComponentColab_DetailListPartisipasiUser />
|
||||
<Stack px={5} spacing={"xl"}>
|
||||
<ComponentColab_AuthorNameOnHeader
|
||||
tglPublish={new Date()}
|
||||
authorName={dataColab?.Author?.Profile?.name}
|
||||
imagesId={dataColab?.Author?.Profile?.imagesId}
|
||||
profileId={dataColab?.Author?.Profile?.id}
|
||||
/>
|
||||
<ComponentColab_DetailData data={dataColab} />
|
||||
<ComponentColab_DetailListPartisipasiUser
|
||||
listPartisipan={listPartisipan}
|
||||
userLoginId={userLoginId}
|
||||
authorId={dataColab?.Author.id}
|
||||
colabId={dataColab?.id}
|
||||
cekPartisipan={cekPartisipan}
|
||||
/>
|
||||
</Stack>
|
||||
</>
|
||||
);
|
||||
|
||||
@@ -0,0 +1,21 @@
|
||||
"use server";
|
||||
|
||||
import prisma from "@/app/lib/prisma";
|
||||
import { RouterColab } from "@/app/lib/router_hipmi/router_colab";
|
||||
import { revalidatePath } from "next/cache";
|
||||
|
||||
export default async function colab_funCreatePartisipan(
|
||||
colabId: string,
|
||||
userId: string
|
||||
) {
|
||||
const create = await prisma.projectCollaboration_Partisipasi.create({
|
||||
data: {
|
||||
projectCollaborationId: colabId,
|
||||
userId: userId,
|
||||
},
|
||||
});
|
||||
|
||||
if (!create) return { status: 400, message: "Gagal menambahkan partisipan" };
|
||||
revalidatePath(RouterColab.main_detail + colabId);
|
||||
return { status: 201, message: "Berhasil menambahkan partisipan" };
|
||||
}
|
||||
@@ -3,12 +3,13 @@
|
||||
import prisma from "@/app/lib/prisma";
|
||||
import { MODEL_COLLABORATION } from "../../model/interface";
|
||||
import { User_getUserId } from "@/app_modules/fun_global/get_user_token";
|
||||
import { revalidatePath } from "next/cache";
|
||||
import { RouterColab } from "@/app/lib/router_hipmi/router_colab";
|
||||
|
||||
export default async function colab_funCreateProyek(
|
||||
value: MODEL_COLLABORATION
|
||||
) {
|
||||
const Author = await User_getUserId();
|
||||
console.log(Author);
|
||||
const AuthorId = await User_getUserId();
|
||||
|
||||
const create = await prisma.projectCollaboration.create({
|
||||
data: {
|
||||
@@ -18,10 +19,11 @@ export default async function colab_funCreateProyek(
|
||||
benefit: value.benefit,
|
||||
projectCollaborationMaster_IndustriId:
|
||||
value.projectCollaborationMaster_IndustriId,
|
||||
userId: Author
|
||||
userId: AuthorId
|
||||
},
|
||||
});
|
||||
|
||||
if (!create) return { status: 400, message: "Gagal Membuat Proyek" };
|
||||
revalidatePath(RouterColab.beranda)
|
||||
return { status: 201, message: "Berhasil Membuar Proyek" };
|
||||
}
|
||||
|
||||
22
src/app_modules/colab/fun/get/cek_partisipasi_by_user_id.ts
Normal file
22
src/app_modules/colab/fun/get/cek_partisipasi_by_user_id.ts
Normal file
@@ -0,0 +1,22 @@
|
||||
"use server";
|
||||
|
||||
import prisma from "@/app/lib/prisma";
|
||||
import { User_getUserId } from "@/app_modules/fun_global/get_user_token";
|
||||
|
||||
export default async function colab_funCekPartisipasiById(colabId: string) {
|
||||
const UserLoginId = await User_getUserId();
|
||||
|
||||
const cek = await prisma.projectCollaboration_Partisipasi.findFirst({
|
||||
where: {
|
||||
projectCollaborationId: colabId,
|
||||
userId: UserLoginId,
|
||||
},
|
||||
});
|
||||
|
||||
|
||||
if (cek === null) {
|
||||
return (false);
|
||||
} else {
|
||||
return (true);
|
||||
}
|
||||
}
|
||||
@@ -1,5 +1,36 @@
|
||||
"use server"
|
||||
"use server";
|
||||
|
||||
import prisma from "@/app/lib/prisma";
|
||||
|
||||
export default async function colab_getListAllProyek() {
|
||||
|
||||
}
|
||||
const data = await prisma.projectCollaboration.findMany({
|
||||
orderBy: {
|
||||
updatedAt: "desc",
|
||||
},
|
||||
where: {
|
||||
projectCollaborationMaster_StatusId: 1,
|
||||
},
|
||||
select: {
|
||||
id: true,
|
||||
isActive: true,
|
||||
title: true,
|
||||
lokasi: true,
|
||||
purpose: true,
|
||||
benefit: true,
|
||||
Author: {
|
||||
select: {
|
||||
Profile: true,
|
||||
},
|
||||
},
|
||||
ProjectCollaborationMaster_Industri: true,
|
||||
ProjectCollaboration_Partisipasi: {
|
||||
where: {
|
||||
isActive: true,
|
||||
},
|
||||
},
|
||||
},
|
||||
});
|
||||
|
||||
|
||||
return data;
|
||||
}
|
||||
|
||||
5
src/app_modules/colab/fun/get/get_list_by_status_id.ts
Normal file
5
src/app_modules/colab/fun/get/get_list_by_status_id.ts
Normal file
@@ -0,0 +1,5 @@
|
||||
"use server"
|
||||
|
||||
export default async function colab_getListByStatusId(statusId: string, colabId: string) {
|
||||
|
||||
}
|
||||
22
src/app_modules/colab/fun/get/get_list_partisipan_by_id.ts
Normal file
22
src/app_modules/colab/fun/get/get_list_partisipan_by_id.ts
Normal file
@@ -0,0 +1,22 @@
|
||||
"use server";
|
||||
|
||||
import prisma from "@/app/lib/prisma";
|
||||
|
||||
export default async function colab_getListPartisipanById(colabId: string) {
|
||||
const data = await prisma.projectCollaboration_Partisipasi.findMany({
|
||||
where: {
|
||||
projectCollaborationId: colabId,
|
||||
},
|
||||
select: {
|
||||
id: true,
|
||||
User: {
|
||||
select: {
|
||||
id: true,
|
||||
Profile: true,
|
||||
},
|
||||
},
|
||||
},
|
||||
});
|
||||
|
||||
return data
|
||||
}
|
||||
33
src/app_modules/colab/fun/get/get_one_by_id.ts
Normal file
33
src/app_modules/colab/fun/get/get_one_by_id.ts
Normal file
@@ -0,0 +1,33 @@
|
||||
"use server";
|
||||
|
||||
import prisma from "@/app/lib/prisma";
|
||||
|
||||
export default async function colab_getOneCollaborationById(colabId: string) {
|
||||
const data = await prisma.projectCollaboration.findFirst({
|
||||
where: {
|
||||
id: colabId,
|
||||
},
|
||||
select: {
|
||||
id: true,
|
||||
isActive: true,
|
||||
title: true,
|
||||
lokasi: true,
|
||||
purpose: true,
|
||||
benefit: true,
|
||||
Author: {
|
||||
select: {
|
||||
id: true,
|
||||
Profile: true,
|
||||
},
|
||||
},
|
||||
ProjectCollaborationMaster_Industri: true,
|
||||
ProjectCollaboration_Partisipasi: {
|
||||
where: {
|
||||
isActive: true,
|
||||
},
|
||||
},
|
||||
},
|
||||
});
|
||||
|
||||
return data;
|
||||
}
|
||||
@@ -24,8 +24,14 @@ import ComponentColab_CardSectionData from "../component/card_view/card_section_
|
||||
import ComponentColab_SectionHeaderAuthorName from "../component/card_view/card_section_header_author_name";
|
||||
import ComponentGlobal_V2_LoadingPage from "@/app_modules/component_global/loading_page_v2";
|
||||
import ComponentColab_CardSectionHeaderAuthorName from "../component/card_view/card_section_header_author_name";
|
||||
import { MODEL_COLLABORATION } from "../model/interface";
|
||||
import ComponentColab_JumlahPartisipan from "../component/card_view/card_section_jumlah_partisipan";
|
||||
|
||||
export default function Colab_Beranda() {
|
||||
export default function Colab_Beranda({
|
||||
listData,
|
||||
}: {
|
||||
listData: MODEL_COLLABORATION[];
|
||||
}) {
|
||||
const router = useRouter();
|
||||
const [scroll, scrollTo] = useWindowScroll();
|
||||
const [loadingCreate, setLoadingCreate] = useState(false);
|
||||
@@ -52,17 +58,27 @@ export default function Colab_Beranda() {
|
||||
</ActionIcon>
|
||||
</Affix>
|
||||
|
||||
{Array(5)
|
||||
.fill(0)
|
||||
.map((e, i) => (
|
||||
<Card key={i} withBorder shadow="lg" mb={"lg"} radius={"md"}>
|
||||
<ComponentColab_CardSectionHeaderAuthorName tglPublish={new Date} jumlah_partisipan={12} />
|
||||
<ComponentColab_CardSectionData
|
||||
colabId={i}
|
||||
path={RouterColab.main_detail}
|
||||
{/* <pre>{JSON.stringify(listData, null, 2)}</pre> */}
|
||||
|
||||
{listData.map((e, i) => (
|
||||
<Card key={e.id} withBorder shadow="lg" mb={"lg"} radius={"md"}>
|
||||
<Stack>
|
||||
<ComponentColab_CardSectionHeaderAuthorName
|
||||
authorName={e?.Author?.Profile?.name}
|
||||
imagesId={e?.Author?.Profile?.imagesId}
|
||||
profileId={e?.Author?.Profile?.id}
|
||||
tglPublish={new Date()}
|
||||
jumlah_partisipan={e?.ProjectCollaboration_Partisipasi}
|
||||
/>
|
||||
</Card>
|
||||
))}
|
||||
<ComponentColab_CardSectionData
|
||||
colabId={e.id}
|
||||
path={RouterColab.main_detail}
|
||||
data={e}
|
||||
/>
|
||||
<ComponentColab_JumlahPartisipan jumlah={e.ProjectCollaboration_Partisipasi} />
|
||||
</Stack>
|
||||
</Card>
|
||||
))}
|
||||
</>
|
||||
);
|
||||
}
|
||||
|
||||
@@ -21,7 +21,7 @@ export default function Colab_PartisipasiProyek() {
|
||||
>
|
||||
<ComponentColab_CardSectionHeaderAuthorName
|
||||
tglPublish={new Date()}
|
||||
jumlah_partisipan={12}
|
||||
jumlah_partisipan={[]}
|
||||
/>
|
||||
<ComponentColab_CardSectionData
|
||||
colabId={i}
|
||||
|
||||
@@ -4,7 +4,7 @@ import { RouterColab } from "@/app/lib/router_hipmi/router_colab";
|
||||
import { Card, Stack } from "@mantine/core";
|
||||
import ComponentColab_CardSectionData from "../../component/card_view/card_section_data";
|
||||
import ComponentColab_CardSectionHeaderAuthorName from "../../component/card_view/card_section_header_author_name";
|
||||
import ComponentColab_JumlahPartisipan from "../../component/card_view/jumlah_partisipan";
|
||||
import ComponentColab_JumlahPartisipan from "../../component/card_view/card_section_jumlah_partisipan";
|
||||
|
||||
export default function Colab_ProyekSaya() {
|
||||
return (
|
||||
|
||||
@@ -6,7 +6,7 @@ import ComponentColab_CardSectionData from "../../component/card_view/card_secti
|
||||
import ComponentColab_AuthorNameOnHeader from "../../component/header_author_name";
|
||||
import ComponentColab_CardSectionHeaderAuthorName from "../../component/card_view/card_section_header_author_name";
|
||||
import { RouterColab } from "@/app/lib/router_hipmi/router_colab";
|
||||
import ComponentColab_JumlahPartisipan from "../../component/card_view/jumlah_partisipan";
|
||||
import ComponentColab_JumlahPartisipan from "../../component/card_view/card_section_jumlah_partisipan";
|
||||
|
||||
export default function Colab_StatusPublish() {
|
||||
return (
|
||||
|
||||
@@ -18,10 +18,21 @@ export interface MODEL_COLLABORATION {
|
||||
lokasi: string;
|
||||
purpose: string;
|
||||
benefit: string;
|
||||
ProjectCollaborationMaster_Industri: MODEL_COLLABORATION_MASTER[];
|
||||
ProjectCollaborationMaster_Industri: MODEL_COLLABORATION_MASTER;
|
||||
projectCollaborationMaster_IndustriId: number;
|
||||
Author: MODEL_USER;
|
||||
ProjectCollaborationMaster_Status: MODEL_COLLABORATION_MASTER[];
|
||||
projectCollaborationMaster_StatusId: number
|
||||
// ProjectCollaboration_Partisipasi
|
||||
ProjectCollaborationMaster_Status: MODEL_COLLABORATION_MASTER;
|
||||
projectCollaborationMaster_StatusId: number;
|
||||
ProjectCollaboration_Partisipasi: any[];
|
||||
}
|
||||
|
||||
export interface MODEL_COLLABORATION_PARTISIPASI {
|
||||
id: string;
|
||||
isActive: boolean;
|
||||
createdAt: Date;
|
||||
updatedAt: Date;
|
||||
userId: string;
|
||||
User: MODEL_USER;
|
||||
projectCollaborationId: string;
|
||||
projectCollaboration_RoomChatId: string;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user