Compare commits
12 Commits
amalia/02-
...
amalia/08-
| Author | SHA1 | Date | |
|---|---|---|---|
| 411037ec4a | |||
| 66ba6dfa91 | |||
| 389f115923 | |||
| 2251818908 | |||
| b625150eb5 | |||
| bae91db60a | |||
| 150151e823 | |||
| d1a591a63a | |||
| 7e80a1f311 | |||
| b648735b06 | |||
| a3d8bf1e92 | |||
| c2c52ed5fd |
@@ -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,
|
||||||
|
|||||||
@@ -255,15 +255,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",
|
||||||
|
|||||||
@@ -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"]),
|
||||||
|
|||||||
@@ -210,9 +210,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 != "");
|
||||||
|
|||||||
@@ -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"]),
|
||||||
|
|||||||
@@ -263,12 +263,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 });
|
||||||
|
}
|
||||||
};
|
};
|
||||||
@@ -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,
|
||||||
|
|||||||
@@ -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 != "");
|
||||||
|
|||||||
@@ -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.0.7", 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 });
|
||||||
|
|||||||
Reference in New Issue
Block a user