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 915f30b..293102f 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,8 +1,17 @@
-import { ViewDetailDivisionTask } from "@/module/division_new"
+import { NavbarDetailDivisionTask, ProgressDetailTask, ListTugasDetailTask, ListFileDetailTask, ListAnggotaDetailTask } from "@/module/task"
+import { Box } from "@mantine/core"
function Page() {
return (
-
+
+
+
+
+
+
+
+
+
)
}
diff --git a/src/app/api/task/[id]/route.ts b/src/app/api/task/[id]/route.ts
new file mode 100644
index 0000000..24409ed
--- /dev/null
+++ b/src/app/api/task/[id]/route.ts
@@ -0,0 +1,134 @@
+import { prisma } from "@/module/_global";
+import { funGetUserByCookies } from "@/module/auth";
+import _ from "lodash";
+import moment from "moment";
+import { NextResponse } from "next/server";
+
+// GET DETAIL TASK DIVISI / GET ONE
+export async function GET(request: Request, context: { params: { id: string } }) {
+ try {
+ let allData
+ const { id } = context.params;
+ const user = await funGetUserByCookies()
+ const { searchParams } = new URL(request.url);
+ const kategori = searchParams.get("cat");
+
+ if (user.id == undefined) {
+ return NextResponse.json({ success: false, message: "Anda harus login untuk mengakses ini" }, { status: 401 });
+ }
+
+ const data = await prisma.divisionProject.findUnique({
+ where: {
+ id: String(id),
+ isActive: true
+ }
+ });
+
+ if (!data) {
+ return NextResponse.json({ success: false, message: "Gagal mendapatkan tugas, data tidak ditemukan", }, { status: 404 });
+ }
+
+ if (kategori == "data") {
+ allData = data
+ } else if (kategori == "progress") {
+ const dataProgress = await prisma.divisionProjectTask.findMany({
+ where: {
+ isActive: true,
+ idProject: String(id)
+ },
+ orderBy:{
+ updatedAt: 'desc'
+ }
+ })
+
+ const semua = dataProgress.length
+ const selesai = _.filter(dataProgress, { status: 1 }).length
+ const progress = Math.ceil((selesai / semua) * 100)
+
+ allData = {
+ progress: progress,
+ lastUpdate: moment(dataProgress[0].updatedAt).format("DD MMMM YYYY"),
+ }
+ } else if (kategori == "task") {
+ const dataProgress = await prisma.divisionProjectTask.findMany({
+ where: {
+ isActive: true,
+ idProject: String(id)
+ },
+ select: {
+ id: true,
+ title: true,
+ status: true,
+ dateStart: true,
+ dateEnd: true,
+ }
+ })
+
+ const fix = dataProgress.map((v: any) => ({
+ ..._.omit(v, ["dateStart", "dateEnd"]),
+ dateStart: moment(v.dateStart).format("DD MMMM YYYY"),
+ dateEnd: moment(v.dateEnd).format("DD MMMM YYYY"),
+ }))
+
+ allData = fix
+
+ } else if (kategori == "file") {
+ const dataFile = await prisma.divisionProjectFile.findMany({
+ where: {
+ isActive: true,
+ idProject: String(id)
+ },
+ select: {
+ id: true,
+ ContainerFileDivision: {
+ select: {
+ name: true,
+ extension: true
+ }
+ }
+ }
+ })
+
+ const fix = dataFile.map((v: any) => ({
+ ..._.omit(v, ["ContainerFileDivision"]),
+ name: v.ContainerFileDivision.name,
+ extension: v.ContainerFileDivision.extension,
+ }))
+
+ allData = fix
+
+ } else if (kategori == "member") {
+ const dataMember = await prisma.divisionProjectMember.findMany({
+ where: {
+ isActive: true,
+ idProject: String(id)
+ },
+ select: {
+ id: true,
+ User: {
+ select: {
+ name: true,
+ email: true
+ }
+ }
+ }
+ })
+
+
+ const fix = dataMember.map((v: any) => ({
+ ..._.omit(v, ["User"]),
+ name: v.User.name,
+ email: v.User.email,
+ }))
+
+ allData = fix
+ }
+
+ return NextResponse.json({ success: true, message: "Berhasil mendapatkan tugas divisi", data: allData }, { status: 200 });
+
+ }
+ catch (error) {
+ console.log(error);
+ return NextResponse.json({ success: false, message: "Gagal mendapatkan tugas divisi, coba lagi nanti", reason: (error as Error).message, }, { status: 500 });
+ }
+}
\ No newline at end of file
diff --git a/src/module/division_new/_division_fitur/task/component/create_task.tsx b/src/module/division_new/_division_fitur/task/component/create_task.tsx
deleted file mode 100644
index a55aa96..0000000
--- a/src/module/division_new/_division_fitur/task/component/create_task.tsx
+++ /dev/null
@@ -1,130 +0,0 @@
-"use client";
-import { LayoutDrawer, LayoutNavbarNew, WARNA } from "@/module/_global";
-import { Box, Button, Center, Flex, Group, Input, Stack, Text } from "@mantine/core";
-import { useRouter } from "next/navigation";
-import React, { useState } from "react";
-import { IoIosArrowDropright } from "react-icons/io";
-import { BsFiletypeCsv } from "react-icons/bs";
-import ResultsDateAndTask from "@/module/project/components/results_date-and_task";
-import ResultsFile from "@/module/project/components/results_file";
-
-export default function CreateTask({ searchParams }: { searchParams: any }) {
- const router = useRouter();
- const [openDrawer, setOpenDrawer] = useState(false);
- return (
-
-
-
-
-
- router.push("/task/create?page=task")}>
-
- Tambah Tanggal & Tugas
-
-
-
- setOpenDrawer(true)}
- >
- Upload File
-
-
-
- {
- (searchParams.anggota == 'yes') &&
- <>
-
- >
- }
-
- {(searchParams.files == 'yes') &&
- <>
-
- >
- }
-
- {
- (searchParams.button == 'yes') &&
- <>
-
-
-
- >
- }
-
-
-
-
-
-
- setOpenDrawer(false)}
- title={"Pilih File"}
- >
-
- ""}>
-
-
-
-
-
-
- Pilih file
-
- diperangkat
-
- router.push("/task/create?page=file-save")}>
-
-
-
-
-
-
- Pilih file yang
-
- sudah ada
-
-
-
-
- );
-}
diff --git a/src/module/division_new/_division_fitur/task/component/detail_list_anggota_task.tsx b/src/module/division_new/_division_fitur/task/component/detail_list_anggota_task.tsx
deleted file mode 100644
index b6fb2d0..0000000
--- a/src/module/division_new/_division_fitur/task/component/detail_list_anggota_task.tsx
+++ /dev/null
@@ -1,89 +0,0 @@
-import { WARNA } from "@/module/_global";
-import { Box, Group, Flex, Avatar, Text } from "@mantine/core";
-
-
-const dataAnggota = [
- {
- id: 1,
- name: "Iqbal Ramadan",
- image: "https://i.pravatar.cc/1000?img=5",
- email: "iqbal.ramadan@gmail.com",
- },
- {
- id: 2,
- name: "Doni Setiawan",
- image: "https://i.pravatar.cc/1000?img=10",
- email: "doni.setiawan@gmail.com",
- },
- {
- id: 3,
- name: "Rangga Agung",
- image: "https://i.pravatar.cc/1000?img=51",
- email: "rangga.agung@gmail.com",
- },
- {
- id: 4,
- name: "Ramadan Sananta",
- image: "https://i.pravatar.cc/1000?img=15",
- email: "ramadan@gmail.com",
- },
- {
- id: 5,
- name: "Imam Baroni",
- image: "https://i.pravatar.cc/1000?img=22",
- email: "imam.baroni@gmail.com",
- },
- ];
-
-
-export default function ListAnggotaDetailTask() {
- return (
-
-
- Anggota Terpilih
- Total 10 Anggota
-
-
-
-
-
- Divisi Kerohanian
-
- {dataAnggota.map((v, i) => {
- return (
-
-
-
-
-
- {v.name}
-
-
- {v.email}
-
-
-
-
- Anggota
-
-
- );
- })}
-
-
-
-
- )
-}
\ No newline at end of file
diff --git a/src/module/division_new/_division_fitur/task/component/detail_list_file_task.tsx b/src/module/division_new/_division_fitur/task/component/detail_list_file_task.tsx
deleted file mode 100644
index 1b3a669..0000000
--- a/src/module/division_new/_division_fitur/task/component/detail_list_file_task.tsx
+++ /dev/null
@@ -1,37 +0,0 @@
-import { WARNA } from "@/module/_global";
-import { Box, Group, Text } from "@mantine/core";
-import { BsFiletypeCsv } from "react-icons/bs";
-
-export default function ListFileDetailTask() {
- return (
-
- File
-
-
-
-
- Proyek Laporan Permasyarakatan
-
-
-
-
-
- Proyek Laporan Permasyarakatan
-
-
-
-
- )
-}
\ No newline at end of file
diff --git a/src/module/division_new/_division_fitur/task/component/detail_list_tugas_task.tsx b/src/module/division_new/_division_fitur/task/component/detail_list_tugas_task.tsx
deleted file mode 100644
index f804112..0000000
--- a/src/module/division_new/_division_fitur/task/component/detail_list_tugas_task.tsx
+++ /dev/null
@@ -1,77 +0,0 @@
-'use client'
-
-import { WARNA } from "@/module/_global"
-import { Box, Grid, Center, Checkbox, Group, SimpleGrid, Text } from "@mantine/core"
-import { AiOutlineFileSync } from "react-icons/ai"
-
-export default function ListTugasDetailTask() {
- return (
-
-
- Tanggal & Tugas
-
-
-
-
-
-
-
-
-
-
-
-
- Laporan Permasyarakatan
-
-
-
-
-
- Tanggal Mulai
-
- 16 Juni 2024
-
-
-
- Tanggal Berakhir
-
- 20 Juni 2024
-
-
-
-
-
-
-
-
- )
-}
\ No newline at end of file
diff --git a/src/module/division_new/_division_fitur/task/component/navbar_detail_division_task.tsx b/src/module/division_new/_division_fitur/task/component/navbar_detail_division_task.tsx
deleted file mode 100644
index 6c7af6e..0000000
--- a/src/module/division_new/_division_fitur/task/component/navbar_detail_division_task.tsx
+++ /dev/null
@@ -1,23 +0,0 @@
-'use client'
-import { LayoutNavbarNew, WARNA } from "@/module/_global";
-import { ActionIcon } from "@mantine/core";
-import { useRouter } from "next/navigation";
-import { LuClipboardEdit } from "react-icons/lu";
-
-export default function NavbarDetailDivisionTask() {
- const router = useRouter()
- return (
- router.push("/task/update/1")}
- >
-
-
- } />
- )
-}
\ No newline at end of file
diff --git a/src/module/division_new/_division_fitur/task/view/view_detail_division_task.tsx b/src/module/division_new/_division_fitur/task/view/view_detail_division_task.tsx
deleted file mode 100644
index 9f3680c..0000000
--- a/src/module/division_new/_division_fitur/task/view/view_detail_division_task.tsx
+++ /dev/null
@@ -1,20 +0,0 @@
-import { Box } from "@mantine/core";
-import NavbarDetailDivisionTask from "../component/navbar_detail_division_task";
-import ProgressDetailTask from "../component/detail_progress_task";
-import ListTugasDetailTask from "../component/detail_list_tugas_task";
-import ListFileDetailTask from "../component/detail_list_file_task";
-import ListAnggotaDetailTask from "../component/detail_list_anggota_task";
-
-export default function ViewDetailDivisionTask() {
- return (
-
-
-
-
-
-
-
-
-
- )
-}
\ No newline at end of file
diff --git a/src/module/division_new/index.ts b/src/module/division_new/index.ts
index 3a45a9f..744d897 100644
--- a/src/module/division_new/index.ts
+++ b/src/module/division_new/index.ts
@@ -9,7 +9,6 @@ import ViewDivisionCalender from "./_division_fitur/calender/view/view_division_
import ViewHistoryDivisionCalender from "./_division_fitur/calender/view/view_history_division_calender";
import ViewUpdateDivisionCalender from "./_division_fitur/calender/view/view_update_division_calender";
import ViewDocumentDivision from "./_division_fitur/document/view/view_document_division";
-import ViewDetailDivisionTask from "./_division_fitur/task/view/view_detail_division_task";
import ViewUpdateProgressDivisionTask from "./_division_fitur/task/view/view_update_progress_division_task";
import CreateAdminDivision from "./ui/create_admin_division";
import CreateUsers from "./ui/create_users";
@@ -30,7 +29,6 @@ import { funGetDivisionById } from './lib/api_division';
export { CreateUsers };
export { CreateAdminDivision };
-export { ViewDetailDivisionTask };
export { ViewUpdateProgressDivisionTask };
export { ViewDivisionCalender };
export { ViewCreateDivisionCalender };
diff --git a/src/module/task/index.ts b/src/module/task/index.ts
index 8b34a28..5a6dd34 100644
--- a/src/module/task/index.ts
+++ b/src/module/task/index.ts
@@ -1,7 +1,12 @@
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 ListTugasDetailTask from "./ui/detail_list_tugas_task";
+import ProgressDetailTask from "./ui/detail_progress_task";
import FileSave from "./ui/file_save";
+import NavbarDetailDivisionTask from "./ui/navbar_detail_division_task";
import NavbarDivisionTask from "./ui/navbar_division_task";
import TabsDivisionTask from "./ui/tabs_division_task";
@@ -10,4 +15,9 @@ export { TabsDivisionTask }
export { CreateTask }
export { ViewDateEndTask }
export { CreateUsersProject }
-export { FileSave }
\ No newline at end of file
+export { FileSave }
+export { NavbarDetailDivisionTask }
+export { ListTugasDetailTask }
+export { ProgressDetailTask }
+export { ListFileDetailTask }
+export { ListAnggotaDetailTask }
\ 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 d2995ce..7fe36fd 100644
--- a/src/module/task/lib/api_task.ts
+++ b/src/module/task/lib/api_task.ts
@@ -18,4 +18,9 @@ export const funCreateTask = async (data: IFormTaskDivision) => {
body: JSON.stringify(data),
});
return await response.json().catch(() => null);
-};
\ No newline at end of file
+};
+
+export const funGetTaskDivisionById = async (path: string, kategori: string) => {
+ const response = await fetch(`/api/task/${path}?cat=${kategori}`);
+ return await response.json().catch(() => null);
+}
\ No newline at end of file
diff --git a/src/module/task/lib/type_task.ts b/src/module/task/lib/type_task.ts
index 998fb18..1cfa5bd 100644
--- a/src/module/task/lib/type_task.ts
+++ b/src/module/task/lib/type_task.ts
@@ -31,4 +31,25 @@ export interface IFormTaskDivision {
export interface IListFileTask {
name: string,
extension: string
+}
+
+
+export interface IDataListTaskDivision {
+ id: string
+ title: string
+ dateStart: string
+ dateEnd: string
+ status: number
+}
+
+export interface IDataMemberTaskDivision {
+ id: string
+ name: string
+ email: string
+}
+
+export interface IDataFileTaskDivision {
+ id: string
+ name: string
+ extension: string
}
\ No newline at end of file
diff --git a/src/module/task/ui/detail_list_anggota_task.tsx b/src/module/task/ui/detail_list_anggota_task.tsx
new file mode 100644
index 0000000..eec2fbb
--- /dev/null
+++ b/src/module/task/ui/detail_list_anggota_task.tsx
@@ -0,0 +1,88 @@
+'use client'
+import { WARNA } from "@/module/_global";
+import { Box, Group, Flex, Avatar, 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 { funGetTaskDivisionById } from "../lib/api_task";
+import { IDataMemberTaskDivision } from "../lib/type_task";
+
+
+export default function ListAnggotaDetailTask() {
+ const [isData, setData] = useState([])
+ const [loading, setLoading] = useState(true)
+ const param = useParams<{ id: string, detail: string }>()
+ async function getOneData() {
+ try {
+ setLoading(true)
+ const res = await funGetTaskDivisionById(param.detail, 'member');
+ if (res.success) {
+ setData(res.data)
+ } else {
+ toast.error(res.message);
+ }
+
+ } catch (error) {
+ console.error(error);
+ toast.error("Gagal mendapatkan member tugas divisi, coba lagi nanti");
+ } finally {
+ setLoading(false)
+ }
+ }
+
+ useShallowEffect(() => {
+ getOneData();
+ }, [param.detail])
+
+
+ return (
+
+
+ Anggota Terpilih
+ Total {isData.length} Anggota
+
+
+
+
+ {
+ loading ? loading :
+ isData.length === 0 ? Tidak ada anggota :
+ isData.map((v, i) => {
+ return (
+
+
+
+
+
+ {v.name}
+
+
+ {v.email}
+
+
+
+
+ Anggota
+
+
+ );
+ })}
+
+
+
+
+ )
+}
\ No newline at end of file
diff --git a/src/module/task/ui/detail_list_file_task.tsx b/src/module/task/ui/detail_list_file_task.tsx
new file mode 100644
index 0000000..7873acf
--- /dev/null
+++ b/src/module/task/ui/detail_list_file_task.tsx
@@ -0,0 +1,76 @@
+'use client'
+import { WARNA } from "@/module/_global";
+import { Box, Group, 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 { BsFiletypeCsv, BsFiletypeHeic, BsFiletypeJpg, BsFiletypePdf, BsFiletypePng } from "react-icons/bs";
+import { funGetTaskDivisionById } from "../lib/api_task";
+import { IDataFileTaskDivision } from "../lib/type_task";
+
+export default function ListFileDetailTask() {
+ const [isData, setData] = useState([])
+ const [loading, setLoading] = useState(true)
+ const param = useParams<{ id: string, detail: string }>()
+ async function getOneData() {
+ try {
+ setLoading(true)
+ const res = await funGetTaskDivisionById(param.detail, 'file');
+ 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();
+ }, [param.detail])
+
+ return (
+
+ File
+
+ {
+
+ loading ? loading :
+ isData.length === 0 ? Tidak ada file :
+ isData.map((item, index) => {
+ return (
+
+
+ {item.extension == "pdf" && }
+ {item.extension == "csv" && }
+ {item.extension == "png" && }
+ {item.extension == "jpg" || item.extension == "jpeg" && }
+ {item.extension == "heic" && }
+ {item.name}
+
+
+ )
+ })
+ }
+
+
+ )
+}
\ No newline at end of file
diff --git a/src/module/task/ui/detail_list_tugas_task.tsx b/src/module/task/ui/detail_list_tugas_task.tsx
new file mode 100644
index 0000000..7218595
--- /dev/null
+++ b/src/module/task/ui/detail_list_tugas_task.tsx
@@ -0,0 +1,116 @@
+'use client'
+import { WARNA } from "@/module/_global"
+import { Box, Grid, Center, Checkbox, Group, SimpleGrid, Text } from "@mantine/core"
+import { useShallowEffect } from "@mantine/hooks"
+import { useParams } from "next/navigation"
+import toast from "react-hot-toast"
+import { AiOutlineFileSync } from "react-icons/ai"
+import { funGetTaskDivisionById } from "../lib/api_task"
+import { useState } from "react"
+import { IDataListTaskDivision } from "../lib/type_task"
+
+export default function ListTugasDetailTask() {
+ const [isData, setData] = useState([])
+ const [loading, setLoading] = useState(true)
+ const param = useParams<{ id: string, detail: string }>()
+ async function getOneData() {
+ try {
+ setLoading(true)
+ const res = await funGetTaskDivisionById(param.detail, 'task');
+ if (res.success) {
+ setData(res.data)
+ } else {
+ toast.error(res.message);
+ }
+
+ } catch (error) {
+ console.error(error);
+ toast.error("Gagal mendapatkan list tugas divisi, coba lagi nanti");
+ } finally {
+ setLoading(false)
+ }
+ }
+
+ useShallowEffect(() => {
+ getOneData();
+ }, [param.detail])
+
+ return (
+
+
+ Tanggal & Tugas
+
+
+ {
+ loading ? loading :
+ isData.length === 0 ? Tidak ada tugas :
+ isData.map((item, index) => {
+ return (
+
+
+
+
+
+
+
+
+
+
+ {item.title}
+
+
+
+
+
+ Tanggal Mulai
+
+ {item.dateStart}
+
+
+
+ Tanggal Berakhir
+
+ {item.dateEnd}
+
+
+
+
+
+
+ )
+ })
+ }
+
+
+
+ )
+}
\ No newline at end of file
diff --git a/src/module/division_new/_division_fitur/task/component/detail_progress_task.tsx b/src/module/task/ui/detail_progress_task.tsx
similarity index 56%
rename from src/module/division_new/_division_fitur/task/component/detail_progress_task.tsx
rename to src/module/task/ui/detail_progress_task.tsx
index 01b585d..51fb1b6 100644
--- a/src/module/division_new/_division_fitur/task/component/detail_progress_task.tsx
+++ b/src/module/task/ui/detail_progress_task.tsx
@@ -1,9 +1,37 @@
'use client'
import { WARNA } from "@/module/_global";
import { Box, Grid, ActionIcon, Progress, Text } from "@mantine/core";
+import { useShallowEffect } from "@mantine/hooks";
+import { useParams } from "next/navigation";
+import toast from "react-hot-toast";
import { HiMiniPresentationChartBar } from "react-icons/hi2";
+import { funGetTaskDivisionById } from "../lib/api_task";
+import { useState } from "react";
export default function ProgressDetailTask() {
+ const [valProgress, setValProgress] = useState(0)
+ const [valLastUpdate, setValLastUpdate] = useState('')
+ const param = useParams<{ id: string, detail: string }>()
+ async function getOneData() {
+ try {
+ const res = await funGetTaskDivisionById(param.detail, 'progress');
+ if (res.success) {
+ setValProgress(res.data.progress);
+ setValLastUpdate(res.data.lastUpdate);
+ } else {
+ toast.error(res.message);
+ }
+
+ } catch (error) {
+ console.error(error);
+ toast.error("Gagal mendapatkan progress tugas divisi, coba lagi nanti");
+ }
+ }
+
+ useShallowEffect(() => {
+ getOneData();
+ }, [param.detail])
+
return (
- Kemajuan Proyek 60%
+ Kemajuan Proyek {valProgress}%
- 18 Juni 2024
+ {valLastUpdate}
diff --git a/src/module/task/ui/list_division_task.tsx b/src/module/task/ui/list_division_task.tsx
index 19eeedc..22ad55f 100644
--- a/src/module/task/ui/list_division_task.tsx
+++ b/src/module/task/ui/list_division_task.tsx
@@ -136,7 +136,7 @@ export default function ListDivisionTask() {
{isData.map((v, i) => {
return (
- router.push(`/task/${v.id}`)}>
+ router.push(`task/${v.id}`)}>
()
+ const [name, setName] = useState('')
+
+ async function getOneData() {
+ try {
+ const res = await funGetTaskDivisionById(param.detail, 'data');
+ if (res.success) {
+ setName(res.data.title);
+ } else {
+ toast.error(res.message);
+ }
+
+ } catch (error) {
+ console.error(error);
+ toast.error("Gagal mendapatkan data tugas divisi, coba lagi nanti");
+ }
+ }
+
+ useShallowEffect(() => {
+ getOneData();
+ }, [param.detail])
+
+
+ return (
+ router.push("/task/update/1")}
+ >
+
+
+ } />
+ )
+}
\ No newline at end of file