Compare commits
34 Commits
amalia/02-
...
amalia/22-
| Author | SHA1 | Date | |
|---|---|---|---|
| 183d40580d | |||
| 60702256a3 | |||
| 9e11208a13 | |||
| 0077ebda05 | |||
| e5b95a828d | |||
| 1f6791e9bd | |||
| 968202e34b | |||
| 0ce94e0e2b | |||
| 9f3acf306e | |||
| 3d2a35446c | |||
| 3ab2566a89 | |||
| 9573c1472a | |||
| ed2c9495c3 | |||
| 1b8bfebf4f | |||
| 10b9037fda | |||
| 4a4be31921 | |||
| 9b48fe56fd | |||
| 18023807cd | |||
| bd1758ce32 | |||
| 878b3aa278 | |||
| f02ffc58ad | |||
| 3d5149cbba | |||
| 411037ec4a | |||
| 66ba6dfa91 | |||
| 389f115923 | |||
| 2251818908 | |||
| b625150eb5 | |||
| bae91db60a | |||
| 150151e823 | |||
| d1a591a63a | |||
| 7e80a1f311 | |||
| b648735b06 | |||
| a3d8bf1e92 | |||
| c2c52ed5fd |
@@ -168,6 +168,7 @@ model Announcement {
|
|||||||
createdAt DateTime @default(now())
|
createdAt DateTime @default(now())
|
||||||
updatedAt DateTime @updatedAt
|
updatedAt DateTime @updatedAt
|
||||||
AnnouncementMember AnnouncementMember[]
|
AnnouncementMember AnnouncementMember[]
|
||||||
|
AnnouncementFile AnnouncementFile[]
|
||||||
}
|
}
|
||||||
|
|
||||||
model AnnouncementMember {
|
model AnnouncementMember {
|
||||||
@@ -183,6 +184,18 @@ model AnnouncementMember {
|
|||||||
updatedAt DateTime @updatedAt
|
updatedAt DateTime @updatedAt
|
||||||
}
|
}
|
||||||
|
|
||||||
|
model AnnouncementFile {
|
||||||
|
id String @id @default(cuid())
|
||||||
|
Announcement Announcement @relation(fields: [idAnnouncement], references: [id])
|
||||||
|
idAnnouncement String
|
||||||
|
name String
|
||||||
|
extension String
|
||||||
|
idStorage String?
|
||||||
|
isActive Boolean @default(true)
|
||||||
|
createdAt DateTime @default(now())
|
||||||
|
updatedAt DateTime @updatedAt
|
||||||
|
}
|
||||||
|
|
||||||
model Project {
|
model Project {
|
||||||
id String @id @default(cuid())
|
id String @id @default(cuid())
|
||||||
Village Village @relation(fields: [idVillage], references: [id])
|
Village Village @relation(fields: [idVillage], references: [id])
|
||||||
@@ -410,6 +423,7 @@ model DivisionDisscussion {
|
|||||||
createdAt DateTime @default(now())
|
createdAt DateTime @default(now())
|
||||||
updatedAt DateTime @updatedAt
|
updatedAt DateTime @updatedAt
|
||||||
DivisionDisscussionComment DivisionDisscussionComment[]
|
DivisionDisscussionComment DivisionDisscussionComment[]
|
||||||
|
DivisionDiscussionFile DivisionDiscussionFile[]
|
||||||
}
|
}
|
||||||
|
|
||||||
model DivisionDisscussionComment {
|
model DivisionDisscussionComment {
|
||||||
@@ -420,6 +434,18 @@ model DivisionDisscussionComment {
|
|||||||
isActive Boolean @default(true)
|
isActive Boolean @default(true)
|
||||||
User User @relation(fields: [createdBy], references: [id])
|
User User @relation(fields: [createdBy], references: [id])
|
||||||
createdBy String
|
createdBy String
|
||||||
|
isEdited Boolean @default(false)
|
||||||
|
createdAt DateTime @default(now())
|
||||||
|
updatedAt DateTime @updatedAt
|
||||||
|
}
|
||||||
|
model DivisionDiscussionFile {
|
||||||
|
id String @id @default(cuid())
|
||||||
|
DivisionDisscussion DivisionDisscussion @relation(fields: [idDiscussion], references: [id])
|
||||||
|
idDiscussion String
|
||||||
|
name String
|
||||||
|
extension String
|
||||||
|
idStorage String?
|
||||||
|
isActive Boolean @default(true)
|
||||||
createdAt DateTime @default(now())
|
createdAt DateTime @default(now())
|
||||||
updatedAt DateTime @updatedAt
|
updatedAt DateTime @updatedAt
|
||||||
}
|
}
|
||||||
@@ -594,6 +620,7 @@ model Discussion {
|
|||||||
updatedAt DateTime @updatedAt
|
updatedAt DateTime @updatedAt
|
||||||
DiscussionMember DiscussionMember[]
|
DiscussionMember DiscussionMember[]
|
||||||
DiscussionComment DiscussionComment[]
|
DiscussionComment DiscussionComment[]
|
||||||
|
DiscussionFile DiscussionFile[]
|
||||||
}
|
}
|
||||||
|
|
||||||
model DiscussionMember {
|
model DiscussionMember {
|
||||||
@@ -615,6 +642,19 @@ model DiscussionComment {
|
|||||||
idUser String
|
idUser String
|
||||||
comment String @db.Text
|
comment String @db.Text
|
||||||
isActive Boolean @default(true)
|
isActive Boolean @default(true)
|
||||||
|
isEdited Boolean @default(false)
|
||||||
|
createdAt DateTime @default(now())
|
||||||
|
updatedAt DateTime @updatedAt
|
||||||
|
}
|
||||||
|
|
||||||
|
model DiscussionFile {
|
||||||
|
id String @id @default(cuid())
|
||||||
|
Discussion Discussion @relation(fields: [idDiscussion], references: [id])
|
||||||
|
idDiscussion String
|
||||||
|
name String
|
||||||
|
extension String
|
||||||
|
idStorage String?
|
||||||
|
isActive Boolean @default(true)
|
||||||
createdAt DateTime @default(now())
|
createdAt DateTime @default(now())
|
||||||
updatedAt DateTime @updatedAt
|
updatedAt DateTime @updatedAt
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -3,8 +3,8 @@ import { funGetUserByCookies } from "@/module/auth";
|
|||||||
import { createLogUser } from "@/module/user";
|
import { createLogUser } from "@/module/user";
|
||||||
import _ from "lodash";
|
import _ from "lodash";
|
||||||
import moment from "moment";
|
import moment from "moment";
|
||||||
import { NextResponse } from "next/server";
|
|
||||||
import "moment/locale/id";
|
import "moment/locale/id";
|
||||||
|
import { NextResponse } from "next/server";
|
||||||
|
|
||||||
|
|
||||||
// GET ONE DETAIL DISKUSI UMUM
|
// GET ONE DETAIL DISKUSI UMUM
|
||||||
@@ -75,6 +75,9 @@ export async function GET(request: Request, context: { params: { id: string } })
|
|||||||
img: true
|
img: true
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
},
|
||||||
|
orderBy: {
|
||||||
|
createdAt: "asc"
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
|
|||||||
@@ -74,6 +74,9 @@ export async function GET(request: Request) {
|
|||||||
DiscussionComment: {
|
DiscussionComment: {
|
||||||
select: {
|
select: {
|
||||||
id: true,
|
id: true,
|
||||||
|
},
|
||||||
|
where:{
|
||||||
|
isActive:true
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -60,6 +60,12 @@ export async function GET(request: Request, context: { params: { id: string } })
|
|||||||
img: true
|
img: true
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
},
|
||||||
|
where: {
|
||||||
|
isActive:true
|
||||||
|
},
|
||||||
|
orderBy: {
|
||||||
|
createdAt: "asc"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -64,6 +64,9 @@ export async function GET(request: Request) {
|
|||||||
DivisionDisscussionComment: {
|
DivisionDisscussionComment: {
|
||||||
select: {
|
select: {
|
||||||
id: true,
|
id: true,
|
||||||
|
},
|
||||||
|
where:{
|
||||||
|
isActive:true
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,4 +1,3 @@
|
|||||||
import { DivisionProject } from './../../../../node_modules/.prisma/client/index.d';
|
|
||||||
import { prisma } from "@/module/_global";
|
import { prisma } from "@/module/_global";
|
||||||
import { funGetUserByCookies } from "@/module/auth";
|
import { funGetUserByCookies } from "@/module/auth";
|
||||||
import _, { ceil } from "lodash";
|
import _, { ceil } from "lodash";
|
||||||
@@ -36,22 +35,28 @@ export async function GET(request: Request) {
|
|||||||
isActive: true,
|
isActive: true,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else if (roleUser == "admin" || roleUser == "cosupadmin") {
|
} else {
|
||||||
kondisi = {
|
kondisi = {
|
||||||
isActive: true,
|
isActive: true,
|
||||||
idGroup: idGroup
|
idGroup: idGroup
|
||||||
}
|
}
|
||||||
} else {
|
|
||||||
kondisi = {
|
|
||||||
isActive: true,
|
|
||||||
idGroup: idGroup,
|
|
||||||
ProjectMember: {
|
|
||||||
some: {
|
|
||||||
idUser: user.id
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
// else if (roleUser == "admin" || roleUser == "cosupadmin") {
|
||||||
|
// kondisi = {
|
||||||
|
// isActive: true,
|
||||||
|
// idGroup: idGroup
|
||||||
|
// }
|
||||||
|
// } else {
|
||||||
|
// kondisi = {
|
||||||
|
// isActive: true,
|
||||||
|
// idGroup: idGroup,
|
||||||
|
// ProjectMember: {
|
||||||
|
// some: {
|
||||||
|
// idUser: user.id
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
|
||||||
const data = await prisma.project.findMany({
|
const data = await prisma.project.findMany({
|
||||||
skip: 0,
|
skip: 0,
|
||||||
@@ -74,7 +79,7 @@ export async function GET(request: Request) {
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
orderBy: {
|
orderBy: {
|
||||||
createdAt: "desc"
|
updatedAt: "desc"
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
@@ -96,22 +101,28 @@ export async function GET(request: Request) {
|
|||||||
isActive: true,
|
isActive: true,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else if (roleUser == "admin" || roleUser == "cosupadmin") {
|
} else {
|
||||||
kondisi = {
|
kondisi = {
|
||||||
isActive: true,
|
isActive: true,
|
||||||
idGroup: idGroup
|
idGroup: idGroup
|
||||||
}
|
}
|
||||||
} else {
|
|
||||||
kondisi = {
|
|
||||||
isActive: true,
|
|
||||||
idGroup: idGroup,
|
|
||||||
DivisionMember: {
|
|
||||||
some: {
|
|
||||||
idUser: user.id
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
// else if (roleUser == "admin" || roleUser == "cosupadmin") {
|
||||||
|
// kondisi = {
|
||||||
|
// isActive: true,
|
||||||
|
// idGroup: idGroup
|
||||||
|
// }
|
||||||
|
// } else {
|
||||||
|
// kondisi = {
|
||||||
|
// isActive: true,
|
||||||
|
// idGroup: idGroup,
|
||||||
|
// DivisionMember: {
|
||||||
|
// some: {
|
||||||
|
// idUser: user.id
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
|
||||||
const data = await prisma.division.findMany({
|
const data = await prisma.division.findMany({
|
||||||
where: kondisi,
|
where: kondisi,
|
||||||
@@ -134,7 +145,9 @@ export async function GET(request: Request) {
|
|||||||
jumlah: v.DivisionProject.length,
|
jumlah: v.DivisionProject.length,
|
||||||
}))
|
}))
|
||||||
|
|
||||||
allData = _.orderBy(format, 'jumlah', 'desc').slice(0, 5)
|
const filter = format.filter((v: any) => v.jumlah > 0)
|
||||||
|
|
||||||
|
allData = _.orderBy(filter, 'jumlah', 'desc').slice(0, 5)
|
||||||
|
|
||||||
} else if (kategori == "progress") {
|
} else if (kategori == "progress") {
|
||||||
let kondisi
|
let kondisi
|
||||||
@@ -143,37 +156,50 @@ export async function GET(request: Request) {
|
|||||||
if (roleUser == "supadmin" || roleUser == "developer") {
|
if (roleUser == "supadmin" || roleUser == "developer") {
|
||||||
kondisi = {
|
kondisi = {
|
||||||
isActive: true,
|
isActive: true,
|
||||||
Division: {
|
idVillage: idVillage,
|
||||||
|
Group: {
|
||||||
isActive: true,
|
isActive: true,
|
||||||
idVillage: idVillage,
|
|
||||||
Group: {
|
|
||||||
isActive: true,
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
} else if (roleUser == "admin" || roleUser == "cosupadmin") {
|
|
||||||
kondisi = {
|
|
||||||
isActive: true,
|
|
||||||
Division: {
|
|
||||||
isActive: true,
|
|
||||||
idGroup: idGroup
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
// kondisi = {
|
||||||
|
// isActive: true,
|
||||||
|
// Division: {
|
||||||
|
// isActive: true,
|
||||||
|
// idVillage: idVillage,
|
||||||
|
// Group: {
|
||||||
|
// isActive: true,
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
// }
|
||||||
} else {
|
} else {
|
||||||
kondisi = {
|
kondisi = {
|
||||||
isActive: true,
|
isActive: true,
|
||||||
Division: {
|
idGroup: idGroup
|
||||||
isActive: true,
|
|
||||||
DivisionMember: {
|
|
||||||
some: {
|
|
||||||
idUser: user.id
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
// else if (roleUser == "admin" || roleUser == "cosupadmin") {
|
||||||
|
// kondisi = {
|
||||||
|
// isActive: true,
|
||||||
|
// Division: {
|
||||||
|
// isActive: true,
|
||||||
|
// idGroup: idGroup
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
// } else {
|
||||||
|
// kondisi = {
|
||||||
|
// isActive: true,
|
||||||
|
// Division: {
|
||||||
|
// isActive: true,
|
||||||
|
// DivisionMember: {
|
||||||
|
// some: {
|
||||||
|
// idUser: user.id
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
|
||||||
const data = await prisma.divisionProject.groupBy({
|
const data = await prisma.project.groupBy({
|
||||||
where: kondisi,
|
where: kondisi,
|
||||||
by: ["status"],
|
by: ["status"],
|
||||||
_count: true
|
_count: true
|
||||||
@@ -218,7 +244,7 @@ export async function GET(request: Request) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else if (roleUser == "admin" || roleUser == "cosupadmin") {
|
} else {
|
||||||
kondisi = {
|
kondisi = {
|
||||||
isActive: true,
|
isActive: true,
|
||||||
category: 'FILE',
|
category: 'FILE',
|
||||||
@@ -227,20 +253,30 @@ export async function GET(request: Request) {
|
|||||||
idGroup: idGroup
|
idGroup: idGroup
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else {
|
|
||||||
kondisi = {
|
|
||||||
isActive: true,
|
|
||||||
category: 'FILE',
|
|
||||||
Division: {
|
|
||||||
isActive: true,
|
|
||||||
DivisionMember: {
|
|
||||||
some: {
|
|
||||||
idUser: user.id
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
// else if (roleUser == "admin" || roleUser == "cosupadmin") {
|
||||||
|
// kondisi = {
|
||||||
|
// isActive: true,
|
||||||
|
// category: 'FILE',
|
||||||
|
// Division: {
|
||||||
|
// isActive: true,
|
||||||
|
// idGroup: idGroup
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
// } else {
|
||||||
|
// kondisi = {
|
||||||
|
// isActive: true,
|
||||||
|
// category: 'FILE',
|
||||||
|
// Division: {
|
||||||
|
// isActive: true,
|
||||||
|
// DivisionMember: {
|
||||||
|
// some: {
|
||||||
|
// idUser: user.id
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
|
||||||
const data = await prisma.divisionDocumentFolderFile.findMany({
|
const data = await prisma.divisionDocumentFolderFile.findMany({
|
||||||
where: kondisi,
|
where: kondisi,
|
||||||
@@ -377,7 +413,7 @@ export async function GET(request: Request) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else if (roleUser == "admin" || roleUser == "cosupadmin") {
|
} else {
|
||||||
kondisi = {
|
kondisi = {
|
||||||
isActive: true,
|
isActive: true,
|
||||||
status: 1,
|
status: 1,
|
||||||
@@ -386,20 +422,30 @@ export async function GET(request: Request) {
|
|||||||
isActive: true
|
isActive: true
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else {
|
|
||||||
kondisi = {
|
|
||||||
isActive: true,
|
|
||||||
status: 1,
|
|
||||||
Division: {
|
|
||||||
isActive: true,
|
|
||||||
DivisionMember: {
|
|
||||||
some: {
|
|
||||||
idUser: user.id
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
// else if (roleUser == "admin" || roleUser == "cosupadmin") {
|
||||||
|
// kondisi = {
|
||||||
|
// isActive: true,
|
||||||
|
// status: 1,
|
||||||
|
// Division: {
|
||||||
|
// idGroup: idGroup,
|
||||||
|
// isActive: true
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
// } else {
|
||||||
|
// kondisi = {
|
||||||
|
// isActive: true,
|
||||||
|
// status: 1,
|
||||||
|
// Division: {
|
||||||
|
// isActive: true,
|
||||||
|
// DivisionMember: {
|
||||||
|
// some: {
|
||||||
|
// idUser: user.id
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
|
||||||
const data = await prisma.divisionDisscussion.findMany({
|
const data = await prisma.divisionDisscussion.findMany({
|
||||||
skip: 0,
|
skip: 0,
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
import { prisma } from "@/module/_global";
|
import { DIR, funUploadFile, prisma } from "@/module/_global";
|
||||||
import { funGetUserById } from "@/module/auth";
|
import { funGetUserById } from "@/module/auth";
|
||||||
import { createLogUserMobile } from "@/module/user";
|
import { createLogUserMobile } from "@/module/user";
|
||||||
import _ from "lodash";
|
import _ from "lodash";
|
||||||
@@ -20,6 +20,7 @@ export async function GET(request: Request, context: { params: { id: string } })
|
|||||||
const data = await prisma.announcement.count({
|
const data = await prisma.announcement.count({
|
||||||
where: {
|
where: {
|
||||||
id: id,
|
id: id,
|
||||||
|
isActive: true,
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
|
||||||
@@ -29,7 +30,7 @@ export async function GET(request: Request, context: { params: { id: string } })
|
|||||||
success: false,
|
success: false,
|
||||||
message: "Gagal mendapatkan pengumuman, data tidak ditemukan",
|
message: "Gagal mendapatkan pengumuman, data tidak ditemukan",
|
||||||
},
|
},
|
||||||
{ status: 404 }
|
{ status: 200 }
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -75,13 +76,26 @@ export async function GET(request: Request, context: { params: { id: string } })
|
|||||||
// const fixMember = Object.groupBy(formatMember, ({ group }) => group);
|
// const fixMember = Object.groupBy(formatMember, ({ group }) => group);
|
||||||
const fixMember = _.groupBy(formatMember, ({ group }) => group);
|
const fixMember = _.groupBy(formatMember, ({ group }) => group);
|
||||||
|
|
||||||
|
const file = await prisma.announcementFile.findMany({
|
||||||
|
where: {
|
||||||
|
idAnnouncement: id
|
||||||
|
},
|
||||||
|
select: {
|
||||||
|
id: true,
|
||||||
|
idStorage: true,
|
||||||
|
name: true,
|
||||||
|
extension: true
|
||||||
|
}
|
||||||
|
})
|
||||||
|
|
||||||
|
|
||||||
return NextResponse.json(
|
return NextResponse.json(
|
||||||
{
|
{
|
||||||
success: true,
|
success: true,
|
||||||
message: "Berhasil mendapatkan pengumuman",
|
message: "Berhasil mendapatkan pengumuman",
|
||||||
data: announcement,
|
data: announcement,
|
||||||
member: fixMember
|
member: fixMember,
|
||||||
|
file: file
|
||||||
},
|
},
|
||||||
{ status: 200 }
|
{ status: 200 }
|
||||||
);
|
);
|
||||||
@@ -153,7 +167,12 @@ export async function DELETE(request: Request, context: { params: { id: string }
|
|||||||
// EDIT PENGUMUMAN
|
// EDIT PENGUMUMAN
|
||||||
export async function PUT(request: Request, context: { params: { id: string } }) {
|
export async function PUT(request: Request, context: { params: { id: string } }) {
|
||||||
try {
|
try {
|
||||||
const { title, desc, groups, user } = (await request.json());
|
const body = await request.formData()
|
||||||
|
const dataBody = body.get("data")
|
||||||
|
const cekFile = body.has("file0")
|
||||||
|
|
||||||
|
// const { title, desc, groups, user } = (await request.json());
|
||||||
|
const { title, desc, groups, user, oldFile } = JSON.parse(dataBody as string)
|
||||||
const { id } = context.params;
|
const { id } = context.params;
|
||||||
const userMobile = await funGetUserById({ id: String(user) })
|
const userMobile = await funGetUserById({ id: String(user) })
|
||||||
|
|
||||||
@@ -173,7 +192,7 @@ export async function PUT(request: Request, context: { params: { id: string } })
|
|||||||
success: false,
|
success: false,
|
||||||
message: "Edit pengumuman gagal, data tidak ditemukan",
|
message: "Edit pengumuman gagal, data tidak ditemukan",
|
||||||
},
|
},
|
||||||
{ status: 404 }
|
{ status: 200 }
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -213,6 +232,41 @@ export async function PUT(request: Request, context: { params: { id: string } })
|
|||||||
data: memberDivision,
|
data: memberDivision,
|
||||||
});
|
});
|
||||||
|
|
||||||
|
if (oldFile.length > 0) {
|
||||||
|
for (let index = 0; index < oldFile.length; index++) {
|
||||||
|
const element = oldFile[index];
|
||||||
|
if (element.delete) {
|
||||||
|
await prisma.announcementFile.delete({
|
||||||
|
where: {
|
||||||
|
id: element.id
|
||||||
|
}
|
||||||
|
})
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (cekFile) {
|
||||||
|
body.delete("data")
|
||||||
|
for (var pair of body.entries()) {
|
||||||
|
if (String(pair[0]).substring(0, 4) == "file") {
|
||||||
|
const file = body.get(pair[0]) as File
|
||||||
|
const fExt = file.name.split(".").pop()
|
||||||
|
const fName = decodeURIComponent(file.name.replace("." + fExt, ""))
|
||||||
|
const upload = await funUploadFile({ file: file, dirId: DIR.announcement })
|
||||||
|
if (upload.success) {
|
||||||
|
await prisma.announcementFile.create({
|
||||||
|
data: {
|
||||||
|
idStorage: upload.data.id,
|
||||||
|
idAnnouncement: id,
|
||||||
|
name: fName,
|
||||||
|
extension: String(fExt)
|
||||||
|
}
|
||||||
|
})
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// create log user
|
// create log user
|
||||||
const log = await createLogUserMobile({ act: 'UPDATE', desc: 'User mengupdate data pengumuman', table: 'announcement', data: id, user: userMobile.id })
|
const log = await createLogUserMobile({ act: 'UPDATE', desc: 'User mengupdate data pengumuman', table: 'announcement', data: id, user: userMobile.id })
|
||||||
|
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
import { funSendWebPush, prisma } from "@/module/_global";
|
import { DIR, funSendWebPush, funUploadFile, prisma } from "@/module/_global";
|
||||||
import { funGetUserById } from "@/module/auth";
|
import { funGetUserById } from "@/module/auth";
|
||||||
import { createLogUserMobile } from '@/module/user';
|
import { createLogUserMobile } from '@/module/user';
|
||||||
import _ from "lodash";
|
import _ from "lodash";
|
||||||
@@ -113,7 +113,12 @@ export async function GET(request: Request) {
|
|||||||
// CREATE PENGUMUMAN
|
// CREATE PENGUMUMAN
|
||||||
export async function POST(request: Request) {
|
export async function POST(request: Request) {
|
||||||
try {
|
try {
|
||||||
const { title, desc, groups, user } = (await request.json());
|
const body = await request.formData()
|
||||||
|
const dataBody = body.get("data")
|
||||||
|
const cekFile = body.has("file0")
|
||||||
|
|
||||||
|
// const { title, desc, groups, user } = (await request.json());
|
||||||
|
const { title, desc, groups, user } = JSON.parse(dataBody as string)
|
||||||
const userMobile = await funGetUserById({ id: String(user) })
|
const userMobile = await funGetUserById({ id: String(user) })
|
||||||
|
|
||||||
if (userMobile.id == "null" || userMobile.id == undefined || userMobile.id == "") {
|
if (userMobile.id == "null" || userMobile.id == undefined || userMobile.id == "") {
|
||||||
@@ -152,6 +157,29 @@ export async function POST(request: Request) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
if (cekFile) {
|
||||||
|
body.delete("data")
|
||||||
|
for (var pair of body.entries()) {
|
||||||
|
if (String(pair[0]).substring(0, 4) == "file") {
|
||||||
|
const file = body.get(pair[0]) as File
|
||||||
|
const fExt = file.name.split(".").pop()
|
||||||
|
const fName = decodeURIComponent(file.name.replace("." + fExt, ""))
|
||||||
|
const upload = await funUploadFile({ file: file, dirId: DIR.announcement })
|
||||||
|
if (upload.success) {
|
||||||
|
await prisma.announcementFile.create({
|
||||||
|
data: {
|
||||||
|
idStorage: upload.data.id,
|
||||||
|
idAnnouncement: data.id,
|
||||||
|
name: fName,
|
||||||
|
extension: String(fExt)
|
||||||
|
}
|
||||||
|
})
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
const announcementMember = await prisma.announcementMember.createMany({
|
const announcementMember = await prisma.announcementMember.createMany({
|
||||||
data: memberDivision,
|
data: memberDivision,
|
||||||
});
|
});
|
||||||
@@ -255,15 +283,20 @@ export async function POST(request: Request) {
|
|||||||
|
|
||||||
|
|
||||||
const dataNotifFilter = dataNotif.filter((v: any) => v.idUserTo != undefined && v.idUserTo != null && v.idUserTo != "" && v.idUserTo != userId)
|
const dataNotifFilter = dataNotif.filter((v: any) => v.idUserTo != undefined && v.idUserTo != null && v.idUserTo != "" && v.idUserTo != userId)
|
||||||
|
const dataNotifFilterUnique = dataNotifFilter
|
||||||
|
.filter((v: any, index: number, self: any[]) =>
|
||||||
|
index === self.findIndex((t: any) => t.idUserTo == v.idUserTo)
|
||||||
|
)
|
||||||
|
|
||||||
const pushNotif = dataPush.filter((item) => item.subscription != undefined)
|
const pushNotif = dataPush.filter((item) => item.subscription != undefined)
|
||||||
|
|
||||||
const sendWebPush = await funSendWebPush({ sub: pushNotif, message: { title: 'Pengumuman Baru', body: title } })
|
const sendWebPush = await funSendWebPush({ sub: pushNotif, message: { title: 'Pengumuman Baru', body: title } })
|
||||||
const insertNotif = await prisma.notifications.createMany({
|
const insertNotif = await prisma.notifications.createMany({
|
||||||
data: dataNotifFilter
|
data: dataNotifFilterUnique
|
||||||
})
|
})
|
||||||
|
|
||||||
const tokenUnique = [...new Set(tokenDup.flat())].filter((v: any) => v != undefined && v != null && v != "");
|
const tokenUnique = [...new Set(tokenDup.flat())].filter((v: any) => v != undefined && v != null && v != "");
|
||||||
|
|
||||||
await sendFCMNotificationMany({
|
await sendFCMNotificationMany({
|
||||||
token: tokenUnique,
|
token: tokenUnique,
|
||||||
title: "Pengumuman Baru",
|
title: "Pengumuman Baru",
|
||||||
|
|||||||
@@ -11,7 +11,7 @@ export async function GET(request: Request) {
|
|||||||
const userMobile = searchParams.get("user")
|
const userMobile = searchParams.get("user")
|
||||||
|
|
||||||
if (userMobile == "null" || userMobile == undefined || userMobile == "") {
|
if (userMobile == "null" || userMobile == undefined || userMobile == "") {
|
||||||
return NextResponse.json({ success: false, message: "Anda harus login untuk mengakses ini" }, { status: 401 });
|
return NextResponse.json({ success: false, message: "Anda harus login untuk mengakses ini" }, { status: 200 });
|
||||||
}
|
}
|
||||||
|
|
||||||
const user = await funGetUserById({ id: userMobile })
|
const user = await funGetUserById({ id: userMobile })
|
||||||
|
|||||||
@@ -37,6 +37,29 @@ export async function POST(request: Request, context: { params: { id: string } }
|
|||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
|
const dataDiscussion = await prisma.discussion.findUnique({
|
||||||
|
where: {
|
||||||
|
id
|
||||||
|
},
|
||||||
|
select: {
|
||||||
|
createdBy: true,
|
||||||
|
User: {
|
||||||
|
select: {
|
||||||
|
Subscribe: {
|
||||||
|
select: {
|
||||||
|
subscription: true
|
||||||
|
}
|
||||||
|
},
|
||||||
|
TokenDeviceUser: {
|
||||||
|
select: {
|
||||||
|
token: true
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
})
|
||||||
|
|
||||||
const member = await prisma.discussionMember.findMany({
|
const member = await prisma.discussionMember.findMany({
|
||||||
where: {
|
where: {
|
||||||
idDiscussion: id,
|
idDiscussion: id,
|
||||||
@@ -70,7 +93,10 @@ export async function POST(request: Request, context: { params: { id: string } }
|
|||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
const memberFilter = member.filter((v: any) => v.idUser != userMobile.id)
|
const memberFilter = [...member, { idUser: dataDiscussion?.createdBy, User: dataDiscussion?.User }].filter((v: any) => v.idUser != userMobile.id)
|
||||||
|
.filter((v: any, index: number, self: any[]) =>
|
||||||
|
index === self.findIndex((t) => t.idUser === v.idUser)
|
||||||
|
);
|
||||||
|
|
||||||
const dataFCM = memberFilter.map((v: any) => ({
|
const dataFCM = memberFilter.map((v: any) => ({
|
||||||
..._.omit(v, ["idUser", "User", "Subscribe", "TokenDeviceUser"]),
|
..._.omit(v, ["idUser", "User", "Subscribe", "TokenDeviceUser"]),
|
||||||
@@ -121,4 +147,90 @@ export async function POST(request: Request, context: { params: { id: string } }
|
|||||||
console.error(error)
|
console.error(error)
|
||||||
return NextResponse.json({ success: false, message: "Gagal menambahkan komentar, coba lagi nanti (error: 500)" })
|
return NextResponse.json({ success: false, message: "Gagal menambahkan komentar, coba lagi nanti (error: 500)" })
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// EDIT KOMENTAR
|
||||||
|
export async function PUT(request: Request, context: { params: { id: string } }) {
|
||||||
|
try {
|
||||||
|
const { id } = context.params
|
||||||
|
const { desc, 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 cek = await prisma.discussionComment.count({
|
||||||
|
where: {
|
||||||
|
id,
|
||||||
|
isActive: true
|
||||||
|
}
|
||||||
|
})
|
||||||
|
|
||||||
|
if (cek == 0) {
|
||||||
|
return NextResponse.json({ success: false, message: "Gagal mengedit komentar, data tidak ditemukan" }, { status: 200 });
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
const data = await prisma.discussionComment.update({
|
||||||
|
where: {
|
||||||
|
id
|
||||||
|
},
|
||||||
|
data: {
|
||||||
|
comment: desc,
|
||||||
|
isEdited: true
|
||||||
|
}
|
||||||
|
})
|
||||||
|
|
||||||
|
// create log user
|
||||||
|
const log = await createLogUserMobile({ act: 'UPDATE', desc: 'User mengedit komentar pada diskusi umum', table: 'discussionComment', data: id, user: userMobile.id })
|
||||||
|
return NextResponse.json({ success: true, message: "Berhasil mengedit komentar" }, { status: 200 });
|
||||||
|
|
||||||
|
} catch (error) {
|
||||||
|
console.error(error)
|
||||||
|
return NextResponse.json({ success: false, message: "Gagal mengedit komentar, coba lagi nanti (error: 500)" })
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// HAPUS KOMENTAR
|
||||||
|
export async function DELETE(request: Request, context: { params: { id: string } }) {
|
||||||
|
try {
|
||||||
|
const { id } = context.params
|
||||||
|
const { 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 cek = await prisma.discussionComment.count({
|
||||||
|
where: {
|
||||||
|
id,
|
||||||
|
isActive: true
|
||||||
|
}
|
||||||
|
})
|
||||||
|
|
||||||
|
if (cek == 0) {
|
||||||
|
return NextResponse.json({ success: false, message: "Gagal mengedit komentar, data tidak ditemukan" }, { status: 200 });
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
const data = await prisma.discussionComment.update({
|
||||||
|
where: {
|
||||||
|
id
|
||||||
|
},
|
||||||
|
data: {
|
||||||
|
isActive: false
|
||||||
|
}
|
||||||
|
})
|
||||||
|
|
||||||
|
// create log user
|
||||||
|
const log = await createLogUserMobile({ act: 'DELETE', desc: 'User menghapus komentar pada diskusi umum', table: 'discussionComment', data: id, user: userMobile.id })
|
||||||
|
return NextResponse.json({ success: true, message: "Berhasil mengedit komentar" }, { status: 200 });
|
||||||
|
|
||||||
|
} catch (error) {
|
||||||
|
console.error(error)
|
||||||
|
return NextResponse.json({ success: false, message: "Gagal mengedit komentar, coba lagi nanti (error: 500)" })
|
||||||
|
}
|
||||||
}
|
}
|
||||||
@@ -1,4 +1,4 @@
|
|||||||
import { countTime, prisma } from "@/module/_global";
|
import { countTime, DIR, funUploadFile, prisma } from "@/module/_global";
|
||||||
import { funGetUserById } from "@/module/auth";
|
import { funGetUserById } from "@/module/auth";
|
||||||
import { createLogUserMobile } from "@/module/user";
|
import { createLogUserMobile } from "@/module/user";
|
||||||
import _ from "lodash";
|
import _ from "lodash";
|
||||||
@@ -19,7 +19,7 @@ export async function GET(request: Request, context: { params: { id: string } })
|
|||||||
const user = await funGetUserById({ id: String(userMobile) })
|
const user = await funGetUserById({ id: String(userMobile) })
|
||||||
|
|
||||||
if (user.id == "null" || user.id == undefined || user.id == "") {
|
if (user.id == "null" || user.id == undefined || user.id == "") {
|
||||||
return NextResponse.json({ success: false, message: "Anda harus login untuk mengakses ini" }, { status: 401 });
|
return NextResponse.json({ success: false, message: "Anda harus login untuk mengakses ini" }, { status: 200 });
|
||||||
}
|
}
|
||||||
|
|
||||||
const cek = await prisma.discussion.count({
|
const cek = await prisma.discussion.count({
|
||||||
@@ -29,7 +29,7 @@ export async function GET(request: Request, context: { params: { id: string } })
|
|||||||
})
|
})
|
||||||
|
|
||||||
if (cek == 0) {
|
if (cek == 0) {
|
||||||
return NextResponse.json({ success: false, message: "Gagal mendapatkan diskusi, data tidak ditemukan" }, { status: 404 });
|
return NextResponse.json({ success: false, message: "Gagal mendapatkan diskusi, data tidak ditemukan" }, { status: 200 });
|
||||||
}
|
}
|
||||||
|
|
||||||
if (kategori == "detail") {
|
if (kategori == "detail") {
|
||||||
@@ -68,6 +68,8 @@ export async function GET(request: Request, context: { params: { id: string } })
|
|||||||
id: true,
|
id: true,
|
||||||
comment: true,
|
comment: true,
|
||||||
createdAt: true,
|
createdAt: true,
|
||||||
|
updatedAt: true,
|
||||||
|
isEdited: true,
|
||||||
idUser: true,
|
idUser: true,
|
||||||
User: {
|
User: {
|
||||||
select: {
|
select: {
|
||||||
@@ -75,12 +77,16 @@ export async function GET(request: Request, context: { params: { id: string } })
|
|||||||
img: true
|
img: true
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
},
|
||||||
|
orderBy: {
|
||||||
|
createdAt: "asc"
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
dataFix = data.map((v: any) => ({
|
dataFix = data.map((v: any) => ({
|
||||||
..._.omit(v, ["createdAt", "User",]),
|
..._.omit(v, ["createdAt", "User", "updatedAt"]),
|
||||||
createdAt: countTime(v.createdAt),
|
createdAt: countTime(v.createdAt),
|
||||||
|
updatedAt: moment(v.updatedAt).format("ll"),
|
||||||
username: v.User.name,
|
username: v.User.name,
|
||||||
img: v.User.img
|
img: v.User.img
|
||||||
}))
|
}))
|
||||||
@@ -121,8 +127,21 @@ export async function GET(request: Request, context: { params: { id: string } })
|
|||||||
} else {
|
} else {
|
||||||
dataFix = false
|
dataFix = false
|
||||||
}
|
}
|
||||||
}
|
} else if (kategori == "file") {
|
||||||
|
const data = await prisma.discussionFile.findMany({
|
||||||
|
where: {
|
||||||
|
idDiscussion: id
|
||||||
|
},
|
||||||
|
select: {
|
||||||
|
id: true,
|
||||||
|
idStorage: true,
|
||||||
|
name: true,
|
||||||
|
extension: true
|
||||||
|
}
|
||||||
|
})
|
||||||
|
|
||||||
|
dataFix = data
|
||||||
|
}
|
||||||
|
|
||||||
return NextResponse.json({ success: true, message: "Berhasil mendapatkan diskusi", data: dataFix }, { status: 200 });
|
return NextResponse.json({ success: true, message: "Berhasil mendapatkan diskusi", data: dataFix }, { status: 200 });
|
||||||
|
|
||||||
@@ -241,7 +260,12 @@ export async function DELETE(request: Request, context: { params: { id: string }
|
|||||||
export async function PUT(request: Request, context: { params: { id: string } }) {
|
export async function PUT(request: Request, context: { params: { id: string } }) {
|
||||||
try {
|
try {
|
||||||
const { id } = context.params
|
const { id } = context.params
|
||||||
const { title, desc, user } = (await request.json());
|
const body = await request.formData()
|
||||||
|
const dataBody = body.get("data")
|
||||||
|
const cekFile = body.has("file0")
|
||||||
|
|
||||||
|
// const { title, desc, user } = (await request.json());
|
||||||
|
const { title, desc, user, oldFile } = JSON.parse(dataBody as string)
|
||||||
|
|
||||||
const userMobile = await funGetUserById({ id: String(user) })
|
const userMobile = await funGetUserById({ id: String(user) })
|
||||||
|
|
||||||
@@ -269,6 +293,41 @@ export async function PUT(request: Request, context: { params: { id: string } })
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
if (oldFile.length > 0) {
|
||||||
|
for (let index = 0; index < oldFile.length; index++) {
|
||||||
|
const element = oldFile[index];
|
||||||
|
if (element.delete) {
|
||||||
|
await prisma.discussionFile.delete({
|
||||||
|
where: {
|
||||||
|
id: element.id
|
||||||
|
}
|
||||||
|
})
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (cekFile) {
|
||||||
|
body.delete("data")
|
||||||
|
for (var pair of body.entries()) {
|
||||||
|
if (String(pair[0]).substring(0, 4) == "file") {
|
||||||
|
const file = body.get(pair[0]) as File
|
||||||
|
const fExt = file.name.split(".").pop()
|
||||||
|
const fName = decodeURIComponent(file.name.replace("." + fExt, ""))
|
||||||
|
const upload = await funUploadFile({ file: file, dirId: DIR.discussion })
|
||||||
|
if (upload.success) {
|
||||||
|
await prisma.discussionFile.create({
|
||||||
|
data: {
|
||||||
|
idStorage: upload.data.id,
|
||||||
|
idDiscussion: id,
|
||||||
|
name: fName,
|
||||||
|
extension: String(fExt)
|
||||||
|
}
|
||||||
|
})
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// create log user
|
// create log user
|
||||||
const log = await createLogUserMobile({ act: 'UPDATE', desc: 'User mengupdate data diskusi umum', table: 'discussion', data: id, user: userMobile.id })
|
const log = await createLogUserMobile({ act: 'UPDATE', desc: 'User mengupdate data diskusi umum', table: 'discussion', data: id, user: userMobile.id })
|
||||||
return NextResponse.json({ success: true, message: "Berhasil mengedit diskusi umum" }, { status: 200 });
|
return NextResponse.json({ success: true, message: "Berhasil mengedit diskusi umum" }, { status: 200 });
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
import { prisma } from "@/module/_global";
|
import { DIR, funUploadFile, prisma } from "@/module/_global";
|
||||||
import { funGetUserById } from "@/module/auth";
|
import { funGetUserById } from "@/module/auth";
|
||||||
import { createLogUserMobile } from "@/module/user";
|
import { createLogUserMobile } from "@/module/user";
|
||||||
import _ from "lodash";
|
import _ from "lodash";
|
||||||
@@ -15,7 +15,7 @@ export async function GET(request: Request) {
|
|||||||
const { searchParams } = new URL(request.url);
|
const { searchParams } = new URL(request.url);
|
||||||
const user = searchParams.get("user")
|
const user = searchParams.get("user")
|
||||||
if (user == "null" || user == undefined || user == "") {
|
if (user == "null" || user == undefined || user == "") {
|
||||||
return NextResponse.json({ success: false, message: "Anda harus login untuk mengakses ini" }, { status: 401 });
|
return NextResponse.json({ success: false, message: "Anda harus login untuk mengakses ini" }, { status: 200 });
|
||||||
}
|
}
|
||||||
|
|
||||||
const userMobile = await funGetUserById({ id: user })
|
const userMobile = await funGetUserById({ id: user })
|
||||||
@@ -75,6 +75,9 @@ export async function GET(request: Request) {
|
|||||||
DiscussionComment: {
|
DiscussionComment: {
|
||||||
select: {
|
select: {
|
||||||
id: true,
|
id: true,
|
||||||
|
},
|
||||||
|
where: {
|
||||||
|
isActive: true
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -109,13 +112,20 @@ export async function GET(request: Request) {
|
|||||||
// CREATE DISCUSSION GENERALE
|
// CREATE DISCUSSION GENERALE
|
||||||
export async function POST(request: Request) {
|
export async function POST(request: Request) {
|
||||||
try {
|
try {
|
||||||
const { idGroup, user, title, desc, member } = await request.json();
|
|
||||||
|
|
||||||
if (user == "null" || user == undefined || user == "") {
|
const body = await request.formData()
|
||||||
|
const dataBody = body.get("data")
|
||||||
|
const cekFile = body.has("file0")
|
||||||
|
|
||||||
|
// const { idGroup, user, title, desc, member } = await request.json();
|
||||||
|
const { idGroup, user, title, desc, member } = JSON.parse(dataBody as string)
|
||||||
|
|
||||||
|
const userMobile = await funGetUserById({ id: user })
|
||||||
|
|
||||||
|
if (userMobile.id == "null" || userMobile.id == undefined || userMobile.id == "") {
|
||||||
return NextResponse.json({ success: false, message: "Anda harus login untuk mengakses ini" }, { status: 200 });
|
return NextResponse.json({ success: false, message: "Anda harus login untuk mengakses ini" }, { status: 200 });
|
||||||
}
|
}
|
||||||
|
|
||||||
const userMobile = await funGetUserById({ id: user })
|
|
||||||
const userId = user
|
const userId = user
|
||||||
const userRoleLogin = userMobile.idUserRole
|
const userRoleLogin = userMobile.idUserRole
|
||||||
|
|
||||||
@@ -142,6 +152,29 @@ export async function POST(request: Request) {
|
|||||||
data: dataMember
|
data: dataMember
|
||||||
})
|
})
|
||||||
|
|
||||||
|
|
||||||
|
if (cekFile) {
|
||||||
|
body.delete("data")
|
||||||
|
for (var pair of body.entries()) {
|
||||||
|
if (String(pair[0]).substring(0, 4) == "file") {
|
||||||
|
const file = body.get(pair[0]) as File
|
||||||
|
const fExt = file.name.split(".").pop()
|
||||||
|
const fName = decodeURIComponent(file.name.replace("." + fExt, ""))
|
||||||
|
const upload = await funUploadFile({ file: file, dirId: DIR.discussion })
|
||||||
|
if (upload.success) {
|
||||||
|
await prisma.discussionFile.create({
|
||||||
|
data: {
|
||||||
|
idStorage: upload.data.id,
|
||||||
|
idDiscussion: data.id,
|
||||||
|
name: fName,
|
||||||
|
extension: String(fExt)
|
||||||
|
}
|
||||||
|
})
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
const memberNotifMobile = await prisma.discussionMember.findMany({
|
const memberNotifMobile = await prisma.discussionMember.findMany({
|
||||||
where: {
|
where: {
|
||||||
idDiscussion: data.id
|
idDiscussion: data.id
|
||||||
@@ -210,9 +243,13 @@ export async function POST(request: Request) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
dataNotif.filter((v: any) => v.idUserTo != undefined && v.idUserTo != null && v.idUserTo != "" && v.idUserTo != userId)
|
dataNotif.filter((v: any) => v.idUserTo != undefined && v.idUserTo != null && v.idUserTo != "" && v.idUserTo != userId)
|
||||||
|
const dataNotifUnique = dataNotif
|
||||||
|
.filter((v: any, index: number, self: any[]) =>
|
||||||
|
index === self.findIndex((t: any) => t.idUserTo == v.idUserTo)
|
||||||
|
)
|
||||||
|
|
||||||
const insertNotif = await prisma.notifications.createMany({
|
const insertNotif = await prisma.notifications.createMany({
|
||||||
data: dataNotif
|
data: dataNotifUnique
|
||||||
})
|
})
|
||||||
|
|
||||||
const tokenUnique = [...new Set(tokenDup.flat())].filter((v: any) => v != undefined && v != null && v != "");
|
const tokenUnique = [...new Set(tokenDup.flat())].filter((v: any) => v != undefined && v != null && v != "");
|
||||||
|
|||||||
@@ -5,7 +5,7 @@ import _ from "lodash";
|
|||||||
import { NextResponse } from "next/server";
|
import { NextResponse } from "next/server";
|
||||||
import { sendFCMNotificationMany } from "../../../../../../../xsendMany";
|
import { sendFCMNotificationMany } from "../../../../../../../xsendMany";
|
||||||
|
|
||||||
// CREATE COMENT BY ID KOMENTAR
|
// CREATE COMENT
|
||||||
export async function POST(request: Request, context: { params: { id: string } }) {
|
export async function POST(request: Request, context: { params: { id: string } }) {
|
||||||
try {
|
try {
|
||||||
const { id } = context.params
|
const { id } = context.params
|
||||||
@@ -50,6 +50,21 @@ export async function POST(request: Request, context: { params: { id: string } }
|
|||||||
},
|
},
|
||||||
select: {
|
select: {
|
||||||
idDivision: true,
|
idDivision: true,
|
||||||
|
createdBy: true,
|
||||||
|
User: {
|
||||||
|
select: {
|
||||||
|
Subscribe: {
|
||||||
|
select: {
|
||||||
|
subscription: true
|
||||||
|
}
|
||||||
|
},
|
||||||
|
TokenDeviceUser: {
|
||||||
|
select: {
|
||||||
|
token: true
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
@@ -86,7 +101,10 @@ export async function POST(request: Request, context: { params: { id: string } }
|
|||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
const memberFilter = member.filter((v: any) => v.idUser != userMobile.id)
|
const memberFilter = [...member, { idUser: dataDivision?.createdBy, User: dataDivision?.User }].filter((v: any) => v.idUser != userMobile.id)
|
||||||
|
.filter((v: any, index: number, self: any[]) =>
|
||||||
|
index === self.findIndex((t) => t.idUser === v.idUser)
|
||||||
|
);
|
||||||
|
|
||||||
const dataFCM = memberFilter.map((v: any) => ({
|
const dataFCM = memberFilter.map((v: any) => ({
|
||||||
..._.omit(v, ["idUser", "User", "Subscribe", "TokenDeviceUser"]),
|
..._.omit(v, ["idUser", "User", "Subscribe", "TokenDeviceUser"]),
|
||||||
@@ -138,4 +156,103 @@ export async function POST(request: Request, context: { params: { id: string } }
|
|||||||
console.error(error);
|
console.error(error);
|
||||||
return NextResponse.json({ success: false, message: "Gagal menambah komentar, coba lagi nanti (error: 500)", reason: (error as Error).message, }, { status: 500 });
|
return NextResponse.json({ success: false, message: "Gagal menambah komentar, coba lagi nanti (error: 500)", reason: (error as Error).message, }, { status: 500 });
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// EDIT KOMENTAR
|
||||||
|
export async function PUT(request: Request, context: { params: { id: string } }) {
|
||||||
|
try {
|
||||||
|
const { id } = context.params
|
||||||
|
const { comment, 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: "User tidak ditemukan" }, { status: 200 });
|
||||||
|
}
|
||||||
|
|
||||||
|
const cek = await prisma.divisionDisscussionComment.count({
|
||||||
|
where: {
|
||||||
|
id,
|
||||||
|
isActive: true
|
||||||
|
}
|
||||||
|
})
|
||||||
|
|
||||||
|
if (cek == 0) {
|
||||||
|
return NextResponse.json(
|
||||||
|
{
|
||||||
|
success: false,
|
||||||
|
message: "Edit komentar gagal, data tidak ditemukan",
|
||||||
|
},
|
||||||
|
{ status: 200 }
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
const data = await prisma.divisionDisscussionComment.update({
|
||||||
|
where: {
|
||||||
|
id: id
|
||||||
|
},
|
||||||
|
data: {
|
||||||
|
comment: comment,
|
||||||
|
isEdited: true
|
||||||
|
}
|
||||||
|
})
|
||||||
|
|
||||||
|
// create log user
|
||||||
|
const log = await createLogUserMobile({ act: 'UPDATE', desc: 'User mengedit komentar pada diskusi divisi', table: 'divisionDisscussionComment', data: id, user: userMobile.id })
|
||||||
|
|
||||||
|
return NextResponse.json({ success: true, message: "Berhasil mengedit komentar" }, { status: 200 });
|
||||||
|
|
||||||
|
} catch (error) {
|
||||||
|
console.error(error);
|
||||||
|
return NextResponse.json({ success: false, message: "Gagal menambah komentar, coba lagi nanti (error: 500)", reason: (error as Error).message, }, { status: 500 });
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// HAPUS KOMENTAR
|
||||||
|
export async function DELETE(request: Request, context: { params: { id: string } }) {
|
||||||
|
try {
|
||||||
|
const { id } = context.params
|
||||||
|
const { 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: "User tidak ditemukan" }, { status: 200 });
|
||||||
|
}
|
||||||
|
|
||||||
|
const cek = await prisma.divisionDisscussionComment.count({
|
||||||
|
where: {
|
||||||
|
id,
|
||||||
|
isActive: true
|
||||||
|
}
|
||||||
|
})
|
||||||
|
|
||||||
|
if (cek == 0) {
|
||||||
|
return NextResponse.json(
|
||||||
|
{
|
||||||
|
success: false,
|
||||||
|
message: "Hapus komentar gagal, data tidak ditemukan",
|
||||||
|
},
|
||||||
|
{ status: 200 }
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
const data = await prisma.divisionDisscussionComment.update({
|
||||||
|
where: {
|
||||||
|
id: id
|
||||||
|
},
|
||||||
|
data: {
|
||||||
|
isActive: false
|
||||||
|
}
|
||||||
|
})
|
||||||
|
|
||||||
|
// create log user
|
||||||
|
const log = await createLogUserMobile({ act: 'DELETE', desc: 'User menghapus komentar pada diskusi divisi', table: 'divisionDisscussionComment', data: id, user: userMobile.id })
|
||||||
|
|
||||||
|
return NextResponse.json({ success: true, message: "Berhasil menghapus komentar" }, { status: 200 });
|
||||||
|
|
||||||
|
} catch (error) {
|
||||||
|
console.error(error);
|
||||||
|
return NextResponse.json({ success: false, message: "Gagal menghapus komentar, coba lagi nanti (error: 500)", reason: (error as Error).message, }, { status: 500 });
|
||||||
|
}
|
||||||
}
|
}
|
||||||
@@ -1,4 +1,4 @@
|
|||||||
import { countTime, prisma } from "@/module/_global";
|
import { countTime, DIR, funUploadFile, prisma } from "@/module/_global";
|
||||||
import { funGetUserById } from "@/module/auth";
|
import { funGetUserById } from "@/module/auth";
|
||||||
import { createLogUserMobile } from "@/module/user";
|
import { createLogUserMobile } from "@/module/user";
|
||||||
import _ from "lodash";
|
import _ from "lodash";
|
||||||
@@ -31,36 +31,60 @@ export async function GET(request: Request, context: { params: { id: string } })
|
|||||||
success: false,
|
success: false,
|
||||||
message: "Gagal mendapatkan diskusi, data tidak ditemukan",
|
message: "Gagal mendapatkan diskusi, data tidak ditemukan",
|
||||||
},
|
},
|
||||||
{ status: 404 }
|
{ status: 200 }
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (cat == "comment") {
|
if (cat == "comment") {
|
||||||
const data = await prisma.divisionDisscussionComment.findMany({
|
const data = await prisma.divisionDisscussionComment.findMany({
|
||||||
where: {
|
where: {
|
||||||
idDisscussion: id
|
idDisscussion: id,
|
||||||
|
isActive: true
|
||||||
},
|
},
|
||||||
select: {
|
select: {
|
||||||
id: true,
|
id: true,
|
||||||
comment: true,
|
comment: true,
|
||||||
createdAt: true,
|
createdAt: true,
|
||||||
|
updatedAt: true,
|
||||||
|
isEdited: true,
|
||||||
|
createdBy: true,
|
||||||
User: {
|
User: {
|
||||||
select: {
|
select: {
|
||||||
name: true,
|
name: true,
|
||||||
img: true
|
img: true
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
},
|
||||||
|
orderBy: {
|
||||||
|
createdAt: "asc"
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
const omitMember = data.map((v: any) => ({
|
const omitMember = data.map((v: any) => ({
|
||||||
..._.omit(v, ["User", "createdAt"]),
|
..._.omit(v, ["User", "createdBy", "createdAt", "updatedAt"]),
|
||||||
|
idUser: v.createdBy,
|
||||||
username: v.User.name,
|
username: v.User.name,
|
||||||
img: v.User.img,
|
img: v.User.img,
|
||||||
createdAt: countTime(v.createdAt),
|
createdAt: countTime(v.createdAt),
|
||||||
|
updatedAt: moment(v.updatedAt).format("ll")
|
||||||
}))
|
}))
|
||||||
|
|
||||||
return NextResponse.json({ success: true, message: "Berhasil mendapatkan komentar", data: omitMember }, { status: 200 });
|
return NextResponse.json({ success: true, message: "Berhasil mendapatkan komentar", data: omitMember }, { status: 200 });
|
||||||
|
} else if (cat == "file") {
|
||||||
|
const data = await prisma.divisionDiscussionFile.findMany({
|
||||||
|
where: {
|
||||||
|
idDiscussion: id,
|
||||||
|
isActive: true
|
||||||
|
},
|
||||||
|
select: {
|
||||||
|
id: true,
|
||||||
|
idStorage: true,
|
||||||
|
name: true,
|
||||||
|
extension: true
|
||||||
|
}
|
||||||
|
})
|
||||||
|
|
||||||
|
return NextResponse.json({ success: true, message: "Berhasil mendapatkan file", data: data }, { status: 200 });
|
||||||
} else {
|
} else {
|
||||||
const data = await prisma.divisionDisscussion.findUnique({
|
const data = await prisma.divisionDisscussion.findUnique({
|
||||||
where: {
|
where: {
|
||||||
@@ -128,7 +152,7 @@ export async function DELETE(request: Request, context: { params: { id: string }
|
|||||||
});
|
});
|
||||||
|
|
||||||
if (data == 0) {
|
if (data == 0) {
|
||||||
return NextResponse.json({ success: false, message: "Gagal mendapatkan diskusi, data tidak ditemukan" }, { status: 404 });
|
return NextResponse.json({ success: false, message: "Gagal mendapatkan diskusi, data tidak ditemukan" }, { status: 200 });
|
||||||
}
|
}
|
||||||
|
|
||||||
const result = await prisma.divisionDisscussion.update({
|
const result = await prisma.divisionDisscussion.update({
|
||||||
@@ -203,7 +227,13 @@ export async function PUT(request: Request, context: { params: { id: string } })
|
|||||||
export async function POST(request: Request, context: { params: { id: string } }) {
|
export async function POST(request: Request, context: { params: { id: string } }) {
|
||||||
try {
|
try {
|
||||||
const { id } = context.params
|
const { id } = context.params
|
||||||
const { title, desc, user } = (await request.json())
|
const body = await request.formData()
|
||||||
|
const dataBody = body.get("data")
|
||||||
|
const cekFile = body.has("file0")
|
||||||
|
|
||||||
|
// const { title, desc, user } = (await request.json())
|
||||||
|
const { title, desc, user, oldFile } = JSON.parse(dataBody as string)
|
||||||
|
|
||||||
|
|
||||||
const userMobile = await funGetUserById({ id: String(user) })
|
const userMobile = await funGetUserById({ id: String(user) })
|
||||||
|
|
||||||
@@ -230,6 +260,41 @@ export async function POST(request: Request, context: { params: { id: string } }
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
if (oldFile.length > 0) {
|
||||||
|
for (let index = 0; index < oldFile.length; index++) {
|
||||||
|
const element = oldFile[index];
|
||||||
|
if (element.delete) {
|
||||||
|
await prisma.divisionDiscussionFile.delete({
|
||||||
|
where: {
|
||||||
|
id: element.id
|
||||||
|
}
|
||||||
|
})
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (cekFile) {
|
||||||
|
body.delete("data")
|
||||||
|
for (var pair of body.entries()) {
|
||||||
|
if (String(pair[0]).substring(0, 4) == "file") {
|
||||||
|
const file = body.get(pair[0]) as File
|
||||||
|
const fExt = file.name.split(".").pop()
|
||||||
|
const fName = decodeURIComponent(file.name.replace("." + fExt, ""))
|
||||||
|
const upload = await funUploadFile({ file: file, dirId: DIR.discussionDivision })
|
||||||
|
if (upload.success) {
|
||||||
|
await prisma.divisionDiscussionFile.create({
|
||||||
|
data: {
|
||||||
|
idStorage: upload.data.id,
|
||||||
|
idDiscussion: id,
|
||||||
|
name: fName,
|
||||||
|
extension: String(fExt)
|
||||||
|
}
|
||||||
|
})
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// create log user
|
// create log user
|
||||||
const log = await createLogUserMobile({ act: 'UPDATE', desc: 'User mengupdate data diskusi', table: 'divisionDisscussion', data: id, user: userMobile.id })
|
const log = await createLogUserMobile({ act: 'UPDATE', desc: 'User mengupdate data diskusi', table: 'divisionDisscussion', data: id, user: userMobile.id })
|
||||||
return NextResponse.json({ success: true, message: "Berhasil mengedit diskusi" }, { status: 200 });
|
return NextResponse.json({ success: true, message: "Berhasil mengedit diskusi" }, { status: 200 });
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
import { funSendWebPush, prisma } from "@/module/_global";
|
import { DIR, funSendWebPush, funUploadFile, prisma } from "@/module/_global";
|
||||||
import { funGetUserById } from "@/module/auth";
|
import { funGetUserById } from "@/module/auth";
|
||||||
import { createLogUserMobile } from "@/module/user";
|
import { createLogUserMobile } from "@/module/user";
|
||||||
import _ from "lodash";
|
import _ from "lodash";
|
||||||
@@ -35,7 +35,7 @@ export async function GET(request: Request) {
|
|||||||
})
|
})
|
||||||
|
|
||||||
if (cekDivision == 0) {
|
if (cekDivision == 0) {
|
||||||
return NextResponse.json({ success: false, message: "Gagal mendapatkan divisi, data tidak ditemukan" }, { status: 404 });
|
return NextResponse.json({ success: false, message: "Gagal mendapatkan divisi, data tidak ditemukan" }, { status: 200 });
|
||||||
}
|
}
|
||||||
|
|
||||||
const data = await prisma.divisionDisscussion.findMany({
|
const data = await prisma.divisionDisscussion.findMany({
|
||||||
@@ -67,6 +67,9 @@ export async function GET(request: Request) {
|
|||||||
DivisionDisscussionComment: {
|
DivisionDisscussionComment: {
|
||||||
select: {
|
select: {
|
||||||
id: true,
|
id: true,
|
||||||
|
},
|
||||||
|
where: {
|
||||||
|
isActive: true
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -99,7 +102,14 @@ export async function GET(request: Request) {
|
|||||||
// CREATE DISCUSSION
|
// CREATE DISCUSSION
|
||||||
export async function POST(request: Request) {
|
export async function POST(request: Request) {
|
||||||
try {
|
try {
|
||||||
const { idDivision, desc, user } = (await request.json());
|
const body = await request.formData()
|
||||||
|
const dataBody = body.get("data")
|
||||||
|
const cekFile = body.has("file0")
|
||||||
|
|
||||||
|
// const { idDivision, desc, user } = (await request.json());
|
||||||
|
const { idDivision, desc, user } = JSON.parse(String(dataBody));
|
||||||
|
|
||||||
|
|
||||||
const userMobile = await funGetUserById({ id: String(user) })
|
const userMobile = await funGetUserById({ id: String(user) })
|
||||||
|
|
||||||
if (userMobile.id == "null" || userMobile.id == undefined || userMobile.id == "") {
|
if (userMobile.id == "null" || userMobile.id == undefined || userMobile.id == "") {
|
||||||
@@ -118,7 +128,7 @@ export async function POST(request: Request) {
|
|||||||
})
|
})
|
||||||
|
|
||||||
if (cekDivision == 0) {
|
if (cekDivision == 0) {
|
||||||
return NextResponse.json({ success: false, message: "Gagal mendapatkan divisi, data tidak ditemukan" }, { status: 404 });
|
return NextResponse.json({ success: false, message: "Gagal mendapatkan divisi, data tidak ditemukan" }, { status: 200 });
|
||||||
}
|
}
|
||||||
|
|
||||||
const data = await prisma.divisionDisscussion.create({
|
const data = await prisma.divisionDisscussion.create({
|
||||||
@@ -132,6 +142,29 @@ export async function POST(request: Request) {
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
|
if (cekFile) {
|
||||||
|
body.delete("data")
|
||||||
|
for (var pair of body.entries()) {
|
||||||
|
if (String(pair[0]).substring(0, 4) == "file") {
|
||||||
|
const file = body.get(pair[0]) as File
|
||||||
|
const fExt = file.name.split(".").pop()
|
||||||
|
const fName = decodeURIComponent(file.name.replace("." + fExt, ""))
|
||||||
|
const upload = await funUploadFile({ file: file, dirId: DIR.discussionDivision })
|
||||||
|
if (upload.success) {
|
||||||
|
await prisma.divisionDiscussionFile.create({
|
||||||
|
data: {
|
||||||
|
idStorage: upload.data.id,
|
||||||
|
idDiscussion: data.id,
|
||||||
|
name: fName,
|
||||||
|
extension: String(fExt)
|
||||||
|
}
|
||||||
|
})
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
const memberDivision = await prisma.divisionMember.findMany({
|
const memberDivision = await prisma.divisionMember.findMany({
|
||||||
where: {
|
where: {
|
||||||
idDivision: idDivision
|
idDivision: idDivision
|
||||||
@@ -263,12 +296,16 @@ export async function POST(request: Request) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
const dataNotifFilter = dataNotif.filter((v: any) => v.idUserTo != undefined && v.idUserTo != null && v.idUserTo != "" && v.idUserTo != userId)
|
const dataNotifFilter = dataNotif.filter((v: any) => v.idUserTo != undefined && v.idUserTo != null && v.idUserTo != "" && v.idUserTo != userId)
|
||||||
|
const dataNotifFilterUnique = dataNotifFilter
|
||||||
|
.filter((v: any, index: number, self: any[]) =>
|
||||||
|
index === self.findIndex((t: any) => t.idUserTo == v.idUserTo)
|
||||||
|
)
|
||||||
|
|
||||||
const pushNotif = dataPush.filter((item) => item.subscription != undefined)
|
const pushNotif = dataPush.filter((item) => item.subscription != undefined)
|
||||||
|
|
||||||
const sendWebPush = await funSendWebPush({ sub: pushNotif, message: { body: deskripsiNotif, title: 'Diskusi Baru' } })
|
const sendWebPush = await funSendWebPush({ sub: pushNotif, message: { body: deskripsiNotif, title: 'Diskusi Baru' } })
|
||||||
const insertNotif = await prisma.notifications.createMany({
|
const insertNotif = await prisma.notifications.createMany({
|
||||||
data: dataNotifFilter
|
data: dataNotifFilterUnique
|
||||||
})
|
})
|
||||||
|
|
||||||
const tokenUnique = [...new Set(tokenDup.flat())].filter((v: any) => v != undefined && v != null && v != "");
|
const tokenUnique = [...new Set(tokenDup.flat())].filter((v: any) => v != undefined && v != null && v != "");
|
||||||
|
|||||||
@@ -314,12 +314,16 @@ export async function POST(request: Request) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
const dataNotifFilter = dataNotif.filter((v: any) => v.idUserTo != undefined && v.idUserTo != null && v.idUserTo != "" && v.idUserTo != userId)
|
const dataNotifFilter = dataNotif.filter((v: any) => v.idUserTo != undefined && v.idUserTo != null && v.idUserTo != "" && v.idUserTo != userId)
|
||||||
|
const dataNotifFilterUnique = dataNotifFilter
|
||||||
|
.filter((v: any, index: number, self: any[]) =>
|
||||||
|
index === self.findIndex((t: any) => t.idUserTo == v.idUserTo)
|
||||||
|
)
|
||||||
|
|
||||||
const pushNotif = dataPush.filter((item) => item.subscription != undefined)
|
const pushNotif = dataPush.filter((item) => item.subscription != undefined)
|
||||||
|
|
||||||
const sendWebPush = await funSendWebPush({ sub: pushNotif, message: { title: 'Divisi Baru', body: `Divisi ${sent.data.name} telah dibuat. Silakan periksa detailnya.` } })
|
const sendWebPush = await funSendWebPush({ sub: pushNotif, message: { title: 'Divisi Baru', body: `Divisi ${sent.data.name} telah dibuat. Silakan periksa detailnya.` } })
|
||||||
const insertNotif = await prisma.notifications.createMany({
|
const insertNotif = await prisma.notifications.createMany({
|
||||||
data: dataNotifFilter
|
data: dataNotifFilterUnique
|
||||||
})
|
})
|
||||||
|
|
||||||
const tokenUnique = [...new Set(tokenDup.flat())].filter((v: any) => v != undefined && v != null && v != "");
|
const tokenUnique = [...new Set(tokenDup.flat())].filter((v: any) => v != undefined && v != null && v != "");
|
||||||
@@ -338,4 +342,45 @@ export async function POST(request: Request) {
|
|||||||
console.error(error);
|
console.error(error);
|
||||||
return NextResponse.json({ success: false, message: "Gagal menambahkan divisi, coba lagi nanti (error: 500)", reason: (error as Error).message, }, { status: 500 });
|
return NextResponse.json({ success: false, message: "Gagal menambahkan divisi, coba lagi nanti (error: 500)", reason: (error as Error).message, }, { status: 500 });
|
||||||
}
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
// CEK DATA DIVISI (NAME DI DESA DAN GROUP YG SAMA)
|
||||||
|
export async function PUT(request: Request) {
|
||||||
|
try {
|
||||||
|
|
||||||
|
const sent = (await request.json())
|
||||||
|
const user = sent.user
|
||||||
|
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 fixGroup
|
||||||
|
if (sent.data.idGroup == "null" || sent.data.idGroup == undefined || sent.data.idGroup == "") {
|
||||||
|
fixGroup = userMobile.idGroup
|
||||||
|
} else {
|
||||||
|
fixGroup = sent.data.idGroup
|
||||||
|
}
|
||||||
|
|
||||||
|
const checkData = await prisma.division.count({
|
||||||
|
where: {
|
||||||
|
name: {
|
||||||
|
equals: sent.data.name,
|
||||||
|
mode: "insensitive"
|
||||||
|
},
|
||||||
|
idGroup: fixGroup,
|
||||||
|
idVillage: String(userMobile.idVillage)
|
||||||
|
}
|
||||||
|
})
|
||||||
|
|
||||||
|
if (checkData > 0) {
|
||||||
|
return NextResponse.json({ success: true, message: "Divisi dengan nama ini sudah ada", available: false }, { status: 200 });
|
||||||
|
}
|
||||||
|
|
||||||
|
return NextResponse.json({ success: true, message: "Berhasil cek data divisi", available: true }, { status: 200 });
|
||||||
|
} catch (error) {
|
||||||
|
console.error(error);
|
||||||
|
return NextResponse.json({ success: false, message: "Gagal menambahkan divisi, coba lagi nanti (error: 500)", reason: (error as Error).message, }, { status: 500 });
|
||||||
|
}
|
||||||
};
|
};
|
||||||
@@ -12,7 +12,7 @@ export async function GET(request: Request, context: { params: { id: string } })
|
|||||||
const userMobile = searchParams.get("user")
|
const userMobile = searchParams.get("user")
|
||||||
|
|
||||||
if (userMobile == "null" || userMobile == undefined || userMobile == "") {
|
if (userMobile == "null" || userMobile == undefined || userMobile == "") {
|
||||||
return NextResponse.json({ success: false, message: "Anda harus login untuk mengakses ini" }, { status: 401 });
|
return NextResponse.json({ success: false, message: "Anda harus login untuk mengakses ini" }, { status: 200 });
|
||||||
}
|
}
|
||||||
|
|
||||||
const { id } = context.params;
|
const { id } = context.params;
|
||||||
@@ -28,7 +28,7 @@ export async function GET(request: Request, context: { params: { id: string } })
|
|||||||
success: false,
|
success: false,
|
||||||
message: "Gagal mendapatkan grup, data tidak ditemukan",
|
message: "Gagal mendapatkan grup, data tidak ditemukan",
|
||||||
},
|
},
|
||||||
{ status: 404 }
|
{ status: 200 }
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -52,7 +52,7 @@ export async function DELETE(request: Request, context: { params: { id: string }
|
|||||||
const { isActive, user } = (await request.json());
|
const { isActive, user } = (await request.json());
|
||||||
|
|
||||||
if (user == "null" || user == undefined || user == "") {
|
if (user == "null" || user == undefined || user == "") {
|
||||||
return NextResponse.json({ success: false, message: "Anda harus login untuk mengakses ini" }, { status: 401 });
|
return NextResponse.json({ success: false, message: "Anda harus login untuk mengakses ini" }, { status: 200 });
|
||||||
}
|
}
|
||||||
const userLogin = await funGetUserById({ id: user })
|
const userLogin = await funGetUserById({ id: user })
|
||||||
|
|
||||||
@@ -68,7 +68,7 @@ export async function DELETE(request: Request, context: { params: { id: string }
|
|||||||
success: false,
|
success: false,
|
||||||
message: "Edit grup gagal, data tidak ditemukan",
|
message: "Edit grup gagal, data tidak ditemukan",
|
||||||
},
|
},
|
||||||
{ status: 404 }
|
{ status: 200 }
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -98,7 +98,7 @@ export async function PUT(request: Request, context: { params: { id: string } })
|
|||||||
const { name, user } = (await request.json());
|
const { name, user } = (await request.json());
|
||||||
|
|
||||||
if (user == "null" || user == undefined || user == "") {
|
if (user == "null" || user == undefined || user == "") {
|
||||||
return NextResponse.json({ success: false, message: "Anda harus login untuk mengakses ini" }, { status: 401 });
|
return NextResponse.json({ success: false, message: "Anda harus login untuk mengakses ini" }, { status: 200 });
|
||||||
}
|
}
|
||||||
|
|
||||||
const data = await prisma.group.count({
|
const data = await prisma.group.count({
|
||||||
@@ -113,7 +113,7 @@ export async function PUT(request: Request, context: { params: { id: string } })
|
|||||||
success: false,
|
success: false,
|
||||||
message: "Edit grup gagal, data tidak ditemukan",
|
message: "Edit grup gagal, data tidak ditemukan",
|
||||||
},
|
},
|
||||||
{ status: 404 }
|
{ status: 200 }
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -11,7 +11,7 @@ export async function GET(request: Request) {
|
|||||||
const userMobile = searchParams.get("user")
|
const userMobile = searchParams.get("user")
|
||||||
|
|
||||||
if (userMobile == "null" || userMobile == undefined || userMobile == "") {
|
if (userMobile == "null" || userMobile == undefined || userMobile == "") {
|
||||||
return NextResponse.json({ success: false, message: "Anda harus login untuk mengakses ini" }, { status: 401 });
|
return NextResponse.json({ success: false, message: "Anda harus login untuk mengakses ini" }, { status: 200 });
|
||||||
}
|
}
|
||||||
|
|
||||||
const user = await funGetUserById({ id: userMobile })
|
const user = await funGetUserById({ id: userMobile })
|
||||||
@@ -51,7 +51,7 @@ export async function POST(request: Request) {
|
|||||||
const { name, user } = (await request.json());
|
const { name, user } = (await request.json());
|
||||||
|
|
||||||
if (user == "null" || user == undefined || user == "") {
|
if (user == "null" || user == undefined || user == "") {
|
||||||
return NextResponse.json({ success: false, message: "Anda harus login untuk mengakses ini" }, { status: 401 });
|
return NextResponse.json({ success: false, message: "Anda harus login untuk mengakses ini" }, { status: 200 });
|
||||||
}
|
}
|
||||||
|
|
||||||
const userMobile = await funGetUserById({ id: user })
|
const userMobile = await funGetUserById({ id: user })
|
||||||
|
|||||||
@@ -81,7 +81,7 @@ export async function GET(request: Request) {
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
orderBy: {
|
orderBy: {
|
||||||
createdAt: "desc"
|
updatedAt: "desc"
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
@@ -425,19 +425,19 @@ export async function GET(request: Request) {
|
|||||||
isActive: true,
|
isActive: true,
|
||||||
status: 1,
|
status: 1,
|
||||||
idVillage: idVillage
|
idVillage: idVillage
|
||||||
},
|
}
|
||||||
|
|
||||||
kondisi = {
|
kondisi = {
|
||||||
|
isActive: true,
|
||||||
|
status: 1,
|
||||||
|
Division: {
|
||||||
isActive: true,
|
isActive: true,
|
||||||
status: 1,
|
idVillage: idVillage,
|
||||||
Division: {
|
Group: {
|
||||||
isActive: true,
|
isActive: true,
|
||||||
idVillage: idVillage,
|
|
||||||
Group: {
|
|
||||||
isActive: true,
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
kondisiUmum = {
|
kondisiUmum = {
|
||||||
isActive: true,
|
isActive: true,
|
||||||
|
|||||||
@@ -11,7 +11,7 @@ export async function GET(request: Request) {
|
|||||||
const userMobile = searchParams.get("user")
|
const userMobile = searchParams.get("user")
|
||||||
|
|
||||||
if (userMobile == "null" || userMobile == undefined || userMobile == "") {
|
if (userMobile == "null" || userMobile == undefined || userMobile == "") {
|
||||||
return NextResponse.json({ success: false, message: "Anda harus login untuk mengakses ini" }, { status: 401 });
|
return NextResponse.json({ success: false, message: "Anda harus login untuk mengakses ini" }, { status: 200 });
|
||||||
}
|
}
|
||||||
|
|
||||||
const userId = await funGetUserById({ id: userMobile })
|
const userId = await funGetUserById({ id: userMobile })
|
||||||
|
|||||||
@@ -11,7 +11,7 @@ export async function GET(request: Request, context: { params: { id: string } })
|
|||||||
const { id } = context.params;
|
const { id } = context.params;
|
||||||
|
|
||||||
if (userMobile == "null" || userMobile == undefined || userMobile == "") {
|
if (userMobile == "null" || userMobile == undefined || userMobile == "") {
|
||||||
return NextResponse.json({ success: false, message: "Anda harus login untuk mengakses ini" }, { status: 401 });
|
return NextResponse.json({ success: false, message: "Anda harus login untuk mengakses ini" }, { status: 200 });
|
||||||
}
|
}
|
||||||
|
|
||||||
const data = await prisma.position.findUnique({
|
const data = await prisma.position.findUnique({
|
||||||
@@ -30,7 +30,7 @@ export async function GET(request: Request, context: { params: { id: string } })
|
|||||||
success: false,
|
success: false,
|
||||||
message: "Gagal mendapatkan jabatan, data tidak ditemukan",
|
message: "Gagal mendapatkan jabatan, data tidak ditemukan",
|
||||||
},
|
},
|
||||||
{ status: 404 }
|
{ status: 200 }
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -55,7 +55,7 @@ export async function DELETE(request: Request, context: { params: { id: string }
|
|||||||
const { isActive, user } = (await request.json());
|
const { isActive, user } = (await request.json());
|
||||||
|
|
||||||
if (user == "null" || user == undefined || user == "") {
|
if (user == "null" || user == undefined || user == "") {
|
||||||
return NextResponse.json({ success: false, message: "Anda harus login untuk mengakses ini" }, { status: 401 });
|
return NextResponse.json({ success: false, message: "Anda harus login untuk mengakses ini" }, { status: 200 });
|
||||||
}
|
}
|
||||||
|
|
||||||
const data = await prisma.position.count({
|
const data = await prisma.position.count({
|
||||||
@@ -104,7 +104,7 @@ export async function PUT(request: Request, context: { params: { id: string } })
|
|||||||
const { name, idGroup, user } = await request.json();
|
const { name, idGroup, user } = await request.json();
|
||||||
|
|
||||||
if (user == "null" || user == undefined || user == "") {
|
if (user == "null" || user == undefined || user == "") {
|
||||||
return NextResponse.json({ success: false, message: "Anda harus login untuk mengakses ini" }, { status: 401 });
|
return NextResponse.json({ success: false, message: "Anda harus login untuk mengakses ini" }, { status: 200 });
|
||||||
}
|
}
|
||||||
|
|
||||||
const cek = await prisma.position.count({
|
const cek = await prisma.position.count({
|
||||||
|
|||||||
@@ -16,7 +16,7 @@ export async function GET(request: Request) {
|
|||||||
const userMobile = searchParams.get("user")
|
const userMobile = searchParams.get("user")
|
||||||
|
|
||||||
if (userMobile == "null" || userMobile == undefined || userMobile == "") {
|
if (userMobile == "null" || userMobile == undefined || userMobile == "") {
|
||||||
return NextResponse.json({ success: false, message: "Anda harus login untuk mengakses ini" }, { status: 401 });
|
return NextResponse.json({ success: false, message: "Anda harus login untuk mengakses ini" }, { status: 200 });
|
||||||
}
|
}
|
||||||
|
|
||||||
const user = await funGetUserById({ id: userMobile })
|
const user = await funGetUserById({ id: userMobile })
|
||||||
@@ -35,7 +35,7 @@ export async function GET(request: Request) {
|
|||||||
})
|
})
|
||||||
|
|
||||||
if (cek == 0) {
|
if (cek == 0) {
|
||||||
return NextResponse.json({ success: false, message: "Gagal mendapatkan jabatan, data tidak ditemukan", }, { status: 404 });
|
return NextResponse.json({ success: false, message: "Gagal mendapatkan jabatan, data tidak ditemukan", }, { status: 200 });
|
||||||
}
|
}
|
||||||
|
|
||||||
const filter = await prisma.group.findUnique({
|
const filter = await prisma.group.findUnique({
|
||||||
@@ -93,7 +93,7 @@ export async function POST(request: Request) {
|
|||||||
const { name, idGroup, user } = await request.json();
|
const { name, idGroup, user } = await request.json();
|
||||||
|
|
||||||
if (user == "null" || user == undefined || user == "") {
|
if (user == "null" || user == undefined || user == "") {
|
||||||
return NextResponse.json({ success: false, message: "Anda harus login untuk mengakses ini" }, { status: 401 });
|
return NextResponse.json({ success: false, message: "Anda harus login untuk mengakses ini" }, { status: 200 });
|
||||||
}
|
}
|
||||||
|
|
||||||
const userMobile = await funGetUserById({ id: user })
|
const userMobile = await funGetUserById({ id: user })
|
||||||
@@ -131,7 +131,7 @@ export async function POST(request: Request) {
|
|||||||
} else {
|
} else {
|
||||||
return NextResponse.json(
|
return NextResponse.json(
|
||||||
{ success: false, message: "Jabatan sudah ada" },
|
{ success: false, message: "Jabatan sudah ada" },
|
||||||
{ status: 400 }
|
{ status: 200 }
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -71,7 +71,7 @@ export async function GET(request: Request, context: { params: { id: string } })
|
|||||||
createdAt: true
|
createdAt: true
|
||||||
},
|
},
|
||||||
orderBy: {
|
orderBy: {
|
||||||
createdAt: 'asc'
|
dateStart: 'asc'
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
|
|||||||
@@ -385,11 +385,15 @@ export async function POST(request: Request) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
const dataNotifFilter = dataNotif.filter((item) => item.idUserTo != undefined && item.idUserTo != null && item.idUserTo != "" && item.idUserTo != userId)
|
const dataNotifFilter = dataNotif.filter((item) => item.idUserTo != undefined && item.idUserTo != null && item.idUserTo != "" && item.idUserTo != userId)
|
||||||
|
const dataNotifFilterUnique = dataNotifFilter
|
||||||
|
.filter((v: any, index: number, self: any[]) =>
|
||||||
|
index === self.findIndex((t: any) => t.idUserTo == v.idUserTo)
|
||||||
|
)
|
||||||
const pushNotif = dataPush.filter((item) => item.subscription != undefined)
|
const pushNotif = dataPush.filter((item) => item.subscription != undefined)
|
||||||
|
|
||||||
const sendWebPush = await funSendWebPush({ sub: pushNotif, message: { title: 'Kegiatan Baru', body: title } })
|
const sendWebPush = await funSendWebPush({ sub: pushNotif, message: { title: 'Kegiatan Baru', body: title } })
|
||||||
const insertNotif = await prisma.notifications.createMany({
|
const insertNotif = await prisma.notifications.createMany({
|
||||||
data: dataNotifFilter
|
data: dataNotifFilterUnique
|
||||||
})
|
})
|
||||||
|
|
||||||
const tokenUnique = [...new Set(tokenDup.flat())].filter((v: any) => v != undefined && v != null && v != "");
|
const tokenUnique = [...new Set(tokenDup.flat())].filter((v: any) => v != undefined && v != null && v != "");
|
||||||
|
|||||||
@@ -76,7 +76,7 @@ export async function GET(request: Request, context: { params: { id: string } })
|
|||||||
dateEnd: true,
|
dateEnd: true,
|
||||||
},
|
},
|
||||||
orderBy: {
|
orderBy: {
|
||||||
createdAt: 'asc'
|
dateStart: 'asc'
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
|
|||||||
@@ -356,11 +356,15 @@ export async function POST(request: Request) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
const dataNotifFilter = dataNotif.filter((v: any) => v.idUserTo != undefined && v.idUserTo != null && v.idUserTo != "" && v.idUserTo != userId)
|
const dataNotifFilter = dataNotif.filter((v: any) => v.idUserTo != undefined && v.idUserTo != null && v.idUserTo != "" && v.idUserTo != userId)
|
||||||
|
const dataNotifFilterUnique = dataNotifFilter
|
||||||
|
.filter((v: any, index: number, self: any[]) =>
|
||||||
|
index === self.findIndex((t: any) => t.idUserTo == v.idUserTo)
|
||||||
|
)
|
||||||
const pushNotif = dataPush.filter((item) => item.subscription != undefined)
|
const pushNotif = dataPush.filter((item) => item.subscription != undefined)
|
||||||
|
|
||||||
const sendWebPush = await funSendWebPush({ sub: pushNotif, message: { body: title, title: 'Tugas Divisi Baru' } })
|
const sendWebPush = await funSendWebPush({ sub: pushNotif, message: { body: title, title: 'Tugas Divisi Baru' } })
|
||||||
const insertNotif = await prisma.notifications.createMany({
|
const insertNotif = await prisma.notifications.createMany({
|
||||||
data: dataNotifFilter
|
data: dataNotifFilterUnique
|
||||||
})
|
})
|
||||||
|
|
||||||
const tokenUnique = [...new Set(tokenDup.flat())].filter((v: any) => v != undefined && v != null && v != "");
|
const tokenUnique = [...new Set(tokenDup.flat())].filter((v: any) => v != undefined && v != null && v != "");
|
||||||
|
|||||||
@@ -87,7 +87,7 @@ export async function DELETE(request: Request, context: { params: { id: string }
|
|||||||
const { isActive, user } = (await request.json());
|
const { isActive, user } = (await request.json());
|
||||||
|
|
||||||
if (user == "null" || user == undefined || user == "") {
|
if (user == "null" || user == undefined || user == "") {
|
||||||
return NextResponse.json({ success: false, message: "Anda harus login untuk mengakses ini" }, { status: 401 });
|
return NextResponse.json({ success: false, message: "Anda harus login untuk mengakses ini" }, { status: 200 });
|
||||||
}
|
}
|
||||||
|
|
||||||
const data = await prisma.user.count({
|
const data = await prisma.user.count({
|
||||||
@@ -102,7 +102,7 @@ export async function DELETE(request: Request, context: { params: { id: string }
|
|||||||
success: false,
|
success: false,
|
||||||
message: "Gagal mendapatkan anggota, data tidak ditemukan",
|
message: "Gagal mendapatkan anggota, data tidak ditemukan",
|
||||||
},
|
},
|
||||||
{ status: 404 }
|
{ status: 200 }
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -158,7 +158,7 @@ export async function PUT(request: Request, context: { params: { id: string } })
|
|||||||
} = JSON.parse(data as string)
|
} = JSON.parse(data as string)
|
||||||
|
|
||||||
if (user == "null" || user == undefined || user == "") {
|
if (user == "null" || user == undefined || user == "") {
|
||||||
return NextResponse.json({ success: false, message: "Anda harus login untuk mengakses ini" }, { status: 401 });
|
return NextResponse.json({ success: false, message: "Anda harus login untuk mengakses ini" }, { status: 200 });
|
||||||
}
|
}
|
||||||
|
|
||||||
const cekNIK = await prisma.user.count({
|
const cekNIK = await prisma.user.count({
|
||||||
@@ -247,7 +247,7 @@ export async function PUT(request: Request, context: { params: { id: string } })
|
|||||||
{ status: 200 }
|
{ status: 200 }
|
||||||
);
|
);
|
||||||
} else {
|
} else {
|
||||||
return Response.json({ success: false, message: "Anggota sudah ada" }, { status: 400 });
|
return Response.json({ success: false, message: "Anggota sudah ada" }, { status: 200 });
|
||||||
}
|
}
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.error(error);
|
console.error(error);
|
||||||
|
|||||||
@@ -11,7 +11,7 @@ export async function GET(request: Request) {
|
|||||||
try {
|
try {
|
||||||
const user = await funGetUserByCookies()
|
const user = await funGetUserByCookies()
|
||||||
if (user.id == undefined) {
|
if (user.id == undefined) {
|
||||||
return NextResponse.json({ success: false, message: "Anda harus login untuk mengakses ini" }, { status: 401 });
|
return NextResponse.json({ success: false, message: "Anda harus login untuk mengakses ini" }, { status: 200 });
|
||||||
}
|
}
|
||||||
const data = await prisma.user.findUnique({
|
const data = await prisma.user.findUnique({
|
||||||
where: {
|
where: {
|
||||||
|
|||||||
@@ -68,7 +68,7 @@ export async function GET(request: Request, context: { params: { id: string } })
|
|||||||
createdAt: true
|
createdAt: true
|
||||||
},
|
},
|
||||||
orderBy: {
|
orderBy: {
|
||||||
createdAt: 'asc'
|
dateStart: 'asc'
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
@@ -78,8 +78,8 @@ export async function GET(request: Request, context: { params: { id: string } })
|
|||||||
dateEnd: moment(v.dateEnd).format("DD-MM-YYYY"),
|
dateEnd: moment(v.dateEnd).format("DD-MM-YYYY"),
|
||||||
createdAt: moment(v.createdAt).format("DD-MM-YYYY HH:mm"),
|
createdAt: moment(v.createdAt).format("DD-MM-YYYY HH:mm"),
|
||||||
}))
|
}))
|
||||||
const dataFix = _.orderBy(formatData, 'createdAt', 'asc')
|
// const dataFix = _.orderBy(formatData, 'createdAt', 'asc')
|
||||||
allData = dataFix
|
allData = formatData
|
||||||
|
|
||||||
} else if (kategori == "file") {
|
} else if (kategori == "file") {
|
||||||
const dataFile = await prisma.projectFile.findMany({
|
const dataFile = await prisma.projectFile.findMany({
|
||||||
|
|||||||
@@ -75,7 +75,7 @@ export async function GET(request: Request, context: { params: { id: string } })
|
|||||||
dateEnd: true,
|
dateEnd: true,
|
||||||
},
|
},
|
||||||
orderBy: {
|
orderBy: {
|
||||||
createdAt: 'asc'
|
dateStart: 'asc'
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
|
|||||||
@@ -2,7 +2,7 @@ import { NextResponse } from "next/server";
|
|||||||
|
|
||||||
export async function GET(request: Request) {
|
export async function GET(request: Request) {
|
||||||
try {
|
try {
|
||||||
return NextResponse.json({ success: true, version: "2.0.4", tahap: "beta", update: "-api mobile; -login tanpa otp (mobile app); -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; -api jenna ai; -privacy policy" }, { status: 200 });
|
return NextResponse.json({ success: true, version: "2.1.0", tahap: "beta", update: "-api mobile; -login tanpa otp (mobile app); -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; -api jenna ai; -privacy policy" }, { status: 200 });
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.error(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 });
|
return NextResponse.json({ success: false, version: "Gagal mendapatkan version, coba lagi nanti (error: 500)", reason: (error as Error).message, }, { status: 500 });
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
import { hookstate } from "@hookstate/core"
|
import { hookstate } from "@hookstate/core";
|
||||||
import { IGlobalTema } from './type_global';
|
|
||||||
import { RefObject } from "react";
|
import { RefObject } from "react";
|
||||||
|
import { IGlobalTema } from './type_global';
|
||||||
|
|
||||||
export const pwd_key_config = "fchgvjknlmdfnbvghhujlaknsdvjbhknlkmsdbdyu567t8y9u30r4587638y9uipkoeghjvuyi89ipkoefmnrjbhtiu4or9ipkoemnjfbhjiuoijdklnjhbviufojkejnshbiuojijknehgruyu"
|
export const pwd_key_config = "fchgvjknlmdfnbvghhujlaknsdvjbhknlkmsdbdyu567t8y9u30r4587638y9uipkoeghjvuyi89ipkoefmnrjbhtiu4or9ipkoemnjfbhjiuoijdklnjhbviufojkejnshbiuojijknehgruyu"
|
||||||
export const globalRole = hookstate<string>('')
|
export const globalRole = hookstate<string>('')
|
||||||
@@ -11,7 +11,10 @@ export const DIR = {
|
|||||||
document: "cm0xhbkf50009acbbtw03qo4l",
|
document: "cm0xhbkf50009acbbtw03qo4l",
|
||||||
village: "cm0xhb91o0007acbbkx8rk8hj",
|
village: "cm0xhb91o0007acbbkx8rk8hj",
|
||||||
user: "cm0x8dbwn0005bp5tgmfcthzw",
|
user: "cm0x8dbwn0005bp5tgmfcthzw",
|
||||||
banner: "cm1sxex19004938bjvyaq8vta"
|
banner: "cm1sxex19004938bjvyaq8vta",
|
||||||
|
announcement: "cmkdfkze4005hkhjgunsroi4t",
|
||||||
|
discussion: "cmkf5h7ic006jkhjgyrkog7ut",
|
||||||
|
discussionDivision: "cmkdfktfm005fkhjggjvnqly5"
|
||||||
}
|
}
|
||||||
|
|
||||||
export const keyWibu = 'padahariminggukuturutayahkekotanaikdelmanistimewakududukdimuka'
|
export const keyWibu = 'padahariminggukuturutayahkekotanaikdelmanistimewakududukdimuka'
|
||||||
|
|||||||
@@ -18,7 +18,7 @@ export function countTime(date: Date) {
|
|||||||
const seconds = totalSeconds;
|
const seconds = totalSeconds;
|
||||||
|
|
||||||
if (days > 0) {
|
if (days > 0) {
|
||||||
return moment(date).format("ll")
|
return String(dateNow.getFullYear()) == moment(date).format("YYYY") ? moment(date).format("DD MMM") : moment(date).format("ll")
|
||||||
} else if (hours > 0) {
|
} else if (hours > 0) {
|
||||||
return `${hours} jam`
|
return `${hours} jam`
|
||||||
} else if (minutes > 0) {
|
} else if (minutes > 0) {
|
||||||
|
|||||||
@@ -8,15 +8,7 @@
|
|||||||
"gender": "F"
|
"gender": "F"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"id": "devLukman",
|
"id": "devMalik",
|
||||||
"idAdminRole": "dev",
|
|
||||||
"name": "Lukman",
|
|
||||||
"phone": "6287701790942",
|
|
||||||
"email": "lukman@bip.com",
|
|
||||||
"gender": "M"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"id": "devLukman",
|
|
||||||
"idAdminRole": "dev",
|
"idAdminRole": "dev",
|
||||||
"name": "Malik",
|
"name": "Malik",
|
||||||
"phone": "6289697338821",
|
"phone": "6289697338821",
|
||||||
|
|||||||
Reference in New Issue
Block a user