Compare commits
28 Commits
amalia/21-
...
join
| Author | SHA1 | Date | |
|---|---|---|---|
| 058b5aba8c | |||
| 67db39ccee | |||
| 076e7f564f | |||
| af504c95c0 | |||
| adee3f9e45 | |||
| 0957e554a1 | |||
| 8f38ede650 | |||
| 8a938257b7 | |||
| 026e07ac78 | |||
| 928acf2c03 | |||
| a14f07b928 | |||
| 1e02747e22 | |||
| a0bffd53cb | |||
| 8dca3e440f | |||
| 1df1d10c91 | |||
| e5891f0da3 | |||
| 619cc9a403 | |||
| 3272ecaef3 | |||
| 3b5126d8ee | |||
| 552957282b | |||
| 22555079f3 | |||
| 6cf6486172 | |||
| 35e51028db | |||
| 37ea4e37e7 | |||
| e270db3bfa | |||
| 32dac32532 | |||
| d369a71eb6 | |||
| 7334831d61 |
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "sistem-desa-mandiri",
|
"name": "sistem-desa-mandiri",
|
||||||
"version": "0.1.16",
|
"version": "0.1.19",
|
||||||
"private": true,
|
"private": true,
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"dev": "next dev --experimental-https",
|
"dev": "next dev --experimental-https",
|
||||||
|
|||||||
1
prisma/migrations/20260522064632_auto/migration.sql
Normal file
1
prisma/migrations/20260522064632_auto/migration.sql
Normal file
@@ -0,0 +1 @@
|
|||||||
|
-- This is an empty migration.
|
||||||
1
prisma/migrations/20260525073630_auto/migration.sql
Normal file
1
prisma/migrations/20260525073630_auto/migration.sql
Normal file
@@ -0,0 +1 @@
|
|||||||
|
-- This is an empty migration.
|
||||||
1
prisma/migrations/20260530064416_auto/migration.sql
Normal file
1
prisma/migrations/20260530064416_auto/migration.sql
Normal file
@@ -0,0 +1 @@
|
|||||||
|
-- This is an empty migration.
|
||||||
@@ -0,0 +1,16 @@
|
|||||||
|
-- CreateTable
|
||||||
|
CREATE TABLE "DiscussionCommentFile" (
|
||||||
|
"id" TEXT NOT NULL,
|
||||||
|
"idComment" TEXT NOT NULL,
|
||||||
|
"name" TEXT NOT NULL,
|
||||||
|
"extension" TEXT NOT NULL,
|
||||||
|
"idStorage" TEXT,
|
||||||
|
"isActive" BOOLEAN NOT NULL DEFAULT true,
|
||||||
|
"createdAt" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP,
|
||||||
|
"updatedAt" TIMESTAMP(3) NOT NULL,
|
||||||
|
|
||||||
|
CONSTRAINT "DiscussionCommentFile_pkey" PRIMARY KEY ("id")
|
||||||
|
);
|
||||||
|
|
||||||
|
-- AddForeignKey
|
||||||
|
ALTER TABLE "DiscussionCommentFile" ADD CONSTRAINT "DiscussionCommentFile_idComment_fkey" FOREIGN KEY ("idComment") REFERENCES "DiscussionComment"("id") ON DELETE RESTRICT ON UPDATE CASCADE;
|
||||||
@@ -0,0 +1,16 @@
|
|||||||
|
-- CreateTable
|
||||||
|
CREATE TABLE "DivisionDiscussionCommentFile" (
|
||||||
|
"id" TEXT NOT NULL,
|
||||||
|
"idComment" TEXT NOT NULL,
|
||||||
|
"name" TEXT NOT NULL,
|
||||||
|
"extension" TEXT NOT NULL,
|
||||||
|
"idStorage" TEXT,
|
||||||
|
"isActive" BOOLEAN NOT NULL DEFAULT true,
|
||||||
|
"createdAt" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP,
|
||||||
|
"updatedAt" TIMESTAMP(3) NOT NULL,
|
||||||
|
|
||||||
|
CONSTRAINT "DivisionDiscussionCommentFile_pkey" PRIMARY KEY ("id")
|
||||||
|
);
|
||||||
|
|
||||||
|
-- AddForeignKey
|
||||||
|
ALTER TABLE "DivisionDiscussionCommentFile" ADD CONSTRAINT "DivisionDiscussionCommentFile_idComment_fkey" FOREIGN KEY ("idComment") REFERENCES "DivisionDisscussionComment"("id") ON DELETE RESTRICT ON UPDATE CASCADE;
|
||||||
@@ -461,16 +461,29 @@ model DivisionDisscussion {
|
|||||||
}
|
}
|
||||||
|
|
||||||
model DivisionDisscussionComment {
|
model DivisionDisscussionComment {
|
||||||
id String @id @default(cuid())
|
id String @id @default(cuid())
|
||||||
DivisionDisscussion DivisionDisscussion @relation(fields: [idDisscussion], references: [id])
|
DivisionDisscussion DivisionDisscussion @relation(fields: [idDisscussion], references: [id])
|
||||||
idDisscussion String
|
idDisscussion String
|
||||||
comment String @db.Text
|
comment String @db.Text
|
||||||
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)
|
isEdited Boolean @default(false)
|
||||||
createdAt DateTime @default(now())
|
createdAt DateTime @default(now())
|
||||||
updatedAt DateTime @updatedAt
|
updatedAt DateTime @updatedAt
|
||||||
|
DivisionDiscussionCommentFile DivisionDiscussionCommentFile[]
|
||||||
|
}
|
||||||
|
|
||||||
|
model DivisionDiscussionCommentFile {
|
||||||
|
id String @id @default(cuid())
|
||||||
|
DivisionDisscussionComment DivisionDisscussionComment @relation(fields: [idComment], references: [id])
|
||||||
|
idComment String
|
||||||
|
name String
|
||||||
|
extension String
|
||||||
|
idStorage String?
|
||||||
|
isActive Boolean @default(true)
|
||||||
|
createdAt DateTime @default(now())
|
||||||
|
updatedAt DateTime @updatedAt
|
||||||
}
|
}
|
||||||
model DivisionDiscussionFile {
|
model DivisionDiscussionFile {
|
||||||
id String @id @default(cuid())
|
id String @id @default(cuid())
|
||||||
@@ -669,16 +682,29 @@ model DiscussionMember {
|
|||||||
}
|
}
|
||||||
|
|
||||||
model DiscussionComment {
|
model DiscussionComment {
|
||||||
id String @id @default(cuid())
|
id String @id @default(cuid())
|
||||||
Discussion Discussion @relation(fields: [idDiscussion], references: [id])
|
Discussion Discussion @relation(fields: [idDiscussion], references: [id])
|
||||||
idDiscussion String
|
idDiscussion String
|
||||||
User User @relation(fields: [idUser], references: [id])
|
User User @relation(fields: [idUser], references: [id])
|
||||||
idUser String
|
idUser String
|
||||||
comment String @db.Text
|
comment String @db.Text
|
||||||
isActive Boolean @default(true)
|
isActive Boolean @default(true)
|
||||||
isEdited Boolean @default(false)
|
isEdited Boolean @default(false)
|
||||||
createdAt DateTime @default(now())
|
createdAt DateTime @default(now())
|
||||||
updatedAt DateTime @updatedAt
|
updatedAt DateTime @updatedAt
|
||||||
|
DiscussionCommentFile DiscussionCommentFile[]
|
||||||
|
}
|
||||||
|
|
||||||
|
model DiscussionCommentFile {
|
||||||
|
id String @id @default(cuid())
|
||||||
|
Comment DiscussionComment @relation(fields: [idComment], references: [id])
|
||||||
|
idComment String
|
||||||
|
name String
|
||||||
|
extension String
|
||||||
|
idStorage String?
|
||||||
|
isActive Boolean @default(true)
|
||||||
|
createdAt DateTime @default(now())
|
||||||
|
updatedAt DateTime @updatedAt
|
||||||
}
|
}
|
||||||
|
|
||||||
model DiscussionFile {
|
model DiscussionFile {
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
import { prisma } from "@/module/_global";
|
import { DIR, funDeleteFile, 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";
|
||||||
@@ -10,7 +10,16 @@ import { sendFCMNotificationMany } from "../../../../../../../xsendMany";
|
|||||||
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 { desc, user } = (await request.json());
|
const contentType = request.headers.get("content-type")
|
||||||
|
let desc, user, cekFile, body: FormData | undefined
|
||||||
|
if (contentType?.includes("multipart/form-data")) {
|
||||||
|
body = await request.formData()
|
||||||
|
const dataBody = body.get("data")
|
||||||
|
cekFile = body.has("file0")
|
||||||
|
;({ desc, user } = JSON.parse(dataBody as string))
|
||||||
|
} else {
|
||||||
|
;({ desc, user } = await request.json())
|
||||||
|
}
|
||||||
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 == "") {
|
||||||
@@ -37,6 +46,28 @@ export async function POST(request: Request, context: { params: { id: string } }
|
|||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
|
if (cekFile && body) {
|
||||||
|
body.delete("data")
|
||||||
|
for (const 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, dirId: DIR.discussion })
|
||||||
|
if (upload.success) {
|
||||||
|
await prisma.discussionCommentFile.create({
|
||||||
|
data: {
|
||||||
|
idComment: data.id,
|
||||||
|
name: fName,
|
||||||
|
extension: String(fExt),
|
||||||
|
idStorage: upload.data.id
|
||||||
|
}
|
||||||
|
})
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
const dataDiscussion = await prisma.discussion.findUnique({
|
const dataDiscussion = await prisma.discussion.findUnique({
|
||||||
where: {
|
where: {
|
||||||
id
|
id
|
||||||
@@ -153,7 +184,7 @@ export async function POST(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 { desc, user } = (await request.json());
|
const { desc, user, filesToRemove = [] } = (await request.json());
|
||||||
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 == "") {
|
||||||
@@ -161,25 +192,30 @@ export async function PUT(request: Request, context: { params: { id: string } })
|
|||||||
}
|
}
|
||||||
|
|
||||||
const cek = await prisma.discussionComment.count({
|
const cek = await prisma.discussionComment.count({
|
||||||
where: {
|
where: { id, isActive: true }
|
||||||
id,
|
|
||||||
isActive: true
|
|
||||||
}
|
|
||||||
})
|
})
|
||||||
|
|
||||||
if (cek == 0) {
|
if (cek == 0) {
|
||||||
return NextResponse.json({ success: false, message: "Gagal mengedit komentar, data tidak ditemukan" }, { status: 200 });
|
return NextResponse.json({ success: false, message: "Gagal mengedit komentar, data tidak ditemukan" }, { status: 200 });
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (filesToRemove.length > 0) {
|
||||||
const data = await prisma.discussionComment.update({
|
const files = await prisma.discussionCommentFile.findMany({
|
||||||
where: {
|
where: { id: { in: filesToRemove }, idComment: id, isActive: true },
|
||||||
id
|
select: { id: true, idStorage: true }
|
||||||
},
|
})
|
||||||
data: {
|
for (const file of files) {
|
||||||
comment: desc,
|
if (file.idStorage) await funDeleteFile({ fileId: file.idStorage })
|
||||||
isEdited: true
|
|
||||||
}
|
}
|
||||||
|
await prisma.discussionCommentFile.updateMany({
|
||||||
|
where: { id: { in: filesToRemove }, idComment: id },
|
||||||
|
data: { isActive: false }
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
await prisma.discussionComment.update({
|
||||||
|
where: { id },
|
||||||
|
data: { comment: desc, isEdited: true }
|
||||||
})
|
})
|
||||||
|
|
||||||
// create log user
|
// create log user
|
||||||
@@ -216,18 +252,30 @@ export async function DELETE(request: Request, context: { params: { id: string }
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
const data = await prisma.discussionComment.update({
|
const commentFiles = await prisma.discussionCommentFile.findMany({
|
||||||
where: {
|
where: { idComment: id, isActive: true },
|
||||||
id
|
select: { id: true, idStorage: true }
|
||||||
},
|
})
|
||||||
data: {
|
|
||||||
isActive: false
|
for (const file of commentFiles) {
|
||||||
}
|
if (file.idStorage) await funDeleteFile({ fileId: file.idStorage })
|
||||||
|
}
|
||||||
|
|
||||||
|
if (commentFiles.length > 0) {
|
||||||
|
await prisma.discussionCommentFile.updateMany({
|
||||||
|
where: { idComment: id },
|
||||||
|
data: { isActive: false }
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
await prisma.discussionComment.update({
|
||||||
|
where: { id },
|
||||||
|
data: { isActive: false }
|
||||||
})
|
})
|
||||||
|
|
||||||
// create log user
|
// create log user
|
||||||
const log = await createLogUserMobile({ act: 'DELETE', desc: 'User menghapus komentar pada diskusi umum', table: 'discussionComment', data: id, user: userMobile.id })
|
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 });
|
return NextResponse.json({ success: true, message: "Berhasil menghapus komentar" }, { status: 200 });
|
||||||
|
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.error(error)
|
console.error(error)
|
||||||
|
|||||||
@@ -76,6 +76,15 @@ export async function GET(request: Request, context: { params: { id: string } })
|
|||||||
name: true,
|
name: true,
|
||||||
img: true
|
img: true
|
||||||
}
|
}
|
||||||
|
},
|
||||||
|
DiscussionCommentFile: {
|
||||||
|
where: { isActive: true },
|
||||||
|
select: {
|
||||||
|
id: true,
|
||||||
|
name: true,
|
||||||
|
extension: true,
|
||||||
|
idStorage: true
|
||||||
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
orderBy: {
|
orderBy: {
|
||||||
@@ -84,11 +93,12 @@ export async function GET(request: Request, context: { params: { id: string } })
|
|||||||
})
|
})
|
||||||
|
|
||||||
dataFix = data.map((v: any) => ({
|
dataFix = data.map((v: any) => ({
|
||||||
..._.omit(v, ["createdAt", "User", "updatedAt"]),
|
..._.omit(v, ["createdAt", "User", "updatedAt", "DiscussionCommentFile"]),
|
||||||
createdAt: countTime(v.createdAt),
|
createdAt: countTime(v.createdAt),
|
||||||
updatedAt: moment(v.updatedAt).format("ll"),
|
updatedAt: moment(v.updatedAt).format("ll"),
|
||||||
username: v.User.name,
|
username: v.User.name,
|
||||||
img: v.User.img
|
img: v.User.img,
|
||||||
|
files: v.DiscussionCommentFile
|
||||||
}))
|
}))
|
||||||
|
|
||||||
} else if (kategori == "anggota") {
|
} else if (kategori == "anggota") {
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
import { prisma } from "@/module/_global";
|
import { DIR, funDeleteFile, 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";
|
||||||
@@ -9,7 +9,18 @@ import { sendFCMNotificationMany } from "../../../../../../../xsendMany";
|
|||||||
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 { comment, user } = (await request.json());
|
const contentType = request.headers.get("content-type")
|
||||||
|
|
||||||
|
let comment: string, user: string, body: FormData | undefined, cekFile = false
|
||||||
|
|
||||||
|
if (contentType?.includes("multipart/form-data")) {
|
||||||
|
body = await request.formData()
|
||||||
|
const dataBody = body.get("data")
|
||||||
|
cekFile = body.has("file0");
|
||||||
|
({ comment, user } = JSON.parse(dataBody as string))
|
||||||
|
} else {
|
||||||
|
({ comment, user } = await request.json())
|
||||||
|
}
|
||||||
|
|
||||||
const userMobile = await funGetUserById({ id: String(user) })
|
const userMobile = await funGetUserById({ id: String(user) })
|
||||||
|
|
||||||
@@ -44,6 +55,28 @@ export async function POST(request: Request, context: { params: { id: string } }
|
|||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
|
if (cekFile && body) {
|
||||||
|
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.divisionDiscussionCommentFile.create({
|
||||||
|
data: {
|
||||||
|
idStorage: upload.data.id,
|
||||||
|
idComment: data.id,
|
||||||
|
name: fName,
|
||||||
|
extension: String(fExt)
|
||||||
|
}
|
||||||
|
})
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
const dataDivision = await prisma.divisionDisscussion.findUnique({
|
const dataDivision = await prisma.divisionDisscussion.findUnique({
|
||||||
where: {
|
where: {
|
||||||
id: id
|
id: id
|
||||||
@@ -162,7 +195,7 @@ export async function POST(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 { comment, user } = (await request.json());
|
const { comment, user, filesToRemove } = (await request.json());
|
||||||
|
|
||||||
const userMobile = await funGetUserById({ id: String(user) })
|
const userMobile = await funGetUserById({ id: String(user) })
|
||||||
|
|
||||||
@@ -187,14 +220,17 @@ export async function PUT(request: Request, context: { params: { id: string } })
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
const data = await prisma.divisionDisscussionComment.update({
|
if (filesToRemove && filesToRemove.length > 0) {
|
||||||
where: {
|
for (const fileId of filesToRemove) {
|
||||||
id: id
|
const file = await prisma.divisionDiscussionCommentFile.findUnique({ where: { id: fileId } })
|
||||||
},
|
if (file?.idStorage) await funDeleteFile({ id: file.idStorage })
|
||||||
data: {
|
await prisma.divisionDiscussionCommentFile.update({ where: { id: fileId }, data: { isActive: false } })
|
||||||
comment: comment,
|
|
||||||
isEdited: true
|
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
await prisma.divisionDisscussionComment.update({
|
||||||
|
where: { id: id },
|
||||||
|
data: { comment: comment, isEdited: true }
|
||||||
})
|
})
|
||||||
|
|
||||||
// create log user
|
// create log user
|
||||||
@@ -237,13 +273,17 @@ export async function DELETE(request: Request, context: { params: { id: string }
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
const data = await prisma.divisionDisscussionComment.update({
|
const commentFiles = await prisma.divisionDiscussionCommentFile.findMany({
|
||||||
where: {
|
where: { idComment: id, isActive: true }
|
||||||
id: id
|
})
|
||||||
},
|
for (const file of commentFiles) {
|
||||||
data: {
|
if (file.idStorage) await funDeleteFile({ id: file.idStorage })
|
||||||
isActive: false
|
await prisma.divisionDiscussionCommentFile.update({ where: { id: file.id }, data: { isActive: false } })
|
||||||
}
|
}
|
||||||
|
|
||||||
|
await prisma.divisionDisscussionComment.update({
|
||||||
|
where: { id: id },
|
||||||
|
data: { isActive: false }
|
||||||
})
|
})
|
||||||
|
|
||||||
// create log user
|
// create log user
|
||||||
|
|||||||
@@ -53,6 +53,15 @@ export async function GET(request: Request, context: { params: { id: string } })
|
|||||||
name: true,
|
name: true,
|
||||||
img: true
|
img: true
|
||||||
}
|
}
|
||||||
|
},
|
||||||
|
DivisionDiscussionCommentFile: {
|
||||||
|
where: { isActive: true },
|
||||||
|
select: {
|
||||||
|
id: true,
|
||||||
|
name: true,
|
||||||
|
extension: true,
|
||||||
|
idStorage: true
|
||||||
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
orderBy: {
|
orderBy: {
|
||||||
@@ -61,12 +70,13 @@ export async function GET(request: Request, context: { params: { id: string } })
|
|||||||
})
|
})
|
||||||
|
|
||||||
const omitMember = data.map((v: any) => ({
|
const omitMember = data.map((v: any) => ({
|
||||||
..._.omit(v, ["User", "createdBy", "createdAt", "updatedAt"]),
|
..._.omit(v, ["User", "createdBy", "createdAt", "updatedAt", "DivisionDiscussionCommentFile"]),
|
||||||
idUser: v.createdBy,
|
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")
|
updatedAt: moment(v.updatedAt).format("ll"),
|
||||||
|
files: v.DivisionDiscussionCommentFile
|
||||||
}))
|
}))
|
||||||
|
|
||||||
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 });
|
||||||
|
|||||||
@@ -27,9 +27,6 @@ export async function GET(request: Request) {
|
|||||||
idUserTo: userMobile.id
|
idUserTo: userMobile.id
|
||||||
},
|
},
|
||||||
orderBy: [
|
orderBy: [
|
||||||
{
|
|
||||||
isRead: 'asc'
|
|
||||||
},
|
|
||||||
{
|
{
|
||||||
createdAt: 'desc'
|
createdAt: 'desc'
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -164,7 +164,7 @@ export async function POST(request: Request, context: { params: { id: string } }
|
|||||||
if (String(pair[0]).substring(0, 4) == "file") {
|
if (String(pair[0]).substring(0, 4) == "file") {
|
||||||
const file = body.get(pair[0]) as File
|
const file = body.get(pair[0]) as File
|
||||||
const fExt = file.name.split(".").pop()
|
const fExt = file.name.split(".").pop()
|
||||||
const fName = file.name.replace("." + fExt, "")
|
const fName = decodeURIComponent(file.name.replace("." + fExt, ""))
|
||||||
|
|
||||||
const upload = await funUploadFile({ file: file, dirId: DIR.project })
|
const upload = await funUploadFile({ file: file, dirId: DIR.project })
|
||||||
if (upload.success) {
|
if (upload.success) {
|
||||||
|
|||||||
@@ -84,7 +84,7 @@ export async function POST(request: Request, context: { params: { id: string } }
|
|||||||
|
|
||||||
const file = body.get(key) as File;
|
const file = body.get(key) as File;
|
||||||
const fExt = file.name.split(".").pop();
|
const fExt = file.name.split(".").pop();
|
||||||
const fName = file.name.replace("." + fExt, "");
|
const fName = decodeURIComponent(file.name.replace("." + fExt, ""));
|
||||||
|
|
||||||
const upload = await funUploadFile({ file, dirId: DIR.project });
|
const upload = await funUploadFile({ file, dirId: DIR.project });
|
||||||
if (!upload.success) continue;
|
if (!upload.success) continue;
|
||||||
|
|||||||
@@ -114,7 +114,7 @@ export async function POST(request: Request, context: { params: { id: string } }
|
|||||||
if (String(pair[0]).substring(0, 4) == "file") {
|
if (String(pair[0]).substring(0, 4) == "file") {
|
||||||
const file = body.get(pair[0]) as File
|
const file = body.get(pair[0]) as File
|
||||||
const fExt = file.name.split(".").pop()
|
const fExt = file.name.split(".").pop()
|
||||||
const fName = file.name.replace("." + fExt, "")
|
const fName = decodeURIComponent(file.name.replace("." + fExt, ""))
|
||||||
|
|
||||||
|
|
||||||
const upload = await funUploadFile({ file: file, dirId: DIR.task })
|
const upload = await funUploadFile({ file: file, dirId: DIR.task })
|
||||||
|
|||||||
@@ -213,7 +213,7 @@ export async function POST(request: Request) {
|
|||||||
if (String(pair[0]).substring(0, 4) == "file") {
|
if (String(pair[0]).substring(0, 4) == "file") {
|
||||||
const file = body.get(pair[0]) as File
|
const file = body.get(pair[0]) as File
|
||||||
const fExt = file.name.split(".").pop()
|
const fExt = file.name.split(".").pop()
|
||||||
const fName = file.name.replace("." + fExt, "")
|
const fName = decodeURIComponent(file.name.replace("." + fExt, ""))
|
||||||
|
|
||||||
const upload = await funUploadFile({ file: file, dirId: DIR.task })
|
const upload = await funUploadFile({ file: file, dirId: DIR.task })
|
||||||
if (upload.success) {
|
if (upload.success) {
|
||||||
|
|||||||
@@ -87,7 +87,7 @@ export async function POST(request: Request, context: { params: { id: string } }
|
|||||||
|
|
||||||
const file = body.get(key) as File;
|
const file = body.get(key) as File;
|
||||||
const fExt = file.name.split(".").pop();
|
const fExt = file.name.split(".").pop();
|
||||||
const fName = file.name.replace("." + fExt, "");
|
const fName = decodeURIComponent(file.name.replace("." + fExt, ""));
|
||||||
|
|
||||||
const upload = await funUploadFile({ file, dirId: DIR.task });
|
const upload = await funUploadFile({ file, dirId: DIR.task });
|
||||||
if (!upload.success) continue;
|
if (!upload.success) continue;
|
||||||
|
|||||||
File diff suppressed because it is too large
Load Diff
Reference in New Issue
Block a user