diff --git a/prisma/schema.prisma b/prisma/schema.prisma
index 9421ad0..eba8a9d 100644
--- a/prisma/schema.prisma
+++ b/prisma/schema.prisma
@@ -113,7 +113,6 @@ model User {
Announcement Announcement[]
Project Project[]
ProjectMember ProjectMember[]
- ProjectComment ProjectComment[]
UserLog UserLog[]
Division Division[]
DivisionMember DivisionMember[]
@@ -184,24 +183,25 @@ model AnnouncementMember {
}
model Project {
- id String @id @default(cuid())
- Village Village @relation(fields: [idVillage], references: [id])
- idVillage String
- Group Group @relation(fields: [idGroup], references: [id])
- idGroup String
- title String
- status Int @default(0) // 0 = pending, 1 = ongoing, 2 = done, 3 = cancelled
- desc String? @db.Text
- reason String? @db.Text
- isActive Boolean @default(true)
- User User @relation(fields: [createdBy], references: [id])
- createdBy String
- createdAt DateTime @default(now())
- updatedAt DateTime @updatedAt
- ProjectMember ProjectMember[]
- ProjectFile ProjectFile[]
- ProjectComment ProjectComment[]
- ProjectTask ProjectTask[]
+ id String @id @default(cuid())
+ Village Village @relation(fields: [idVillage], references: [id])
+ idVillage String
+ Group Group @relation(fields: [idGroup], references: [id])
+ idGroup String
+ title String
+ status Int @default(0) // 0 = pending, 1 = ongoing, 2 = done, 3 = cancelled
+ desc String? @db.Text
+ reason String? @db.Text
+ report String? @db.Text
+ isActive Boolean @default(true)
+ User User @relation(fields: [createdBy], references: [id])
+ createdBy String
+ createdAt DateTime @default(now())
+ updatedAt DateTime @updatedAt
+ ProjectMember ProjectMember[]
+ ProjectFile ProjectFile[]
+ ProjectTask ProjectTask[]
+ ProjectLink ProjectLink[]
}
model ProjectMember {
@@ -228,33 +228,44 @@ model ProjectFile {
updatedAt DateTime @updatedAt
}
-model ProjectTask {
- id String @id @default(cuid())
- Project Project @relation(fields: [idProject], references: [id])
- idProject String
- title String
- desc String?
- status Int @default(0) // 0 = todo, 1 = done
- notifikasi Boolean @default(false)
- dateStart DateTime @db.Date
- dateEnd DateTime @db.Date
- isActive Boolean @default(true)
- createdAt DateTime @default(now())
- updatedAt DateTime @updatedAt
-}
-
-model ProjectComment {
+model ProjectLink {
id String @id @default(cuid())
Project Project @relation(fields: [idProject], references: [id])
idProject String
- User User @relation(fields: [createdBy], references: [id])
- createdBy String
- comment String @db.Text
+ link String @db.Text
isActive Boolean @default(true)
createdAt DateTime @default(now())
updatedAt DateTime @updatedAt
}
+model ProjectTask {
+ id String @id @default(cuid())
+ Project Project @relation(fields: [idProject], references: [id])
+ idProject String
+ title String
+ desc String?
+ status Int @default(0) // 0 = todo, 1 = done
+ notifikasi Boolean @default(false)
+ dateStart DateTime @db.Date
+ dateEnd DateTime @db.Date
+ isActive Boolean @default(true)
+ createdAt DateTime @default(now())
+ updatedAt DateTime @updatedAt
+ ProjectTaskDetail ProjectTaskDetail[]
+}
+
+model ProjectTaskDetail {
+ id String @id @default(cuid())
+ ProjectTask ProjectTask @relation(fields: [idTask], references: [id])
+ idTask String
+ date DateTime @db.Date
+ timeStart DateTime? @db.Time()
+ timeEnd DateTime? @db.Time()
+ isActive Boolean @default(true)
+ createdAt DateTime @default(now())
+ updatedAt DateTime @updatedAt
+}
+
model Division {
id String @id @default(cuid())
Village Village @relation(fields: [idVillage], references: [id])
@@ -280,6 +291,7 @@ model Division {
DivisionCalendar DivisionCalendar[]
DivisionCalendarReminder DivisionCalendarReminder[]
ContainerFileDivision ContainerFileDivision[]
+ DivisionProjectLink DivisionProjectLink[]
}
model DivisionMember {
@@ -302,6 +314,7 @@ model DivisionProject {
title String
desc String? @db.Text
reason String? @db.Text
+ report String? @db.Text
status Int @default(0) // 0 = pending, 1 = ongoing, 2 = done, 3 = cancelled
isActive Boolean @default(true)
createdAt DateTime @default(now())
@@ -309,6 +322,19 @@ model DivisionProject {
DivisionProjectTask DivisionProjectTask[]
DivisionProjectMember DivisionProjectMember[]
DivisionProjectFile DivisionProjectFile[]
+ DivisionProjectLink DivisionProjectLink[]
+}
+
+model DivisionProjectLink {
+ id String @id @default(cuid())
+ Division Division @relation(fields: [idDivision], references: [id])
+ idDivision String
+ DivisionProject DivisionProject @relation(fields: [idProject], references: [id])
+ idProject String
+ link String @db.Text
+ isActive Boolean @default(true)
+ createdAt DateTime @default(now())
+ updatedAt DateTime @updatedAt
}
model DivisionProjectTask {
@@ -326,6 +352,19 @@ model DivisionProjectTask {
isActive Boolean @default(true)
createdAt DateTime @default(now())
updatedAt DateTime @updatedAt
+ DivisionProjectTaskDetail DivisionProjectTaskDetail[]
+}
+
+model DivisionProjectTaskDetail {
+ id String @id @default(cuid())
+ DivisionProjectTask DivisionProjectTask @relation(fields: [idTask], references: [id])
+ idTask String
+ date DateTime @db.Date
+ timeStart DateTime? @db.Time()
+ timeEnd DateTime? @db.Time()
+ isActive Boolean @default(true)
+ createdAt DateTime @default(now())
+ updatedAt DateTime @updatedAt
}
model DivisionProjectMember {
diff --git a/src/app/(application)/division/[id]/(fitur-division)/task/[detail]/page.tsx b/src/app/(application)/division/[id]/(fitur-division)/task/[detail]/page.tsx
index 293102f..f964f3b 100644
--- a/src/app/(application)/division/[id]/(fitur-division)/task/[detail]/page.tsx
+++ b/src/app/(application)/division/[id]/(fitur-division)/task/[detail]/page.tsx
@@ -1,4 +1,4 @@
-import { NavbarDetailDivisionTask, ProgressDetailTask, ListTugasDetailTask, ListFileDetailTask, ListAnggotaDetailTask } from "@/module/task"
+import { ListAnggotaDetailTask, ListFileDetailTask, ListLinkDetailTask, ListReportDetailTask, ListTugasDetailTask, NavbarDetailDivisionTask, ProgressDetailTask } from "@/module/task"
import { Box } from "@mantine/core"
function Page() {
@@ -7,8 +7,10 @@ function Page() {
+
+
diff --git a/src/app/(application)/division/[id]/(fitur-division)/task/[detail]/report/page.tsx b/src/app/(application)/division/[id]/(fitur-division)/task/[detail]/report/page.tsx
new file mode 100644
index 0000000..9da9b27
--- /dev/null
+++ b/src/app/(application)/division/[id]/(fitur-division)/task/[detail]/report/page.tsx
@@ -0,0 +1,8 @@
+import { AddReportTask } from "@/module/task"
+
+function Page() {
+ return (
+
+ )
+}
+export default Page
diff --git a/src/app/(application)/project/[id]/page.tsx b/src/app/(application)/project/[id]/page.tsx
index 26dfc03..715f53a 100644
--- a/src/app/(application)/project/[id]/page.tsx
+++ b/src/app/(application)/project/[id]/page.tsx
@@ -1,6 +1,5 @@
-import { ListAnggotaDetailProject, ListFileDetailProject, ListTugasDetailProject, NavbarDetailProject, ProgressDetailProject } from '@/module/project';
+import { ListAnggotaDetailProject, ListFileDetailProject, ListLinkDetailProject, ListReportDetailProject, ListTugasDetailProject, NavbarDetailProject, ProgressDetailProject } from '@/module/project';
import { Box } from '@mantine/core';
-import React from 'react';
function Page() {
return (
@@ -8,8 +7,10 @@ function Page() {
+
+
diff --git a/src/app/(application)/project/[id]/report/page.tsx b/src/app/(application)/project/[id]/report/page.tsx
new file mode 100644
index 0000000..c3b9021
--- /dev/null
+++ b/src/app/(application)/project/[id]/report/page.tsx
@@ -0,0 +1,9 @@
+import { AddReportProject } from "@/module/project";
+
+function Page() {
+ return (
+
+ );
+}
+
+export default Page;
diff --git a/src/app/api/mobile/discussion-general/[id]/comment/route.ts b/src/app/api/mobile/discussion-general/[id]/comment/route.ts
index da842a6..6df4622 100644
--- a/src/app/api/mobile/discussion-general/[id]/comment/route.ts
+++ b/src/app/api/mobile/discussion-general/[id]/comment/route.ts
@@ -70,7 +70,9 @@ export async function POST(request: Request, context: { params: { id: string } }
}
})
- const dataFCM = member.map((v: any) => ({
+ const memberFilter = member.filter((v: any) => v.idUser != userMobile.id)
+
+ const dataFCM = memberFilter.map((v: any) => ({
..._.omit(v, ["idUser", "User", "Subscribe", "TokenDeviceUser"]),
tokens: v.User.TokenDeviceUser.map((v: any) => v.token)
}))
@@ -106,7 +108,7 @@ export async function POST(request: Request, context: { params: { id: string } }
token: tokenUnique,
title: "Komentar Baru",
body: `${userSent?.name}: ${data.comment}`,
- data: { id: data.id, category: "discussion", content: id }
+ data: { id: data.id, category: "discussion-general", content: id }
})
// create log user
diff --git a/src/app/api/mobile/discussion/[id]/comment/route.ts b/src/app/api/mobile/discussion/[id]/comment/route.ts
index 52216af..e1b0fbc 100644
--- a/src/app/api/mobile/discussion/[id]/comment/route.ts
+++ b/src/app/api/mobile/discussion/[id]/comment/route.ts
@@ -86,7 +86,9 @@ export async function POST(request: Request, context: { params: { id: string } }
}
})
- const dataFCM = member.map((v: any) => ({
+ const memberFilter = member.filter((v: any) => v.idUser != userMobile.id)
+
+ const dataFCM = memberFilter.map((v: any) => ({
..._.omit(v, ["idUser", "User", "Subscribe", "TokenDeviceUser"]),
tokens: v.User.TokenDeviceUser.map((v: any) => v.token)
}))
@@ -122,7 +124,7 @@ export async function POST(request: Request, context: { params: { id: string } }
token: tokenUnique,
title: "Komentar Baru",
body: `${userSent?.name}: ${comment}`,
- data: { id: data.id, category: `division/${dataDivision?.idDivision}/discussion/`, content: id }
+ data: { id: data.id, category: `division/${dataDivision?.idDivision}/discussion`, content: id }
})
// create log user
diff --git a/src/app/api/mobile/project/[id]/lainnya/route.ts b/src/app/api/mobile/project/[id]/lainnya/route.ts
index d6a8260..48de186 100644
--- a/src/app/api/mobile/project/[id]/lainnya/route.ts
+++ b/src/app/api/mobile/project/[id]/lainnya/route.ts
@@ -47,4 +47,51 @@ export async function DELETE(request: Request, context: { params: { id: string }
console.error(error);
return NextResponse.json({ success: false, message: "Gagal menghapus kegiatan, coba lagi nanti (error: 500)", reason: (error as Error).message, }, { status: 500 });
}
+}
+
+// EDIT PROJECT REPORT
+export async function PUT(request: Request, context: { params: { id: string } }) {
+ try {
+ const { id } = context.params
+ const { report, user } = await request.json()
+
+ const userMobile = await funGetUserById({ id: String(user) })
+
+ if (userMobile.id == "null" || userMobile.id == undefined || userMobile.id == "") {
+ return NextResponse.json({ success: false, message: "Anda harus login untuk mengakses ini" }, { status: 200 });
+ }
+
+ const data = await prisma.project.count({
+ where: {
+ id: id
+ }
+ })
+
+ if (data == 0) {
+ return NextResponse.json(
+ {
+ success: false, message: "Gagal mendapatkan kegiatan, data tidak ditemukan",
+ },
+ { status: 200 }
+ );
+ }
+
+ const dataCreate = await prisma.project.update({
+ where: {
+ id
+ },
+ data: {
+ report: report
+ }
+ })
+
+ // create log user
+ const log = await createLogUserMobile({ act: 'UPDATE', desc: 'User mengupdate laporan kegiatan', table: 'project', data: String(id), user: userMobile.id })
+
+ return NextResponse.json({ success: true, message: "Laporan kegiatan berhasil diupdate" }, { status: 200 });
+
+ } catch (error) {
+ console.error(error);
+ return NextResponse.json({ success: false, message: "Gagal mengupdate kegiatan, coba lagi nanti (error: 500)", reason: (error as Error).message, }, { status: 500 });
+ }
}
\ No newline at end of file
diff --git a/src/app/api/mobile/project/[id]/link/route.ts b/src/app/api/mobile/project/[id]/link/route.ts
new file mode 100644
index 0000000..c42ffde
--- /dev/null
+++ b/src/app/api/mobile/project/[id]/link/route.ts
@@ -0,0 +1,95 @@
+import { prisma } from "@/module/_global";
+import { funGetUserById } from "@/module/auth";
+import { createLogUserMobile } from "@/module/user";
+import { NextResponse } from "next/server";
+
+// ADD LINK PROJECT
+export async function POST(request: Request, context: { params: { id: string } }) {
+ try {
+ const { id } = context.params
+ const { link, user } = (await request.json())
+
+ const userMobile = await funGetUserById({ id: String(user) })
+
+ if (userMobile.id == "null" || userMobile.id == undefined || userMobile.id == "") {
+ return NextResponse.json({ success: false, message: "Anda harus login untuk mengakses ini" }, { status: 200 });
+ }
+
+ const data = await prisma.project.count({
+ where: {
+ id: id
+ }
+ })
+
+ if (data == 0) {
+ return NextResponse.json(
+ {
+ success: false, message: "Gagal mendapatkan kegiatan, data tidak ditemukan",
+ },
+ { status: 200 }
+ );
+ }
+
+
+ const insertLink = await prisma.projectLink.create({
+ data: {
+ idProject: id,
+ link: link
+ }
+ })
+
+ // create log user
+ const log = await createLogUserMobile({ act: 'CREATE', desc: 'User menambah link kegiatan', table: 'projectLink', data: insertLink.id, user: userMobile.id })
+ return NextResponse.json({ success: true, message: "Berhasil menambahkan link kegiatan" }, { status: 200 });
+
+ } catch (error) {
+ console.error(error);
+ return NextResponse.json({ success: false, message: "Gagal menambah link kegiatan, coba lagi nanti (error: 500)", reason: (error as Error).message, }, { status: 500 });
+ }
+}
+
+
+// DELETE LINK PROJECT
+export async function DELETE(request: Request, context: { params: { id: string } }) {
+ try {
+ const { idLink, user } = (await request.json())
+
+ const userMobile = await funGetUserById({ id: String(user) })
+
+ if (userMobile.id == "null" || userMobile.id == undefined || userMobile.id == "") {
+ return NextResponse.json({ success: false, message: "Anda harus login untuk mengakses ini" }, { status: 200 });
+ }
+
+ const data = await prisma.projectLink.count({
+ where: {
+ id: idLink
+ }
+ })
+
+ if (data == 0) {
+ return NextResponse.json(
+ {
+ success: false, message: "Gagal mendapatkan link, data tidak ditemukan",
+ },
+ { status: 200 }
+ );
+ }
+
+ const deleteLink = await prisma.projectLink.update({
+ where: {
+ id: idLink
+ },
+ data: {
+ isActive: false
+ }
+ })
+
+ // create log user
+ const log = await createLogUserMobile({ act: 'DELETE', desc: 'User menghapus link kegiatan', table: 'projectLink', data: String(idLink), user: userMobile.id })
+ return NextResponse.json({ success: true, message: "Berhasil menghapus link kegiatan" }, { status: 200 });
+
+ } catch (error) {
+ console.error(error);
+ return NextResponse.json({ success: false, message: "Gagal menghapus link kegiatan, coba lagi nanti (error: 500)", reason: (error as Error).message, }, { status: 500 });
+ }
+}
diff --git a/src/app/api/mobile/project/[id]/route.ts b/src/app/api/mobile/project/[id]/route.ts
index e261dae..7c09849 100644
--- a/src/app/api/mobile/project/[id]/route.ts
+++ b/src/app/api/mobile/project/[id]/route.ts
@@ -136,6 +136,18 @@ export async function GET(request: Request, context: { params: { id: string } })
}))
allData = fix
+ } else if (kategori == "link") {
+ const dataLink = await prisma.projectLink.findMany({
+ where: {
+ isActive: true,
+ idProject: String(id)
+ },
+ orderBy: {
+ createdAt: 'asc'
+ }
+ })
+
+ allData = dataLink
}
return NextResponse.json({ success: true, message: "Berhasil mendapatkan kegiatan", data: allData, }, { status: 200 });
@@ -150,7 +162,7 @@ export async function GET(request: Request, context: { params: { id: string } })
export async function POST(request: Request, context: { params: { id: string } }) {
try {
const { id } = context.params
- const { name, dateStart, dateEnd, user } = await request.json()
+ const { name, dateStart, dateEnd, user, dataDetail } = await request.json()
const userMobile = await funGetUserById({ id: String(user) })
@@ -185,6 +197,51 @@ export async function POST(request: Request, context: { params: { id: string } }
}
})
+ if (dataDetail.length > 0) {
+ const dataDetailFix = dataDetail.map((v: any) => ({
+ ...v,
+ idTask: dataCreate.id,
+ date: new Date(v.date),
+ timeStart: v.timeStart == null ? null : new Date(new Date('1970-01-01 ' + v.timeStart).getTime() - (new Date('1970-01-01 ' + v.timeStart).getTimezoneOffset() * 60000)).toISOString(),
+ timeEnd: v.timeEnd == null ? null : new Date(new Date('1970-01-01 ' + v.timeEnd).getTime() - (new Date('1970-01-01 ' + v.timeEnd).getTimezoneOffset() * 60000)).toISOString(),
+ }))
+
+
+ const dataDetailCreate = await prisma.projectTaskDetail.createMany({
+ data: dataDetailFix
+ })
+ }
+
+ // const cek progress
+ const dataTask = await prisma.projectTask.findMany({
+ where: {
+ isActive: true,
+ idProject: id,
+ }
+ })
+
+ const semua = dataTask.length
+ const selesai = dataTask.filter((item) => item.status == 1).length
+ const prosess = Math.ceil((selesai / semua) * 100)
+ let statusProject = 1
+
+ if (prosess == 100) {
+ statusProject = 2
+ } else if (prosess == 0) {
+ statusProject = 0
+ }
+
+
+ const update = await prisma.project.update({
+ where: {
+ id: id
+ },
+ data: {
+ status: statusProject
+ }
+ })
+
+
// create log user
const log = await createLogUserMobile({ act: 'CREATE', desc: 'User membuat data tahapan kegiatan', table: 'projectTask', data: String(dataCreate.id), user: userMobile.id })
diff --git a/src/app/api/mobile/project/detail/[id]/route.ts b/src/app/api/mobile/project/detail/[id]/route.ts
index 8a550da..73630a8 100644
--- a/src/app/api/mobile/project/detail/[id]/route.ts
+++ b/src/app/api/mobile/project/detail/[id]/route.ts
@@ -171,12 +171,14 @@ export async function GET(request: Request, context: { params: { id: string } })
const { id } = context.params;
const { searchParams } = new URL(request.url);
const user = searchParams.get("user");
+ const kategori = searchParams.get("cat");
const userMobile = await funGetUserById({ id: String(user) })
if (userMobile.id == "null" || userMobile.id == undefined || userMobile.id == "") {
return NextResponse.json({ success: false, message: "Anda harus login untuk mengakses ini" }, { status: 200 });
}
+ let dataFix
const data = await prisma.projectTask.findUnique({
where: {
id: String(id),
@@ -195,7 +197,29 @@ export async function GET(request: Request, context: { params: { id: string } })
);
}
- return NextResponse.json({ success: true, message: "Detail kegiatan berhasil ditemukan", data: fixData }, { status: 200 });
+ if (kategori == "detailTask") {
+ const dataDetail = await prisma.projectTaskDetail.findMany({
+ where: {
+ idTask: String(id)
+ },
+ orderBy: {
+ date: "asc"
+ }
+ })
+
+ const dataDetailFix = dataDetail.map((data: any) => ({
+ ...data,
+ date: moment(data?.date).format('DD-MM-YYYY'),
+ timeStart: data.timeStart == null ? "" : moment.utc(data.timeStart).format("HH:mm"),
+ timeEnd: data.timeEnd == null ? "" : moment.utc(data.timeEnd).format("HH:mm")
+ }))
+
+ dataFix = dataDetailFix
+ } else {
+ dataFix = fixData
+ }
+
+ return NextResponse.json({ success: true, message: "Detail kegiatan berhasil ditemukan", data: dataFix }, { status: 200 });
} catch (error) {
console.error(error);
return NextResponse.json({ success: false, message: "Gagal mendapatkan kegiatan, coba lagi nanti (error: 500)", reason: (error as Error).message, }, { status: 500 });
@@ -207,7 +231,7 @@ export async function GET(request: Request, context: { params: { id: string } })
export async function POST(request: Request, context: { params: { id: string } }) {
try {
const { id } = context.params;
- const { title, dateStart, dateEnd, user } = (await request.json());
+ const { title, dateStart, dateEnd, user, dataDetail } = (await request.json());
const userMobile = await funGetUserById({ id: String(user) })
if (userMobile.id == "null" || userMobile.id == undefined || userMobile.id == "") {
@@ -240,6 +264,26 @@ export async function POST(request: Request, context: { params: { id: string } }
}
})
+ const dataDetailDelete = await prisma.projectTaskDetail.deleteMany({
+ where: {
+ idTask: id
+ }
+ })
+
+ if (dataDetail.length > 0) {
+ const dataDetailFix = dataDetail.map((v: any) => ({
+ ...v,
+ idTask: id,
+ date: new Date(v.date),
+ timeStart: v.timeStart == null ? null : new Date(new Date('1970-01-01 ' + v.timeStart).getTime() - (new Date('1970-01-01 ' + v.timeStart).getTimezoneOffset() * 60000)).toISOString(),
+ timeEnd: v.timeEnd == null ? null : new Date(new Date('1970-01-01 ' + v.timeEnd).getTime() - (new Date('1970-01-01 ' + v.timeEnd).getTimezoneOffset() * 60000)).toISOString(),
+ }))
+
+ const dataDetailCreate = await prisma.projectTaskDetail.createMany({
+ data: dataDetailFix
+ })
+ }
+
// create log user
const log = await createLogUserMobile({ act: 'UPDATE', desc: 'User mengupdate tahapan kegiatan', table: 'projectTask', data: String(id), user: userMobile.id })
diff --git a/src/app/api/mobile/project/route.ts b/src/app/api/mobile/project/route.ts
index 1950782..5a2c8a8 100644
--- a/src/app/api/mobile/project/route.ts
+++ b/src/app/api/mobile/project/route.ts
@@ -179,16 +179,33 @@ export async function POST(request: Request) {
if (task.length > 0) {
const dataProject = task.map((v: any) => ({
- ..._.omit(v, ["dateStart", "dateEnd", "name", "dateEndFix", "dateStartFix"]),
+ ..._.omit(v, ["dateStart", "dateEnd", "name", "dateEndFix", "dateStartFix", "dataDetail"]),
idProject: data.id,
title: v.title,
dateStart: new Date(v.dateStartFix),
dateEnd: new Date(v.dateEndFix),
}))
+ let dataDetailFix = []
+ for (let i = 0; i < dataProject.length; i++) {
+ const insertTask = await prisma.projectTask.create({
+ data: dataProject[i],
+ select: {
+ id: true
+ }
+ })
+ const dataDetail = task[i].dataDetail.map((v: any) => ({
+ ...v,
+ idTask: insertTask.id,
+ date: new Date(v.date),
+ timeStart: v.timeStart == null ? null : new Date(new Date('1970-01-01 ' + v.timeStart).getTime() - (new Date('1970-01-01 ' + v.timeStart).getTimezoneOffset() * 60000)).toISOString(),
+ timeEnd: v.timeEnd == null ? null : new Date(new Date('1970-01-01 ' + v.timeEnd).getTime() - (new Date('1970-01-01 ' + v.timeEnd).getTimezoneOffset() * 60000)).toISOString(),
+ }))
+ dataDetailFix.push(...dataDetail)
+ }
- const insertTask = await prisma.projectTask.createMany({
- data: dataProject
+ const insertDetail = await prisma.projectTaskDetail.createMany({
+ data: dataDetailFix
})
}
diff --git a/src/app/api/mobile/task/[id]/lainnya/route.ts b/src/app/api/mobile/task/[id]/lainnya/route.ts
index 4dc98e5..ef33d75 100644
--- a/src/app/api/mobile/task/[id]/lainnya/route.ts
+++ b/src/app/api/mobile/task/[id]/lainnya/route.ts
@@ -46,4 +46,51 @@ export async function DELETE(request: Request, context: { params: { id: string }
console.error(error);
return NextResponse.json({ success: false, message: "Gagal menghapus tugas, coba lagi nanti (error: 500)", reason: (error as Error).message, }, { status: 500 });
}
+}
+
+// EDIT TASK REPORT
+export async function PUT(request: Request, context: { params: { id: string } }) {
+ try {
+ const { id } = context.params
+ const { report, user } = await request.json()
+
+ const userMobile = await funGetUserById({ id: String(user) })
+ if (userMobile.id == "null" || userMobile.id == undefined || userMobile.id == "") {
+ return NextResponse.json({ success: false, message: "Anda harus login untuk mengakses ini" }, { status: 200 });
+ }
+
+
+ const data = await prisma.divisionProject.count({
+ where: {
+ id: id
+ }
+ })
+
+ if (data == 0) {
+ return NextResponse.json(
+ {
+ success: false, message: "Gagal mendapatkan kegiatan, data tidak ditemukan",
+ },
+ { status: 200 }
+ );
+ }
+
+ const dataCreate = await prisma.divisionProject.update({
+ where: {
+ id
+ },
+ data: {
+ report: report
+ }
+ })
+
+ // create log user
+ const log = await createLogUserMobile({ act: 'UPDATE', desc: 'User mengupdate laporan tugas divisi', table: 'divisionProject', data: String(id), user: userMobile.id })
+
+ return NextResponse.json({ success: true, message: "Laporan tugas divisi berhasil diupdate" }, { status: 200 });
+
+ } catch (error) {
+ console.error(error);
+ return NextResponse.json({ success: false, message: "Gagal mengupdate laporan tugas divisi, coba lagi nanti (error: 500)", reason: (error as Error).message, }, { status: 500 });
+ }
}
\ No newline at end of file
diff --git a/src/app/api/mobile/task/[id]/link/route.ts b/src/app/api/mobile/task/[id]/link/route.ts
new file mode 100644
index 0000000..067394a
--- /dev/null
+++ b/src/app/api/mobile/task/[id]/link/route.ts
@@ -0,0 +1,98 @@
+import { prisma } from "@/module/_global";
+import { funGetUserById } from "@/module/auth";
+import { createLogUserMobile } from "@/module/user";
+import { NextResponse } from "next/server";
+
+// ADD LINK TASK DIVISI
+export async function POST(request: Request, context: { params: { id: string } }) {
+ try {
+ const { id } = context.params;
+ const { link, idDivision, user } = (await request.json());
+
+ const userMobile = await funGetUserById({ id: String(user) })
+ if (userMobile.id == "null" || userMobile.id == undefined || userMobile.id == "") {
+ return NextResponse.json({ success: false, message: "Anda harus login untuk mengakses ini" }, { status: 200 });
+ }
+
+ const data = await prisma.divisionProject.count({
+ where: {
+ id: id,
+ },
+ });
+
+ if (data == 0) {
+ return NextResponse.json(
+ {
+ success: false,
+ message: "Tambah link tugas gagal, data tugas tidak ditemukan",
+ },
+ { status: 200 }
+ );
+ }
+
+
+
+ const insertlink = await prisma.divisionProjectLink.create({
+ data: {
+ idProject: id,
+ link,
+ idDivision,
+ }
+ })
+
+
+ // create log user
+ const log = await createLogUserMobile({ act: 'CREATE', desc: 'User menambahkan link tugas divisi', table: 'divisionProjectLink', data: insertlink.id, user: userMobile.id })
+
+
+ return NextResponse.json({ success: true, message: "Berhasil menambahkan link tugas", }, { status: 200 });
+ } catch (error) {
+ console.error(error);
+ return NextResponse.json({ success: false, message: "Gagal menambah link tugas, coba lagi nanti (error: 500)", reason: (error as Error).message, }, { status: 500 });
+ }
+}
+
+
+// DELETE LINK TASK DIVISI
+export async function DELETE(request: Request, context: { params: { id: string } }) {
+ try {
+ const { idLink, user } = (await request.json())
+
+ const userMobile = await funGetUserById({ id: String(user) })
+ if (userMobile.id == "null" || userMobile.id == undefined || userMobile.id == "") {
+ return NextResponse.json({ success: false, message: "Anda harus login untuk mengakses ini" }, { status: 200 });
+ }
+
+ const data = await prisma.divisionProjectLink.count({
+ where: {
+ id: idLink
+ }
+ })
+
+ if (data == 0) {
+ return NextResponse.json(
+ {
+ success: false, message: "Gagal mendapatkan link, data tidak ditemukan",
+ },
+ { status: 200 }
+ );
+ }
+
+ const deleteLink = await prisma.divisionProjectLink.update({
+ where: {
+ id: idLink
+ },
+ data: {
+ isActive: false
+ }
+ })
+
+ // create log user
+ const log = await createLogUserMobile({ act: 'DELETE', desc: 'User menghapus link tugas divisi', table: 'divisionProjectLink', data: String(idLink), user: userMobile.id })
+ return NextResponse.json({ success: true, message: "Berhasil menghapus link tugas divisi" }, { status: 200 });
+
+ } catch (error) {
+ console.error(error);
+ return NextResponse.json({ success: false, message: "Gagal menghapus link tugas divisi, coba lagi nanti (error: 500)", reason: (error as Error).message, }, { status: 500 });
+ }
+}
\ No newline at end of file
diff --git a/src/app/api/mobile/task/[id]/route.ts b/src/app/api/mobile/task/[id]/route.ts
index 8328320..a7260f0 100644
--- a/src/app/api/mobile/task/[id]/route.ts
+++ b/src/app/api/mobile/task/[id]/route.ts
@@ -151,6 +151,18 @@ export async function GET(request: Request, context: { params: { id: string } })
}))
allData = fix
+ } else if (kategori == "link") {
+ const dataLink = await prisma.divisionProjectLink.findMany({
+ where: {
+ isActive: true,
+ idProject: String(id)
+ },
+ orderBy: {
+ createdAt: 'asc'
+ }
+ })
+
+ allData = dataLink
}
return NextResponse.json({ success: true, message: "Berhasil mendapatkan tugas divisi", data: allData }, { status: 200 });
@@ -167,7 +179,7 @@ export async function GET(request: Request, context: { params: { id: string } })
export async function POST(request: Request, context: { params: { id: string } }) {
try {
const { id } = context.params;
- const { title, dateStart, dateEnd, idDivision, user } = (await request.json());
+ const { title, dateStart, dateEnd, idDivision, user, dataDetail } = (await request.json());
const userMobile = await funGetUserById({ id: String(user) })
if (userMobile.id == "null" || userMobile.id == undefined || userMobile.id == "") {
@@ -203,6 +215,20 @@ export async function POST(request: Request, context: { params: { id: string } }
}
});
+ if (dataDetail.length > 0) {
+ const dataDetailFix = dataDetail.map((v: any) => ({
+ ...v,
+ idTask: create.id,
+ date: new Date(v.date),
+ timeStart: v.timeStart == null ? null : new Date(new Date('1970-01-01 ' + v.timeStart).getTime() - (new Date('1970-01-01 ' + v.timeStart).getTimezoneOffset() * 60000)).toISOString(),
+ timeEnd: v.timeEnd == null ? null : new Date(new Date('1970-01-01 ' + v.timeEnd).getTime() - (new Date('1970-01-01 ' + v.timeEnd).getTimezoneOffset() * 60000)).toISOString(),
+ }))
+
+ const dataDetailCreate = await prisma.divisionProjectTaskDetail.createMany({
+ data: dataDetailFix
+ })
+ }
+
// const cek progress
const dataTask = await prisma.divisionProjectTask.findMany({
where: {
diff --git a/src/app/api/mobile/task/detail/[id]/route.ts b/src/app/api/mobile/task/detail/[id]/route.ts
index cc53e39..e5c1423 100644
--- a/src/app/api/mobile/task/detail/[id]/route.ts
+++ b/src/app/api/mobile/task/detail/[id]/route.ts
@@ -2,6 +2,7 @@ import { prisma } from "@/module/_global";
import { funGetUserById } from "@/module/auth";
import { createLogUserMobile } from "@/module/user";
import _ from "lodash";
+import moment from "moment";
import { NextResponse } from "next/server";
@@ -166,6 +167,7 @@ export async function GET(request: Request, context: { params: { id: string } })
const { id } = context.params;
const { searchParams } = new URL(request.url);
const user = searchParams.get("user");
+ const kategori = searchParams.get("cat");
const userMobile = await funGetUserById({ id: String(user) })
if (userMobile.id == "null" || userMobile.id == undefined || userMobile.id == "") {
@@ -183,7 +185,30 @@ export async function GET(request: Request, context: { params: { id: string } })
return NextResponse.json({ success: false, message: "Gagal mendapatkan detail tugas, data tidak ditemukan" }, { status: 200 });
}
- return NextResponse.json({ success: true, message: "Berhasil mendapatkan detail tugas divisi", data }, { status: 200 });
+ let dataFix
+ if (kategori == "detailTask") {
+ const dataDetail = await prisma.divisionProjectTaskDetail.findMany({
+ where: {
+ idTask: String(id)
+ },
+ orderBy: {
+ date: "asc"
+ }
+ })
+
+ const dataDetailFix = dataDetail.map((data: any) => ({
+ ...data,
+ date: moment(data?.date).format('DD-MM-YYYY'),
+ timeStart: data.timeStart == null ? "" : moment.utc(data.timeStart).format("HH:mm"),
+ timeEnd: data.timeEnd == null ? "" : moment.utc(data.timeEnd).format("HH:mm")
+ }))
+
+ dataFix = dataDetailFix
+ } else {
+ dataFix = data
+ }
+
+ return NextResponse.json({ success: true, message: "Berhasil mendapatkan detail tugas divisi", data: dataFix }, { status: 200 });
}
catch (error) {
@@ -198,7 +223,7 @@ export async function GET(request: Request, context: { params: { id: string } })
export async function POST(request: Request, context: { params: { id: string } }) {
try {
const { id } = context.params;
- const { title, dateStart, dateEnd, user } = (await request.json());
+ const { title, dateStart, dateEnd, user, dataDetail } = (await request.json());
const userMobile = await funGetUserById({ id: String(user) })
if (userMobile.id == "null" || userMobile.id == undefined || userMobile.id == "") {
@@ -232,6 +257,26 @@ export async function POST(request: Request, context: { params: { id: string } }
},
});
+ const dataDetailDelete = await prisma.divisionProjectTaskDetail.deleteMany({
+ where: {
+ idTask: id
+ }
+ })
+
+ if (dataDetail.length > 0) {
+ const dataDetailFix = dataDetail.map((v: any) => ({
+ ...v,
+ idTask: id,
+ date: new Date(v.date),
+ timeStart: v.timeStart == null ? null : new Date(new Date('1970-01-01 ' + v.timeStart).getTime() - (new Date('1970-01-01 ' + v.timeStart).getTimezoneOffset() * 60000)).toISOString(),
+ timeEnd: v.timeEnd == null ? null : new Date(new Date('1970-01-01 ' + v.timeEnd).getTime() - (new Date('1970-01-01 ' + v.timeEnd).getTimezoneOffset() * 60000)).toISOString(),
+ }))
+
+ const dataDetailCreate = await prisma.divisionProjectTaskDetail.createMany({
+ data: dataDetailFix
+ })
+ }
+
// create log user
const log = await createLogUserMobile({ act: 'UPDATE', desc: 'User mengupdate data detail task divisi', table: 'divisionProjectTask', data: id, user: userMobile.id })
diff --git a/src/app/api/mobile/task/route.ts b/src/app/api/mobile/task/route.ts
index ebaf027..479f4ea 100644
--- a/src/app/api/mobile/task/route.ts
+++ b/src/app/api/mobile/task/route.ts
@@ -142,7 +142,7 @@ export async function POST(request: Request) {
if (task.length > 0) {
const dataTask = task.map((v: any) => ({
- ..._.omit(v, ["dateStart", "dateEnd", "title", "dateStartFix", "dateEndFix"]),
+ ..._.omit(v, ["dateStart", "dateEnd", "title", "dateStartFix", "dateEndFix", "dataDetail"]),
idDivision: idDivision,
idProject: data.id,
title: v.title,
@@ -150,9 +150,26 @@ export async function POST(request: Request) {
dateEnd: new Date(v.dateEndFix),
}))
+ let dataDetailFix = []
+ for (let i = 0; i < dataTask.length; i++) {
+ const insertTask = await prisma.divisionProjectTask.create({
+ data: dataTask[i],
+ select: {
+ id: true
+ }
+ })
+ const dataDetail = task[i].dataDetail.map((v: any) => ({
+ ...v,
+ idTask: insertTask.id,
+ date: new Date(v.date),
+ timeStart: v.timeStart == null ? null : new Date(new Date('1970-01-01 ' + v.timeStart).getTime() - (new Date('1970-01-01 ' + v.timeStart).getTimezoneOffset() * 60000)).toISOString(),
+ timeEnd: v.timeEnd == null ? null : new Date(new Date('1970-01-01 ' + v.timeEnd).getTime() - (new Date('1970-01-01 ' + v.timeEnd).getTimezoneOffset() * 60000)).toISOString(),
+ }))
+ dataDetailFix.push(...dataDetail)
+ }
- const insertTask = await prisma.divisionProjectTask.createMany({
- data: dataTask
+ const insertDetail = await prisma.divisionProjectTaskDetail.createMany({
+ data: dataDetailFix
})
}
@@ -350,7 +367,7 @@ export async function POST(request: Request) {
token: tokenUnique,
title: "Tugas Baru",
body: "Anda memiliki tugas baru. Silahkan periksa detailnya.",
- data: { id: data.id, category:'division/' + idDivision + '/task', content: data.id }
+ data: { id: data.id, category: 'division/' + idDivision + '/task', content: data.id }
})
// create log user
diff --git a/src/app/api/project/[id]/lainnya/route.ts b/src/app/api/project/[id]/lainnya/route.ts
index bf3f042..1e28df9 100644
--- a/src/app/api/project/[id]/lainnya/route.ts
+++ b/src/app/api/project/[id]/lainnya/route.ts
@@ -45,4 +45,50 @@ export async function DELETE(request: Request, context: { params: { id: string }
console.error(error);
return NextResponse.json({ success: false, message: "Gagal menghapus kegiatan, coba lagi nanti (error: 500)", reason: (error as Error).message, }, { status: 500 });
}
+}
+
+// EDIT PROJECT REPORT
+export async function PUT(request: Request, context: { params: { id: string } }) {
+ try {
+ const user = await funGetUserByCookies()
+ if (user.id == undefined) {
+ return NextResponse.json({ success: false, message: "Anda harus login untuk mengakses ini" }, { status: 401 });
+ }
+
+ const { id } = context.params
+ const { report } = await request.json()
+
+ const data = await prisma.project.count({
+ where: {
+ id: id
+ }
+ })
+
+ if (data == 0) {
+ return NextResponse.json(
+ {
+ success: false, message: "Gagal mendapatkan kegiatan, data tidak ditemukan",
+ },
+ { status: 404 }
+ );
+ }
+
+ const dataCreate = await prisma.project.update({
+ where: {
+ id
+ },
+ data: {
+ report: report
+ }
+ })
+
+ // create log user
+ const log = await createLogUser({ act: 'UPDATE', desc: 'User mengupdate laporan kegiatan', table: 'project', data: String(id) })
+
+ return NextResponse.json({ success: true, message: "Laporan kegiatan berhasil diupdate" }, { status: 200 });
+
+ } catch (error) {
+ console.error(error);
+ return NextResponse.json({ success: false, message: "Gagal mengupdate kegiatan, coba lagi nanti (error: 500)", reason: (error as Error).message, }, { status: 500 });
+ }
}
\ No newline at end of file
diff --git a/src/app/api/project/[id]/link/route.ts b/src/app/api/project/[id]/link/route.ts
new file mode 100644
index 0000000..eb642e4
--- /dev/null
+++ b/src/app/api/project/[id]/link/route.ts
@@ -0,0 +1,93 @@
+import { prisma } from "@/module/_global";
+import { funGetUserByCookies } from "@/module/auth";
+import { createLogUser } from "@/module/user";
+import { NextResponse } from "next/server";
+
+// ADD LINK PROJECT
+export async function POST(request: Request, context: { params: { id: string } }) {
+ try {
+ const user = await funGetUserByCookies()
+ if (user.id == undefined) {
+ return NextResponse.json({ success: false, message: "Anda harus login untuk mengakses ini" }, { status: 401 });
+ }
+
+ const { id } = context.params
+ const { link } = (await request.json())
+
+ const data = await prisma.project.count({
+ where: {
+ id: id
+ }
+ })
+
+ if (data == 0) {
+ return NextResponse.json(
+ {
+ success: false, message: "Gagal mendapatkan kegiatan, data tidak ditemukan",
+ },
+ { status: 404 }
+ );
+ }
+
+
+ const insertLink = await prisma.projectLink.create({
+ data: {
+ idProject: id,
+ link: link
+ }
+ })
+
+ // create log user
+ const log = await createLogUser({ act: 'CREATE', desc: 'User menambah link kegiatan', table: 'projectLink', data: insertLink.id })
+ return NextResponse.json({ success: true, message: "Berhasil menambahkan link kegiatan" }, { status: 200 });
+
+ } catch (error) {
+ console.error(error);
+ return NextResponse.json({ success: false, message: "Gagal menambah link kegiatan, coba lagi nanti (error: 500)", reason: (error as Error).message, }, { status: 500 });
+ }
+}
+
+
+// DELETE LINK PROJECT
+export async function DELETE(request: Request, context: { params: { id: string } }) {
+ try {
+ const user = await funGetUserByCookies()
+ if (user.id == undefined) {
+ return NextResponse.json({ success: false, message: "Anda harus login untuk mengakses ini" }, { status: 401 });
+ }
+
+ const { idLink } = (await request.json())
+
+ const data = await prisma.projectLink.count({
+ where: {
+ id: idLink
+ }
+ })
+
+ if (data == 0) {
+ return NextResponse.json(
+ {
+ success: false, message: "Gagal mendapatkan link, data tidak ditemukan",
+ },
+ { status: 404 }
+ );
+ }
+
+ const deleteLink = await prisma.projectLink.update({
+ where: {
+ id: idLink
+ },
+ data: {
+ isActive: false
+ }
+ })
+
+ // create log user
+ const log = await createLogUser({ act: 'DELETE', desc: 'User menghapus link kegiatan', table: 'projectLink', data: String(idLink) })
+ return NextResponse.json({ success: true, message: "Berhasil menghapus link kegiatan" }, { status: 200 });
+
+ } catch (error) {
+ console.error(error);
+ return NextResponse.json({ success: false, message: "Gagal menghapus link kegiatan, coba lagi nanti (error: 500)", reason: (error as Error).message, }, { status: 500 });
+ }
+}
diff --git a/src/app/api/project/[id]/route.ts b/src/app/api/project/[id]/route.ts
index 19bc836..df7e87f 100644
--- a/src/app/api/project/[id]/route.ts
+++ b/src/app/api/project/[id]/route.ts
@@ -133,6 +133,17 @@ export async function GET(request: Request, context: { params: { id: string } })
}))
allData = fix
+ } else if (kategori == "link") {
+ const dataLink = await prisma.projectLink.findMany({
+ where: {
+ isActive: true,
+ idProject: String(id)
+ },
+ orderBy: {
+ createdAt: 'asc'
+ }
+ })
+ allData = dataLink
}
return NextResponse.json({ success: true, message: "Berhasil mendapatkan kegiatan", data: allData, }, { status: 200 });
@@ -152,7 +163,7 @@ export async function POST(request: Request, context: { params: { id: string } }
}
const { id } = context.params
- const { name, dateStart, dateEnd, } = await request.json()
+ const { name, dateStart, dateEnd, dataDetail } = await request.json()
const data = await prisma.project.count({
where: {
@@ -181,6 +192,50 @@ export async function POST(request: Request, context: { params: { id: string } }
}
})
+ if (dataDetail.length > 0) {
+ const dataDetailFix = dataDetail.map((v: any) => ({
+ ...v,
+ idTask: dataCreate.id,
+ date: new Date(v.date),
+ timeStart: v.timeStart == null ? null : new Date(new Date('1970-01-01 ' + v.timeStart).getTime() - (new Date('1970-01-01 ' + v.timeStart).getTimezoneOffset() * 60000)).toISOString(),
+ timeEnd: v.timeEnd == null ? null : new Date(new Date('1970-01-01 ' + v.timeEnd).getTime() - (new Date('1970-01-01 ' + v.timeEnd).getTimezoneOffset() * 60000)).toISOString(),
+ }))
+
+ const dataDetailCreate = await prisma.projectTaskDetail.createMany({
+ data: dataDetailFix
+ })
+ }
+
+ // const cek progress
+ const dataTask = await prisma.projectTask.findMany({
+ where: {
+ isActive: true,
+ idProject: id,
+ }
+ })
+
+ const semua = dataTask.length
+ const selesai = dataTask.filter((item) => item.status == 1).length
+ const prosess = Math.ceil((selesai / semua) * 100)
+ let statusProject = 1
+
+ if (prosess == 100) {
+ statusProject = 2
+ } else if (prosess == 0) {
+ statusProject = 0
+ }
+
+
+ const update = await prisma.project.update({
+ where: {
+ id: id
+ },
+ data: {
+ status: statusProject
+ }
+ })
+
+
// create log user
const log = await createLogUser({ act: 'CREATE', desc: 'User membuat data tahapan kegiatan', table: 'projectTask', data: String(dataCreate.id) })
diff --git a/src/app/api/project/detail/[id]/route.ts b/src/app/api/project/detail/[id]/route.ts
index abd5571..d29ed5e 100644
--- a/src/app/api/project/detail/[id]/route.ts
+++ b/src/app/api/project/detail/[id]/route.ts
@@ -1,6 +1,7 @@
import { prisma } from "@/module/_global";
import { funGetUserByCookies } from "@/module/auth";
import { createLogUser } from "@/module/user";
+import moment from "moment";
import { NextResponse } from "next/server";
@@ -171,7 +172,11 @@ export async function GET(request: Request, context: { params: { id: string } })
return NextResponse.json({ success: false, message: "Anda harus login untuk mengakses ini" }, { status: 401 });
}
+ const { searchParams } = new URL(request.url);
+ const kategori = searchParams.get("cat");
const { id } = context.params;
+
+ let dataFix
const data = await prisma.projectTask.findUnique({
where: {
id: String(id),
@@ -188,7 +193,28 @@ export async function GET(request: Request, context: { params: { id: string } })
);
}
- return NextResponse.json({ success: true, message: "Detail kegiatan berhasil ditemukan", data }, { status: 200 });
+ if (kategori == "detailTask") {
+ const dataDetail = await prisma.projectTaskDetail.findMany({
+ where: {
+ idTask: String(id)
+ },
+ orderBy: {
+ date: "asc"
+ }
+ })
+
+ const dataDetailFix = dataDetail.map((data: any) => ({
+ ...data,
+ timeStart: moment.utc(data.timeStart).format("HH:mm"),
+ timeEnd: moment.utc(data.timeEnd).format("HH:mm")
+ }))
+
+ dataFix = dataDetailFix
+ } else {
+ dataFix = data
+ }
+
+ return NextResponse.json({ success: true, message: "Detail kegiatan berhasil ditemukan", data: dataFix }, { status: 200 });
} catch (error) {
console.error(error);
return NextResponse.json({ success: false, message: "Gagal mendapatkan kegiatan, coba lagi nanti (error: 500)", reason: (error as Error).message, }, { status: 500 });
@@ -205,17 +231,17 @@ export async function POST(request: Request, context: { params: { id: string } }
}
const { id } = context.params;
- const { title, dateStart, dateEnd } = (await request.json());
+ const { title, dateStart, dateEnd, dataDetail } = (await request.json());
- const dataTask = await prisma.projectTask.count({
+ const dataTaskLama = await prisma.projectTask.findUnique({
where: {
id
}
})
- if (dataTask == 0) {
+ if (dataTaskLama?.title == undefined) {
return NextResponse.json(
{
success: false, message: "Gagal mendapatkan kegiatan, data tidak ditemukan",
@@ -235,6 +261,26 @@ export async function POST(request: Request, context: { params: { id: string } }
}
})
+ const dataDetailDelete = await prisma.projectTaskDetail.deleteMany({
+ where: {
+ idTask: id
+ }
+ })
+
+ if (dataDetail.length > 0) {
+ const dataDetailFix = dataDetail.map((v: any) => ({
+ ...v,
+ idTask: id,
+ date: new Date(v.date),
+ timeStart: v.timeStart == null ? null : new Date(new Date('1970-01-01 ' + v.timeStart).getTime() - (new Date('1970-01-01 ' + v.timeStart).getTimezoneOffset() * 60000)).toISOString(),
+ timeEnd: v.timeEnd == null ? null : new Date(new Date('1970-01-01 ' + v.timeEnd).getTime() - (new Date('1970-01-01 ' + v.timeEnd).getTimezoneOffset() * 60000)).toISOString(),
+ }))
+
+ const dataDetailCreate = await prisma.projectTaskDetail.createMany({
+ data: dataDetailFix
+ })
+ }
+
// create log user
const log = await createLogUser({ act: 'UPDATE', desc: 'User mengupdate tahapan kegiatan', table: 'projectTask', data: String(id) })
diff --git a/src/app/api/project/route.ts b/src/app/api/project/route.ts
index ee2a96b..d4e6652 100644
--- a/src/app/api/project/route.ts
+++ b/src/app/api/project/route.ts
@@ -169,15 +169,34 @@ export async function POST(request: Request) {
if (task.length > 0) {
const dataProject = task.map((v: any) => ({
- ..._.omit(v, ["dateStart", "dateEnd", "name"]),
+ ..._.omit(v, ["dateStart", "dateEnd", "name", "dataDetail"]),
idProject: data.id,
title: v.title,
dateStart: new Date(v.dateStart),
dateEnd: new Date(v.dateEnd),
}))
- const insertTask = await prisma.projectTask.createMany({
- data: dataProject
+ let dataDetailFix = []
+
+ for (let i = 0; i < dataProject.length; i++) {
+ const insertTask = await prisma.projectTask.create({
+ data: dataProject[i],
+ select:{
+ id: true
+ }
+ })
+ const dataDetail = task[i].dataDetail.map((v: any) => ({
+ ...v,
+ idTask: insertTask.id,
+ date: new Date(v.date),
+ timeStart: v.timeStart == null ? null : new Date(new Date('1970-01-01 ' + v.timeStart).getTime() - (new Date('1970-01-01 ' + v.timeStart).getTimezoneOffset() * 60000)).toISOString(),
+ timeEnd: v.timeEnd == null ? null : new Date(new Date('1970-01-01 ' + v.timeEnd).getTime() - (new Date('1970-01-01 ' + v.timeEnd).getTimezoneOffset() * 60000)).toISOString(),
+ }))
+ dataDetailFix.push(...dataDetail)
+ }
+
+ const insertDetail = await prisma.projectTaskDetail.createMany({
+ data: dataDetailFix
})
}
diff --git a/src/app/api/task/[id]/lainnya/route.ts b/src/app/api/task/[id]/lainnya/route.ts
index cc67eeb..585a0ac 100644
--- a/src/app/api/task/[id]/lainnya/route.ts
+++ b/src/app/api/task/[id]/lainnya/route.ts
@@ -45,4 +45,52 @@ export async function DELETE(request: Request, context: { params: { id: string }
console.error(error);
return NextResponse.json({ success: false, message: "Gagal menghapus tugas, coba lagi nanti (error: 500)", reason: (error as Error).message, }, { status: 500 });
}
+}
+
+
+// EDIT TASK REPORT
+export async function PUT(request: Request, context: { params: { id: string } }) {
+ try {
+ const user = await funGetUserByCookies()
+ if (user.id == undefined) {
+ return NextResponse.json({ success: false, message: "Anda harus login untuk mengakses ini" }, { status: 401 });
+ }
+
+ const { id } = context.params
+ const { report } = await request.json()
+
+
+ const data = await prisma.divisionProject.count({
+ where: {
+ id: id
+ }
+ })
+
+ if (data == 0) {
+ return NextResponse.json(
+ {
+ success: false, message: "Gagal mendapatkan kegiatan, data tidak ditemukan",
+ },
+ { status: 404 }
+ );
+ }
+
+ const dataCreate = await prisma.divisionProject.update({
+ where: {
+ id
+ },
+ data: {
+ report: report
+ }
+ })
+
+ // create log user
+ const log = await createLogUser({ act: 'UPDATE', desc: 'User mengupdate laporan tugas divisi', table: 'divisionProject', data: String(id) })
+
+ return NextResponse.json({ success: true, message: "Laporan tugas divisi berhasil diupdate" }, { status: 200 });
+
+ } catch (error) {
+ console.error(error);
+ return NextResponse.json({ success: false, message: "Gagal mengupdate laporan tugas divisi, coba lagi nanti (error: 500)", reason: (error as Error).message, }, { status: 500 });
+ }
}
\ No newline at end of file
diff --git a/src/app/api/task/[id]/link/route.ts b/src/app/api/task/[id]/link/route.ts
new file mode 100644
index 0000000..25b927b
--- /dev/null
+++ b/src/app/api/task/[id]/link/route.ts
@@ -0,0 +1,98 @@
+import { prisma } from "@/module/_global";
+import { funGetUserByCookies } from "@/module/auth";
+import { createLogUser } from "@/module/user";
+import { NextResponse } from "next/server";
+
+// ADD LINK TASK DIVISI
+export async function POST(request: Request, context: { params: { id: string } }) {
+ try {
+ const user = await funGetUserByCookies()
+ if (user.id == undefined) {
+ return NextResponse.json({ success: false, message: "Anda harus login untuk mengakses ini" }, { status: 401 });
+ }
+
+ const { id } = context.params;
+ const { link, idDivision } = (await request.json());
+
+ const data = await prisma.divisionProject.count({
+ where: {
+ id: id,
+ },
+ });
+
+ if (data == 0) {
+ return NextResponse.json(
+ {
+ success: false,
+ message: "Tambah link tugas gagal, data tugas tidak ditemukan",
+ },
+ { status: 404 }
+ );
+ }
+
+
+
+ const insertlink = await prisma.divisionProjectLink.create({
+ data: {
+ idProject: id,
+ link,
+ idDivision,
+ }
+ })
+
+
+ // create log user
+ const log = await createLogUser({ act: 'CREATE', desc: 'User menambahkan link tugas divisi', table: 'divisionProjectLink', data: insertlink.id })
+
+
+ return NextResponse.json({ success: true, message: "Berhasil menambahkan link tugas", }, { status: 200 });
+ } catch (error) {
+ console.error(error);
+ return NextResponse.json({ success: false, message: "Gagal menambah link tugas, coba lagi nanti (error: 500)", reason: (error as Error).message, }, { status: 500 });
+ }
+}
+
+
+// DELETE LINK TASK DIVISI
+export async function DELETE(request: Request, context: { params: { id: string } }) {
+ try {
+ const user = await funGetUserByCookies()
+ if (user.id == undefined) {
+ return NextResponse.json({ success: false, message: "Anda harus login untuk mengakses ini" }, { status: 401 });
+ }
+
+ const { idLink } = (await request.json())
+
+ const data = await prisma.divisionProjectLink.count({
+ where: {
+ id: idLink
+ }
+ })
+
+ if (data == 0) {
+ return NextResponse.json(
+ {
+ success: false, message: "Gagal mendapatkan link, data tidak ditemukan",
+ },
+ { status: 404 }
+ );
+ }
+
+ const deleteLink = await prisma.divisionProjectLink.update({
+ where: {
+ id: idLink
+ },
+ data: {
+ isActive: false
+ }
+ })
+
+ // create log user
+ const log = await createLogUser({ act: 'DELETE', desc: 'User menghapus link tugas divisi', table: 'divisionProjectLink', data: String(idLink) })
+ return NextResponse.json({ success: true, message: "Berhasil menghapus link tugas divisi" }, { status: 200 });
+
+ } catch (error) {
+ console.error(error);
+ return NextResponse.json({ success: false, message: "Gagal menghapus link tugas divisi, coba lagi nanti (error: 500)", reason: (error as Error).message, }, { status: 500 });
+ }
+}
\ No newline at end of file
diff --git a/src/app/api/task/[id]/route.ts b/src/app/api/task/[id]/route.ts
index 07e9dc2..7ef6090 100644
--- a/src/app/api/task/[id]/route.ts
+++ b/src/app/api/task/[id]/route.ts
@@ -150,6 +150,18 @@ export async function GET(request: Request, context: { params: { id: string } })
}))
allData = fix
+ } else if (kategori == "link") {
+ const dataLink = await prisma.divisionProjectLink.findMany({
+ where: {
+ isActive: true,
+ idProject: String(id)
+ },
+ orderBy: {
+ createdAt: 'asc'
+ }
+ })
+
+ allData = dataLink
}
return NextResponse.json({ success: true, message: "Berhasil mendapatkan tugas divisi", data: allData }, { status: 200 });
@@ -171,7 +183,8 @@ export async function POST(request: Request, context: { params: { id: string } }
}
const { id } = context.params;
- const { title, dateStart, dateEnd, idDivision } = (await request.json());
+ const { title, dateStart, dateEnd, idDivision, dataDetail } = (await request.json());
+
const data = await prisma.divisionProject.count({
where: {
id: id,
@@ -201,6 +214,20 @@ export async function POST(request: Request, context: { params: { id: string } }
}
});
+ if(dataDetail.length>0){
+ const dataDetailFix = dataDetail.map((v: any) => ({
+ ...v,
+ idTask: create.id,
+ date: new Date(v.date),
+ timeStart: v.timeStart == null ? null : new Date(new Date('1970-01-01 ' + v.timeStart).getTime() - (new Date('1970-01-01 ' + v.timeStart).getTimezoneOffset() * 60000)).toISOString(),
+ timeEnd: v.timeEnd == null ? null : new Date(new Date('1970-01-01 ' + v.timeEnd).getTime() - (new Date('1970-01-01 ' + v.timeEnd).getTimezoneOffset() * 60000)).toISOString(),
+ }))
+
+ const dataDetailCreate = await prisma.divisionProjectTaskDetail.createMany({
+ data: dataDetailFix
+ })
+ }
+
// const cek progress
const dataTask = await prisma.divisionProjectTask.findMany({
where: {
diff --git a/src/app/api/task/detail/[id]/route.ts b/src/app/api/task/detail/[id]/route.ts
index ddaa1f0..7a55930 100644
--- a/src/app/api/task/detail/[id]/route.ts
+++ b/src/app/api/task/detail/[id]/route.ts
@@ -2,6 +2,7 @@ import { prisma } from "@/module/_global";
import { funGetUserByCookies } from "@/module/auth";
import { createLogUser } from "@/module/user";
import _ from "lodash";
+import moment from "moment";
import { NextResponse } from "next/server";
@@ -155,12 +156,15 @@ export async function PUT(request: Request, context: { params: { id: string } })
export async function GET(request: Request, context: { params: { id: string } }) {
try {
const { id } = context.params;
+ const { searchParams } = new URL(request.url);
+ const kategori = searchParams.get("cat");
const user = await funGetUserByCookies()
if (user.id == undefined) {
return NextResponse.json({ success: false, message: "Anda harus login untuk mengakses ini" }, { status: 401 });
}
+ let dataFix
const data = await prisma.divisionProjectTask.findUnique({
where: {
id: String(id),
@@ -172,7 +176,28 @@ export async function GET(request: Request, context: { params: { id: string } })
return NextResponse.json({ success: false, message: "Gagal mendapatkan detail tugas, data tidak ditemukan", }, { status: 404 });
}
- return NextResponse.json({ success: true, message: "Berhasil mendapatkan detail tugas divisi", data }, { status: 200 });
+ if (kategori == "detailTask") {
+ const dataDetail = await prisma.divisionProjectTaskDetail.findMany({
+ where: {
+ idTask: String(id)
+ },
+ orderBy: {
+ date: "asc"
+ }
+ })
+
+ const dataDetailFix = dataDetail.map((data: any) => ({
+ ...data,
+ timeStart: moment.utc(data.timeStart).format("HH:mm"),
+ timeEnd: moment.utc(data.timeEnd).format("HH:mm")
+ }))
+
+ dataFix = dataDetailFix
+ } else {
+ dataFix = data
+ }
+
+ return NextResponse.json({ success: true, message: "Berhasil mendapatkan detail tugas divisi", data: dataFix }, { status: 200 });
}
catch (error) {
@@ -192,7 +217,7 @@ export async function POST(request: Request, context: { params: { id: string } }
}
const { id } = context.params;
- const { title, dateStart, dateEnd } = (await request.json());
+ const { title, dateStart, dateEnd, dataDetail } = (await request.json());
const data = await prisma.divisionProjectTask.count({
where: {
id: id,
@@ -220,6 +245,26 @@ export async function POST(request: Request, context: { params: { id: string } }
},
});
+ const dataDetailDelete = await prisma.divisionProjectTaskDetail.deleteMany({
+ where: {
+ idTask: id
+ }
+ })
+
+ if (dataDetail.length > 0) {
+ const dataDetailFix = dataDetail.map((v: any) => ({
+ ...v,
+ idTask: id,
+ date: new Date(v.date),
+ timeStart: v.timeStart == null ? null : new Date(new Date('1970-01-01 ' + v.timeStart).getTime() - (new Date('1970-01-01 ' + v.timeStart).getTimezoneOffset() * 60000)).toISOString(),
+ timeEnd: v.timeEnd == null ? null : new Date(new Date('1970-01-01 ' + v.timeEnd).getTime() - (new Date('1970-01-01 ' + v.timeEnd).getTimezoneOffset() * 60000)).toISOString(),
+ }))
+
+ const dataDetailCreate = await prisma.divisionProjectTaskDetail.createMany({
+ data: dataDetailFix
+ })
+ }
+
// create log user
const log = await createLogUser({ act: 'UPDATE', desc: 'User mengupdate data detail task divisi', table: 'divisionProjectTask', data: id })
diff --git a/src/app/api/task/route.ts b/src/app/api/task/route.ts
index b55940e..976b941 100644
--- a/src/app/api/task/route.ts
+++ b/src/app/api/task/route.ts
@@ -140,7 +140,7 @@ export async function POST(request: Request) {
if (task.length > 0) {
const dataTask = task.map((v: any) => ({
- ..._.omit(v, ["dateStart", "dateEnd", "title"]),
+ ..._.omit(v, ["dateStart", "dateEnd", "title", "dataDetail"]),
idDivision: idDivision,
idProject: data.id,
title: v.title,
@@ -148,8 +148,26 @@ export async function POST(request: Request) {
dateEnd: new Date(v.dateEnd),
}))
- const insertTask = await prisma.divisionProjectTask.createMany({
- data: dataTask
+ let dataDetailFix = []
+ for (let i = 0; i < dataTask.length; i++) {
+ const insertTask = await prisma.divisionProjectTask.create({
+ data: dataTask[i],
+ select: {
+ id: true
+ }
+ })
+ const dataDetail = task[i].dataDetail.map((v: any) => ({
+ ...v,
+ idTask: insertTask.id,
+ date: new Date(v.date),
+ timeStart: v.timeStart == null ? null : new Date(new Date('1970-01-01 ' + v.timeStart).getTime() - (new Date('1970-01-01 ' + v.timeStart).getTimezoneOffset() * 60000)).toISOString(),
+ timeEnd: v.timeEnd == null ? null : new Date(new Date('1970-01-01 ' + v.timeEnd).getTime() - (new Date('1970-01-01 ' + v.timeEnd).getTimezoneOffset() * 60000)).toISOString(),
+ }))
+ dataDetailFix.push(...dataDetail)
+ }
+
+ const insertDetail = await prisma.divisionProjectTaskDetail.createMany({
+ data: dataDetailFix
})
}
diff --git a/src/app/api/version-app/route.ts b/src/app/api/version-app/route.ts
index b3eae59..f14e0ef 100644
--- a/src/app/api/version-app/route.ts
+++ b/src/app/api/version-app/route.ts
@@ -2,7 +2,7 @@ import { NextResponse } from "next/server";
export async function GET(request: Request) {
try {
- return NextResponse.json({ success: true, version: "1.5.8", tahap: "beta", update: "-update notif komen diskusi" }, { status: 200 });
+ return NextResponse.json({ success: true, version: "1.7.0", tahap: "beta", update: "-api mobile; -tambah laporan pada project dan tugas divisi; -tambah upload link pada project dan tugas divisi; -tambah detail tanggal dan jam pada project dan tugas divisi" }, { status: 200 });
} catch (error) {
console.error(error);
return NextResponse.json({ success: false, version: "Gagal mendapatkan version, coba lagi nanti (error: 500)", reason: (error as Error).message, }, { status: 500 });
diff --git a/src/lib/getDatesInRange.ts b/src/lib/getDatesInRange.ts
new file mode 100644
index 0000000..c706968
--- /dev/null
+++ b/src/lib/getDatesInRange.ts
@@ -0,0 +1,9 @@
+export function getDatesInRange(startDate: Date, endDate: Date) {
+ const dates = [];
+ const currentDate = new Date(startDate);
+ while (currentDate <= endDate) {
+ dates.push(new Date(currentDate));
+ currentDate.setDate(currentDate.getDate() + 1);
+ }
+ return dates;
+}
\ No newline at end of file
diff --git a/src/lib/urlCompleted.ts b/src/lib/urlCompleted.ts
new file mode 100644
index 0000000..2af7aad
--- /dev/null
+++ b/src/lib/urlCompleted.ts
@@ -0,0 +1,7 @@
+export function urlCompleted(url: string) {
+ if (url.startsWith("http://") || url.startsWith("https://")) {
+ return url
+ } else {
+ return `https://${url}`
+ }
+}
\ No newline at end of file
diff --git a/src/module/project/index.ts b/src/module/project/index.ts
index 1c33e04..35107a1 100644
--- a/src/module/project/index.ts
+++ b/src/module/project/index.ts
@@ -5,7 +5,6 @@ import NavbarDetailProject from "./ui/navbar_detail_project";
import ProgressDetailProject from "./ui/progress_detail_project";
import ListTugasDetailProject from "./ui/list_tugas_detail_project";
import ListFileDetailProject from "./ui/list_file_detail_project";
-import LiatAnggotaDetailProject from "./ui/list_anggota_detail_project";
import EditTaskProject from "./ui/edit_task_project";
import EditDetailTaskProject from "./ui/edit_detail_task_project";
import ListAnggotaDetailProject from "./ui/list_anggota_detail_project";
@@ -15,6 +14,9 @@ import AddMemberDetailProject from "./ui/add_member_detail_project";
import CreateProject from "./ui/create_project";
import AddFileDetailProject from "./ui/add_file_detail_project";
import WrapLayoutProject from "./ui/wrap_project";
+import ListLinkDetailProject from "./ui/list_link_detail_project";
+import AddReportProject from "./ui/add_report_project";
+import ListReportDetailProject from "./ui/list_report_project";
export { ViewDateEndTask }
export { CreateUsersProject }
@@ -31,4 +33,7 @@ export { CancelProject }
export { AddMemberDetailProject }
export { CreateProject }
export { AddFileDetailProject }
-export { WrapLayoutProject }
\ No newline at end of file
+export { WrapLayoutProject }
+export { ListLinkDetailProject }
+export { AddReportProject }
+export { ListReportDetailProject }
\ No newline at end of file
diff --git a/src/module/project/lib/api_project.ts b/src/module/project/lib/api_project.ts
index 255faae..d4dc5cc 100644
--- a/src/module/project/lib/api_project.ts
+++ b/src/module/project/lib/api_project.ts
@@ -1,4 +1,4 @@
-import { IFormAddDetailproject, IFormAddMemberProject, IFormDateProject, NewIFormDateProject } from "./type_project";
+import { IFormAddDetailproject, IFormAddMemberProject, NewIFormDateProject } from "./type_project";
export const funGetAllProject = async (path?: string) => {
@@ -49,8 +49,8 @@ export const funUpdateStatusProject = async (path: string, data: { status: numbe
}
-export const funGetDetailProject = async (path: string) => {
- const response = await fetch(`/api/project/detail/${path}`);
+export const funGetDetailProject = async (path: string, kat?: string) => {
+ const response = await fetch(`/api/project/detail/${path}${(kat) ? `?cat=${kat}` : ''}`);
return await response.json().catch(() => null);
}
@@ -122,6 +122,17 @@ export const funEditProject = async (path: string, data: { name: string }) => {
return await response.json().catch(() => null);
}
+export const funEditReportProject = async (path: string, data: { report: string }) => {
+ const response = await fetch(`/api/project/${path}/lainnya`, {
+ method: "PUT",
+ headers: {
+ "Content-Type": "application/json",
+ },
+ body: JSON.stringify(data),
+ });
+ return await response.json().catch(() => null);
+}
+
export const funDeleteFileProject = async (path: string) => {
const response = await fetch(`/api/project/file/${path}`, {
@@ -149,6 +160,17 @@ export const funAddFileProject = async (path: string, data: FormData) => {
return await response.json().catch(() => null);
};
+export const funDeleteLinkProject = async (path: string, data: { idLink: string }) => {
+ const response = await fetch(`/api/project/${path}/link`, {
+ method: "DELETE",
+ headers: {
+ "Content-Type": "application/json",
+ },
+ body: JSON.stringify(data),
+ });
+ return await response.json().catch(() => null);
+};
+
export const funDeleteProject = async (path: string) => {
const response = await fetch(`/api/project/${path}/lainnya`, {
method: "DELETE",
@@ -159,3 +181,14 @@ export const funDeleteProject = async (path: string) => {
return await response.json().catch(() => null);
};
+
+export const funAddLinkProject = async (path: string, data: { link: string }) => {
+ const response = await fetch(`/api/project/${path}/link`, {
+ method: "POST",
+ headers: {
+ "Content-Type": "application/json",
+ },
+ body: JSON.stringify(data),
+ });
+ return await response.json().catch(() => null);
+}
diff --git a/src/module/project/lib/type_project.ts b/src/module/project/lib/type_project.ts
index 8c1bb4c..8adb847 100644
--- a/src/module/project/lib/type_project.ts
+++ b/src/module/project/lib/type_project.ts
@@ -20,7 +20,13 @@ export interface IDataFileProject {
id: string
name: string
extension: string
- idStorage:string
+ idStorage: string
+}
+
+
+export interface IDataLinkProject {
+ id: string
+ link: string
}
export interface IDataMemberProject {
@@ -46,10 +52,11 @@ export interface IFormDateProject {
title: string,
}
-export interface NewIFormDateProject{
+export interface NewIFormDateProject {
dateStart: string,
dateEnd: string,
title: string,
+ dataDetail: any[]
}
export interface IFormMemberProject {
@@ -62,7 +69,8 @@ export interface IFormMemberProject {
export interface IFormAddDetailproject {
dateStart: string,
dateEnd: string,
- name: string
+ name: string,
+ dataDetail: any[]
}
diff --git a/src/module/project/ui/add_detail_task_project.tsx b/src/module/project/ui/add_detail_task_project.tsx
index abc9bce..1dbc9f0 100644
--- a/src/module/project/ui/add_detail_task_project.tsx
+++ b/src/module/project/ui/add_detail_task_project.tsx
@@ -1,4 +1,5 @@
"use client"
+import { getDatesInRange } from '@/lib/getDatesInRange';
import { keyWibu, LayoutNavbarNew, TEMA } from '@/module/_global';
import LayoutModal from '@/module/_global/layout/layout_modal';
import { useHookstate } from '@hookstate/core';
@@ -11,6 +12,7 @@ import { useState } from 'react';
import toast from 'react-hot-toast';
import { useWibuRealtime } from 'wibu-realtime';
import { funCreateDetailProject } from '../lib/api_project';
+import { ModalAddDetailTaskProject } from './modal_add_detail_task_project';
export default function AddDetailTaskProject() {
const [value, setValue] = useState<[Date | null, Date | null]>([null, null]);
@@ -21,6 +23,8 @@ export default function AddDetailTaskProject() {
const param = useParams<{ id: string }>()
const tema = useHookstate(TEMA)
const [acuan, setAcuan] = useState(false)
+ const [openModalDetailTask, setOpenModalDetailTask] = useState(false)
+ const [dataDetail, setDataDetail] = useState([])
const [touched, setTouched] = useState({
title: false,
date: false
@@ -33,10 +37,16 @@ export default function AddDetailTaskProject() {
async function onSubmit() {
try {
setLoadingModal(true)
+ const dataDetailFix = dataDetail.map((v: any) => ({
+ ...v,
+ date: moment(v.date).format("YYYY-MM-DD"),
+ }))
+
const res = await funCreateDetailProject(param.id, {
name,
dateStart: (value[0] != null) ? moment(value[0]).format('YYYY-MM-DD') : moment(new Date).format('YYYY-MM-DD'),
dateEnd: (value[1] != null) ? moment(value[1]).format('YYYY-MM-DD') : moment(new Date).format('YYYY-MM-DD'),
+ dataDetail: dataDetailFix
})
if (res.success) {
@@ -94,8 +104,15 @@ export default function AddDetailTaskProject() {
const array = val.split(",")
if (array[0] == '' || array[1] == '') {
setTouched({ ...touched, date: true })
+ setDataDetail([])
} else {
setTouched({ ...touched, date: false })
+ const datanya = getDatesInRange(value[0]!, value[1]!)
+ setDataDetail(datanya.map((data: any) => ({
+ date: data,
+ timeStart: null,
+ timeEnd: null
+ })))
}
}
}
@@ -119,7 +136,6 @@ export default function AddDetailTaskProject() {
style={{ borderRadius: 10, border: `1px solid ${"#D6D8F6"}` }}
>
Tanggal Tidak Boleh Kosong
: <>>
}
+
+ setOpenModalDetailTask(false)}
+ data={dataDetail}
+ onSubmit={(data) => {
+ setDataDetail(data)
+ setOpenModalDetailTask(false)
+ }}
+ />
setOpenModal(false)}
description="Apakah Anda yakin ingin menambahkan tugas?"
diff --git a/src/module/project/ui/add_report_project.tsx b/src/module/project/ui/add_report_project.tsx
new file mode 100644
index 0000000..593e4b0
--- /dev/null
+++ b/src/module/project/ui/add_report_project.tsx
@@ -0,0 +1,157 @@
+"use client"
+import { keyWibu, LayoutNavbarNew, TEMA } from '@/module/_global';
+import LayoutModal from '@/module/_global/layout/layout_modal';
+import { useHookstate } from '@hookstate/core';
+import { Box, Button, rem, Skeleton, Stack, Textarea } from '@mantine/core';
+import { useShallowEffect } from '@mantine/hooks';
+import { useParams, useRouter } from 'next/navigation';
+import { useState } from 'react';
+import toast from 'react-hot-toast';
+import { useWibuRealtime } from 'wibu-realtime';
+import { funEditReportProject, funGetOneProjectById } from '../lib/api_project';
+
+export default function AddReportProject() {
+ const router = useRouter()
+ const [report, setReport] = useState("")
+ const [openModal, setOpenModal] = useState(false)
+ const param = useParams<{ id: string }>()
+ const [loading, setLoading] = useState(true)
+ const [loadingSubmit, setLoadingSubmit] = useState(false)
+ const tema = useHookstate(TEMA)
+ const [touched, setTouched] = useState({
+ report: false,
+ });
+ const [dataRealTime, setDataRealtime] = useWibuRealtime({
+ WIBU_REALTIME_TOKEN: keyWibu,
+ project: "sdm"
+ })
+
+ async function onSubmit() {
+ try {
+ setLoadingSubmit(true)
+ const res = await funEditReportProject(param.id, { report })
+ if (res.success) {
+ setDataRealtime([{
+ category: "project-report",
+ id: param.id,
+ }])
+ toast.success(res.message)
+ router.push("./")
+ } else {
+ toast.error(res.message)
+ }
+ } catch (error) {
+ console.error(error)
+ toast.error("Gagal mengedit Laporan Kegiatan, coba lagi nanti")
+ } finally {
+ setLoadingSubmit(false)
+ setOpenModal(false)
+ }
+ }
+
+ function onCheck() {
+ if (report == "") {
+ setTouched({ ...touched, report: true })
+ return false
+ }
+ setOpenModal(true)
+ }
+
+
+
+ function onValidation(kategori: string, val: string) {
+ if (kategori == 'report') {
+ setReport(val)
+ if (val === "") {
+ setTouched({ ...touched, report: true })
+ } else {
+ setTouched({ ...touched, report: false })
+ }
+ }
+ }
+
+ async function getOneData() {
+ try {
+ setLoading(true)
+ const res = await funGetOneProjectById(param.id, 'data');
+ if (res.success) {
+ setReport(res.data.report);
+ } else {
+ toast.error(res.message);
+ }
+ setLoading(false);
+ } catch (error) {
+ console.error(error);
+ toast.error("Gagal mendapatkan data Kegiatan, coba lagi nanti");
+ } finally {
+ setLoading(false);
+ }
+ }
+
+ useShallowEffect(() => {
+ getOneData();
+ }, [param.id])
+
+
+ return (
+
+
+
+
+ {loading ?
+
+ :
+
+
+
+ {loading ?
+
+ :
+
+ }
+
+
+
+ setOpenModal(false)}
+ description="Apakah Anda yakin ingin mengedit Laporan Kegiatan ini?"
+ onYes={(val) => {
+ if (val) {
+ onSubmit()
+ } else {
+ setOpenModal(false)
+ }
+ }} />
+
+ );
+}
+
diff --git a/src/module/project/ui/create_date_end_task.tsx b/src/module/project/ui/create_date_end_task.tsx
index acecb76..3e2685c 100644
--- a/src/module/project/ui/create_date_end_task.tsx
+++ b/src/module/project/ui/create_date_end_task.tsx
@@ -1,4 +1,5 @@
"use client";
+import { getDatesInRange } from "@/lib/getDatesInRange";
import { LayoutNavbarNew, TEMA } from "@/module/_global";
import { useHookstate } from "@hookstate/core";
import { ActionIcon, Box, Button, Flex, Group, rem, SimpleGrid, Stack, Text, TextInput } from "@mantine/core";
@@ -9,6 +10,7 @@ import { useState } from "react";
import toast from "react-hot-toast";
import { HiChevronLeft } from "react-icons/hi2";
import { NewIFormDateProject } from "../lib/type_project";
+import { ModalAddDetailTaskProject } from "./modal_add_detail_task_project";
export default function ViewDateEndTask({ onClose, onSet }: { onClose: (val: boolean) => void, onSet: (val: NewIFormDateProject) => void }) {
@@ -16,6 +18,8 @@ export default function ViewDateEndTask({ onClose, onSet }: { onClose: (val: boo
const [title, setTitle] = useState("")
const tema = useHookstate(TEMA)
const [acuan, setAcuan] = useState(false)
+ const [openModalDetailTask, setOpenModalDetailTask] = useState(false)
+ const [dataDetail, setDataDetail] = useState([])
const [touched, setTouched] = useState({
title: false,
date: false
@@ -28,10 +32,16 @@ export default function ViewDateEndTask({ onClose, onSet }: { onClose: (val: boo
if (title == "")
return toast.error("Error! harus memasukkan judul tugas")
+ const dataDetailFix = dataDetail.map((v: any) => ({
+ ...v,
+ date: moment(v.date).format("YYYY-MM-DD"),
+ }))
+
onSet({
dateStart: moment(value[0]).format('YYYY-MM-DD'),
dateEnd: moment(value[1]).format('YYYY-MM-DD'),
- title: title
+ title,
+ dataDetail: dataDetailFix
})
}
@@ -72,8 +82,15 @@ export default function ViewDateEndTask({ onClose, onSet }: { onClose: (val: boo
const array = val.split(",")
if (array[0] == '' || array[1] == '') {
setTouched({ ...touched, date: true })
+ setDataDetail([])
} else {
setTouched({ ...touched, date: false })
+ const datanya = getDatesInRange(value[0]!, value[1]!)
+ setDataDetail(datanya.map((data: any) => ({
+ date: data,
+ timeStart: null,
+ timeEnd: null
+ })))
}
}
}
@@ -144,6 +161,16 @@ export default function ViewDateEndTask({ onClose, onSet }: { onClose: (val: boo
? Tanggal Tidak Boleh Kosong
: <>>
}
+
+
+ setOpenModalDetailTask(false)}
+ data={dataDetail}
+ onSubmit={(data) => {
+ setDataDetail(data)
+ setOpenModalDetailTask(false)
+ }}
+ />
);
}
diff --git a/src/module/project/ui/create_project.tsx b/src/module/project/ui/create_project.tsx
index 311fcf9..069536a 100644
--- a/src/module/project/ui/create_project.tsx
+++ b/src/module/project/ui/create_project.tsx
@@ -299,7 +299,7 @@ export default function CreateProject() {
setIndexDelTask(i)
setOpenDrawerTask(true)
}}>
-
+
)
})
diff --git a/src/module/project/ui/edit_detail_task_project.tsx b/src/module/project/ui/edit_detail_task_project.tsx
index 849518c..4412fc6 100644
--- a/src/module/project/ui/edit_detail_task_project.tsx
+++ b/src/module/project/ui/edit_detail_task_project.tsx
@@ -1,4 +1,5 @@
"use client"
+import { getDatesInRange } from '@/lib/getDatesInRange';
import { keyWibu, LayoutNavbarNew, TEMA } from '@/module/_global';
import LayoutModal from '@/module/_global/layout/layout_modal';
import { useHookstate } from '@hookstate/core';
@@ -11,6 +12,7 @@ import { useState } from 'react';
import toast from 'react-hot-toast';
import { useWibuRealtime } from 'wibu-realtime';
import { funEditDetailProject, funGetDetailProject } from '../lib/api_project';
+import { ModalAddDetailTaskProject } from './modal_add_detail_task_project';
export default function EditDetailTaskProject() {
const [value, setValue] = useState<[Date | null, Date | null]>([null, null]);
@@ -19,6 +21,8 @@ export default function EditDetailTaskProject() {
const param = useParams<{ id: string }>()
const [openModal, setOpenModal] = useState(false)
const [loading, setLoading] = useState(true)
+ const [openModalDetailTask, setOpenModalDetailTask] = useState(false)
+ const [dataDetail, setDataDetail] = useState([])
const [loadingModal, setLoadingModal] = useState(false)
const tema = useHookstate(TEMA)
const [touched, setTouched] = useState({
@@ -40,11 +44,15 @@ export default function EditDetailTaskProject() {
try {
setLoadingModal(true)
+ const dataDetailFix = dataDetail.map((v: any) => ({
+ ...v,
+ date: moment(v.date).format("YYYY-MM-DD"),
+ }))
const res = await funEditDetailProject(param.id, {
title: name,
dateStart: moment(value[0]).format('YYYY-MM-DD'),
dateEnd: moment(value[1]).format('YYYY-MM-DD'),
-
+ dataDetail: dataDetailFix
})
if (res.success) {
@@ -77,6 +85,18 @@ export default function EditDetailTaskProject() {
new Date(moment(res.data.dateStart).format('YYYY-MM-DD')),
new Date(moment(res.data.dateEnd).format('YYYY-MM-DD')),
])
+
+ const res2 = await funGetDetailProject(param.id, 'detailTask');
+ if (res2.data.length == 0) {
+ const datanya = getDatesInRange(new Date(moment(res.data.dateStart).format('YYYY-MM-DD')) , new Date(moment(res.data.dateEnd).format('YYYY-MM-DD')))
+ setDataDetail(datanya.map((data: any) => ({
+ date: data,
+ timeStart: null,
+ timeEnd: null
+ })))
+ } else {
+ setDataDetail(res2.data)
+ }
} else {
toast.error(res.message);
}
@@ -112,8 +132,15 @@ export default function EditDetailTaskProject() {
const array = val.split(",")
if (array[0] == '' || array[1] == '') {
setTouched({ ...touched, date: true })
+ setDataDetail([])
} else {
setTouched({ ...touched, date: false })
+ const datanya = getDatesInRange(value[0]!, value[1]!)
+ setDataDetail(datanya.map((data: any) => ({
+ date: data,
+ timeStart: null,
+ timeEnd: null
+ })))
}
}
}
@@ -187,6 +214,16 @@ export default function EditDetailTaskProject() {
? Tanggal Tidak Boleh Kosong
: <>>
}
+
{loading ?
@@ -234,6 +271,17 @@ export default function EditDetailTaskProject() {
}
+
+ setOpenModalDetailTask(false)}
+ data={dataDetail}
+ onSubmit={(data) => {
+ setDataDetail(data)
+ setOpenModalDetailTask(false)
+ }}
+ />
+
setOpenModal(false)}
description="Apakah Anda yakin ingin mengubah data?"
onYes={(val) => {
diff --git a/src/module/project/ui/list_link_detail_project.tsx b/src/module/project/ui/list_link_detail_project.tsx
new file mode 100644
index 0000000..eb2440b
--- /dev/null
+++ b/src/module/project/ui/list_link_detail_project.tsx
@@ -0,0 +1,231 @@
+'use client'
+import { urlCompleted } from '@/lib/urlCompleted';
+import { globalRole, keyWibu, LayoutDrawer, TEMA } from '@/module/_global';
+import LayoutModal from '@/module/_global/layout/layout_modal';
+import { useHookstate } from '@hookstate/core';
+import { Box, Flex, Grid, Group, SimpleGrid, Stack, Text } from '@mantine/core';
+import { useMediaQuery, useShallowEffect } from '@mantine/hooks';
+import { useParams } from 'next/navigation';
+import { useState } from 'react';
+import toast from 'react-hot-toast';
+import { FaTrash } from 'react-icons/fa6';
+import { LuLink } from 'react-icons/lu';
+import { RiExternalLinkLine } from 'react-icons/ri';
+import { useWibuRealtime } from 'wibu-realtime';
+import { funDeleteLinkProject, funGetOneProjectById } from '../lib/api_project';
+import { IDataLinkProject } from '../lib/type_project';
+import { globalIsMemberProject } from '../lib/val_project';
+
+export default function ListLinkDetailProject() {
+ const [isData, setData] = useState([])
+ const param = useParams<{ id: string }>()
+ const [loading, setLoading] = useState(true)
+ const [loadingDelete, setLoadingDelete] = useState(false)
+ const [idData, setIdData] = useState('')
+ const [linkData, setLinkData] = useState('')
+ const [openDrawer, setOpenDrawer] = useState(false)
+ const [isOpenModal, setOpenModal] = useState(false)
+ const tema = useHookstate(TEMA)
+ const roleLogin = useHookstate(globalRole)
+ const memberProject = useHookstate(globalIsMemberProject)
+ const isMobile = useMediaQuery("(max-width: 350px)");
+ const [reason, setReason] = useState("")
+ const [dataRealTime, setDataRealtime] = useWibuRealtime({
+ WIBU_REALTIME_TOKEN: keyWibu,
+ project: "sdm"
+ })
+
+ async function getOneDataCancel() {
+ try {
+ const res = await funGetOneProjectById(param.id, 'data');
+ if (res.success) {
+ setReason(res.data.reason);
+ } else {
+ toast.error(res.message);
+ }
+
+ } catch (error) {
+ console.error(error);
+ toast.error("Gagal mendapatkan data Kegiatan, coba lagi nanti");
+ }
+ }
+
+ useShallowEffect(() => {
+ getOneDataCancel();
+ }, [param.id])
+
+ async function getOneData(loading: boolean) {
+ try {
+ setLoading(loading)
+ const res = await funGetOneProjectById(param.id, 'link');
+ if (res.success) {
+ setData(res.data)
+ } else {
+ toast.error(res.message);
+ }
+
+ } catch (error) {
+ console.error(error);
+ toast.error("Gagal mendapatkan link kegiatan, coba lagi nanti");
+ } finally {
+ setLoading(false)
+ }
+ }
+
+ useShallowEffect(() => {
+ getOneData(true);
+ }, [param.id])
+
+
+ async function onDelete() {
+ try {
+ setLoadingDelete(true)
+ const res = await funDeleteLinkProject(param.id, { idLink: idData });
+ if (res.success) {
+ setDataRealtime([{
+ category: "project-detail-link",
+ id: param.id,
+ }])
+ toast.success(res.message)
+ getOneData(false)
+ setIdData("")
+ setOpenDrawer(false)
+ } else {
+ toast.error(res.message);
+ }
+ } catch (error) {
+ console.error(error);
+ toast.error("Gagal menghapus link, coba lagi nanti");
+ } finally {
+ setOpenModal(false)
+ setLoadingDelete(false)
+ }
+
+ }
+
+ useShallowEffect(() => {
+ if (dataRealTime && dataRealTime.some((i: any) => i.category == 'project-detail-link' && i.id == param.id)) {
+ getOneData(false)
+ } else if (dataRealTime && dataRealTime.some((i: any) => i.category == 'project-detail-status' && i.id == param.id)) {
+ getOneDataCancel()
+ }
+ }, [dataRealTime])
+
+ return (
+ <>
+ {
+ isData.length > 0
+ &&
+
+ Link
+
+ {
+ isData.map((item, index) => {
+ return (
+ {
+ setLinkData(item.link)
+ setIdData(item.id)
+ setOpenDrawer(true)
+ }}
+ >
+
+
+
+
+
+ {item.link}
+
+
+
+
+
+ )
+ })
+ }
+
+
+
+ Menu} onClose={() => setOpenDrawer(false)}>
+
+
+
+ {
+ { window.open(urlCompleted(linkData), '_blank', 'noopener,noreferrer') }} justify={'center'} align={'center'} direction={'column'} >
+
+
+
+
+ Buka Link
+
+
+ }
+
+ {
+ (roleLogin.get() == "user" || roleLogin.get() == "coadmin") && !memberProject.get() ? <>>
+ :
+ {
+ reason == null ?
+ setOpenModal(true)
+ : setOpenModal(false)
+ }} justify={'center'} align={'center'} direction={'column'} >
+
+
+
+
+ Hapus
+
+
+ }
+
+
+
+
+
+
+ setOpenModal(false)}
+ description="Apakah Anda yakin ingin menghapus link ini? Link yang dihapus tidak dapat dikembalikan"
+ onYes={(val) => {
+ if (val) {
+ onDelete()
+ } else {
+ setOpenModal(false)
+ }
+ }} />
+
+
+ }
+ >
+ );
+}
+
diff --git a/src/module/project/ui/list_report_project.tsx b/src/module/project/ui/list_report_project.tsx
new file mode 100644
index 0000000..203faf1
--- /dev/null
+++ b/src/module/project/ui/list_report_project.tsx
@@ -0,0 +1,82 @@
+'use client'
+import { keyWibu, TEMA } from '@/module/_global';
+import { useHookstate } from '@hookstate/core';
+import { Box, Spoiler, Text } from '@mantine/core';
+import { useShallowEffect } from '@mantine/hooks';
+import { useParams } from 'next/navigation';
+import { useState } from 'react';
+import toast from 'react-hot-toast';
+import { useWibuRealtime } from 'wibu-realtime';
+import { funGetOneProjectById } from '../lib/api_project';
+import { globalRefreshProject } from '../lib/val_project';
+
+export default function ListReportDetailProject() {
+ const [isData, setData] = useState("")
+ const param = useParams<{ id: string }>()
+ const refresh = useHookstate(globalRefreshProject)
+ const tema = useHookstate(TEMA)
+ const [dataRealTime, setDataRealtime] = useWibuRealtime({
+ WIBU_REALTIME_TOKEN: keyWibu,
+ project: "sdm"
+ })
+
+
+ async function getOneData() {
+ try {
+ const res = await funGetOneProjectById(param.id, 'data');
+ if (res.success) {
+ setData(res.data.report)
+ } else {
+ toast.error(res.message);
+ }
+ } catch (error) {
+ console.error(error);
+ toast.error("Gagal mendapatkan list Laporan Kegiatan, coba lagi nanti");
+ }
+ }
+
+ useShallowEffect(() => {
+ getOneData();
+ }, [param.id])
+
+
+ useShallowEffect(() => {
+ if (dataRealTime && dataRealTime.some((i: any) => i.category == 'project-report' && i.id == param.id)) {
+ refresh.set(true)
+ getOneData()
+ }
+
+ }, [dataRealTime])
+
+ return (
+ <>
+ {
+ isData != "" && isData != null
+ &&
+
+
+ Laporan Kegiatan
+
+
+
+
+ {isData}
+
+
+
+
+ }
+ >
+ );
+}
+
diff --git a/src/module/project/ui/list_tugas_detail_project.tsx b/src/module/project/ui/list_tugas_detail_project.tsx
index c14c45a..5508cc1 100644
--- a/src/module/project/ui/list_tugas_detail_project.tsx
+++ b/src/module/project/ui/list_tugas_detail_project.tsx
@@ -2,17 +2,19 @@
import { globalRole, keyWibu, LayoutDrawer, SkeletonDetailListTugasTask, TEMA } from '@/module/_global';
import LayoutModal from '@/module/_global/layout/layout_modal';
import { useHookstate } from '@hookstate/core';
-import { Box, Center, Checkbox, Divider, Flex, Grid, Group, SimpleGrid, Stack, Text, Loader } from '@mantine/core';
+import { Box, Center, Checkbox, Divider, Flex, Grid, Group, Loader, SimpleGrid, Stack, Text } from '@mantine/core';
import { useShallowEffect } from '@mantine/hooks';
import { useParams, useRouter } from 'next/navigation';
import { useState } from 'react';
import toast from 'react-hot-toast';
import { AiOutlineFileDone, AiOutlineFileSync } from 'react-icons/ai';
import { FaCheck, FaPencil, FaTrash } from 'react-icons/fa6';
+import { IoTimeOutline } from 'react-icons/io5';
import { useWibuRealtime } from 'wibu-realtime';
import { funDeleteDetailProject, funGetOneProjectById, funUpdateStatusProject } from '../lib/api_project';
import { IDataListTaskProject } from '../lib/type_project';
import { globalIsMemberProject, globalRefreshProject, valStatusDetailProject } from '../lib/val_project';
+import { ModalListDetailTaskProject } from './modal_list_detail_task_project';
export default function ListTugasDetailProject() {
const [isData, setData] = useState([])
@@ -32,6 +34,7 @@ export default function ListTugasDetailProject() {
const [loadingStatus, setLoadingStatus] = useState(false)
const [pilihStatus, setPilihStatus] = useState(0)
const [reason, setReason] = useState("")
+ const [openModalDetailTask, setOpenModalDetailTask] = useState(false)
const [dataRealTime, setDataRealtime] = useWibuRealtime({
WIBU_REALTIME_TOKEN: keyWibu,
project: "sdm"
@@ -259,6 +262,15 @@ export default function ListTugasDetailProject() {
+ {setOpenModalDetailTask(true)}} justify={'center'} align={'center'} direction={'column'} >
+
+
+
+
+ Detail Waktu
+
+
+
{ setOpenModal(true) }} justify={'center'} align={'center'} direction={'column'} >
@@ -272,6 +284,8 @@ export default function ListTugasDetailProject() {
+ setOpenModalDetailTask(false)} task={idData} />
+
setOpenModal(false)}
description="Apakah Anda yakin ingin menghapus tahapan tugas ini?"
onYes={(val) => {
diff --git a/src/module/project/ui/modal_add_detail_task_project.tsx b/src/module/project/ui/modal_add_detail_task_project.tsx
new file mode 100644
index 0000000..09235f8
--- /dev/null
+++ b/src/module/project/ui/modal_add_detail_task_project.tsx
@@ -0,0 +1,100 @@
+import { TEMA } from "@/module/_global";
+import { Box, Button, Grid, Modal, SimpleGrid, Text } from "@mantine/core";
+import { TimeInput } from "@mantine/dates";
+import moment from "moment";
+import { useEffect, useState } from "react";
+
+export function ModalAddDetailTaskProject({ open, onClose, data, onSubmit }: { open: boolean, onClose: () => void, data: any[], onSubmit: (data: any) => void }) {
+ const [dataDetail, setDataDetail] = useState(data)
+ const [touched, setTouched] = useState([])
+
+ useEffect(() => {
+ setDataDetail(data)
+ }, [data])
+
+ function onInputTime(date: any, value: any, cat: 'timeStart' | 'timeEnd') {
+ if (cat == "timeEnd") {
+ if (value == "" || dataDetail.find((data: any) => data.date == date)?.timeStart > value) {
+ setTouched((touched: any) => [...touched, { date: date, timeEnd: true }])
+ } else {
+ setTouched((touched: any) => touched.filter((item: any) => item.date != date))
+ }
+ } else {
+ if (value == "" || dataDetail.find((data: any) => data.date == date)?.timeEnd < value) {
+ setTouched((touched: any) => [...touched, { date: date, timeEnd: true }])
+ } else {
+ setTouched((touched: any) => touched.filter((item: any) => item.date != date))
+ }
+ }
+
+ setDataDetail(dataDetail.map((data: any) => {
+ if (data.date == date) {
+ return {
+ ...data,
+ [cat]: value
+ }
+ }
+ return data
+ }))
+ }
+
+ return (
+ onClose()} centered withCloseButton={false} title={"Detail Tanggal dan Waktu Tugas"}>
+
+
+ {
+ dataDetail.map((data: any, index: any) => (
+
+ {moment(data.date).format('DD-MM-YYYY')}
+
+ onInputTime(data.date, event.target.value, 'timeStart')}
+ />
+ onInputTime(data.date, event.target.value, 'timeEnd')}
+ error={touched.find((item: any) => item.date == data.date)?.timeEnd ? "Waktu akhir harus lebih dari waktu awal" : ""}
+ />
+
+
+ ))
+ }
+
+
+
+
+
+
+
+
+
+
+
+
+ )
+}
\ No newline at end of file
diff --git a/src/module/project/ui/modal_list_detail_task_project.tsx b/src/module/project/ui/modal_list_detail_task_project.tsx
new file mode 100644
index 0000000..5df6e3d
--- /dev/null
+++ b/src/module/project/ui/modal_list_detail_task_project.tsx
@@ -0,0 +1,99 @@
+import { Box, Modal, SimpleGrid, Skeleton, Text } from "@mantine/core";
+import { TimeInput } from "@mantine/dates";
+import { useShallowEffect } from "@mantine/hooks";
+import moment from "moment";
+import { useState } from "react";
+import toast from "react-hot-toast";
+import { funGetDetailProject } from "../lib/api_project";
+
+export function ModalListDetailTaskProject({ open, onClose, task, }: { open: boolean, onClose: () => void, task: string }) {
+ const [dataDetail, setDataDetail] = useState([])
+ const [loading, setLoading] = useState(false)
+
+ async function getData() {
+ try {
+ setLoading(true)
+ const response = await funGetDetailProject(task, 'detailTask')
+ if (response.success) {
+ setDataDetail(response.data)
+ } else {
+ toast.error(response.message)
+ }
+ } catch (error) {
+ console.error(error);
+ toast.error("Gagal mendapatkan detail tugas Kegiatan, coba lagi nanti");
+ } finally {
+ setLoading(false)
+ }
+ }
+
+ useShallowEffect(() => {
+ if(task!=""){
+ getData()
+ }
+ }, [task])
+
+ return (
+ onClose()} centered withCloseButton={false} title={"Detail Tanggal dan Waktu Tugas"}>
+
+
+ {
+ loading ?
+ Array(5)
+ .fill(null)
+ .map((_, i) => (
+
+
+
+
+
+ ))
+ :
+ dataDetail.length > 0 ?
+ dataDetail.map((data: any, index: any) => (
+
+ {moment(data.date).format('DD-MM-YYYY')}
+
+
+
+
+
+ ))
+ :
+ Tidak ada detail tugas
+ }
+
+
+
+ )
+}
\ No newline at end of file
diff --git a/src/module/project/ui/navbar_detail_project.tsx b/src/module/project/ui/navbar_detail_project.tsx
index f3ff1ea..02c37ab 100644
--- a/src/module/project/ui/navbar_detail_project.tsx
+++ b/src/module/project/ui/navbar_detail_project.tsx
@@ -3,17 +3,19 @@ import { globalRole, keyWibu, LayoutDrawer, LayoutNavbarNew, TEMA } from '@/modu
import LayoutModal from '@/module/_global/layout/layout_modal';
import { funGetUserByCookies } from '@/module/auth';
import { useHookstate } from '@hookstate/core';
-import { ActionIcon, Box, Flex, SimpleGrid, Stack, Text } from '@mantine/core';
+import { ActionIcon, Box, Button, Flex, Grid, Modal, SimpleGrid, Stack, Text, TextInput } from '@mantine/core';
import { useShallowEffect } from '@mantine/hooks';
import { useParams, useRouter } from 'next/navigation';
import { useState } from 'react';
import toast from 'react-hot-toast';
+import { AiFillFileText } from 'react-icons/ai';
import { FaFileCirclePlus, FaPencil, FaTrash, FaUsers } from 'react-icons/fa6';
import { HiMenu } from 'react-icons/hi';
import { IoAddCircle } from 'react-icons/io5';
+import { LuLink } from 'react-icons/lu';
import { MdCancel } from 'react-icons/md';
import { useWibuRealtime } from 'wibu-realtime';
-import { funDeleteProject, funGetOneProjectById } from '../lib/api_project';
+import { funAddLinkProject, funDeleteProject, funGetOneProjectById } from '../lib/api_project';
import { globalIsMemberProject } from '../lib/val_project';
export default function NavbarDetailProject() {
@@ -28,7 +30,10 @@ export default function NavbarDetailProject() {
const tema = useHookstate(TEMA)
const [reason, setReason] = useState("")
const [openModal, setOpenModal] = useState(false)
+ const [openNewLink, setOpenNewLink] = useState(false)
const [loadingModal, setLoadingModal] = useState(false)
+ const [loadingLink, setLoadingLink] = useState(false)
+ const [valLink, setValLink] = useState("")
const [dataRealTime, setDataRealtime] = useWibuRealtime({
WIBU_REALTIME_TOKEN: keyWibu,
project: "sdm"
@@ -52,6 +57,30 @@ export default function NavbarDetailProject() {
}
}
+ async function addLinkProject() {
+ try {
+ setLoadingLink(true)
+ const res = await funAddLinkProject(param.id, { link: valLink });
+ if (res.success) {
+ setDataRealtime([{
+ category: "project-detail-link",
+ id: param.id,
+ user: res.user
+ }])
+ toast.success(res.message)
+ } else {
+ toast.error(res.message)
+ }
+ } catch (error) {
+ console.error(error);
+ toast.error("Gagal menambahkan link, coba lagi nanti");
+ } finally {
+ setLoadingLink(false)
+ setOpenNewLink(false)
+ setValLink("")
+ }
+ }
+
async function deleteDataProject() {
try {
setLoadingModal(true)
@@ -110,7 +139,7 @@ export default function NavbarDetailProject() {
} />
- setOpen(false)}>
+ setOpen(false)} size='md'>
+ {
+ if (reason == null) {
+ setOpen(false)
+ setOpenNewLink(true)
+ } else {
+ null
+ }
+ }}
+ >
+
+
+
+
+ Tambah link
+
+
+
+ {
+ if (reason == null) {
+ router.push(param.id + '/report')
+ } else {
+ null
+ }
+ }}
+ >
+
+
+
+
+ Laporan
+
+
+
{
(roleLogin.get() != "user" && roleLogin.get() != "coadmin") &&
<>
@@ -229,11 +299,50 @@ export default function NavbarDetailProject() {
-
+
setOpenModal(false)}
description="Apakah Anda yakin ingin menghapus kegiatan ini?"
onYes={(val) => { val ? deleteDataProject() : setOpenModal(false) }} />
+
+ setOpenNewLink(false)} centered withCloseButton={false}>
+
+ Tambah Link
+
+ setValLink(e.target.value)}
+ />
+
+
+
+
+
+
+
+
+
+
+
+
>
);
}
diff --git a/src/module/task/index.ts b/src/module/task/index.ts
index fcaa02e..dfca2b6 100644
--- a/src/module/task/index.ts
+++ b/src/module/task/index.ts
@@ -1,12 +1,15 @@
import AddDetailTask from "./ui/add_detail_task";
import AddFileDetailTask from "./ui/add_file_detail_task";
import AddMemberDetailTask from "./ui/add_member_detail_task";
+import AddReportTask from "./ui/add_report_detail_task";
import CancelTask from "./ui/cancel_task";
import ViewDateEndTask from "./ui/create_date_end_task";
import CreateTask from "./ui/create_task";
import CreateUsersProject from "./ui/create_users_project";
import ListAnggotaDetailTask from "./ui/detail_list_anggota_task";
import ListFileDetailTask from "./ui/detail_list_file_task";
+import ListLinkDetailTask from "./ui/detail_list_link_task";
+import ListReportDetailTask from "./ui/detail_list_report_task";
import ListTugasDetailTask from "./ui/detail_list_tugas_task";
import ProgressDetailTask from "./ui/detail_progress_task";
import EditDetailTask from "./ui/edit_detail_task";
@@ -32,4 +35,7 @@ export { AddDetailTask }
export { AddMemberDetailTask }
export { CancelTask }
export { EditTask }
-export { AddFileDetailTask }
\ No newline at end of file
+export { AddFileDetailTask }
+export { ListLinkDetailTask }
+export { AddReportTask }
+export { ListReportDetailTask }
\ No newline at end of file
diff --git a/src/module/task/lib/api_task.ts b/src/module/task/lib/api_task.ts
index 077bd98..f4d3496 100644
--- a/src/module/task/lib/api_task.ts
+++ b/src/module/task/lib/api_task.ts
@@ -44,8 +44,8 @@ export const funUpdateStatusDetailTask = async (path: string, data: { status: nu
};
-export const funGetDetailTask = async (path: string) => {
- const response = await fetch(`/api/task/detail/${path}`);
+export const funGetDetailTask = async (path: string, kat?:string) => {
+ const response = await fetch(`/api/task/detail/${path}${(kat) ? `?cat=${kat}` : ''}`);
return await response.json().catch(() => null);
}
@@ -61,6 +61,17 @@ export const funEditDetailTask = async (path: string, data: IFormDateTask) => {
return await response.json().catch(() => null);
};
+export const funEditReportTask = async (path: string, data: { report: string }) => {
+ const response = await fetch(`/api/task/${path}/lainnya`, {
+ method: "PUT",
+ headers: {
+ "Content-Type": "application/json",
+ },
+ body: JSON.stringify(data),
+ });
+ return await response.json().catch(() => null);
+};
+
export const funCreateDetailTask = async (path: string, data: IFormAddDetailTask) => {
const response = await fetch(`/api/task/${path}`, {
@@ -154,4 +165,27 @@ export const funDeleteTask = async (path: string) => {
},
});
return await response.json().catch(() => null);
-};
\ No newline at end of file
+};
+
+export const funAddLinkTask = async (path: string, data: { link: string, idDivision: string }) => {
+ const response = await fetch(`/api/task/${path}/link`, {
+ method: "POST",
+ headers: {
+ "Content-Type": "application/json",
+ },
+ body: JSON.stringify(data),
+ });
+ return await response.json().catch(() => null);
+};
+
+
+export const funDeleteLinkTask = async (path: string, data: { idLink: string }) => {
+ const response = await fetch(`/api/task/${path}/link`, {
+ method: "DELETE",
+ headers: {
+ "Content-Type": "application/json",
+ },
+ body: JSON.stringify(data),
+ });
+ return await response.json().catch(() => null);
+};
diff --git a/src/module/task/lib/type_task.ts b/src/module/task/lib/type_task.ts
index ed88fb0..e7c181f 100644
--- a/src/module/task/lib/type_task.ts
+++ b/src/module/task/lib/type_task.ts
@@ -16,14 +16,16 @@ export interface IFormMemberTask {
export interface IFormDateTask {
dateStart: string,
dateEnd: string,
- title: string
+ title: string,
+ dataDetail: any[]
}
export interface IFormAddDetailTask {
dateStart: string,
dateEnd: string,
title: string
- idDivision: string
+ idDivision: string,
+ dataDetail: any[]
}
@@ -70,4 +72,9 @@ export interface IDataFileTaskDivision {
extension: string,
nameInStorage: string,
idStorage: string
-}
\ No newline at end of file
+}
+
+export interface IDataLinkTaskDivision {
+ id: string
+ link: string
+}
diff --git a/src/module/task/ui/add_detail_task.tsx b/src/module/task/ui/add_detail_task.tsx
index 7feae9c..b6af2b9 100644
--- a/src/module/task/ui/add_detail_task.tsx
+++ b/src/module/task/ui/add_detail_task.tsx
@@ -1,4 +1,5 @@
"use client";
+import { getDatesInRange } from "@/lib/getDatesInRange";
import { keyWibu, LayoutNavbarNew, TEMA } from "@/module/_global";
import LayoutModal from "@/module/_global/layout/layout_modal";
import { useHookstate } from "@hookstate/core";
@@ -11,6 +12,7 @@ import { useState } from "react";
import toast from "react-hot-toast";
import { useWibuRealtime } from "wibu-realtime";
import { funCreateDetailTask } from "../lib/api_task";
+import { ModalAddDetailTugasTask } from "./modal_add_detail_tugas_task";
export default function AddDetailTask() {
const [value, setValue] = useState<[Date | null, Date | null]>([null, null]);
@@ -18,6 +20,8 @@ export default function AddDetailTask() {
const [title, setTitle] = useState("")
const [openModal, setOpenModal] = useState(false)
const [loadingModal, setLoadingModal] = useState(false)
+ const [openModalDetailTask, setOpenModalDetailTask] = useState(false)
+ const [dataDetail, setDataDetail] = useState([])
const param = useParams<{ id: string, detail: string }>()
const tema = useHookstate(TEMA)
const [acuan, setAcuan] = useState(false)
@@ -57,11 +61,17 @@ export default function AddDetailTask() {
async function onSubmit() {
try {
setLoadingModal(true)
+ const dataDetailFix = dataDetail.map((v: any) => ({
+ ...v,
+ date: moment(v.date).format("YYYY-MM-DD"),
+ }))
+
const res = await funCreateDetailTask(param.detail, {
title,
dateStart: (value[0] != null) ? moment(value[0]).format('YYYY-MM-DD') : moment(new Date).format('YYYY-MM-DD'),
dateEnd: (value[1] != null) ? moment(value[1]).format('YYYY-MM-DD') : moment(new Date).format('YYYY-MM-DD'),
- idDivision: param.id
+ idDivision: param.id,
+ dataDetail: dataDetailFix
})
if (res.success) {
@@ -96,8 +106,15 @@ export default function AddDetailTask() {
const array = val.split(",")
if (array[0] == '' || array[1] == '') {
setTouched({ ...touched, date: true })
+ setDataDetail([])
} else {
setTouched({ ...touched, date: false })
+ const datanya = getDatesInRange(value[0]!, value[1]!)
+ setDataDetail(datanya.map((data: any) => ({
+ date: data,
+ timeStart: null,
+ timeEnd: null
+ })))
}
}
}
@@ -163,6 +180,16 @@ export default function AddDetailTask() {
? Tanggal Tidak Boleh Kosong
: <>>
}
+
+ setOpenModalDetailTask(false)}
+ data={dataDetail}
+ onSubmit={(data) => {
+ setDataDetail(data)
+ setOpenModalDetailTask(false)
+ }} />
+
setOpenModal(false)}
description="Apakah Anda yakin ingin menambahkan tugas?"
onYes={(val) => {
diff --git a/src/module/task/ui/add_report_detail_task.tsx b/src/module/task/ui/add_report_detail_task.tsx
new file mode 100644
index 0000000..a7fac41
--- /dev/null
+++ b/src/module/task/ui/add_report_detail_task.tsx
@@ -0,0 +1,156 @@
+"use client"
+import { keyWibu, LayoutNavbarNew, TEMA } from '@/module/_global';
+import LayoutModal from '@/module/_global/layout/layout_modal';
+import { useHookstate } from '@hookstate/core';
+import { Box, Button, rem, Skeleton, Stack, Textarea } from '@mantine/core';
+import { useShallowEffect } from '@mantine/hooks';
+import { useParams, useRouter } from 'next/navigation';
+import { useState } from 'react';
+import toast from 'react-hot-toast';
+import { useWibuRealtime } from 'wibu-realtime';
+import { funEditReportTask, funGetTaskDivisionById } from '../lib/api_task';
+
+export default function AddReportTask() {
+ const router = useRouter()
+ const [report, setReport] = useState("")
+ const [openModal, setOpenModal] = useState(false)
+ const param = useParams<{ id: string, detail: string }>()
+ const [loading, setLoading] = useState(true)
+ const [loadingSubmit, setLoadingSubmit] = useState(false)
+ const tema = useHookstate(TEMA)
+ const [touched, setTouched] = useState({
+ report: false,
+ });
+ const [dataRealTime, setDataRealtime] = useWibuRealtime({
+ WIBU_REALTIME_TOKEN: keyWibu,
+ project: "sdm"
+ })
+
+ async function onSubmit() {
+ try {
+ setLoadingSubmit(true)
+ const res = await funEditReportTask(param.detail, { report })
+ if (res.success) {
+ setDataRealtime([{
+ category: "tugas-detail-report",
+ id: param.detail,
+ }])
+ toast.success(res.message)
+ router.push("./")
+ } else {
+ toast.error(res.message)
+ }
+ } catch (error) {
+ console.error(error)
+ toast.error("Gagal mengedit Laporan Kegiatan, coba lagi nanti")
+ } finally {
+ setLoadingSubmit(false)
+ setOpenModal(false)
+ }
+ }
+
+ function onCheck() {
+ if (report == "") {
+ setTouched({ ...touched, report: true })
+ return false
+ }
+ setOpenModal(true)
+ }
+
+
+
+ function onValidation(kategori: string, val: string) {
+ if (kategori == 'report') {
+ setReport(val)
+ if (val === "") {
+ setTouched({ ...touched, report: true })
+ } else {
+ setTouched({ ...touched, report: false })
+ }
+ }
+ }
+
+ async function getOneData() {
+ try {
+ setLoading(true)
+ const res = await funGetTaskDivisionById(param.detail, 'data');
+ if (res.success) {
+ setReport(res.data.report);
+ } else {
+ toast.error(res.message);
+ }
+ } catch (error) {
+ console.error(error);
+ toast.error("Gagal mendapatkan data Tugas, coba lagi nanti");
+ } finally {
+ setLoading(false);
+ }
+ }
+
+ useShallowEffect(() => {
+ getOneData();
+ }, [param.detail])
+
+
+ return (
+
+
+
+
+ {loading ?
+
+ :
+
+
+
+ {loading ?
+
+ :
+
+ }
+
+
+
+ setOpenModal(false)}
+ description="Apakah Anda yakin ingin mengedit Laporan Kegiatan ini?"
+ onYes={(val) => {
+ if (val) {
+ onSubmit()
+ } else {
+ setOpenModal(false)
+ }
+ }} />
+
+ );
+}
+
diff --git a/src/module/task/ui/create_date_end_task.tsx b/src/module/task/ui/create_date_end_task.tsx
index 0b769eb..cd8a31f 100644
--- a/src/module/task/ui/create_date_end_task.tsx
+++ b/src/module/task/ui/create_date_end_task.tsx
@@ -1,4 +1,5 @@
"use client";
+import { getDatesInRange } from "@/lib/getDatesInRange";
import { LayoutNavbarNew, TEMA } from "@/module/_global";
import { useHookstate } from "@hookstate/core";
import { ActionIcon, Box, Button, Flex, Group, rem, SimpleGrid, Stack, Text, TextInput } from "@mantine/core";
@@ -9,13 +10,16 @@ import { useState } from "react";
import toast from "react-hot-toast";
import { HiChevronLeft } from "react-icons/hi2";
import { IFormDateTask } from "../lib/type_task";
+import { ModalAddDetailTugasTask } from "./modal_add_detail_tugas_task";
export default function ViewDateEndTask({ onClose, onSet }: { onClose: (val: boolean) => void, onSet: (val: IFormDateTask) => void }) {
const [value, setValue] = useState<[Date | null, Date | null]>([null, null]);
const [title, setTitle] = useState("")
const [acuan, setAcuan] = useState(false)
+ const [dataDetail, setDataDetail] = useState([])
const tema = useHookstate(TEMA)
+ const [openModalDetailTask, setOpenModalDetailTask] = useState(false)
const [touched, setTouched] = useState({
title: false,
date: false
@@ -28,10 +32,16 @@ export default function ViewDateEndTask({ onClose, onSet }: { onClose: (val: boo
if (title == "")
return toast.error("Error! harus memasukkan judul tugas")
+ const dataDetailFix = dataDetail.map((v: any) => ({
+ ...v,
+ date: moment(v.date).format("YYYY-MM-DD"),
+ }))
+
onSet({
dateStart: moment(value[0]).format('YYYY-MM-DD'),
dateEnd: moment(value[1]).format('YYYY-MM-DD'),
- title: title
+ title: title,
+ dataDetail: dataDetailFix
})
}
@@ -73,8 +83,15 @@ export default function ViewDateEndTask({ onClose, onSet }: { onClose: (val: boo
const array = val.split(",")
if (array[0] == '' || array[1] == '') {
setTouched({ ...touched, date: true })
+ setDataDetail([])
} else {
setTouched({ ...touched, date: false })
+ const datanya = getDatesInRange(value[0]!, value[1]!)
+ setDataDetail(datanya.map((data: any) => ({
+ date: data,
+ timeStart: null,
+ timeEnd: null
+ })))
}
}
}
@@ -145,6 +162,16 @@ export default function ViewDateEndTask({ onClose, onSet }: { onClose: (val: boo
? Tanggal Tidak Boleh Kosong
: <>>
}
+
+
+ setOpenModalDetailTask(false)}
+ data={dataDetail}
+ onSubmit={(data) => {
+ setDataDetail(data)
+ setOpenModalDetailTask(false)
+ }}
+ />
);
}
diff --git a/src/module/task/ui/create_task.tsx b/src/module/task/ui/create_task.tsx
index d83564a..b8cc5f4 100644
--- a/src/module/task/ui/create_task.tsx
+++ b/src/module/task/ui/create_task.tsx
@@ -223,7 +223,7 @@ export default function CreateTask() {
setIndexDelTask(i)
setOpenDrawerTask(true)
}}>
-
+
)
})
diff --git a/src/module/task/ui/detail_list_link_task.tsx b/src/module/task/ui/detail_list_link_task.tsx
new file mode 100644
index 0000000..2e84f45
--- /dev/null
+++ b/src/module/task/ui/detail_list_link_task.tsx
@@ -0,0 +1,230 @@
+'use client'
+import { urlCompleted } from '@/lib/urlCompleted';
+import { globalRole, keyWibu, LayoutDrawer, TEMA } from '@/module/_global';
+import LayoutModal from '@/module/_global/layout/layout_modal';
+import { globalIsMemberDivision } from '@/module/division_new';
+import { useHookstate } from '@hookstate/core';
+import { Box, Flex, Grid, Group, SimpleGrid, Stack, Text } from '@mantine/core';
+import { useMediaQuery, useShallowEffect } from '@mantine/hooks';
+import { useParams } from 'next/navigation';
+import { useState } from 'react';
+import toast from 'react-hot-toast';
+import { FaTrash } from 'react-icons/fa6';
+import { LuLink } from 'react-icons/lu';
+import { RiExternalLinkLine } from 'react-icons/ri';
+import { useWibuRealtime } from 'wibu-realtime';
+import { funDeleteLinkTask, funGetTaskDivisionById } from '../lib/api_task';
+import { IDataLinkTaskDivision } from '../lib/type_task';
+
+export default function ListLinkDetailTask() {
+ const isMobile = useMediaQuery("(max-width: 350px)");
+ const roleLogin = useHookstate(globalRole)
+ const memberDivision = useHookstate(globalIsMemberDivision)
+ const [isData, setData] = useState([])
+ const [loading, setLoading] = useState(true)
+ const param = useParams<{ id: string, detail: string }>()
+ const [openDrawer, setOpenDrawer] = useState(false)
+ const [isOpenModal, setOpenModal] = useState(false)
+ const [loadingModal, setLoadingModal] = useState(false)
+ const [linkData, setLinkData] = useState('')
+ const [idData, setIdData] = useState('')
+ const tema = useHookstate(TEMA)
+ const [reason, setReason] = useState("")
+ const [dataRealTime, setDataRealtime] = useWibuRealtime({
+ WIBU_REALTIME_TOKEN: keyWibu,
+ project: "sdm"
+ })
+
+
+ async function getOneDataCancel() {
+ try {
+ const res = await funGetTaskDivisionById(param.detail, 'data');
+ if (res.success) {
+ setReason(res.data.reason);
+ } else {
+ toast.error(res.message);
+ }
+
+ } catch (error) {
+ console.error(error);
+ toast.error("Gagal mendapatkan data tugas divisi, coba lagi nanti");
+ }
+ }
+
+ useShallowEffect(() => {
+ getOneDataCancel();
+ }, [param.detail])
+
+ async function getOneData(loading: boolean) {
+ try {
+ setLoading(loading)
+ const res = await funGetTaskDivisionById(param.detail, 'link');
+ if (res.success) {
+ setData(res.data)
+ } else {
+ toast.error(res.message);
+ }
+ } catch (error) {
+ console.error(error);
+ toast.error("Gagal mendapatkan file tugas divisi, coba lagi nanti");
+ } finally {
+ setLoading(false)
+ }
+ }
+
+ useShallowEffect(() => {
+ getOneData(true);
+ }, [param.detail])
+
+
+ async function onDelete() {
+ try {
+ setLoadingModal(true)
+ const res = await funDeleteLinkTask(param.detail, { idLink: idData });
+ if (res.success) {
+ setDataRealtime([{
+ category: "tugas-detail-link",
+ id: param.detail,
+ }])
+ toast.success(res.message)
+ getOneData(false)
+ setIdData("")
+ setOpenDrawer(false)
+ } else {
+ toast.error(res.message);
+ }
+ } catch (error) {
+ console.error(error);
+ toast.error("Gagal menghapus file, coba lagi nanti");
+ } finally {
+ setLoadingModal(false)
+ setOpenModal(false)
+ }
+ }
+
+ useShallowEffect(() => {
+ if (dataRealTime && dataRealTime.some((i: any) => i.category == 'tugas-detail-link' && i.id == param.detail)) {
+ getOneData(false)
+ } else if (dataRealTime && dataRealTime.some((i: any) => i.category == 'tugas-detail-status' && i.id == param.detail)) {
+ getOneDataCancel()
+ }
+ }, [dataRealTime])
+
+ return (
+ <>
+ {
+ isData.length > 0
+ &&
+
+ Link
+
+ {
+ isData.map((item, index) => {
+ return (
+ {
+ setLinkData(item.link)
+ setIdData(item.id)
+ setOpenDrawer(true)
+ }}
+ >
+
+
+
+
+
+ {item.link}
+
+
+
+
+
+ )
+ })
+ }
+
+
+
+ Menu} onClose={() => setOpenDrawer(false)}>
+
+
+
+ {
+ { window.open(urlCompleted(linkData), '_blank', 'noopener,noreferrer') }} justify={'center'} align={'center'} direction={'column'} >
+
+
+
+
+ Buka Link
+
+
+ }
+
+ {
+ (roleLogin.get() == "user" || roleLogin.get() == "coadmin") && !memberDivision.get() ? <>>
+ :
+ {
+ reason == null ?
+ setOpenModal(true)
+ : setOpenModal(false)
+ }} justify={'center'} align={'center'} direction={'column'} >
+
+
+
+
+ Hapus
+
+
+ }
+
+
+
+
+
+
+ setOpenModal(false)}
+ description="Apakah Anda yakin ingin menghapus link ini? Link yang dihapus tidak dapat dikembalikan"
+ onYes={(val) => {
+ if (val) {
+ onDelete()
+ } else {
+ setOpenModal(false)
+ }
+ }} />
+
+
+ }
+ >
+ );
+}
+
diff --git a/src/module/task/ui/detail_list_report_task.tsx b/src/module/task/ui/detail_list_report_task.tsx
new file mode 100644
index 0000000..49e7aff
--- /dev/null
+++ b/src/module/task/ui/detail_list_report_task.tsx
@@ -0,0 +1,83 @@
+'use client'
+import { keyWibu, TEMA } from '@/module/_global';
+import { useHookstate } from '@hookstate/core';
+import { Box, Spoiler, Text } from '@mantine/core';
+import { useShallowEffect } from '@mantine/hooks';
+import { useParams } from 'next/navigation';
+import { useState } from 'react';
+import toast from 'react-hot-toast';
+import { useWibuRealtime } from 'wibu-realtime';
+import { funGetTaskDivisionById } from '../lib/api_task';
+import { globalRefreshTask } from '../lib/val_task';
+
+
+export default function ListReportDetailTask() {
+ const [isData, setData] = useState("")
+ const param = useParams<{ id: string, detail: string }>()
+ const refresh = useHookstate(globalRefreshTask)
+ const tema = useHookstate(TEMA)
+ const [dataRealTime, setDataRealtime] = useWibuRealtime({
+ WIBU_REALTIME_TOKEN: keyWibu,
+ project: "sdm"
+ })
+
+
+ async function getOneData() {
+ try {
+ const res = await funGetTaskDivisionById(param.detail, 'data');
+ if (res.success) {
+ setData(res.data.report)
+ } else {
+ toast.error(res.message);
+ }
+ } catch (error) {
+ console.error(error);
+ toast.error("Gagal mendapatkan list Laporan Kegiatan, coba lagi nanti");
+ }
+ }
+
+ useShallowEffect(() => {
+ getOneData();
+ }, [param.detail])
+
+
+ useShallowEffect(() => {
+ if (dataRealTime && dataRealTime.some((i: any) => i.category == 'tugas-detail-report' && i.id == param.detail)) {
+ refresh.set(true)
+ getOneData()
+ }
+
+ }, [dataRealTime])
+
+ return (
+ <>
+ {
+ isData != "" && isData != null
+ &&
+
+
+ Laporan Kegiatan
+
+
+
+
+ {isData}
+
+
+
+
+ }
+ >
+ );
+}
+
diff --git a/src/module/task/ui/detail_list_tugas_task.tsx b/src/module/task/ui/detail_list_tugas_task.tsx
index aff1535..849d194 100644
--- a/src/module/task/ui/detail_list_tugas_task.tsx
+++ b/src/module/task/ui/detail_list_tugas_task.tsx
@@ -1,8 +1,9 @@
'use client'
import { globalRole, keyWibu, LayoutDrawer, SkeletonDetailListTugasTask, TEMA } from "@/module/_global"
import LayoutModal from "@/module/_global/layout/layout_modal"
+import { globalIsMemberDivision } from "@/module/division_new"
import { useHookstate } from "@hookstate/core"
-import { Box, Center, Checkbox, Divider, Flex, Grid, Group, SimpleGrid, Stack, Text, Loader } from "@mantine/core"
+import { Box, Center, Checkbox, Divider, Flex, Grid, Group, Loader, SimpleGrid, Stack, Text } from "@mantine/core"
import { useShallowEffect } from "@mantine/hooks"
import "moment/locale/id"
import { useParams, useRouter } from "next/navigation"
@@ -10,15 +11,17 @@ import { useState } from "react"
import toast from "react-hot-toast"
import { AiOutlineFileDone, AiOutlineFileSync } from "react-icons/ai"
import { FaCheck, FaPencil, FaTrash } from "react-icons/fa6"
+import { IoTimeOutline } from "react-icons/io5"
import { useWibuRealtime } from "wibu-realtime"
import { funDeleteDetailTask, funGetTaskDivisionById, funUpdateStatusDetailTask } from "../lib/api_task"
import { IDataListTaskDivision } from "../lib/type_task"
import { globalRefreshTask, valStatusDetailTask } from "../lib/val_task"
-import { globalIsMemberDivision } from "@/module/division_new"
+import { ModalListDetailTugasTask } from "./modal_list_tugas_task"
export default function ListTugasDetailTask() {
const roleLogin = useHookstate(globalRole)
const memberDivision = useHookstate(globalIsMemberDivision)
+ const [openModalDetailTask, setOpenModalDetailTask] = useState(false)
const [openDrawer, setOpenDrawer] = useState(false)
const [openDrawerStatus, setOpenDrawerStatus] = useState(false)
const [isOpenModal, setOpenModal] = useState(false)
@@ -268,6 +271,15 @@ export default function ListTugasDetailTask() {
+ { setOpenModalDetailTask(true) }} justify={'center'} align={'center'} direction={'column'} >
+
+
+
+
+ Detail Waktu
+
+
+
{ setOpenModal(true) }} justify={'center'} align={'center'} direction={'column'} >
@@ -281,6 +293,8 @@ export default function ListTugasDetailTask() {
+ setOpenModalDetailTask(false)} task={idData} />
+
setOpenModal(false)}
description="Apakah Anda yakin ingin menghapus tugas ini?"
onYes={(val) => {
diff --git a/src/module/task/ui/edit_detail_task.tsx b/src/module/task/ui/edit_detail_task.tsx
index 13b34a0..d5a355e 100644
--- a/src/module/task/ui/edit_detail_task.tsx
+++ b/src/module/task/ui/edit_detail_task.tsx
@@ -1,4 +1,5 @@
"use client";
+import { getDatesInRange } from "@/lib/getDatesInRange";
import { LayoutNavbarNew, TEMA } from "@/module/_global";
import LayoutModal from "@/module/_global/layout/layout_modal";
import { useHookstate } from "@hookstate/core";
@@ -10,11 +11,14 @@ import { useParams, useRouter } from "next/navigation";
import { useState } from "react";
import toast from "react-hot-toast";
import { funEditDetailTask, funGetDetailTask } from "../lib/api_task";
+import { ModalAddDetailTugasTask } from "./modal_add_detail_tugas_task";
export default function EditDetailTask() {
const [value, setValue] = useState<[Date | null, Date | null]>([null, null]);
const router = useRouter()
+ const [openModalDetailTask, setOpenModalDetailTask] = useState(false)
+ const [dataDetail, setDataDetail] = useState([])
const [title, setTitle] = useState("")
const param = useParams<{ id: string, detail: string }>()
const [openModal, setOpenModal] = useState(false)
@@ -36,10 +40,15 @@ export default function EditDetailTask() {
try {
setLoadingModal(true)
+ const dataDetailFix = dataDetail.map((v: any) => ({
+ ...v,
+ date: moment(v.date).format("YYYY-MM-DD"),
+ }))
const res = await funEditDetailTask(param.detail, {
title: title,
dateStart: moment(value[0]).format('YYYY-MM-DD'),
dateEnd: moment(value[1]).format('YYYY-MM-DD'),
+ dataDetail: dataDetailFix
})
if (res.success) {
@@ -69,6 +78,18 @@ export default function EditDetailTask() {
new Date(moment(res.data.dateStart).format('YYYY-MM-DD')),
new Date(moment(res.data.dateEnd).format('YYYY-MM-DD')),
])
+
+ const res2 = await funGetDetailTask(param.detail, 'detailTask');
+ if (res2.data.length == 0) {
+ const datanya = getDatesInRange(new Date(moment(res.data.dateStart).format('YYYY-MM-DD')), new Date(moment(res.data.dateEnd).format('YYYY-MM-DD')))
+ setDataDetail(datanya.map((data: any) => ({
+ date: data,
+ timeStart: null,
+ timeEnd: null
+ })))
+ } else {
+ setDataDetail(res2.data)
+ }
} else {
toast.error(res.message);
}
@@ -104,8 +125,15 @@ export default function EditDetailTask() {
const array = val.split(",")
if (array[0] == '' || array[1] == '') {
setTouched({ ...touched, date: true })
+ setDataDetail([])
} else {
setTouched({ ...touched, date: false })
+ const datanya = getDatesInRange(value[0]!, value[1]!)
+ setDataDetail(datanya.map((data: any) => ({
+ date: data,
+ timeStart: null,
+ timeEnd: null
+ })))
}
}
}
@@ -180,7 +208,16 @@ export default function EditDetailTask() {
? Tanggal Tidak Boleh Kosong
: <>>
}
-
+
{loading ?
@@ -229,6 +266,16 @@ export default function EditDetailTask() {
}
+ setOpenModalDetailTask(false)}
+ data={dataDetail}
+ onSubmit={(data) => {
+ setDataDetail(data)
+ setOpenModalDetailTask(false)
+ }}
+ />
+
setOpenModal(false)}
description="Apakah Anda yakin ingin mengubah data?"
onYes={(val) => {
diff --git a/src/module/task/ui/modal_add_detail_tugas_task.tsx b/src/module/task/ui/modal_add_detail_tugas_task.tsx
new file mode 100644
index 0000000..eab0659
--- /dev/null
+++ b/src/module/task/ui/modal_add_detail_tugas_task.tsx
@@ -0,0 +1,100 @@
+import { TEMA } from "@/module/_global";
+import { Box, Button, Grid, Modal, SimpleGrid, Text } from "@mantine/core";
+import { TimeInput } from "@mantine/dates";
+import moment from "moment";
+import { useEffect, useState } from "react";
+
+export function ModalAddDetailTugasTask({ open, onClose, data, onSubmit }: { open: boolean, onClose: () => void, data: any[], onSubmit: (data: any) => void }) {
+ const [dataDetail, setDataDetail] = useState(data)
+ const [touched, setTouched] = useState([])
+
+ useEffect(() => {
+ setDataDetail(data)
+ }, [data])
+
+ function onInputTime(date: any, value: any, cat: 'timeStart' | 'timeEnd') {
+ if (cat == "timeEnd") {
+ if (value == "" || dataDetail.find((data: any) => data.date == date)?.timeStart > value) {
+ setTouched((touched: any) => [...touched, { date: date, timeEnd: true }])
+ } else {
+ setTouched((touched: any) => touched.filter((item: any) => item.date != date))
+ }
+ } else {
+ if (value == "" || dataDetail.find((data: any) => data.date == date)?.timeEnd < value) {
+ setTouched((touched: any) => [...touched, { date: date, timeEnd: true }])
+ } else {
+ setTouched((touched: any) => touched.filter((item: any) => item.date != date))
+ }
+ }
+
+ setDataDetail(dataDetail.map((data: any) => {
+ if (data.date == date) {
+ return {
+ ...data,
+ [cat]: value
+ }
+ }
+ return data
+ }))
+ }
+
+ return (
+ onClose()} centered withCloseButton={false} title={"Detail Tanggal dan Waktu Tugas"}>
+
+
+ {
+ dataDetail.map((data: any, index: any) => (
+
+ {moment(data.date).format('DD-MM-YYYY')}
+
+ onInputTime(data.date, event.target.value, 'timeStart')}
+ />
+ onInputTime(data.date, event.target.value, 'timeEnd')}
+ error={touched.find((item: any) => item.date == data.date)?.timeEnd ? "Waktu akhir harus lebih dari waktu awal" : ""}
+ />
+
+
+ ))
+ }
+
+
+
+
+
+
+
+
+
+
+
+
+ )
+}
\ No newline at end of file
diff --git a/src/module/task/ui/modal_list_tugas_task.tsx b/src/module/task/ui/modal_list_tugas_task.tsx
new file mode 100644
index 0000000..9c23549
--- /dev/null
+++ b/src/module/task/ui/modal_list_tugas_task.tsx
@@ -0,0 +1,99 @@
+import { Box, Modal, SimpleGrid, Skeleton, Text } from "@mantine/core";
+import { TimeInput } from "@mantine/dates";
+import { useShallowEffect } from "@mantine/hooks";
+import moment from "moment";
+import { useState } from "react";
+import toast from "react-hot-toast";
+import { funGetDetailTask } from "../lib/api_task";
+
+export function ModalListDetailTugasTask({ open, onClose, task, }: { open: boolean, onClose: () => void, task: string }) {
+ const [dataDetail, setDataDetail] = useState([])
+ const [loading, setLoading] = useState(false)
+
+ async function getData() {
+ try {
+ setLoading(true)
+ const response = await funGetDetailTask(task, 'detailTask')
+ if (response.success) {
+ setDataDetail(response.data)
+ } else {
+ toast.error(response.message)
+ }
+ } catch (error) {
+ console.error(error);
+ toast.error("Gagal mendapatkan detail tugas Kegiatan, coba lagi nanti");
+ } finally {
+ setLoading(false)
+ }
+ }
+
+ useShallowEffect(() => {
+ if(task!=""){
+ getData()
+ }
+ }, [task])
+
+ return (
+ onClose()} centered withCloseButton={false} title={"Detail Tanggal dan Waktu Tugas"}>
+
+
+ {
+ loading ?
+ Array(5)
+ .fill(null)
+ .map((_, i) => (
+
+
+
+
+
+ ))
+ :
+ dataDetail.length > 0 ?
+ dataDetail.map((data: any, index: any) => (
+
+ {moment(data.date).format('DD-MM-YYYY')}
+
+
+
+
+
+ ))
+ :
+ Tidak ada detail tugas
+ }
+
+
+
+ )
+}
\ No newline at end of file
diff --git a/src/module/task/ui/navbar_detail_division_task.tsx b/src/module/task/ui/navbar_detail_division_task.tsx
index fb3131a..7113b37 100644
--- a/src/module/task/ui/navbar_detail_division_task.tsx
+++ b/src/module/task/ui/navbar_detail_division_task.tsx
@@ -1,20 +1,22 @@
'use client'
import { globalRole, keyWibu, LayoutDrawer, LayoutNavbarNew, TEMA } from "@/module/_global";
+import LayoutModal from "@/module/_global/layout/layout_modal";
+import { funGetUserByCookies } from "@/module/auth";
import { globalIsAdminDivision, globalIsMemberDivision } from "@/module/division_new";
import { useHookstate } from "@hookstate/core";
-import { ActionIcon, Box, Flex, SimpleGrid, Stack, Text } from "@mantine/core";
+import { ActionIcon, Box, Button, Flex, Grid, Modal, SimpleGrid, Stack, Text, TextInput } from "@mantine/core";
import { useShallowEffect } from "@mantine/hooks";
import { useParams, useRouter } from "next/navigation";
import { useState } from "react";
import toast from "react-hot-toast";
+import { AiFillFileText } from "react-icons/ai";
import { FaFileCirclePlus, FaPencil, FaTrash, FaUsers } from "react-icons/fa6";
import { HiMenu } from "react-icons/hi";
import { IoAddCircle } from "react-icons/io5";
+import { LuLink } from "react-icons/lu";
import { MdCancel } from "react-icons/md";
-import { funDeleteTask, funGetTaskDivisionById } from "../lib/api_task";
import { useWibuRealtime } from "wibu-realtime";
-import LayoutModal from "@/module/_global/layout/layout_modal";
-import { funGetUserByCookies } from "@/module/auth";
+import { funAddLinkTask, funDeleteTask, funGetTaskDivisionById } from "../lib/api_task";
export default function NavbarDetailDivisionTask() {
const router = useRouter()
@@ -29,6 +31,9 @@ export default function NavbarDetailDivisionTask() {
const [isUser, setUser] = useState('')
const [loadingModal, setLoadingModal] = useState(false)
const [openModal, setOpenModal] = useState(false)
+ const [openNewLink, setOpenNewLink] = useState(false)
+ const [valLink, setValLink] = useState("")
+ const [loadingLink, setLoadingLink] = useState(false)
const [dataRealTime, setDataRealtime] = useWibuRealtime({
WIBU_REALTIME_TOKEN: keyWibu,
project: "sdm"
@@ -80,6 +85,29 @@ export default function NavbarDetailDivisionTask() {
getOneData();
}, [param.detail])
+ async function addLinkProject() {
+ try {
+ setLoadingLink(true)
+ const res = await funAddLinkTask(param.detail, { link: valLink, idDivision: param.id });
+ if (res.success) {
+ setDataRealtime([{
+ category: "tugas-detail-link",
+ id: param.detail,
+ }])
+ toast.success(res.message)
+ } else {
+ toast.error(res.message)
+ }
+ } catch (error) {
+ console.error(error);
+ toast.error("Gagal menambahkan link, coba lagi nanti");
+ } finally {
+ setLoadingLink(false)
+ setOpenNewLink(false)
+ setValLink("")
+ }
+ }
+
useShallowEffect(() => {
if (dataRealTime && dataRealTime.some((i: any) => (i.category == 'tugas-detail' || i.category == 'tugas-detail-status') && i.id == param.detail)) {
@@ -111,7 +139,7 @@ export default function NavbarDetailDivisionTask() {
} />
- setOpen(false)}>
+ setOpen(false)} size='md'>
+ {
+ if (reason == null) {
+ setOpen(false)
+ setOpenNewLink(true)
+ } else {
+ null
+ }
+ }}
+ >
+
+
+
+
+ Tambah link
+
+
+
+ {
+ if (reason == null) {
+ router.push(param.detail + '/report')
+ } else {
+ null
+ }
+ }}
+ >
+
+
+
+
+ Laporan
+
+
+
{
(roleLogin.get() != "user" && roleLogin.get() != "coadmin") || adminLogin.get() ?
<>
@@ -239,7 +308,46 @@ export default function NavbarDetailDivisionTask() {
setOpenModal(false)}
description="Apakah Anda yakin ingin menghapus tugas divisi ini?"
- onYes={(val) => { val ? deleteDataProject() : setOpenModal(false) }} />
+ onYes={(val) => { val ? deleteDataProject() : setOpenModal(false) }}
+ />
+
+ setOpenNewLink(false)} centered withCloseButton={false}>
+
+ Tambah Link
+
+ setValLink(e.target.value)}
+ />
+
+
+
+
+
+
+
+
+
+
+
>
)
}
\ No newline at end of file
diff --git a/xsendMany.ts b/xsendMany.ts
index a03b132..aba35aa 100644
--- a/xsendMany.ts
+++ b/xsendMany.ts
@@ -22,7 +22,7 @@ export async function sendFCMNotificationMany({ token, title, body, data }: { to
title,
body,
},
- tokens:token,
+ tokens: token,
data,
android: {
priority: "high",
@@ -44,18 +44,22 @@ export async function sendFCMNotificationMany({ token, title, body, data }: { to
},
};
- // Kirim pesan
- const response = await getMessaging().sendEachForMulticast(message as any);
- if (response.failureCount > 0) {
- const failedTokens: any[] = [];
- response.responses.forEach((resp, idx) => {
- if (!resp.success) {
- failedTokens.push(token[idx]);
- }
- });
- const del = await deleteDeviceError({ device: failedTokens });
+ if (token.length > 0) {
+ // Kirim pesan
+ const response = await getMessaging().sendEachForMulticast(message as any);
+ if (response.failureCount > 0) {
+ const failedTokens: any[] = [];
+ response.responses.forEach((resp, idx) => {
+ if (!resp.success) {
+ failedTokens.push(token[idx]);
+ }
+ });
+ const del = await deleteDeviceError({ device: failedTokens });
+ }
+
}
+
return { success: true, message: "Notifikasi berhasil dikirim", };
} catch (error) {
console.error("Error mengirim notifikasi:", error);