@@ -170,6 +170,25 @@ export async function POST(request: Request) {
|
||||
})
|
||||
}
|
||||
|
||||
if (userRoleLogin != "cosupadmin") {
|
||||
const ketuaGrup = await prisma.user.findFirst({
|
||||
where: {
|
||||
isActive: true,
|
||||
idUserRole: "cosupadmin",
|
||||
idGroup: user.idGroup
|
||||
}
|
||||
})
|
||||
|
||||
dataNotif.push({
|
||||
idUserTo: ketuaGrup?.id,
|
||||
idUserFrom: userId,
|
||||
category: 'division/' + idDivision + '/discussion',
|
||||
idContent: data.id,
|
||||
title: 'Diskusi Baru',
|
||||
desc: 'Terdapat diskusi baru. Silahkan periksa detailnya.'
|
||||
})
|
||||
}
|
||||
|
||||
const insertNotif = await prisma.notifications.createMany({
|
||||
data: dataNotif
|
||||
})
|
||||
|
||||
@@ -142,8 +142,8 @@ export async function GET(request: Request) {
|
||||
extension: v.DivisionDocumentFolderFile.extension,
|
||||
path: v.DivisionDocumentFolderFile.path,
|
||||
createdBy: v.DivisionDocumentFolderFile.User.name,
|
||||
createdAt: moment(v.DivisionDocumentFolderFile.createdAt).format("DD-MM-YYYY HH:mm"),
|
||||
updatedAt: moment(v.DivisionDocumentFolderFile.updatedAt).format("DD-MM-YYYY HH:mm"),
|
||||
createdAt: v.DivisionDocumentFolderFile.createdAt,
|
||||
updatedAt: v.DivisionDocumentFolderFile.updatedAt,
|
||||
share: true
|
||||
}))
|
||||
|
||||
@@ -181,8 +181,8 @@ export async function GET(request: Request) {
|
||||
const allData = data.map((v: any) => ({
|
||||
..._.omit(v, ["User", "createdAt", "updatedAt"]),
|
||||
createdBy: v.User.name,
|
||||
createdAt: moment(v.createdAt).format("DD-MM-YYYY HH:mm"),
|
||||
updatedAt: moment(v.updatedAt).format("DD-MM-YYYY HH:mm"),
|
||||
createdAt: v.createdAt,
|
||||
updatedAt: v.updatedAt,
|
||||
share: false
|
||||
}))
|
||||
|
||||
@@ -190,7 +190,13 @@ export async function GET(request: Request) {
|
||||
allData.push(...formatDataShare)
|
||||
}
|
||||
|
||||
const formatData = _.orderBy(allData, ['category', 'createdAt'], ['desc', 'asc']);
|
||||
const formatData = _.orderBy(allData, ['category', 'createdAt'], ['desc', 'desc']);
|
||||
|
||||
const fixData = formatData.map((v: any) => ({
|
||||
..._.omit(v, ["createdAt", "updatedAt"]),
|
||||
createdAt: moment(v.createdAt).format("DD-MM-YYYY HH:mm"),
|
||||
updatedAt: moment(v.updatedAt).format("DD-MM-YYYY HH:mm"),
|
||||
}))
|
||||
|
||||
let pathNow = path
|
||||
let jalur = []
|
||||
@@ -221,7 +227,7 @@ export async function GET(request: Request) {
|
||||
jalur.push({ id: 'home', name: 'home' })
|
||||
jalur = [...jalur].reverse()
|
||||
|
||||
return NextResponse.json({ success: true, message: "Berhasil mendapatkan item", data: formatData, jalur }, { status: 200 });
|
||||
return NextResponse.json({ success: true, message: "Berhasil mendapatkan item", data: fixData, jalur }, { status: 200 });
|
||||
|
||||
} catch (error) {
|
||||
console.error(error);
|
||||
|
||||
@@ -68,11 +68,14 @@ export async function GET(request: Request) {
|
||||
});
|
||||
|
||||
const allData = positions.map((v: any) => ({
|
||||
..._.omit(v, ["Group"]),
|
||||
..._.omit(v, ["Group", "name"]),
|
||||
name: v.name,
|
||||
group: v.Group.name
|
||||
}))
|
||||
|
||||
return NextResponse.json({ success: true, message: "Berhasil mendapatkan jabatan", data: allData, filter }, { status: 200 });
|
||||
const dataFix = _.orderBy(allData, [data => data.name.toLowerCase()], ['asc']);
|
||||
|
||||
return NextResponse.json({ success: true, message: "Berhasil mendapatkan jabatan", data: dataFix, filter }, { status: 200 });
|
||||
} catch (error) {
|
||||
console.error(error);
|
||||
return NextResponse.json({ success: false, message: "Gagal mendapatkan jabatan, coba lagi nanti (error: 500)", reason: (error as Error).message, }, { status: 500 });
|
||||
|
||||
@@ -193,8 +193,8 @@ export async function POST(request: Request, context: { params: { id: string } }
|
||||
idProject: id,
|
||||
idDivision,
|
||||
title,
|
||||
dateStart: new Date(moment(dateStart).format('YYYY-MM-DD')),
|
||||
dateEnd: new Date(moment(dateEnd).format('YYYY-MM-DD')),
|
||||
dateStart: new Date(dateStart),
|
||||
dateEnd: new Date(dateEnd),
|
||||
},
|
||||
select: {
|
||||
id: true
|
||||
|
||||
@@ -2,7 +2,6 @@ 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";
|
||||
|
||||
|
||||
@@ -78,8 +77,6 @@ export async function DELETE(request: Request, context: { params: { id: string }
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
// EDIT STATUS DETAIL TASK
|
||||
export async function PUT(request: Request, context: { params: { id: string } }) {
|
||||
try {
|
||||
@@ -218,8 +215,8 @@ export async function POST(request: Request, context: { params: { id: string } }
|
||||
},
|
||||
data: {
|
||||
title,
|
||||
dateStart: new Date(moment(dateStart).format('YYYY-MM-DD')),
|
||||
dateEnd: new Date(moment(dateEnd).format('YYYY-MM-DD')),
|
||||
dateStart: new Date(dateStart),
|
||||
dateEnd: new Date(dateEnd),
|
||||
},
|
||||
});
|
||||
|
||||
|
||||
@@ -2,7 +2,6 @@ import { DIR, funUploadFile, prisma } from "@/module/_global";
|
||||
import { funGetUserByCookies } from "@/module/auth";
|
||||
import { createLogUser } from "@/module/user";
|
||||
import _, { ceil } from "lodash";
|
||||
import moment from "moment";
|
||||
import { NextResponse } from "next/server";
|
||||
|
||||
|
||||
@@ -145,8 +144,8 @@ export async function POST(request: Request) {
|
||||
idDivision: idDivision,
|
||||
idProject: data.id,
|
||||
title: v.title,
|
||||
dateStart: new Date(moment(v.dateStart).format('YYYY-MM-DD')),
|
||||
dateEnd: new Date(moment(v.dateEnd).format('YYYY-MM-DD')),
|
||||
dateStart: new Date(v.dateStart),
|
||||
dateEnd: new Date(v.dateEnd),
|
||||
}))
|
||||
|
||||
const insertTask = await prisma.divisionProjectTask.createMany({
|
||||
|
||||
@@ -2,7 +2,7 @@ import { NextResponse } from "next/server";
|
||||
|
||||
export async function GET(request: Request) {
|
||||
try {
|
||||
return NextResponse.json({ success: true, version: "0.2.0", mode: "staging" }, { status: 200 });
|
||||
return NextResponse.json({ success: true, version: "0.2.1", mode: "staging" }, { 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 });
|
||||
|
||||
@@ -59,11 +59,16 @@ export default function DrawerDetailDiscussion({ onSuccess, id, status, idDivisi
|
||||
setLoadingDelete(true)
|
||||
const response = await funDeleteDiscussion(id)
|
||||
if (response.success) {
|
||||
setDataRealtime([{
|
||||
category: "discussion-delete",
|
||||
id: id,
|
||||
user: response.user
|
||||
}])
|
||||
setDataRealtime([
|
||||
{
|
||||
category: "discussion-delete",
|
||||
id: id,
|
||||
user: response.user
|
||||
},
|
||||
{
|
||||
category: "division/" + param.id + "/discussion",
|
||||
}
|
||||
])
|
||||
toast.success(response.message)
|
||||
onSuccess(false)
|
||||
router.push(`/division/${param.id}/discussion`)
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
'use client'
|
||||
import { currentScroll, globalNotifPage, ReloadButtonTop, TEMA } from "@/module/_global";
|
||||
import { currentScroll, globalNotifPage, keyWibu, ReloadButtonTop, TEMA } from "@/module/_global";
|
||||
import { useHookstate } from "@hookstate/core";
|
||||
import { Avatar, Badge, Box, Divider, Flex, Grid, Group, Skeleton, Spoiler, Text, TextInput } from "@mantine/core";
|
||||
import { useShallowEffect } from "@mantine/hooks";
|
||||
@@ -9,6 +9,7 @@ import { useEffect, useState } from "react";
|
||||
import toast from "react-hot-toast";
|
||||
import { GrChatOption } from "react-icons/gr";
|
||||
import { HiMagnifyingGlass } from "react-icons/hi2";
|
||||
import { useWibuRealtime } from "wibu-realtime";
|
||||
import { funGetAllDiscussion } from "../lib/api_discussion";
|
||||
import { IDataDiscussion } from "../lib/type_discussion";
|
||||
|
||||
@@ -24,6 +25,10 @@ export default function ListDiscussion({ id }: { id: string }) {
|
||||
const [isPage, setPage] = useState(1)
|
||||
const notifLoadPage = useHookstate(globalNotifPage)
|
||||
const [isRefresh, setRefresh] = useState(false)
|
||||
const [dataRealTime, setDataRealtime] = useWibuRealtime({
|
||||
WIBU_REALTIME_TOKEN: keyWibu,
|
||||
project: "sdm"
|
||||
})
|
||||
|
||||
const getData = async (loading: boolean) => {
|
||||
try {
|
||||
@@ -83,6 +88,12 @@ export default function ListDiscussion({ id }: { id: string }) {
|
||||
}
|
||||
}, [notifLoadPage.get().load])
|
||||
|
||||
useShallowEffect(() => {
|
||||
if (dataRealTime && dataRealTime.some((i: any) => i.category == 'division/' + param.id + '/discussion')) {
|
||||
setRefresh(true)
|
||||
}
|
||||
}, [dataRealTime])
|
||||
|
||||
function onRefresh() {
|
||||
notifLoadPage.set({
|
||||
category: '',
|
||||
|
||||
@@ -14,14 +14,14 @@ export interface IFormMemberTask {
|
||||
|
||||
|
||||
export interface IFormDateTask {
|
||||
dateStart: Date,
|
||||
dateEnd: Date,
|
||||
dateStart: string,
|
||||
dateEnd: string,
|
||||
title: string
|
||||
}
|
||||
|
||||
export interface IFormAddDetailTask {
|
||||
dateStart: Date,
|
||||
dateEnd: Date,
|
||||
dateStart: string,
|
||||
dateEnd: string,
|
||||
title: string
|
||||
idDivision: string
|
||||
}
|
||||
|
||||
@@ -4,13 +4,13 @@ import LayoutModal from "@/module/_global/layout/layout_modal";
|
||||
import { useHookstate } from "@hookstate/core";
|
||||
import { Box, Button, Flex, Group, rem, SimpleGrid, Stack, Text, TextInput } from "@mantine/core";
|
||||
import { DatePicker } from "@mantine/dates";
|
||||
import { useShallowEffect } from "@mantine/hooks";
|
||||
import moment from "moment";
|
||||
import { useParams, useRouter } from "next/navigation";
|
||||
import { useState } from "react";
|
||||
import toast from "react-hot-toast";
|
||||
import { useWibuRealtime } from "wibu-realtime";
|
||||
import { funCreateDetailTask } from "../lib/api_task";
|
||||
import { useShallowEffect } from "@mantine/hooks";
|
||||
|
||||
export default function AddDetailTask() {
|
||||
const [value, setValue] = useState<[Date | null, Date | null]>([null, null]);
|
||||
@@ -59,8 +59,8 @@ export default function AddDetailTask() {
|
||||
setLoadingModal(true)
|
||||
const res = await funCreateDetailTask(param.detail, {
|
||||
title,
|
||||
dateStart: (value[0] != null) ? value[0] : new Date,
|
||||
dateEnd: (value[1] != null) ? value[1] : new Date,
|
||||
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
|
||||
})
|
||||
|
||||
|
||||
@@ -29,8 +29,8 @@ export default function ViewDateEndTask({ onClose, onSet }: { onClose: (val: boo
|
||||
return toast.error("Error! harus memasukkan judul tugas")
|
||||
|
||||
onSet({
|
||||
dateStart: value[0],
|
||||
dateEnd: value[1],
|
||||
dateStart: moment(value[0]).format('YYYY-MM-DD'),
|
||||
dateEnd: moment(value[1]).format('YYYY-MM-DD'),
|
||||
title: title
|
||||
})
|
||||
|
||||
|
||||
@@ -38,8 +38,8 @@ export default function EditDetailTask() {
|
||||
setLoadingModal(true)
|
||||
const res = await funEditDetailTask(param.detail, {
|
||||
title: title,
|
||||
dateStart: value[0],
|
||||
dateEnd: value[1],
|
||||
dateStart: moment(value[0]).format('YYYY-MM-DD'),
|
||||
dateEnd: moment(value[1]).format('YYYY-MM-DD'),
|
||||
})
|
||||
|
||||
if (res.success) {
|
||||
|
||||
Reference in New Issue
Block a user