Compare commits
12 Commits
amalia/08-
...
amalia/16-
| Author | SHA1 | Date | |
|---|---|---|---|
| 3ab2566a89 | |||
| 9573c1472a | |||
| ed2c9495c3 | |||
| 1b8bfebf4f | |||
| 10b9037fda | |||
| 4a4be31921 | |||
| 9b48fe56fd | |||
| 18023807cd | |||
| bd1758ce32 | |||
| 878b3aa278 | |||
| f02ffc58ad | |||
| 3d5149cbba |
@@ -420,6 +420,7 @@ 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())
|
createdAt DateTime @default(now())
|
||||||
updatedAt DateTime @updatedAt
|
updatedAt DateTime @updatedAt
|
||||||
}
|
}
|
||||||
@@ -615,6 +616,7 @@ 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())
|
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
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -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 }
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -173,7 +174,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 }
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -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 })
|
||||||
|
|||||||
@@ -147,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)" })
|
||||||
|
}
|
||||||
}
|
}
|
||||||
@@ -8,7 +8,7 @@ import { NextResponse } from "next/server";
|
|||||||
|
|
||||||
|
|
||||||
// GET ONE DETAIL DISKUSI UMUM
|
// GET ONE DETAIL DISKUSI UMUM
|
||||||
export async function GET(request: Request, context: { params: { id: string } }) {
|
export async function GET(request : Request, context: { params: { id: string } }) {
|
||||||
try {
|
try {
|
||||||
let dataFix
|
let dataFix
|
||||||
const { id } = context.params
|
const { id } = context.params
|
||||||
@@ -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
|
||||||
}))
|
}))
|
||||||
|
|||||||
@@ -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
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -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
|
||||||
@@ -156,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 });
|
||||||
|
}
|
||||||
}
|
}
|
||||||
@@ -31,33 +31,42 @@ 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 });
|
||||||
@@ -128,7 +137,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({
|
||||||
|
|||||||
@@ -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
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -118,7 +121,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({
|
||||||
|
|||||||
@@ -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 })
|
||||||
|
|||||||
@@ -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 }
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -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: {
|
||||||
|
|||||||
@@ -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.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 });
|
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 });
|
||||||
|
|||||||
@@ -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) {
|
||||||
|
|||||||
Reference in New Issue
Block a user