upd: task
Deskripsi : - realtime pada halaman list task No Issues
This commit is contained in:
@@ -1,11 +1,9 @@
|
||||
import { DIR, funUploadFile, prisma } from "@/module/_global";
|
||||
import { funGetUserByCookies } from "@/module/auth";
|
||||
import _, { ceil } from "lodash";
|
||||
import { NextResponse } from "next/server";
|
||||
import path from "path";
|
||||
import fs from "fs";
|
||||
import moment from "moment";
|
||||
import { createLogUser } from "@/module/user";
|
||||
import _, { ceil } from "lodash";
|
||||
import moment from "moment";
|
||||
import { NextResponse } from "next/server";
|
||||
|
||||
|
||||
// GET ALL DATA TUGAS DIVISI
|
||||
@@ -113,6 +111,8 @@ export async function POST(request: Request) {
|
||||
const body = await request.formData()
|
||||
const dataBody = body.get("data")
|
||||
const cekFile = body.has("file0")
|
||||
const userId = user.id
|
||||
const userRoleLogin = user.idUserRole
|
||||
|
||||
const { title, task, member, idDivision } = JSON.parse(dataBody as string)
|
||||
|
||||
@@ -233,6 +233,25 @@ export async function POST(request: Request) {
|
||||
desc: 'Terdapat tugas baru. Silahkan periksa detailnya.'
|
||||
}))
|
||||
|
||||
if (userRoleLogin != "supadmin") {
|
||||
const perbekel = await prisma.user.findFirst({
|
||||
where: {
|
||||
isActive: true,
|
||||
idUserRole: "supadmin",
|
||||
idVillage: user.idVillage
|
||||
}
|
||||
})
|
||||
|
||||
dataNotif.push({
|
||||
idUserTo: perbekel?.id,
|
||||
idUserFrom: userId,
|
||||
category: 'division/' + idDivision + '/task',
|
||||
idContent: data.id,
|
||||
title: 'Tugas Baru',
|
||||
desc: 'Terdapat tugas baru. Silahkan periksa detailnya.'
|
||||
})
|
||||
}
|
||||
|
||||
const insertNotif = await prisma.notifications.createMany({
|
||||
data: dataNotif
|
||||
})
|
||||
@@ -242,7 +261,7 @@ export async function POST(request: Request) {
|
||||
const log = await createLogUser({ act: 'CREATE', desc: 'User membuat tugas divisi baru', table: 'divisionProject', data: data.id })
|
||||
|
||||
|
||||
return NextResponse.json({ success: true, message: "Berhasil membuat tugas divisi" }, { status: 200 });
|
||||
return NextResponse.json({ success: true, message: "Berhasil membuat tugas divisi", notif:dataNotif }, { status: 200 });
|
||||
|
||||
} catch (error) {
|
||||
console.error(error);
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
"use client";
|
||||
import { LayoutDrawer, LayoutNavbarNew, TEMA } from "@/module/_global";
|
||||
import { keyWibu, LayoutDrawer, LayoutNavbarNew, TEMA } from "@/module/_global";
|
||||
import { Avatar, Box, Button, Center, Divider, Flex, Grid, Group, Input, rem, SimpleGrid, Stack, Text, TextInput } from "@mantine/core";
|
||||
import { useParams, useRouter } from "next/navigation";
|
||||
import React, { useRef, useState } from "react";
|
||||
@@ -19,6 +19,7 @@ import { FaTrash } from "react-icons/fa6";
|
||||
import LayoutModal from "@/module/_global/layout/layout_modal";
|
||||
import { funCreateTask } from "../lib/api_task";
|
||||
import { useMediaQuery } from "@mantine/hooks";
|
||||
import { useWibuRealtime } from "wibu-realtime";
|
||||
|
||||
export default function CreateTask() {
|
||||
const router = useRouter()
|
||||
@@ -46,6 +47,10 @@ export default function CreateTask() {
|
||||
task: false,
|
||||
member: false
|
||||
});
|
||||
const [data, setData] = useWibuRealtime({
|
||||
WIBU_REALTIME_TOKEN: keyWibu,
|
||||
project: "sdm"
|
||||
})
|
||||
|
||||
function deleteFile(index: number) {
|
||||
setListFile([...listFile.filter((val, i) => i !== index)])
|
||||
@@ -76,6 +81,7 @@ export default function CreateTask() {
|
||||
const response = await funCreateTask(fd)
|
||||
|
||||
if (response.success) {
|
||||
setData(response.notif)
|
||||
toast.success(response.message)
|
||||
setTitle("")
|
||||
member.set([])
|
||||
|
||||
Reference in New Issue
Block a user