Tambahan Lagi
This commit is contained in:
@@ -2,6 +2,8 @@
|
|||||||
|
|
||||||
All notable changes to this project will be documented in this file. See [commit-and-tag-version](https://github.com/absolute-version/commit-and-tag-version) for commit guidelines.
|
All notable changes to this project will be documented in this file. See [commit-and-tag-version](https://github.com/absolute-version/commit-and-tag-version) for commit guidelines.
|
||||||
|
|
||||||
|
## [1.2.58](https://github.com/bipproduction/hipmi/compare/v1.2.57...v1.2.58) (2025-02-25)
|
||||||
|
|
||||||
## [1.2.57](https://github.com/bipproduction/hipmi/compare/v1.2.56...v1.2.57) (2025-02-20)
|
## [1.2.57](https://github.com/bipproduction/hipmi/compare/v1.2.56...v1.2.57) (2025-02-20)
|
||||||
|
|
||||||
## [1.2.56](https://github.com/bipproduction/hipmi/compare/v1.2.55...v1.2.56) (2025-02-19)
|
## [1.2.56](https://github.com/bipproduction/hipmi/compare/v1.2.55...v1.2.56) (2025-02-19)
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "hipmi",
|
"name": "hipmi",
|
||||||
"version": "1.2.57",
|
"version": "1.2.58",
|
||||||
"private": true,
|
"private": true,
|
||||||
"type": "module",
|
"type": "module",
|
||||||
"prisma": {
|
"prisma": {
|
||||||
|
|||||||
72
src/app/api/admin/user/route.ts
Normal file
72
src/app/api/admin/user/route.ts
Normal file
@@ -0,0 +1,72 @@
|
|||||||
|
import _ from "lodash";
|
||||||
|
import { NextResponse } from "next/server";
|
||||||
|
import prisma from "@/lib/prisma";
|
||||||
|
|
||||||
|
export async function GET(request: Request) {
|
||||||
|
try {
|
||||||
|
let fixData;
|
||||||
|
const { searchParams } = new URL(request.url);
|
||||||
|
const search = searchParams.get("search");
|
||||||
|
const page = searchParams.get("page");
|
||||||
|
const takeData = 10;
|
||||||
|
const skipData = Number(page) * takeData - takeData;
|
||||||
|
|
||||||
|
if (!page) {
|
||||||
|
fixData = await prisma.user.findMany({
|
||||||
|
where: {
|
||||||
|
masterUserRoleId: "1",
|
||||||
|
username: {
|
||||||
|
contains: search || "",
|
||||||
|
mode: "insensitive",
|
||||||
|
},
|
||||||
|
},
|
||||||
|
});
|
||||||
|
} else {
|
||||||
|
const getData = await prisma.user.findMany({
|
||||||
|
skip: skipData,
|
||||||
|
take: takeData,
|
||||||
|
orderBy: {
|
||||||
|
active: "asc",
|
||||||
|
},
|
||||||
|
where: {
|
||||||
|
masterUserRoleId: "1",
|
||||||
|
username: {
|
||||||
|
contains: search || "",
|
||||||
|
mode: "insensitive",
|
||||||
|
},
|
||||||
|
},
|
||||||
|
});
|
||||||
|
|
||||||
|
const nCount = await prisma.user.count({
|
||||||
|
where: {
|
||||||
|
masterUserRoleId: "1",
|
||||||
|
username: {
|
||||||
|
contains: search || "",
|
||||||
|
mode: "insensitive",
|
||||||
|
},
|
||||||
|
},
|
||||||
|
});
|
||||||
|
|
||||||
|
fixData = {
|
||||||
|
data: getData,
|
||||||
|
nPage: _.ceil(nCount / takeData),
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
return NextResponse.json(
|
||||||
|
{
|
||||||
|
success: true,
|
||||||
|
message: "Success get data",
|
||||||
|
data: fixData,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
status: 200,
|
||||||
|
}
|
||||||
|
);
|
||||||
|
} catch (error) {
|
||||||
|
return NextResponse.json(
|
||||||
|
{ success: false, message: "Internal Server Error" },
|
||||||
|
{ status: 500 }
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -4,152 +4,216 @@ import _ from "lodash";
|
|||||||
import moment from "moment";
|
import moment from "moment";
|
||||||
import { NextResponse } from "next/server";
|
import { NextResponse } from "next/server";
|
||||||
|
|
||||||
export async function GET(request: Request,
|
export async function GET(
|
||||||
{ params }: { params: { name: string } }
|
request: Request,
|
||||||
|
{ params }: { params: { name: string } }
|
||||||
) {
|
) {
|
||||||
|
|
||||||
|
try {
|
||||||
|
let fixData;
|
||||||
const { name } = params;
|
const { name } = params;
|
||||||
const { searchParams } = new URL(request.url);
|
const { searchParams } = new URL(request.url);
|
||||||
const search = searchParams.get("search");
|
const search = searchParams.get("search");
|
||||||
const page = searchParams.get("page");
|
const page = searchParams.get("page");
|
||||||
const takeData = 10;
|
const takeData = 10
|
||||||
const skipData = Number(page) * takeData - takeData;
|
const skipData = Number(page) * takeData - takeData;
|
||||||
|
|
||||||
try {
|
const fixStatus = _.startCase(name);
|
||||||
let fixData;
|
|
||||||
const fixStatus = _.startCase(name);
|
|
||||||
|
|
||||||
if (!page) {
|
if (!page) {
|
||||||
fixData = await prisma.voting.findMany({
|
fixData = await prisma.voting.findMany({
|
||||||
orderBy: {
|
orderBy: {
|
||||||
createdAt: "desc",
|
createdAt: "desc",
|
||||||
},
|
},
|
||||||
where: {
|
where: {
|
||||||
Voting_Status: {
|
Voting_Status: {
|
||||||
name: fixStatus,
|
name: fixStatus,
|
||||||
},
|
},
|
||||||
isActive: true,
|
isActive: true,
|
||||||
title: {
|
title: {
|
||||||
contains: search ? search : "",
|
contains: search ? search : "",
|
||||||
mode: "insensitive",
|
mode: "insensitive",
|
||||||
},
|
},
|
||||||
isArsip: false,
|
isArsip: false,
|
||||||
},
|
},
|
||||||
include: {
|
include: {
|
||||||
Author: {
|
Author: {
|
||||||
select: {
|
select: {
|
||||||
id: true,
|
id: true,
|
||||||
username: true,
|
username: true,
|
||||||
Profile: {
|
Profile: {
|
||||||
select: {
|
select: {
|
||||||
id: true,
|
id: true,
|
||||||
name: true,
|
name: true,
|
||||||
},
|
|
||||||
},
|
|
||||||
},
|
|
||||||
},
|
|
||||||
Voting_Kontributor: true,
|
|
||||||
Voting_DaftarNamaVote: true,
|
|
||||||
},
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
Voting_Kontributor: true,
|
||||||
|
Voting_DaftarNamaVote: true,
|
||||||
|
},
|
||||||
|
});
|
||||||
|
} else {
|
||||||
|
if (fixStatus === "Publish") {
|
||||||
|
const getAllData = await prisma.voting.findMany({
|
||||||
|
where: {
|
||||||
|
Voting_Status: {
|
||||||
|
name: fixStatus,
|
||||||
|
},
|
||||||
|
isActive: true,
|
||||||
|
isArsip: false,
|
||||||
|
akhirVote: {
|
||||||
|
gte: new Date(),
|
||||||
|
},
|
||||||
|
},
|
||||||
|
});
|
||||||
|
|
||||||
|
for (let i of getAllData) {
|
||||||
|
if (moment(i.akhirVote).diff(moment(), "minutes") < 0) {
|
||||||
|
await prisma.event.update({
|
||||||
|
where: {
|
||||||
|
id: i.id,
|
||||||
|
},
|
||||||
|
data: {
|
||||||
|
isArsip: true,
|
||||||
|
},
|
||||||
});
|
});
|
||||||
} else {
|
}
|
||||||
fixData = await prisma.voting.findMany({
|
|
||||||
take: takeData,
|
|
||||||
skip: skipData,
|
|
||||||
orderBy: {
|
|
||||||
createdAt: "desc",
|
|
||||||
},
|
|
||||||
where: {
|
|
||||||
Voting_Status: {
|
|
||||||
name: fixStatus,
|
|
||||||
},
|
|
||||||
isActive: true,
|
|
||||||
title: {
|
|
||||||
contains: search ? search : "",
|
|
||||||
mode: "insensitive",
|
|
||||||
},
|
|
||||||
isArsip: false,
|
|
||||||
},
|
|
||||||
include: {
|
|
||||||
Author: {
|
|
||||||
select: {
|
|
||||||
id: true,
|
|
||||||
username: true,
|
|
||||||
Profile: {
|
|
||||||
select: {
|
|
||||||
id: true,
|
|
||||||
name: true,
|
|
||||||
},
|
|
||||||
},
|
|
||||||
},
|
|
||||||
},
|
|
||||||
Voting_Kontributor: true,
|
|
||||||
Voting_DaftarNamaVote: true,
|
|
||||||
},
|
|
||||||
});
|
|
||||||
|
|
||||||
if (fixStatus === "Publish") {
|
|
||||||
const data = await prisma.voting.findMany({
|
|
||||||
where: {
|
|
||||||
Voting_Status: {
|
|
||||||
name: fixStatus,
|
|
||||||
},
|
|
||||||
isActive: true,
|
|
||||||
title: {
|
|
||||||
contains: search ? search : "",
|
|
||||||
mode: "insensitive",
|
|
||||||
},
|
|
||||||
isArsip: false,
|
|
||||||
},
|
|
||||||
});
|
|
||||||
|
|
||||||
for (let i of data) {
|
|
||||||
if (moment(i.akhirVote).diff(moment(), "minutes") < 0) {
|
|
||||||
await prisma.event.update({
|
|
||||||
where: {
|
|
||||||
id: i.id,
|
|
||||||
},
|
|
||||||
data: {
|
|
||||||
isArsip: true,
|
|
||||||
},
|
|
||||||
});
|
|
||||||
}
|
|
||||||
}
|
|
||||||
const nCount = await prisma.voting.count({
|
|
||||||
where: {
|
|
||||||
Voting_Status: {
|
|
||||||
name: fixStatus,
|
|
||||||
},
|
|
||||||
isActive: true,
|
|
||||||
title: {
|
|
||||||
contains: search ? search : "",
|
|
||||||
mode: "insensitive",
|
|
||||||
},
|
|
||||||
},
|
|
||||||
});
|
|
||||||
|
|
||||||
fixData = {
|
|
||||||
data: data,
|
|
||||||
count: _.ceil(nCount / takeData)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return NextResponse.json({
|
const data = await prisma.voting.findMany({
|
||||||
success: true,
|
take: takeData,
|
||||||
message: "Success get data voting dashboard",
|
skip: skipData,
|
||||||
data: fixData
|
orderBy: {
|
||||||
},
|
createdAt: "desc",
|
||||||
{ status: 200 }
|
},
|
||||||
)
|
where: {
|
||||||
} catch (error) {
|
Voting_Status: {
|
||||||
backendLogger.error("Error get data voting dashboard >>", error);
|
name: fixStatus,
|
||||||
return NextResponse.json({
|
},
|
||||||
success: false,
|
isActive: true,
|
||||||
message: "Error get data voting dashboard",
|
title: {
|
||||||
reason: (error as Error).message
|
contains: search ? search : "",
|
||||||
},
|
mode: "insensitive",
|
||||||
{ status: 500 }
|
},
|
||||||
)
|
akhirVote: {
|
||||||
|
gte: new Date(),
|
||||||
|
},
|
||||||
|
isArsip: false,
|
||||||
|
},
|
||||||
|
include: {
|
||||||
|
Author: {
|
||||||
|
select: {
|
||||||
|
id: true,
|
||||||
|
username: true,
|
||||||
|
Profile: {
|
||||||
|
select: {
|
||||||
|
id: true,
|
||||||
|
name: true,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
Voting_Kontributor: true,
|
||||||
|
Voting_DaftarNamaVote: true,
|
||||||
|
},
|
||||||
|
});
|
||||||
|
|
||||||
|
const nCount = await prisma.voting.count({
|
||||||
|
where: {
|
||||||
|
Voting_Status: {
|
||||||
|
name: fixStatus,
|
||||||
|
},
|
||||||
|
isActive: true,
|
||||||
|
title: {
|
||||||
|
contains: search ? search : "",
|
||||||
|
mode: "insensitive",
|
||||||
|
},
|
||||||
|
akhirVote: {
|
||||||
|
gte: new Date(),
|
||||||
|
},
|
||||||
|
isArsip: false,
|
||||||
|
},
|
||||||
|
});
|
||||||
|
|
||||||
|
fixData = {
|
||||||
|
data: data,
|
||||||
|
nPage: _.ceil(nCount / takeData),
|
||||||
|
};
|
||||||
|
} else {
|
||||||
|
const data = await prisma.voting.findMany({
|
||||||
|
take: takeData,
|
||||||
|
skip: skipData,
|
||||||
|
orderBy: {
|
||||||
|
createdAt: "desc",
|
||||||
|
},
|
||||||
|
where: {
|
||||||
|
Voting_Status: {
|
||||||
|
name: fixStatus,
|
||||||
|
},
|
||||||
|
isActive: true,
|
||||||
|
title: {
|
||||||
|
contains: search ? search : "",
|
||||||
|
mode: "insensitive",
|
||||||
|
},
|
||||||
|
isArsip: false,
|
||||||
|
},
|
||||||
|
include: {
|
||||||
|
Author: {
|
||||||
|
select: {
|
||||||
|
id: true,
|
||||||
|
username: true,
|
||||||
|
Profile: {
|
||||||
|
select: {
|
||||||
|
id: true,
|
||||||
|
name: true,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
Voting_Kontributor: true,
|
||||||
|
Voting_DaftarNamaVote: true,
|
||||||
|
},
|
||||||
|
});
|
||||||
|
|
||||||
|
const nCount = await prisma.voting.count({
|
||||||
|
where: {
|
||||||
|
Voting_Status: {
|
||||||
|
name: fixStatus,
|
||||||
|
},
|
||||||
|
isActive: true,
|
||||||
|
title: {
|
||||||
|
contains: search ? search : "",
|
||||||
|
mode: "insensitive",
|
||||||
|
},
|
||||||
|
isArsip: false,
|
||||||
|
},
|
||||||
|
});
|
||||||
|
|
||||||
|
fixData = {
|
||||||
|
data: data,
|
||||||
|
nPage: _.ceil(nCount / takeData),
|
||||||
|
};
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
return NextResponse.json(
|
||||||
|
{
|
||||||
|
success: true,
|
||||||
|
message: "Success get data voting status",
|
||||||
|
data: fixData,
|
||||||
|
},
|
||||||
|
{ status: 200 }
|
||||||
|
);
|
||||||
|
} catch (error) {
|
||||||
|
backendLogger.error("Error get data voting status ", error);
|
||||||
|
return NextResponse.json(
|
||||||
|
{
|
||||||
|
success: false,
|
||||||
|
message: "Error get data voting status",
|
||||||
|
reason: (error as Error).message,
|
||||||
|
},
|
||||||
|
{ status: 500 }
|
||||||
|
);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
123
src/app/api/admin/vote/status/riwayat/route.ts
Normal file
123
src/app/api/admin/vote/status/riwayat/route.ts
Normal file
@@ -0,0 +1,123 @@
|
|||||||
|
import { prisma } from "@/lib";
|
||||||
|
import backendLogger from "@/util/backendLogger";
|
||||||
|
import _ from "lodash";
|
||||||
|
import { NextResponse } from "next/server";
|
||||||
|
|
||||||
|
export async function GET(request: Request) {
|
||||||
|
try {
|
||||||
|
let fixData;
|
||||||
|
const { searchParams } = new URL(request.url);
|
||||||
|
const search = searchParams.get("search");
|
||||||
|
const page = searchParams.get("page");
|
||||||
|
const takeData = 2;
|
||||||
|
const skipData = Number(page) * takeData - takeData;
|
||||||
|
|
||||||
|
if (!page) {
|
||||||
|
fixData = await prisma.voting.findMany({
|
||||||
|
orderBy: {
|
||||||
|
updatedAt: "desc",
|
||||||
|
},
|
||||||
|
where: {
|
||||||
|
voting_StatusId: "1",
|
||||||
|
isActive: true,
|
||||||
|
akhirVote: {
|
||||||
|
lte: new Date(),
|
||||||
|
},
|
||||||
|
title: {
|
||||||
|
contains: search ? search : "",
|
||||||
|
mode: "insensitive",
|
||||||
|
},
|
||||||
|
},
|
||||||
|
include: {
|
||||||
|
Author: {
|
||||||
|
select: {
|
||||||
|
id: true,
|
||||||
|
username: true,
|
||||||
|
Profile: {
|
||||||
|
select: {
|
||||||
|
id: true,
|
||||||
|
name: true,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
Voting_Kontributor: true,
|
||||||
|
Voting_DaftarNamaVote: true,
|
||||||
|
},
|
||||||
|
});
|
||||||
|
} else {
|
||||||
|
const data = await prisma.voting.findMany({
|
||||||
|
skip: skipData,
|
||||||
|
take: takeData,
|
||||||
|
orderBy: {
|
||||||
|
updatedAt: "desc",
|
||||||
|
},
|
||||||
|
where: {
|
||||||
|
voting_StatusId: "1",
|
||||||
|
isActive: true,
|
||||||
|
akhirVote: {
|
||||||
|
lte: new Date(),
|
||||||
|
},
|
||||||
|
title: {
|
||||||
|
contains: search ? search : "",
|
||||||
|
mode: "insensitive",
|
||||||
|
},
|
||||||
|
},
|
||||||
|
include: {
|
||||||
|
Author: {
|
||||||
|
select: {
|
||||||
|
id: true,
|
||||||
|
username: true,
|
||||||
|
Profile: {
|
||||||
|
select: {
|
||||||
|
id: true,
|
||||||
|
name: true,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
Voting_Kontributor: true,
|
||||||
|
Voting_DaftarNamaVote: true,
|
||||||
|
},
|
||||||
|
});
|
||||||
|
|
||||||
|
const nCount = await prisma.voting.count({
|
||||||
|
where: {
|
||||||
|
voting_StatusId: "1",
|
||||||
|
isActive: true,
|
||||||
|
akhirVote: {
|
||||||
|
lte: new Date(),
|
||||||
|
},
|
||||||
|
title: {
|
||||||
|
contains: search ? search : "",
|
||||||
|
mode: "insensitive",
|
||||||
|
},
|
||||||
|
},
|
||||||
|
});
|
||||||
|
|
||||||
|
fixData = {
|
||||||
|
data: data,
|
||||||
|
nPage: _.ceil(nCount / takeData),
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
return NextResponse.json(
|
||||||
|
{
|
||||||
|
success: true,
|
||||||
|
message: "Success get data voting riwayat",
|
||||||
|
data: fixData,
|
||||||
|
},
|
||||||
|
{ status: 200 }
|
||||||
|
);
|
||||||
|
} catch (error) {
|
||||||
|
backendLogger.error("Error get data voting riwayat ", error);
|
||||||
|
return NextResponse.json(
|
||||||
|
{
|
||||||
|
success: false,
|
||||||
|
message: "Error get data voting riwayat",
|
||||||
|
reason: (error as Error).message,
|
||||||
|
},
|
||||||
|
{ status: 500 }
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
32
src/app/api/master/admin-contact/route.ts
Normal file
32
src/app/api/master/admin-contact/route.ts
Normal file
@@ -0,0 +1,32 @@
|
|||||||
|
import backendLogger from "@/util/backendLogger";
|
||||||
|
import { NextResponse } from "next/server";
|
||||||
|
import prisma from "@/lib/prisma";
|
||||||
|
|
||||||
|
export async function GET(request: Request) {
|
||||||
|
try {
|
||||||
|
const data = await prisma.nomorAdmin.findFirst({
|
||||||
|
where: {
|
||||||
|
isActive: true,
|
||||||
|
},
|
||||||
|
});
|
||||||
|
|
||||||
|
return NextResponse.json(
|
||||||
|
{
|
||||||
|
success: true,
|
||||||
|
message: "Success get admin contact",
|
||||||
|
data: data,
|
||||||
|
},
|
||||||
|
{ status: 200 }
|
||||||
|
);
|
||||||
|
} catch (error) {
|
||||||
|
backendLogger.error("Error get admin contact", error);
|
||||||
|
return NextResponse.json(
|
||||||
|
{
|
||||||
|
success: false,
|
||||||
|
message: "Error get admin contact",
|
||||||
|
reason: (error as Error).message,
|
||||||
|
},
|
||||||
|
{ status: 500 }
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -4,14 +4,12 @@ import adminAppInformation_getNomorAdmin from "@/app_modules/admin/app_info/fun/
|
|||||||
import { AdminAppInformation_UiMain } from "@/app_modules/admin/app_info/ui";
|
import { AdminAppInformation_UiMain } from "@/app_modules/admin/app_info/ui";
|
||||||
|
|
||||||
export default async function Page() {
|
export default async function Page() {
|
||||||
const nomorAdmin = await adminAppInformation_getNomorAdmin();
|
|
||||||
const listBank = await adminAppInformation_getMasterBank();
|
const listBank = await adminAppInformation_getMasterBank();
|
||||||
const dataBidangBisnis = await adminAppInformation_funGetBidangBisnis()
|
const dataBidangBisnis = await adminAppInformation_funGetBidangBisnis()
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<>
|
<>
|
||||||
<AdminAppInformation_UiMain
|
<AdminAppInformation_UiMain
|
||||||
nomorAdmin={nomorAdmin}
|
|
||||||
listBank={listBank}
|
listBank={listBank}
|
||||||
dataBidangBisnis={dataBidangBisnis}
|
dataBidangBisnis={dataBidangBisnis}
|
||||||
/>
|
/>
|
||||||
|
|||||||
@@ -2,11 +2,11 @@ import { AdminUserAccess_View } from "@/app_modules/admin/user-access";
|
|||||||
import adminUserAccess_getListUser from "@/app_modules/admin/user-access/fun/get/get_list_all_user";
|
import adminUserAccess_getListUser from "@/app_modules/admin/user-access/fun/get/get_list_all_user";
|
||||||
|
|
||||||
export default async function Page() {
|
export default async function Page() {
|
||||||
const listUser = await adminUserAccess_getListUser({ page: 1 });
|
// const listUser = await adminUserAccess_getListUser({ page: 1 });
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<>
|
<>
|
||||||
<AdminUserAccess_View listUser={listUser as any} />
|
<AdminUserAccess_View />
|
||||||
</>
|
</>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,13 +1,9 @@
|
|||||||
import { AdminVote_Riwayat } from "@/app_modules/admin/vote";
|
import { AdminVote_Riwayat } from "@/app_modules/admin/vote";
|
||||||
import { adminVote_funGetListRiwayat } from "@/app_modules/admin/vote/fun";
|
|
||||||
import { AdminVote_getListTableByStatusId } from "@/app_modules/admin/vote/fun/get/get_list_table_by_status_id";
|
|
||||||
|
|
||||||
export default async function Page() {
|
export default async function Page() {
|
||||||
const dataVote = await adminVote_funGetListRiwayat({page: 1});
|
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<>
|
<>
|
||||||
<AdminVote_Riwayat dataVote={dataVote as any} />
|
<AdminVote_Riwayat />
|
||||||
</>
|
</>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,13 +1,9 @@
|
|||||||
import { AdminVote_TablePublish } from "@/app_modules/admin/vote";
|
import { AdminVote_TablePublish } from "@/app_modules/admin/vote";
|
||||||
import { AdminVote_getListTableByStatusId } from "@/app_modules/admin/vote/fun/get/get_list_table_by_status_id";
|
|
||||||
import { adminVote_funGetListPublish } from "@/app_modules/admin/vote/fun/get/status/get_list_publish";
|
|
||||||
|
|
||||||
export default async function Page() {
|
export default async function Page() {
|
||||||
const dataVote = await adminVote_funGetListPublish({page: 1});
|
return (
|
||||||
|
<>
|
||||||
return (
|
<AdminVote_TablePublish />
|
||||||
<>
|
</>
|
||||||
<AdminVote_TablePublish dataVote={dataVote} />
|
);
|
||||||
</>
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
@@ -1,11 +1,9 @@
|
|||||||
import { AdminVote_TableReject } from "@/app_modules/admin/vote";
|
import { AdminVote_TableReject } from "@/app_modules/admin/vote";
|
||||||
import { adminVote_funGetListReject } from "@/app_modules/admin/vote/fun";
|
|
||||||
|
|
||||||
export default async function Page() {
|
export default async function Page() {
|
||||||
const dataVote = await adminVote_funGetListReject({ page: 1 });
|
|
||||||
return (
|
return (
|
||||||
<>
|
<>
|
||||||
<AdminVote_TableReject dataVote={dataVote as any} />
|
<AdminVote_TableReject />
|
||||||
</>
|
</>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,12 +1,9 @@
|
|||||||
import { AdminVote_TableReview } from "@/app_modules/admin/vote";
|
import { AdminVote_TableReview } from "@/app_modules/admin/vote";
|
||||||
import { adminVote_funGetListReview } from "@/app_modules/admin/vote/fun";
|
|
||||||
|
|
||||||
export default async function Page() {
|
export default async function Page() {
|
||||||
const listVote = await adminVote_funGetListReview({ page: 1 });
|
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<>
|
<>
|
||||||
<AdminVote_TableReview listVote={listVote as any} />
|
<AdminVote_TableReview />
|
||||||
</>
|
</>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,4 +1,9 @@
|
|||||||
export { apiGetMasterBank, apiGetMasterBidangBisnis, apiGetMasterStatusTransaksi };
|
export {
|
||||||
|
apiGetMasterBank,
|
||||||
|
apiGetMasterBidangBisnis,
|
||||||
|
apiGetMasterStatusTransaksi,
|
||||||
|
apiGetAdminContact,
|
||||||
|
};
|
||||||
|
|
||||||
const apiGetMasterBank = async () => {
|
const apiGetMasterBank = async () => {
|
||||||
const { token } = await fetch("/api/get-cookie").then((res) => res.json());
|
const { token } = await fetch("/api/get-cookie").then((res) => res.json());
|
||||||
@@ -37,14 +42,51 @@ const apiGetMasterStatusTransaksi = async () => {
|
|||||||
if (!token) return await token.json().catch(() => null);
|
if (!token) return await token.json().catch(() => null);
|
||||||
|
|
||||||
const response = await fetch(`/api/master/status_transaksi`, {
|
const response = await fetch(`/api/master/status_transaksi`, {
|
||||||
method: "GET",
|
method: "GET",
|
||||||
headers: {
|
headers: {
|
||||||
"Content-Type": "application/json",
|
"Content-Type": "application/json",
|
||||||
Accept: "application/json",
|
Accept: "application/json",
|
||||||
"Access-Control-Allow-Origin": "*",
|
"Access-Control-Allow-Origin": "*",
|
||||||
Authorization: `Bearer ${token}`,
|
Authorization: `Bearer ${token}`,
|
||||||
}
|
},
|
||||||
})
|
});
|
||||||
|
|
||||||
return await response.json().catch(() => null);
|
return await response.json().catch(() => null);
|
||||||
}
|
};
|
||||||
|
|
||||||
|
const apiGetAdminContact = async () => {
|
||||||
|
try {
|
||||||
|
// Fetch token from cookie
|
||||||
|
const { token } = await fetch("/api/get-cookie").then((res) => res.json());
|
||||||
|
if (!token) {
|
||||||
|
console.error("No token found");
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Send PUT request to update portfolio logo
|
||||||
|
const response = await fetch(`/api/master/admin-contact`, {
|
||||||
|
method: "GET",
|
||||||
|
headers: {
|
||||||
|
"Content-Type": "application/json",
|
||||||
|
Accept: "application/json",
|
||||||
|
Authorization: `Bearer ${token}`,
|
||||||
|
},
|
||||||
|
});
|
||||||
|
|
||||||
|
// Check if the response is OK
|
||||||
|
if (!response.ok) {
|
||||||
|
const errorData = await response.json().catch(() => null);
|
||||||
|
console.error(
|
||||||
|
"Error get admin contact:",
|
||||||
|
errorData?.message || "Unknown error"
|
||||||
|
);
|
||||||
|
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
return await response.json();
|
||||||
|
} catch (error) {
|
||||||
|
console.error("Error get admin contact:", error);
|
||||||
|
throw error; // Re-throw the error to handle it in the calling function
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|||||||
@@ -7,15 +7,23 @@ export default async function adminAppInformation_funUpdateNomorAdmin({
|
|||||||
}: {
|
}: {
|
||||||
data: any;
|
data: any;
|
||||||
}) {
|
}) {
|
||||||
const updt = await prisma.nomorAdmin.update({
|
try {
|
||||||
where: {
|
const updt = await prisma.nomorAdmin.update({
|
||||||
id: data.id,
|
where: {
|
||||||
},
|
id: data.id,
|
||||||
data: {
|
},
|
||||||
nomor: data.nomor,
|
data: {
|
||||||
},
|
nomor: data.nomor,
|
||||||
});
|
},
|
||||||
|
});
|
||||||
|
|
||||||
if (!updt) return { status: 400, message: "Gagal update" };
|
if (!updt) return { status: 400, message: "Gagal update" };
|
||||||
return { status: 200, message: "Berhasil update" };
|
return { status: 200, message: "Berhasil update" };
|
||||||
|
} catch (error) {
|
||||||
|
return {
|
||||||
|
status: 500,
|
||||||
|
message: "Error update",
|
||||||
|
error: (error as Error).message,
|
||||||
|
};
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -12,11 +12,9 @@ import {
|
|||||||
import { AccentColor, AdminColor, MainColor } from "@/app_modules/_global/color/color_pallet";
|
import { AccentColor, AdminColor, MainColor } from "@/app_modules/_global/color/color_pallet";
|
||||||
|
|
||||||
export default function AdminAppInformation_UiMain({
|
export default function AdminAppInformation_UiMain({
|
||||||
nomorAdmin,
|
|
||||||
listBank,
|
listBank,
|
||||||
dataBidangBisnis,
|
dataBidangBisnis,
|
||||||
}: {
|
}: {
|
||||||
nomorAdmin: any;
|
|
||||||
listBank: any[];
|
listBank: any[];
|
||||||
dataBidangBisnis: any[];
|
dataBidangBisnis: any[];
|
||||||
}) {
|
}) {
|
||||||
@@ -61,7 +59,7 @@ export default function AdminAppInformation_UiMain({
|
|||||||
</Group>
|
</Group>
|
||||||
|
|
||||||
{selectPage === "1" && (
|
{selectPage === "1" && (
|
||||||
<AdminAppInformation_ViewInformasiWhatApps nomorAdmin={nomorAdmin} />
|
<AdminAppInformation_ViewInformasiWhatApps />
|
||||||
)}
|
)}
|
||||||
|
|
||||||
{selectPage === "2" && (
|
{selectPage === "2" && (
|
||||||
|
|||||||
@@ -1,9 +1,17 @@
|
|||||||
" use client";
|
" use client";
|
||||||
|
|
||||||
|
import {
|
||||||
|
AccentColor,
|
||||||
|
AdminColor,
|
||||||
|
} from "@/app_modules/_global/color/color_pallet";
|
||||||
|
import { apiGetAdminContact } from "@/app_modules/_global/lib/api_fetch_master";
|
||||||
|
import CustomSkeleton from "@/app_modules/components/CustomSkeleton";
|
||||||
|
import { clientLogger } from "@/util/clientLogger";
|
||||||
import {
|
import {
|
||||||
ActionIcon,
|
ActionIcon,
|
||||||
Button,
|
Button,
|
||||||
Collapse,
|
Collapse,
|
||||||
|
Grid,
|
||||||
Group,
|
Group,
|
||||||
Paper,
|
Paper,
|
||||||
Stack,
|
Stack,
|
||||||
@@ -11,41 +19,57 @@ import {
|
|||||||
Title,
|
Title,
|
||||||
Tooltip,
|
Tooltip,
|
||||||
} from "@mantine/core";
|
} from "@mantine/core";
|
||||||
|
import { useDisclosure, useShallowEffect } from "@mantine/hooks";
|
||||||
import { IconEdit, IconPhone } from "@tabler/icons-react";
|
import { IconEdit, IconPhone } from "@tabler/icons-react";
|
||||||
import { useState } from "react";
|
import { useState } from "react";
|
||||||
import { ComponentAdminGlobal_NotifikasiBerhasil } from "../../_admin_global/admin_notifikasi/notifikasi_berhasil";
|
import { ComponentAdminGlobal_NotifikasiBerhasil } from "../../_admin_global/admin_notifikasi/notifikasi_berhasil";
|
||||||
import { ComponentAdminGlobal_NotifikasiGagal } from "../../_admin_global/admin_notifikasi/notifikasi_gagal";
|
import { ComponentAdminGlobal_NotifikasiGagal } from "../../_admin_global/admin_notifikasi/notifikasi_gagal";
|
||||||
import adminAppInformation_getNomorAdmin from "../fun/master/get_nomor_admin";
|
|
||||||
import adminAppInformation_funUpdateNomorAdmin from "../fun/update/fun_update_nomor";
|
import adminAppInformation_funUpdateNomorAdmin from "../fun/update/fun_update_nomor";
|
||||||
import { useDisclosure } from "@mantine/hooks";
|
|
||||||
import { AccentColor, AdminColor, MainColor } from "@/app_modules/_global/color/color_pallet";
|
|
||||||
|
|
||||||
export default function AdminAppInformation_ViewInformasiWhatApps({
|
export default function AdminAppInformation_ViewInformasiWhatApps() {
|
||||||
nomorAdmin,
|
const [dataNomor, setDataNomor] = useState<any | null>(null);
|
||||||
}: {
|
|
||||||
nomorAdmin: any;
|
|
||||||
}) {
|
|
||||||
const [dataNomor, setDataNomor] = useState(nomorAdmin);
|
|
||||||
const [updateNomor, setUpdateNomor] = useState("");
|
const [updateNomor, setUpdateNomor] = useState("");
|
||||||
const [opened, { toggle }] = useDisclosure(false);
|
const [opened, { toggle }] = useDisclosure(false);
|
||||||
|
|
||||||
async function onUpdate() {
|
useShallowEffect(() => {
|
||||||
const newNumber = (dataNomor.nomor = updateNomor);
|
handleLoadData();
|
||||||
setDataNomor({
|
}, []);
|
||||||
...dataNomor,
|
|
||||||
nomor: newNumber,
|
|
||||||
});
|
|
||||||
|
|
||||||
const updt = await adminAppInformation_funUpdateNomorAdmin({
|
const handleLoadData = async () => {
|
||||||
data: dataNomor,
|
try {
|
||||||
});
|
const response = await apiGetAdminContact();
|
||||||
if (updt.status === 200) {
|
|
||||||
const loadDdata = await adminAppInformation_getNomorAdmin();
|
if (response) {
|
||||||
setDataNomor(loadDdata);
|
setDataNomor(response.data);
|
||||||
toggle();
|
} else {
|
||||||
ComponentAdminGlobal_NotifikasiBerhasil(updt.message);
|
setDataNomor("");
|
||||||
} else {
|
}
|
||||||
ComponentAdminGlobal_NotifikasiGagal(updt.message);
|
} catch (error) {
|
||||||
|
clientLogger.error("Error get admin contact", error);
|
||||||
|
setDataNomor("");
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
async function onUpdate() {
|
||||||
|
try {
|
||||||
|
const newNumber = (dataNomor.nomor = updateNomor);
|
||||||
|
setDataNomor({
|
||||||
|
...dataNomor,
|
||||||
|
nomor: newNumber,
|
||||||
|
});
|
||||||
|
|
||||||
|
const updt = await adminAppInformation_funUpdateNomorAdmin({
|
||||||
|
data: dataNomor,
|
||||||
|
});
|
||||||
|
if (updt.status === 200) {
|
||||||
|
handleLoadData();
|
||||||
|
toggle();
|
||||||
|
ComponentAdminGlobal_NotifikasiBerhasil(updt.message);
|
||||||
|
} else {
|
||||||
|
ComponentAdminGlobal_NotifikasiGagal(updt.message);
|
||||||
|
}
|
||||||
|
} catch (error) {
|
||||||
|
clientLogger.error("Error update nomor admin", error);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -59,78 +83,96 @@ export default function AdminAppInformation_ViewInformasiWhatApps({
|
|||||||
p={"xs"}
|
p={"xs"}
|
||||||
style={{ borderRadius: "6px" }}
|
style={{ borderRadius: "6px" }}
|
||||||
>
|
>
|
||||||
<Title c={AdminColor.white} order={4}>Informasi WhatsApp</Title>
|
<Title c={AdminColor.white} order={4}>
|
||||||
|
Informasi WhatsApp
|
||||||
|
</Title>
|
||||||
</Group>
|
</Group>
|
||||||
</Stack>
|
</Stack>
|
||||||
|
|
||||||
<Paper w={"50%"} bg={AdminColor.softBlue} p={"md"}>
|
<Grid>
|
||||||
<Stack>
|
<Grid.Col span={4}>
|
||||||
<Paper c={AdminColor.white} bg={AccentColor.darkblue} p={"xl"}>
|
{!dataNomor ? (
|
||||||
<Group position="apart">
|
<CustomSkeleton height={100} width={300} />
|
||||||
<Title order={2}>{`+${dataNomor.nomor}`}</Title>
|
) : (
|
||||||
<Tooltip label={"Edit"}>
|
<Paper bg={AdminColor.softBlue} p={"md"}>
|
||||||
<ActionIcon
|
<Stack>
|
||||||
style={{ transition: "0.2s" }}
|
<Paper
|
||||||
variant="transparent"
|
c={AdminColor.white}
|
||||||
radius={"xl"}
|
bg={AccentColor.darkblue}
|
||||||
onClick={() => {
|
p={"xl"}
|
||||||
toggle();
|
|
||||||
setUpdateNomor(dataNomor.nomor);
|
|
||||||
}}
|
|
||||||
>
|
>
|
||||||
<IconEdit
|
<Group position="apart">
|
||||||
style={{
|
<Title order={2}>{`+${dataNomor?.nomor}`}</Title>
|
||||||
transition: "0.2s",
|
<Tooltip label={"Edit"}>
|
||||||
}}
|
<ActionIcon
|
||||||
color={AdminColor.white}
|
style={{ transition: "0.2s" }}
|
||||||
/>
|
variant="transparent"
|
||||||
</ActionIcon>
|
radius={"xl"}
|
||||||
</Tooltip>
|
onClick={() => {
|
||||||
</Group>
|
toggle();
|
||||||
</Paper>
|
setUpdateNomor(dataNomor?.nomor);
|
||||||
|
}}
|
||||||
|
>
|
||||||
|
<IconEdit
|
||||||
|
style={{
|
||||||
|
transition: "0.2s",
|
||||||
|
}}
|
||||||
|
color={opened ? "gray" : AdminColor.white}
|
||||||
|
/>
|
||||||
|
</ActionIcon>
|
||||||
|
</Tooltip>
|
||||||
|
</Group>
|
||||||
|
</Paper>
|
||||||
|
|
||||||
<Collapse
|
<Collapse
|
||||||
in={opened}
|
in={opened}
|
||||||
transitionDuration={300}
|
transitionDuration={300}
|
||||||
transitionTimingFunction="linear"
|
transitionTimingFunction="linear"
|
||||||
>
|
|
||||||
<Stack>
|
|
||||||
<TextInput
|
|
||||||
type="number"
|
|
||||||
placeholder="Update nomor admin"
|
|
||||||
icon={<IconPhone />}
|
|
||||||
value={updateNomor}
|
|
||||||
label={<Title order={6}>Nomor Aktif Admin</Title>}
|
|
||||||
onChange={(val) => {
|
|
||||||
setUpdateNomor(val.currentTarget.value);
|
|
||||||
}}
|
|
||||||
/>
|
|
||||||
<Group position="right">
|
|
||||||
<Button
|
|
||||||
style={{ transition: "0.2s" }}
|
|
||||||
radius={"xl"}
|
|
||||||
onClick={() => {
|
|
||||||
toggle();
|
|
||||||
}}
|
|
||||||
>
|
>
|
||||||
Batal
|
<Stack>
|
||||||
</Button>
|
<TextInput
|
||||||
<Button
|
type="number"
|
||||||
style={{ transition: "0.2s" }}
|
placeholder="Update nomor admin"
|
||||||
disabled={updateNomor === "" ? true : false}
|
icon={<IconPhone />}
|
||||||
color="green"
|
value={updateNomor}
|
||||||
radius={"xl"}
|
label={
|
||||||
onClick={() => {
|
<Title c="white" order={6}>
|
||||||
onUpdate();
|
Nomor Aktif Admin
|
||||||
}}
|
</Title>
|
||||||
>
|
}
|
||||||
Update
|
onChange={(val) => {
|
||||||
</Button>
|
setUpdateNomor(val.currentTarget.value);
|
||||||
</Group>
|
}}
|
||||||
</Stack>
|
/>
|
||||||
</Collapse>
|
<Group position="right">
|
||||||
</Stack>
|
<Button
|
||||||
</Paper>
|
style={{ transition: "0.2s" }}
|
||||||
|
radius={"xl"}
|
||||||
|
onClick={() => {
|
||||||
|
toggle();
|
||||||
|
}}
|
||||||
|
>
|
||||||
|
Batal
|
||||||
|
</Button>
|
||||||
|
<Button
|
||||||
|
style={{ transition: "0.2s" }}
|
||||||
|
disabled={updateNomor === "" ? true : false}
|
||||||
|
color="green"
|
||||||
|
radius={"xl"}
|
||||||
|
onClick={() => {
|
||||||
|
onUpdate();
|
||||||
|
}}
|
||||||
|
>
|
||||||
|
Update
|
||||||
|
</Button>
|
||||||
|
</Group>
|
||||||
|
</Stack>
|
||||||
|
</Collapse>
|
||||||
|
</Stack>
|
||||||
|
</Paper>
|
||||||
|
)}
|
||||||
|
</Grid.Col>
|
||||||
|
</Grid>
|
||||||
</Stack>
|
</Stack>
|
||||||
</>
|
</>
|
||||||
);
|
);
|
||||||
|
|||||||
@@ -0,0 +1,45 @@
|
|||||||
|
export { apiGetUserAccess };
|
||||||
|
|
||||||
|
const apiGetUserAccess = async ({
|
||||||
|
page,
|
||||||
|
search,
|
||||||
|
}: {
|
||||||
|
page: string;
|
||||||
|
search?: string;
|
||||||
|
}) => {
|
||||||
|
try {
|
||||||
|
// Fetch token from cookie
|
||||||
|
const { token } = await fetch("/api/get-cookie").then((res) => res.json());
|
||||||
|
if (!token) {
|
||||||
|
console.error("No token found");
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Fetch data
|
||||||
|
const isPage = `?page=${page}`;
|
||||||
|
const isSearch = search ? `&search=${search}` : "";
|
||||||
|
const response = await fetch(`/api/admin/user${isPage}${isSearch}`, {
|
||||||
|
method: "GET",
|
||||||
|
headers: {
|
||||||
|
"Content-Type": "application/json",
|
||||||
|
Accept: "application/json",
|
||||||
|
Authorization: `Bearer ${token}`,
|
||||||
|
},
|
||||||
|
});
|
||||||
|
|
||||||
|
// Check if the response is OK
|
||||||
|
if (!response.ok) {
|
||||||
|
const errorData = await response.json().catch(() => null);
|
||||||
|
console.error(
|
||||||
|
"Error get data user access:",
|
||||||
|
errorData?.message || "Unknown error"
|
||||||
|
);
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
return response.json();
|
||||||
|
} catch (error) {
|
||||||
|
console.error("Error get data user access:", error);
|
||||||
|
throw error;
|
||||||
|
}
|
||||||
|
};
|
||||||
@@ -10,41 +10,50 @@ export default async function adminUserAccess_funEditAccess(
|
|||||||
value: boolean,
|
value: boolean,
|
||||||
nomor?: string
|
nomor?: string
|
||||||
) {
|
) {
|
||||||
const updt = await prisma.user.update({
|
try {
|
||||||
where: {
|
const updt = await prisma.user.update({
|
||||||
id: userId,
|
where: {
|
||||||
},
|
id: userId,
|
||||||
data: {
|
},
|
||||||
active: value,
|
data: {
|
||||||
},
|
active: value,
|
||||||
});
|
},
|
||||||
|
});
|
||||||
|
|
||||||
const headersList = headers();
|
const headersList = headers();
|
||||||
const host = headersList.get("host");
|
const host = headersList.get("host");
|
||||||
const protocol = headersList.get("x-forwarded-proto") || "http";
|
const protocol = headersList.get("x-forwarded-proto") || "http";
|
||||||
const path = headersList.get("x-invoke-path");
|
const path = headersList.get("x-invoke-path");
|
||||||
const baseUrl = `${protocol}://${host}`;
|
const baseUrl = `${protocol}://${host}`;
|
||||||
// const fullUrl = `${protocol}://${host}${path}`;
|
// const fullUrl = `${protocol}://${host}${path}`;
|
||||||
|
|
||||||
if (value === true) {
|
if (value === true) {
|
||||||
const message = `Hallo rekan HIPMI, Anda telah diberikan akses ke HIPMI Apps. Silakan mulai jelajahi fitur-fitur yang tersedia melalui link berikut: ${baseUrl}`;
|
const message = `Hallo rekan HIPMI, Anda telah diberikan akses ke HIPMI Apps. Silakan mulai jelajahi fitur-fitur yang tersedia melalui link berikut: ${baseUrl}`;
|
||||||
const encodedMessage = encodeURIComponent(message);
|
const encodedMessage = encodeURIComponent(message);
|
||||||
|
|
||||||
const res = await fetch(
|
const res = await fetch(
|
||||||
`https://wa.wibudev.com/code?nom=${nomor}&text=${encodedMessage}
|
`https://wa.wibudev.com/code?nom=${nomor}&text=${encodedMessage}
|
||||||
`
|
`
|
||||||
);
|
);
|
||||||
|
|
||||||
if (!res.ok) {
|
if (!res.ok) {
|
||||||
backendLogger.error("Error send message", res);
|
backendLogger.error("Error send message", res);
|
||||||
|
}
|
||||||
|
|
||||||
|
const result = await res.json();
|
||||||
|
|
||||||
|
backendLogger.info("Success send message", result);
|
||||||
}
|
}
|
||||||
|
|
||||||
const result = await res.json();
|
if (!updt) return { status: 400, message: "Update gagal" };
|
||||||
|
revalidatePath("/dev/admin/user-access");
|
||||||
backendLogger.info("Success send message", result);
|
return { status: 200, message: "Update berhasil" };
|
||||||
|
} catch (error) {
|
||||||
|
backendLogger.error("Error update user", error);
|
||||||
|
return {
|
||||||
|
status: 500,
|
||||||
|
message: "Error udpate user",
|
||||||
|
error: (error as Error).message,
|
||||||
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!updt) return { status: 400, message: "Update gagal" };
|
|
||||||
revalidatePath("/dev/admin/user-access");
|
|
||||||
return { status: 200, message: "Update berhasil" };
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -24,28 +24,58 @@ import { WibuRealtime } from "wibu-pkg";
|
|||||||
import { gs_access_user, IRealtimeData } from "@/lib/global_state";
|
import { gs_access_user, IRealtimeData } from "@/lib/global_state";
|
||||||
import { useAtom } from "jotai";
|
import { useAtom } from "jotai";
|
||||||
import { AdminColor } from "@/app_modules/_global/color/color_pallet";
|
import { AdminColor } from "@/app_modules/_global/color/color_pallet";
|
||||||
|
import { useShallowEffect } from "@mantine/hooks";
|
||||||
|
import { apiGetUserAccess } from "../_lib/api_fetch_user_access";
|
||||||
|
import CustomSkeleton from "@/app_modules/components/CustomSkeleton";
|
||||||
|
|
||||||
export default function AdminUserAccess_View({ listUser }: { listUser: any }) {
|
export default function AdminUserAccess_View() {
|
||||||
const [data, setData] = useState<MODEL_USER[]>(listUser.data);
|
const [data, setData] = useState<MODEL_USER[]>([]);
|
||||||
|
const [nPage, setNPage] = useState(1);
|
||||||
const [isActivePage, setActivePage] = useState(1);
|
const [isActivePage, setActivePage] = useState(1);
|
||||||
const [isNPage, setNPage] = useState(listUser.nPage);
|
|
||||||
const [isSearch, setSearch] = useState("");
|
const [isSearch, setSearch] = useState("");
|
||||||
|
|
||||||
const [isLoadingAccess, setIsLoadingAccess] = useState(false);
|
const [isLoadingAccess, setIsLoadingAccess] = useState(false);
|
||||||
const [isLoadingDelete, setIsLoadingDelete] = useState(false);
|
const [isLoadingDelete, setIsLoadingDelete] = useState(false);
|
||||||
const [userId, setUserId] = useState("");
|
const [userId, setUserId] = useState("");
|
||||||
|
|
||||||
|
useShallowEffect(() => {
|
||||||
|
handleLoadData();
|
||||||
|
}, [isActivePage, isSearch]);
|
||||||
|
|
||||||
|
const handleLoadData = async () => {
|
||||||
|
try {
|
||||||
|
const response = await apiGetUserAccess({
|
||||||
|
page: `${isActivePage}`,
|
||||||
|
search: isSearch,
|
||||||
|
});
|
||||||
|
|
||||||
|
if (response.success) {
|
||||||
|
setData(response.data.data);
|
||||||
|
setNPage(response.data.nPage);
|
||||||
|
} else {
|
||||||
|
setData([]);
|
||||||
|
}
|
||||||
|
} catch (error) {
|
||||||
|
console.error("Error get user access", error);
|
||||||
|
setData([]);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
async function onSearch(s: any) {
|
||||||
|
setSearch(s);
|
||||||
|
}
|
||||||
|
|
||||||
|
async function onPageClick(p: any) {
|
||||||
|
setActivePage(p);
|
||||||
|
}
|
||||||
|
|
||||||
async function onAccess(id: string, nomor: string) {
|
async function onAccess(id: string, nomor: string) {
|
||||||
try {
|
try {
|
||||||
setUserId(id);
|
setUserId(id);
|
||||||
setIsLoadingAccess(true);
|
setIsLoadingAccess(true);
|
||||||
await adminUserAccess_funEditAccess(id, true, nomor).then(async (res) => {
|
await adminUserAccess_funEditAccess(id, true, nomor).then(async (res) => {
|
||||||
if (res.status === 200) {
|
if (res.status === 200) {
|
||||||
const value = await adminUserAccess_getListUser({
|
handleLoadData();
|
||||||
page: 1,
|
|
||||||
search: isSearch,
|
|
||||||
});
|
|
||||||
setData(value.data as any);
|
|
||||||
setNPage(value.nPage);
|
|
||||||
|
|
||||||
const dataNotifikasi: IRealtimeData = {
|
const dataNotifikasi: IRealtimeData = {
|
||||||
status: true as any,
|
status: true as any,
|
||||||
@@ -78,12 +108,8 @@ export default function AdminUserAccess_View({ listUser }: { listUser: any }) {
|
|||||||
setIsLoadingDelete(true);
|
setIsLoadingDelete(true);
|
||||||
await adminUserAccess_funEditAccess(id, false).then(async (res) => {
|
await adminUserAccess_funEditAccess(id, false).then(async (res) => {
|
||||||
if (res.status === 200) {
|
if (res.status === 200) {
|
||||||
const value = await adminUserAccess_getListUser({
|
handleLoadData();
|
||||||
page: 1,
|
|
||||||
search: isSearch,
|
|
||||||
});
|
|
||||||
setData(value.data as any);
|
|
||||||
setNPage(value.nPage);
|
|
||||||
ComponentGlobal_NotifikasiBerhasil(res.message);
|
ComponentGlobal_NotifikasiBerhasil(res.message);
|
||||||
} else {
|
} else {
|
||||||
ComponentGlobal_NotifikasiGagal(res.message);
|
ComponentGlobal_NotifikasiGagal(res.message);
|
||||||
@@ -97,27 +123,6 @@ export default function AdminUserAccess_View({ listUser }: { listUser: any }) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
async function onSearch(s: any) {
|
|
||||||
setSearch(s);
|
|
||||||
setActivePage(1);
|
|
||||||
const loadData = await adminUserAccess_getListUser({
|
|
||||||
search: s,
|
|
||||||
page: 1,
|
|
||||||
});
|
|
||||||
setData(loadData.data as any);
|
|
||||||
setNPage(loadData.nPage);
|
|
||||||
}
|
|
||||||
|
|
||||||
async function onPageClick(p: any) {
|
|
||||||
setActivePage(p);
|
|
||||||
const loadData = await adminUserAccess_getListUser({
|
|
||||||
search: isSearch,
|
|
||||||
page: p,
|
|
||||||
});
|
|
||||||
setData(loadData.data as any);
|
|
||||||
setNPage(loadData.nPage);
|
|
||||||
}
|
|
||||||
|
|
||||||
const tableBody = data.map((e, i) => (
|
const tableBody = data.map((e, i) => (
|
||||||
<tr key={e.id}>
|
<tr key={e.id}>
|
||||||
<td>
|
<td>
|
||||||
@@ -181,40 +186,39 @@ export default function AdminUserAccess_View({ listUser }: { listUser: any }) {
|
|||||||
/>
|
/>
|
||||||
</Group>
|
</Group>
|
||||||
|
|
||||||
<Paper p={"md"} bg={AdminColor.softBlue} h={"80vh"}>
|
{!data.length ? (
|
||||||
<ScrollArea w={"100%"} h={"90%"}>
|
<CustomSkeleton height={"80vh"} width="100%" />
|
||||||
<Table
|
) : (
|
||||||
verticalSpacing={"xs"}
|
<Paper p={"md"} bg={AdminColor.softBlue} h={"80vh"}>
|
||||||
horizontalSpacing={"md"}
|
<ScrollArea w={"100%"} h={"90%"}>
|
||||||
p={"md"}
|
<Table verticalSpacing={"xs"} horizontalSpacing={"md"} p={"md"}>
|
||||||
|
<thead>
|
||||||
>
|
<tr>
|
||||||
<thead>
|
<th>
|
||||||
<tr>
|
<Center c={AdminColor.white}>Username</Center>
|
||||||
<th>
|
</th>
|
||||||
<Center c={AdminColor.white}>Username</Center>
|
<th>
|
||||||
</th>
|
<Center c={AdminColor.white}>Nomor</Center>
|
||||||
<th>
|
</th>
|
||||||
<Center c={AdminColor.white}>Nomor</Center>
|
<th>
|
||||||
</th>
|
<Center c={AdminColor.white}>Aksi</Center>
|
||||||
<th>
|
</th>
|
||||||
<Center c={AdminColor.white}>Aksi</Center>
|
</tr>
|
||||||
</th>
|
</thead>
|
||||||
</tr>
|
<tbody>{tableBody}</tbody>
|
||||||
</thead>
|
</Table>
|
||||||
<tbody>{tableBody}</tbody>
|
</ScrollArea>
|
||||||
</Table>
|
<Center mt={"xl"}>
|
||||||
</ScrollArea>
|
<Pagination
|
||||||
<Center mt={"xl"}>
|
value={isActivePage}
|
||||||
<Pagination
|
total={nPage}
|
||||||
value={isActivePage}
|
onChange={(val) => {
|
||||||
total={isNPage}
|
onPageClick(val);
|
||||||
onChange={(val) => {
|
}}
|
||||||
onPageClick(val);
|
/>
|
||||||
}}
|
</Center>
|
||||||
/>
|
</Paper>
|
||||||
</Center>
|
)}
|
||||||
</Paper>
|
|
||||||
</Stack>
|
</Stack>
|
||||||
</>
|
</>
|
||||||
);
|
);
|
||||||
|
|||||||
@@ -14,130 +14,161 @@ import {
|
|||||||
Stack,
|
Stack,
|
||||||
Table,
|
Table,
|
||||||
Text,
|
Text,
|
||||||
TextInput
|
TextInput,
|
||||||
} from "@mantine/core";
|
} from "@mantine/core";
|
||||||
import { useDisclosure } from "@mantine/hooks";
|
import { useDisclosure, useShallowEffect } from "@mantine/hooks";
|
||||||
import { IconReportAnalytics, IconSearch } from "@tabler/icons-react";
|
import { IconReportAnalytics, IconSearch } from "@tabler/icons-react";
|
||||||
import { useRouter } from "next/navigation";
|
import { useRouter } from "next/navigation";
|
||||||
|
|
||||||
import { ComponentAdminGlobal_TitlePage } from "@/app_modules/admin/_admin_global/_component";
|
|
||||||
import { useState } from "react";
|
|
||||||
import ComponentAdminVote_DetailHasil from "../../component/detail_hasil";
|
|
||||||
import { adminVote_funGetListRiwayat } from "../../fun";
|
|
||||||
import { AdminVote_getHasilById } from "../../fun/get/get_hasil_by_id";
|
|
||||||
import { AdminVote_getListKontributorById } from "../../fun/get/get_list_kontributor_by_id";
|
|
||||||
import { AccentColor } from "@/app_modules/_global/color";
|
import { AccentColor } from "@/app_modules/_global/color";
|
||||||
import { AdminColor } from "@/app_modules/_global/color/color_pallet";
|
import { AdminColor } from "@/app_modules/_global/color/color_pallet";
|
||||||
|
import { ComponentAdminGlobal_TitlePage } from "@/app_modules/admin/_admin_global/_component";
|
||||||
|
import ComponentAdminGlobal_IsEmptyData from "@/app_modules/admin/_admin_global/is_empty_data";
|
||||||
|
import CustomSkeleton from "@/app_modules/components/CustomSkeleton";
|
||||||
|
import { clientLogger } from "@/util/clientLogger";
|
||||||
|
import _ from "lodash";
|
||||||
|
import { useState } from "react";
|
||||||
|
import ComponentAdminVote_DetailHasil from "../../component/detail_hasil";
|
||||||
|
import { AdminVote_getHasilById } from "../../fun/get/get_hasil_by_id";
|
||||||
|
import { AdminVote_getListKontributorById } from "../../fun/get/get_list_kontributor_by_id";
|
||||||
|
import { apiGetAdminVotingRiwayat } from "../../lib/api_fetch_admin_voting";
|
||||||
|
|
||||||
export default function AdminVote_Riwayat({
|
export default function AdminVote_Riwayat() {
|
||||||
dataVote,
|
|
||||||
}: {
|
|
||||||
dataVote: MODEL_VOTING[];
|
|
||||||
}) {
|
|
||||||
return (
|
return (
|
||||||
<>
|
<>
|
||||||
<Stack>
|
<Stack>
|
||||||
<ComponentAdminGlobal_HeaderTamplate name="Voting" />
|
<ComponentAdminGlobal_HeaderTamplate name="Voting" />
|
||||||
<TableStatus listPublish={dataVote} />
|
<TableStatus />
|
||||||
</Stack>
|
</Stack>
|
||||||
</>
|
</>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
function TableStatus({ listPublish }: { listPublish: any }) {
|
function TableStatus() {
|
||||||
const router = useRouter();
|
const router = useRouter();
|
||||||
const [opened, { open, close }] = useDisclosure(false);
|
const [opened, { open, close }] = useDisclosure(false);
|
||||||
const [data, setData] = useState<MODEL_VOTING[]>(listPublish.data);
|
|
||||||
const [hasil, setHasil] = useState<any[]>();
|
const [hasil, setHasil] = useState<any[]>();
|
||||||
const [kontributor, setKontributor] = useState<any[]>();
|
const [kontributor, setKontributor] = useState<any[]>();
|
||||||
const [voteId, setVoteId] = useState("");
|
const [voteId, setVoteId] = useState("");
|
||||||
const [loading, setLoading] = useState(false);
|
const [loading, setLoading] = useState(false);
|
||||||
|
|
||||||
const [isNPage, setNPage] = useState(listPublish.nPage);
|
const [data, setData] = useState<MODEL_VOTING[] | null>(null);
|
||||||
|
const [isNPage, setNPage] = useState(1);
|
||||||
const [isActivePage, setActivePage] = useState(1);
|
const [isActivePage, setActivePage] = useState(1);
|
||||||
const [isSearch, setSearch] = useState("");
|
const [isSearch, setSearch] = useState("");
|
||||||
|
|
||||||
|
useShallowEffect(() => {
|
||||||
|
handleLoadData();
|
||||||
|
}, [isActivePage, isSearch]);
|
||||||
|
|
||||||
|
const handleLoadData = async () => {
|
||||||
|
try {
|
||||||
|
const response = await apiGetAdminVotingRiwayat({
|
||||||
|
page: `${isActivePage}`,
|
||||||
|
search: isSearch,
|
||||||
|
});
|
||||||
|
|
||||||
|
if (response?.success && response?.data?.data) {
|
||||||
|
setData(response.data.data);
|
||||||
|
setNPage(response.data.nPage || 1);
|
||||||
|
} else {
|
||||||
|
console.error("Invalid data format received:", response);
|
||||||
|
setData([]);
|
||||||
|
}
|
||||||
|
} catch (error) {
|
||||||
|
clientLogger.error("Error get data table publish", error);
|
||||||
|
setData([]);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
async function onSearch(s: string) {
|
async function onSearch(s: string) {
|
||||||
setSearch(s);
|
setSearch(s);
|
||||||
const loadData = await adminVote_funGetListRiwayat({
|
|
||||||
page: 1,
|
|
||||||
search: s,
|
|
||||||
});
|
|
||||||
setData(loadData.data as any);
|
|
||||||
setNPage(loadData.nPage);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
async function onPageClick(p: any) {
|
async function onPageClick(p: any) {
|
||||||
setActivePage(p);
|
setActivePage(p);
|
||||||
const loadData = await adminVote_funGetListRiwayat({
|
|
||||||
search: isSearch,
|
|
||||||
page: p,
|
|
||||||
});
|
|
||||||
setData(loadData.data as any);
|
|
||||||
setNPage(loadData.nPage);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
const TableRows = data.map((e, i) => (
|
const renderTableBody = () => {
|
||||||
<tr key={i}>
|
if (!Array.isArray(data) || data.length === 0) {
|
||||||
<td>
|
return (
|
||||||
<Center>
|
<tr>
|
||||||
<Button
|
<td colSpan={12}>
|
||||||
loading={
|
<Center>
|
||||||
e?.id === voteId ? (loading === true ? true : false) : false
|
<Text color={"gray"}>Tidak ada data</Text>
|
||||||
}
|
</Center>
|
||||||
radius={"xl"}
|
</td>
|
||||||
color="green"
|
</tr>
|
||||||
leftIcon={<IconReportAnalytics />}
|
);
|
||||||
onClick={async () => {
|
}
|
||||||
setVoteId(e?.id);
|
|
||||||
setLoading(true);
|
return data.map((e, i) => (
|
||||||
await new Promise((r) => setTimeout(r, 500));
|
<tr key={i}>
|
||||||
onList(e?.id, setHasil, setKontributor, setLoading, open);
|
<td>
|
||||||
}}
|
<Center>
|
||||||
>
|
<Button
|
||||||
Lihat Hasil
|
loading={
|
||||||
</Button>
|
e?.id === voteId ? (loading === true ? true : false) : false
|
||||||
</Center>
|
}
|
||||||
</td>
|
radius={"xl"}
|
||||||
<td>
|
color="green"
|
||||||
<Center c={AccentColor.white}>{e?.Author?.username}</Center>
|
leftIcon={<IconReportAnalytics />}
|
||||||
</td>
|
onClick={async () => {
|
||||||
<td>
|
setVoteId(e?.id);
|
||||||
<Center c={AccentColor.white}>{e?.title}</Center>
|
setLoading(true);
|
||||||
</td>
|
await new Promise((r) => setTimeout(r, 500));
|
||||||
<td>
|
onList(e?.id, setHasil, setKontributor, setLoading, open);
|
||||||
<Center>
|
}}
|
||||||
<Spoiler
|
>
|
||||||
hideLabel="sembunyikan"
|
Lihat Hasil
|
||||||
maw={400}
|
</Button>
|
||||||
maxHeight={50}
|
</Center>
|
||||||
showLabel="tampilkan"
|
</td>
|
||||||
>
|
<td>
|
||||||
{e?.deskripsi}
|
<Center c={AccentColor.white}>{e?.Author?.username}</Center>
|
||||||
</Spoiler>
|
</td>
|
||||||
</Center>
|
<td>
|
||||||
</td>
|
<Center c={AccentColor.white}>{e?.title}</Center>
|
||||||
<th>
|
</td>
|
||||||
<Stack>
|
<td>
|
||||||
{e?.Voting_DaftarNamaVote.map((v) => (
|
<Center c="white">
|
||||||
<Box key={v?.id}>
|
<Spoiler
|
||||||
<Text c={AccentColor.white}>- {v?.value}</Text>
|
hideLabel="sembunyikan"
|
||||||
</Box>
|
maw={400}
|
||||||
))}
|
maxHeight={50}
|
||||||
</Stack>
|
showLabel="tampilkan"
|
||||||
</th>
|
>
|
||||||
<td>
|
{e?.deskripsi}
|
||||||
<Center c={AccentColor.white}>
|
</Spoiler>
|
||||||
{e?.awalVote.toLocaleDateString("id-ID", { dateStyle: "long" })}
|
</Center>
|
||||||
</Center>
|
</td>
|
||||||
</td>
|
<td>
|
||||||
<td>
|
<Stack>
|
||||||
<Center c={AccentColor.white}>
|
{e?.Voting_DaftarNamaVote.map((v) => (
|
||||||
{e?.akhirVote.toLocaleDateString("id-ID", { dateStyle: "long" })}
|
<Box key={v?.id}>
|
||||||
</Center>
|
<Text c={AccentColor.white}>- {v?.value}</Text>
|
||||||
</td>
|
</Box>
|
||||||
</tr>
|
))}
|
||||||
));
|
</Stack>
|
||||||
|
</td>
|
||||||
|
|
||||||
|
<td>
|
||||||
|
<Center c={AccentColor.white}>
|
||||||
|
{new Intl.DateTimeFormat("id-ID", {
|
||||||
|
dateStyle: "long",
|
||||||
|
}).format(new Date(e?.awalVote))}
|
||||||
|
</Center>
|
||||||
|
</td>
|
||||||
|
<td>
|
||||||
|
<Center c={AccentColor.white}>
|
||||||
|
{new Intl.DateTimeFormat("id-ID", {
|
||||||
|
dateStyle: "long",
|
||||||
|
}).format(new Date(e?.akhirVote))}
|
||||||
|
</Center>
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
|
));
|
||||||
|
};
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<>
|
<>
|
||||||
@@ -148,80 +179,69 @@ function TableStatus({ listPublish }: { listPublish: any }) {
|
|||||||
color={AdminColor.softBlue}
|
color={AdminColor.softBlue}
|
||||||
component={
|
component={
|
||||||
<TextInput
|
<TextInput
|
||||||
icon={<IconSearch size={20} />}
|
icon={<IconSearch size={20} />}
|
||||||
radius={"xl"}
|
radius={"xl"}
|
||||||
placeholder="Masukan judul"
|
placeholder="Masukan judul"
|
||||||
onChange={(val) => {
|
|
||||||
onSearch(val.currentTarget.value);
|
|
||||||
}}
|
|
||||||
/>
|
|
||||||
}
|
|
||||||
/>
|
|
||||||
{/* <Group
|
|
||||||
position="apart"
|
|
||||||
bg={"gray.4"}
|
|
||||||
p={"xs"}
|
|
||||||
style={{ borderRadius: "6px" }}
|
|
||||||
>
|
|
||||||
<Title order={4}>Riwayat</Title>
|
|
||||||
<TextInput
|
|
||||||
icon={<IconSearch size={20} />}
|
|
||||||
radius={"xl"}
|
|
||||||
placeholder="Masukan judul"
|
|
||||||
onChange={(val) => {
|
|
||||||
onSearch(val.currentTarget.value);
|
|
||||||
}}
|
|
||||||
/>
|
|
||||||
</Group> */}
|
|
||||||
|
|
||||||
<Paper p={"md"} bg={AdminColor.softBlue} shadow="lg" h={"80vh"}>
|
|
||||||
<ScrollArea w={"100%"} h={"90%"}>
|
|
||||||
<Table
|
|
||||||
verticalSpacing={"md"}
|
|
||||||
horizontalSpacing={"md"}
|
|
||||||
p={"md"}
|
|
||||||
w={1500}
|
|
||||||
|
|
||||||
>
|
|
||||||
<thead>
|
|
||||||
<tr>
|
|
||||||
<th>
|
|
||||||
<Center c={AccentColor.white}>Aksi</Center>
|
|
||||||
</th>
|
|
||||||
<th>
|
|
||||||
<Center c={AccentColor.white}>Username</Center>
|
|
||||||
</th>
|
|
||||||
<th>
|
|
||||||
<Center c={AccentColor.white}>Judul</Center>
|
|
||||||
</th>
|
|
||||||
<th>
|
|
||||||
<Center c={AccentColor.white}>Deskripsi</Center>
|
|
||||||
</th>
|
|
||||||
<th>
|
|
||||||
<Center c={AccentColor.white}>Pilihan</Center>
|
|
||||||
</th>
|
|
||||||
<th>
|
|
||||||
<Center c={AccentColor.white}>Mulai Vote</Center>
|
|
||||||
</th>
|
|
||||||
<th>
|
|
||||||
<Center c={AccentColor.white}>Selesai Vote</Center>
|
|
||||||
</th>
|
|
||||||
</tr>
|
|
||||||
</thead>
|
|
||||||
<tbody>{TableRows}</tbody>
|
|
||||||
</Table>
|
|
||||||
</ScrollArea>
|
|
||||||
|
|
||||||
<Center mt={"xl"}>
|
|
||||||
<Pagination
|
|
||||||
value={isActivePage}
|
|
||||||
total={isNPage}
|
|
||||||
onChange={(val) => {
|
onChange={(val) => {
|
||||||
onPageClick(val);
|
onSearch(val.currentTarget.value);
|
||||||
}}
|
}}
|
||||||
/>
|
/>
|
||||||
</Center>
|
}
|
||||||
</Paper>
|
/>
|
||||||
|
|
||||||
|
{!data ? (
|
||||||
|
<CustomSkeleton height={"80vh"} width="100%" />
|
||||||
|
) : _.isEmpty(data) ? (
|
||||||
|
<ComponentAdminGlobal_IsEmptyData />
|
||||||
|
) : (
|
||||||
|
<Paper p={"md"} bg={AdminColor.softBlue} shadow="lg" h={"80vh"}>
|
||||||
|
<ScrollArea w={"100%"} h={"90%"}>
|
||||||
|
<Table
|
||||||
|
verticalSpacing={"md"}
|
||||||
|
horizontalSpacing={"md"}
|
||||||
|
p={"md"}
|
||||||
|
w={1500}
|
||||||
|
>
|
||||||
|
<thead>
|
||||||
|
<tr>
|
||||||
|
<th>
|
||||||
|
<Center c={AccentColor.white}>Aksi</Center>
|
||||||
|
</th>
|
||||||
|
<th>
|
||||||
|
<Center c={AccentColor.white}>Username</Center>
|
||||||
|
</th>
|
||||||
|
<th>
|
||||||
|
<Center c={AccentColor.white}>Judul</Center>
|
||||||
|
</th>
|
||||||
|
<th>
|
||||||
|
<Center c={AccentColor.white}>Deskripsi</Center>
|
||||||
|
</th>
|
||||||
|
<th>
|
||||||
|
<Center c={AccentColor.white}>Pilihan</Center>
|
||||||
|
</th>
|
||||||
|
<th>
|
||||||
|
<Center c={AccentColor.white}>Mulai Vote</Center>
|
||||||
|
</th>
|
||||||
|
<th>
|
||||||
|
<Center c={AccentColor.white}>Selesai Vote</Center>
|
||||||
|
</th>
|
||||||
|
</tr>
|
||||||
|
</thead>
|
||||||
|
<tbody>{renderTableBody()}</tbody>
|
||||||
|
</Table>
|
||||||
|
</ScrollArea>
|
||||||
|
|
||||||
|
<Center mt={"xl"}>
|
||||||
|
<Pagination
|
||||||
|
value={isActivePage}
|
||||||
|
total={isNPage}
|
||||||
|
onChange={(val) => {
|
||||||
|
onPageClick(val);
|
||||||
|
}}
|
||||||
|
/>
|
||||||
|
</Center>
|
||||||
|
</Paper>
|
||||||
|
)}
|
||||||
</Stack>
|
</Stack>
|
||||||
|
|
||||||
<Modal
|
<Modal
|
||||||
|
|||||||
@@ -1,12 +1,19 @@
|
|||||||
"use client";
|
"use client";
|
||||||
|
|
||||||
|
import {
|
||||||
|
AccentColor,
|
||||||
|
AdminColor,
|
||||||
|
} from "@/app_modules/_global/color/color_pallet";
|
||||||
|
import { ComponentAdminGlobal_TitlePage } from "@/app_modules/admin/_admin_global/_component";
|
||||||
import ComponentAdminGlobal_HeaderTamplate from "@/app_modules/admin/_admin_global/header_tamplate";
|
import ComponentAdminGlobal_HeaderTamplate from "@/app_modules/admin/_admin_global/header_tamplate";
|
||||||
|
import ComponentAdminGlobal_IsEmptyData from "@/app_modules/admin/_admin_global/is_empty_data";
|
||||||
|
import CustomSkeleton from "@/app_modules/components/CustomSkeleton";
|
||||||
import { MODEL_VOTING } from "@/app_modules/vote/model/interface";
|
import { MODEL_VOTING } from "@/app_modules/vote/model/interface";
|
||||||
|
import { clientLogger } from "@/util/clientLogger";
|
||||||
import {
|
import {
|
||||||
Box,
|
Box,
|
||||||
Button,
|
Button,
|
||||||
Center,
|
Center,
|
||||||
Group,
|
|
||||||
Modal,
|
Modal,
|
||||||
Pagination,
|
Pagination,
|
||||||
Paper,
|
Paper,
|
||||||
@@ -15,213 +22,231 @@ import {
|
|||||||
Stack,
|
Stack,
|
||||||
Table,
|
Table,
|
||||||
Text,
|
Text,
|
||||||
TextInput,
|
TextInput
|
||||||
Title,
|
|
||||||
} from "@mantine/core";
|
} from "@mantine/core";
|
||||||
import { useDisclosure } from "@mantine/hooks";
|
import { useDisclosure, useShallowEffect } from "@mantine/hooks";
|
||||||
import { IconCircleCheckFilled, IconEyeCheck, IconSearch } from "@tabler/icons-react";
|
import {
|
||||||
|
IconCircleCheckFilled,
|
||||||
|
IconSearch
|
||||||
|
} from "@tabler/icons-react";
|
||||||
|
import _ from "lodash";
|
||||||
import { useRouter } from "next/navigation";
|
import { useRouter } from "next/navigation";
|
||||||
import { useState } from "react";
|
import { useState } from "react";
|
||||||
import ComponentAdminVote_DetailHasil from "../../component/detail_hasil";
|
import ComponentAdminVote_DetailHasil from "../../component/detail_hasil";
|
||||||
import { AdminVote_getHasilById } from "../../fun/get/get_hasil_by_id";
|
import { AdminVote_getHasilById } from "../../fun/get/get_hasil_by_id";
|
||||||
import { AdminVote_getListKontributorById } from "../../fun/get/get_list_kontributor_by_id";
|
import { AdminVote_getListKontributorById } from "../../fun/get/get_list_kontributor_by_id";
|
||||||
import { adminVote_funGetListPublish } from "../../fun/get/status/get_list_publish";
|
import { apiGetAdminVotingByStatus } from "../../lib/api_fetch_admin_voting";
|
||||||
import { ComponentAdminGlobal_TitlePage } from "@/app_modules/admin/_admin_global/_component";
|
|
||||||
import { MainColor } from "@/app_modules/_global/color";
|
|
||||||
import { AccentColor, AdminColor } from "@/app_modules/_global/color/color_pallet";
|
|
||||||
|
|
||||||
export default function AdminVote_TablePublish({
|
export default function AdminVote_TablePublish() {
|
||||||
dataVote,
|
|
||||||
}: {
|
|
||||||
dataVote: any;
|
|
||||||
}) {
|
|
||||||
return (
|
return (
|
||||||
<>
|
<>
|
||||||
<Stack>
|
<Stack>
|
||||||
<ComponentAdminGlobal_HeaderTamplate name="Voting" />
|
<ComponentAdminGlobal_HeaderTamplate name="Voting" />
|
||||||
<TableStatus listPublish={dataVote} />
|
<TableStatus />
|
||||||
</Stack>
|
</Stack>
|
||||||
</>
|
</>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
function TableStatus({ listPublish }: { listPublish: any }) {
|
function TableStatus() {
|
||||||
const router = useRouter();
|
const router = useRouter();
|
||||||
const [opened, { open, close }] = useDisclosure(false);
|
const [opened, { open, close }] = useDisclosure(false);
|
||||||
const [data, setData] = useState<MODEL_VOTING[]>(listPublish.data);
|
|
||||||
const [hasil, setHasil] = useState<any[]>();
|
const [hasil, setHasil] = useState<any[]>();
|
||||||
const [kontributor, setKontributor] = useState<any[]>();
|
const [kontributor, setKontributor] = useState<any[]>();
|
||||||
const [voteId, setVoteId] = useState("");
|
const [voteId, setVoteId] = useState("");
|
||||||
const [loading, setLoading] = useState(false);
|
const [loading, setLoading] = useState(false);
|
||||||
|
|
||||||
const [isNPage, setNPage] = useState(listPublish.nPage);
|
const [data, setData] = useState<MODEL_VOTING[] | null>(null);
|
||||||
|
const [isNPage, setNPage] = useState(1);
|
||||||
const [isActivePage, setActivePage] = useState(1);
|
const [isActivePage, setActivePage] = useState(1);
|
||||||
const [isSearch, setSearch] = useState("");
|
const [isSearch, setSearch] = useState("");
|
||||||
|
|
||||||
|
useShallowEffect(() => {
|
||||||
|
handleLoadData();
|
||||||
|
}, [isActivePage, isSearch]);
|
||||||
|
|
||||||
|
const handleLoadData = async () => {
|
||||||
|
try {
|
||||||
|
const response = await apiGetAdminVotingByStatus({
|
||||||
|
name: "Publish",
|
||||||
|
page: `${isActivePage}`,
|
||||||
|
search: isSearch,
|
||||||
|
});
|
||||||
|
|
||||||
|
if (response?.success && response?.data?.data) {
|
||||||
|
setData(response.data.data);
|
||||||
|
setNPage(response.data.nPage || 1);
|
||||||
|
} else {
|
||||||
|
console.error("Invalid data format received:", response);
|
||||||
|
setData([]);
|
||||||
|
}
|
||||||
|
} catch (error) {
|
||||||
|
clientLogger.error("Error get data table publish", error);
|
||||||
|
setData([]);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
async function onSearch(s: string) {
|
async function onSearch(s: string) {
|
||||||
setSearch(s);
|
setSearch(s);
|
||||||
const loadData = await adminVote_funGetListPublish({
|
|
||||||
page: 1,
|
|
||||||
search: s,
|
|
||||||
});
|
|
||||||
setData(loadData.data as any);
|
|
||||||
setNPage(loadData.nPage);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
async function onPageClick(p: any) {
|
async function onPageClick(p: any) {
|
||||||
setActivePage(p);
|
setActivePage(p);
|
||||||
const loadData = await adminVote_funGetListPublish({
|
|
||||||
search: isSearch,
|
|
||||||
page: p,
|
|
||||||
});
|
|
||||||
setData(loadData.data as any);
|
|
||||||
setNPage(loadData.nPage);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
const TableRows = data.map((e, i) => (
|
const renderTableBody = () => {
|
||||||
<tr key={i}>
|
if (!Array.isArray(data) || data.length === 0) {
|
||||||
<td>
|
return (
|
||||||
<Center>
|
<tr>
|
||||||
<Button
|
<td colSpan={12}>
|
||||||
loading={
|
<Center>
|
||||||
e?.id === voteId ? (loading === true ? true : false) : false
|
<Text color={"gray"}>Tidak ada data</Text>
|
||||||
}
|
</Center>
|
||||||
radius={"xl"}
|
</td>
|
||||||
color="green"
|
</tr>
|
||||||
leftIcon={<IconCircleCheckFilled />}
|
);
|
||||||
onClick={async () => {
|
}
|
||||||
setVoteId(e?.id);
|
|
||||||
setLoading(true);
|
return data?.map((e, i) => (
|
||||||
await new Promise((r) => setTimeout(r, 500));
|
<tr key={i}>
|
||||||
onList(e?.id, setHasil, setKontributor, setLoading, open);
|
<td>
|
||||||
}}
|
<Center>
|
||||||
>
|
<Button
|
||||||
Lihat Hasil
|
loading={
|
||||||
</Button>
|
e?.id === voteId ? (loading === true ? true : false) : false
|
||||||
</Center>
|
}
|
||||||
</td>
|
radius={"xl"}
|
||||||
<td>
|
color="green"
|
||||||
<Center c={AccentColor.white}>{e?.Author?.username}</Center>
|
leftIcon={<IconCircleCheckFilled />}
|
||||||
</td>
|
onClick={async () => {
|
||||||
<td>
|
setVoteId(e?.id);
|
||||||
<Center c={AccentColor.white}>{e?.title}</Center>
|
setLoading(true);
|
||||||
</td>
|
await new Promise((r) => setTimeout(r, 500));
|
||||||
<td>
|
onList(e?.id, setHasil, setKontributor, setLoading, open);
|
||||||
<Center>
|
}}
|
||||||
<Spoiler
|
>
|
||||||
hideLabel="sembunyikan"
|
Lihat Hasil
|
||||||
maw={400}
|
</Button>
|
||||||
maxHeight={50}
|
</Center>
|
||||||
showLabel="tampilkan"
|
</td>
|
||||||
>
|
<td>
|
||||||
{e?.deskripsi}
|
<Center c={AccentColor.white}>{e?.Author?.username}</Center>
|
||||||
</Spoiler>
|
</td>
|
||||||
</Center>
|
<td>
|
||||||
</td>
|
<Center c={AccentColor.white}>{e?.title}</Center>
|
||||||
<th>
|
</td>
|
||||||
<Stack>
|
<td>
|
||||||
{e?.Voting_DaftarNamaVote.map((v) => (
|
<Center c={"white"}>
|
||||||
<Box key={v?.id}>
|
<Spoiler
|
||||||
<Text c={AccentColor.white}>- {v?.value}</Text>
|
hideLabel="sembunyikan"
|
||||||
</Box>
|
maw={400}
|
||||||
))}
|
maxHeight={50}
|
||||||
</Stack>
|
showLabel="tampilkan"
|
||||||
</th>
|
>
|
||||||
<td>
|
{e?.deskripsi}
|
||||||
<Center c={AccentColor.white}>
|
</Spoiler>
|
||||||
{e?.awalVote.toLocaleDateString("id-ID", { dateStyle: "long" })}
|
</Center>
|
||||||
</Center>
|
</td>
|
||||||
</td>
|
<td>
|
||||||
<td>
|
<Stack>
|
||||||
<Center c={AccentColor.white}>
|
{e?.Voting_DaftarNamaVote.map((v) => (
|
||||||
{e?.akhirVote.toLocaleDateString("id-ID", { dateStyle: "long" })}
|
<Box key={v?.id}>
|
||||||
</Center>
|
<Text c={AccentColor.white}>- {v?.value}</Text>
|
||||||
</td>
|
</Box>
|
||||||
</tr>
|
))}
|
||||||
));
|
</Stack>
|
||||||
|
</td>
|
||||||
|
|
||||||
|
<td>
|
||||||
|
<Center c={AccentColor.white}>
|
||||||
|
{new Intl.DateTimeFormat("id-ID", {
|
||||||
|
dateStyle: "long",
|
||||||
|
}).format(new Date(e?.awalVote))}
|
||||||
|
</Center>
|
||||||
|
</td>
|
||||||
|
<td>
|
||||||
|
<Center c={AccentColor.white}>
|
||||||
|
{new Intl.DateTimeFormat("id-ID", {
|
||||||
|
dateStyle: "long",
|
||||||
|
}).format(new Date(e?.akhirVote))}
|
||||||
|
</Center>
|
||||||
|
</td>
|
||||||
|
|
||||||
|
</tr>
|
||||||
|
));
|
||||||
|
};
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<>
|
<>
|
||||||
<Stack spacing={"xs"} h={"100%"}>
|
<Stack spacing={"xs"} h={"100%"}>
|
||||||
{/* <pre>{JSON.stringify(listUser, null, 2)}</pre> */}
|
|
||||||
<ComponentAdminGlobal_TitlePage
|
<ComponentAdminGlobal_TitlePage
|
||||||
name="Publish"
|
name="Publish"
|
||||||
color={AdminColor.softBlue}
|
color={AdminColor.softBlue}
|
||||||
component={
|
component={
|
||||||
<TextInput
|
<TextInput
|
||||||
icon={<IconSearch size={20} />}
|
icon={<IconSearch size={20} />}
|
||||||
radius={"xl"}
|
radius={"xl"}
|
||||||
placeholder="Masukan judul"
|
placeholder="Masukan judul"
|
||||||
onChange={(val) => {
|
|
||||||
onSearch(val.currentTarget.value);
|
|
||||||
}}
|
|
||||||
/>
|
|
||||||
}
|
|
||||||
/>
|
|
||||||
{/* <Group
|
|
||||||
position="apart"
|
|
||||||
bg={"green.4"}
|
|
||||||
p={"xs"}
|
|
||||||
style={{ borderRadius: "6px" }}
|
|
||||||
>
|
|
||||||
<Title order={4}>Publish</Title>
|
|
||||||
<TextInput
|
|
||||||
icon={<IconSearch size={20} />}
|
|
||||||
radius={"xl"}
|
|
||||||
placeholder="Masukan judul"
|
|
||||||
onChange={(val) => {
|
|
||||||
onSearch(val.currentTarget.value);
|
|
||||||
}}
|
|
||||||
/>
|
|
||||||
</Group> */}
|
|
||||||
|
|
||||||
<Paper p={"md"} bg={AdminColor.softBlue} shadow="lg" h={"80vh"}>
|
|
||||||
<ScrollArea w={"100%"} h={"90%"}>
|
|
||||||
<Table
|
|
||||||
verticalSpacing={"md"}
|
|
||||||
horizontalSpacing={"md"}
|
|
||||||
p={"md"}
|
|
||||||
w={1500}
|
|
||||||
>
|
|
||||||
<thead>
|
|
||||||
<tr>
|
|
||||||
<th>
|
|
||||||
<Center c={AccentColor.white}>Aksi</Center>
|
|
||||||
</th>
|
|
||||||
<th>
|
|
||||||
<Center c={AccentColor.white}>Username</Center>
|
|
||||||
</th>
|
|
||||||
<th>
|
|
||||||
<Center c={AccentColor.white}>Judul</Center>
|
|
||||||
</th>
|
|
||||||
<th>
|
|
||||||
<Center c={AccentColor.white}>Deskripsi</Center>
|
|
||||||
</th>
|
|
||||||
<th>
|
|
||||||
<Center c={AccentColor.white}>Pilihan</Center>
|
|
||||||
</th>
|
|
||||||
<th>
|
|
||||||
<Center c={AccentColor.white}>Mulai Vote</Center>
|
|
||||||
</th>
|
|
||||||
<th>
|
|
||||||
<Center c={AccentColor.white}>Selesai Vote</Center>
|
|
||||||
</th>
|
|
||||||
</tr>
|
|
||||||
</thead>
|
|
||||||
<tbody>{TableRows}</tbody>
|
|
||||||
</Table>
|
|
||||||
</ScrollArea>
|
|
||||||
|
|
||||||
<Center mt={"xl"}>
|
|
||||||
<Pagination
|
|
||||||
value={isActivePage}
|
|
||||||
total={isNPage}
|
|
||||||
onChange={(val) => {
|
onChange={(val) => {
|
||||||
onPageClick(val);
|
onSearch(val.currentTarget.value);
|
||||||
}}
|
}}
|
||||||
/>
|
/>
|
||||||
</Center>
|
}
|
||||||
</Paper>
|
/>
|
||||||
|
|
||||||
|
{!data ? (
|
||||||
|
<CustomSkeleton height={"80vh"} width="100%" />
|
||||||
|
) : _.isEmpty(data) ? (
|
||||||
|
<ComponentAdminGlobal_IsEmptyData />
|
||||||
|
) : (
|
||||||
|
<Paper p={"md"} bg={AdminColor.softBlue} shadow="lg" h={"80vh"}>
|
||||||
|
<ScrollArea w={"100%"} h={"90%"}>
|
||||||
|
<Table
|
||||||
|
verticalSpacing={"md"}
|
||||||
|
horizontalSpacing={"md"}
|
||||||
|
p={"md"}
|
||||||
|
w={1500}
|
||||||
|
>
|
||||||
|
<thead>
|
||||||
|
<tr>
|
||||||
|
<th>
|
||||||
|
<Center c={AccentColor.white}>Aksi</Center>
|
||||||
|
</th>
|
||||||
|
<th>
|
||||||
|
<Center c={AccentColor.white}>Username</Center>
|
||||||
|
</th>
|
||||||
|
<th>
|
||||||
|
<Center c={AccentColor.white}>Judul</Center>
|
||||||
|
</th>
|
||||||
|
<th>
|
||||||
|
<Center c={AccentColor.white}>Deskripsi</Center>
|
||||||
|
</th>
|
||||||
|
<th>
|
||||||
|
<Center c={AccentColor.white}>Pilihan</Center>
|
||||||
|
</th>
|
||||||
|
<th>
|
||||||
|
<Center c={AccentColor.white}>Mulai Vote</Center>
|
||||||
|
</th>
|
||||||
|
<th>
|
||||||
|
<Center c={AccentColor.white}>Selesai Vote</Center>
|
||||||
|
</th>
|
||||||
|
</tr>
|
||||||
|
</thead>
|
||||||
|
<tbody>{renderTableBody()}</tbody>
|
||||||
|
</Table>
|
||||||
|
</ScrollArea>
|
||||||
|
|
||||||
|
<Center mt={"xl"}>
|
||||||
|
<Pagination
|
||||||
|
value={isActivePage}
|
||||||
|
total={isNPage}
|
||||||
|
onChange={(val) => {
|
||||||
|
onPageClick(val);
|
||||||
|
}}
|
||||||
|
/>
|
||||||
|
</Center>
|
||||||
|
</Paper>
|
||||||
|
)}
|
||||||
</Stack>
|
</Stack>
|
||||||
|
|
||||||
<Modal
|
<Modal
|
||||||
|
|||||||
@@ -1,9 +1,17 @@
|
|||||||
"use client";
|
"use client";
|
||||||
|
|
||||||
|
import {
|
||||||
|
AccentColor,
|
||||||
|
AdminColor,
|
||||||
|
} from "@/app_modules/_global/color/color_pallet";
|
||||||
|
import { ComponentAdminGlobal_TitlePage } from "@/app_modules/admin/_admin_global/_component";
|
||||||
import { ComponentAdminGlobal_NotifikasiBerhasil } from "@/app_modules/admin/_admin_global/admin_notifikasi/notifikasi_berhasil";
|
import { ComponentAdminGlobal_NotifikasiBerhasil } from "@/app_modules/admin/_admin_global/admin_notifikasi/notifikasi_berhasil";
|
||||||
import { ComponentAdminGlobal_NotifikasiGagal } from "@/app_modules/admin/_admin_global/admin_notifikasi/notifikasi_gagal";
|
import { ComponentAdminGlobal_NotifikasiGagal } from "@/app_modules/admin/_admin_global/admin_notifikasi/notifikasi_gagal";
|
||||||
import ComponentAdminGlobal_HeaderTamplate from "@/app_modules/admin/_admin_global/header_tamplate";
|
import ComponentAdminGlobal_HeaderTamplate from "@/app_modules/admin/_admin_global/header_tamplate";
|
||||||
|
import ComponentAdminGlobal_IsEmptyData from "@/app_modules/admin/_admin_global/is_empty_data";
|
||||||
|
import CustomSkeleton from "@/app_modules/components/CustomSkeleton";
|
||||||
import { MODEL_VOTING } from "@/app_modules/vote/model/interface";
|
import { MODEL_VOTING } from "@/app_modules/vote/model/interface";
|
||||||
|
import { clientLogger } from "@/util/clientLogger";
|
||||||
import {
|
import {
|
||||||
Box,
|
Box,
|
||||||
Button,
|
Button,
|
||||||
@@ -19,241 +27,257 @@ import {
|
|||||||
Text,
|
Text,
|
||||||
Textarea,
|
Textarea,
|
||||||
TextInput,
|
TextInput,
|
||||||
Title,
|
|
||||||
} from "@mantine/core";
|
} from "@mantine/core";
|
||||||
import { useDisclosure } from "@mantine/hooks";
|
import { useDisclosure, useShallowEffect } from "@mantine/hooks";
|
||||||
import { IconBan, IconSearch } from "@tabler/icons-react";
|
import { IconBan, IconSearch } from "@tabler/icons-react";
|
||||||
|
import _ from "lodash";
|
||||||
import { useRouter } from "next/navigation";
|
import { useRouter } from "next/navigation";
|
||||||
import { useState } from "react";
|
import { useState } from "react";
|
||||||
import { adminVote_funGetListReject } from "../../fun";
|
|
||||||
import { AdminVote_funEditCatatanRejectById } from "../../fun/edit/fun_edit_catatan_reject_by_id";
|
import { AdminVote_funEditCatatanRejectById } from "../../fun/edit/fun_edit_catatan_reject_by_id";
|
||||||
import { ComponentAdminGlobal_TitlePage } from "@/app_modules/admin/_admin_global/_component";
|
import { apiGetAdminVotingByStatus } from "../../lib/api_fetch_admin_voting";
|
||||||
import { MainColor } from "@/app_modules/_global/color";
|
|
||||||
import { AccentColor, AdminColor } from "@/app_modules/_global/color/color_pallet";
|
|
||||||
|
|
||||||
export default function AdminVote_TableReject({ dataVote }: { dataVote: any }) {
|
export default function AdminVote_TableReject() {
|
||||||
return (
|
return (
|
||||||
<>
|
<>
|
||||||
<Stack>
|
<Stack>
|
||||||
<ComponentAdminGlobal_HeaderTamplate name="Voting" />
|
<ComponentAdminGlobal_HeaderTamplate name="Voting" />
|
||||||
<TableStatus listData={dataVote} />
|
<TableStatus />
|
||||||
</Stack>
|
</Stack>
|
||||||
</>
|
</>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
function TableStatus({ listData }: { listData: any }) {
|
function TableStatus() {
|
||||||
const router = useRouter();
|
const router = useRouter();
|
||||||
const [opened, { open, close }] = useDisclosure(false);
|
const [opened, { open, close }] = useDisclosure(false);
|
||||||
const [data, setData] = useState<MODEL_VOTING[]>(listData.data);
|
|
||||||
const [votingId, setVotingId] = useState("");
|
const [votingId, setVotingId] = useState("");
|
||||||
const [catatan, setCatatan] = useState("");
|
const [catatan, setCatatan] = useState("");
|
||||||
|
const [isLoading, setLoading] = useState(false);
|
||||||
|
|
||||||
const [isNPage, setNPage] = useState(listData.nPage);
|
const [data, setData] = useState<MODEL_VOTING[] | null>(null);
|
||||||
|
const [nPage, setNPage] = useState(1);
|
||||||
const [isActivePage, setActivePage] = useState(1);
|
const [isActivePage, setActivePage] = useState(1);
|
||||||
const [isSearch, setSearch] = useState("");
|
const [isSearch, setSearch] = useState("");
|
||||||
|
|
||||||
|
useShallowEffect(() => {
|
||||||
|
handleLoadData();
|
||||||
|
}, [isActivePage, isSearch]);
|
||||||
|
|
||||||
|
const handleLoadData = async () => {
|
||||||
|
try {
|
||||||
|
const response = await apiGetAdminVotingByStatus({
|
||||||
|
name: "Reject",
|
||||||
|
page: `${isActivePage}`,
|
||||||
|
search: isSearch,
|
||||||
|
});
|
||||||
|
|
||||||
|
if (response?.success && response?.data?.data) {
|
||||||
|
setData(response.data.data);
|
||||||
|
setNPage(response.data.nPage || 1);
|
||||||
|
} else {
|
||||||
|
console.error("Invalid data format received:", response);
|
||||||
|
setData([]);
|
||||||
|
}
|
||||||
|
} catch (error) {
|
||||||
|
clientLogger.error("Error get data table publish", error);
|
||||||
|
setData([]);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
async function onSearch(s: string) {
|
async function onSearch(s: string) {
|
||||||
setSearch(s);
|
setSearch(s);
|
||||||
const loadData = await adminVote_funGetListReject({
|
|
||||||
page: 1,
|
|
||||||
search: s,
|
|
||||||
});
|
|
||||||
setData(loadData.data as any);
|
|
||||||
setNPage(loadData.nPage);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
async function onPageClick(p: any) {
|
async function onPageClick(p: any) {
|
||||||
setActivePage(p);
|
setActivePage(p);
|
||||||
const loadData = await adminVote_funGetListReject({
|
|
||||||
search: isSearch,
|
|
||||||
page: p,
|
|
||||||
});
|
|
||||||
setData(loadData.data as any);
|
|
||||||
setNPage(loadData.nPage);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
async function onReject(
|
async function onReject() {
|
||||||
votingId: string,
|
try {
|
||||||
catatan: string,
|
setLoading(true);
|
||||||
close: any,
|
const res = await AdminVote_funEditCatatanRejectById(votingId, catatan);
|
||||||
setData: any
|
if (res.status === 200) {
|
||||||
) {
|
handleLoadData();
|
||||||
const res = await AdminVote_funEditCatatanRejectById(votingId, catatan);
|
ComponentAdminGlobal_NotifikasiBerhasil(res.message);
|
||||||
if (res.status === 200) {
|
} else {
|
||||||
const loadData = await adminVote_funGetListReject({
|
ComponentAdminGlobal_NotifikasiGagal(res.message);
|
||||||
page: 1,
|
}
|
||||||
search: isSearch,
|
} catch (error) {
|
||||||
});
|
console.log("Error get data voting review", error);
|
||||||
setData(loadData.data as any);
|
setVotingId("");
|
||||||
setNPage(loadData.nPage);
|
} finally {
|
||||||
setActivePage(1);
|
|
||||||
ComponentAdminGlobal_NotifikasiBerhasil(res.message);
|
|
||||||
close();
|
close();
|
||||||
} else {
|
setLoading(false);
|
||||||
ComponentAdminGlobal_NotifikasiGagal(res.message);
|
setVotingId("");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
const TableRows = data.map((e, i) => (
|
const renderTableBody = () => {
|
||||||
<tr key={i}>
|
if (!Array.isArray(data) || data.length === 0) {
|
||||||
<td>
|
return (
|
||||||
<Center>
|
<tr>
|
||||||
<Button
|
<td colSpan={12}>
|
||||||
color={"red"}
|
<Center>
|
||||||
leftIcon={<IconBan />}
|
<Text color={"gray"}>Tidak ada data</Text>
|
||||||
radius={"xl"}
|
</Center>
|
||||||
onClick={() => {
|
</td>
|
||||||
open();
|
</tr>
|
||||||
setVotingId(e.id);
|
);
|
||||||
setCatatan(e.catatan);
|
}
|
||||||
}}
|
|
||||||
>
|
return data?.map((e, i) => (
|
||||||
<Stack c={AccentColor.white} spacing={0}>
|
<tr key={i}>
|
||||||
<Text fz={10}>Tambah</Text>
|
<td>
|
||||||
<Text fz={10}>Catatan</Text>
|
<Center>
|
||||||
</Stack>
|
<Button
|
||||||
</Button>
|
color={"red"}
|
||||||
</Center>
|
leftIcon={<IconBan />}
|
||||||
</td>
|
radius={"xl"}
|
||||||
<td>
|
onClick={() => {
|
||||||
<Center>
|
open();
|
||||||
<Spoiler
|
setVotingId(e.id);
|
||||||
hideLabel="sembunyikan"
|
setCatatan(e.catatan);
|
||||||
maw={400}
|
}}
|
||||||
maxHeight={50}
|
>
|
||||||
showLabel="tampilkan"
|
<Stack c={AccentColor.white} spacing={0}>
|
||||||
>
|
<Text fz={10}>Tambah</Text>
|
||||||
{e.catatan}
|
<Text fz={10}>Catatan</Text>
|
||||||
</Spoiler>
|
</Stack>
|
||||||
</Center>
|
</Button>
|
||||||
</td>
|
</Center>
|
||||||
<td>
|
</td>
|
||||||
<Center c={AccentColor.white}>{e?.Author?.Profile?.name}</Center>
|
<td>
|
||||||
</td>
|
<Center c={"white"}>
|
||||||
<td>
|
<Spoiler
|
||||||
<Center c={AccentColor.white}>{e.title}</Center>
|
hideLabel="sembunyikan"
|
||||||
</td>
|
maw={400}
|
||||||
<td>
|
maxHeight={50}
|
||||||
<Center>
|
showLabel="tampilkan"
|
||||||
<Spoiler
|
>
|
||||||
hideLabel="sembunyikan"
|
{e.catatan}
|
||||||
maw={400}
|
</Spoiler>
|
||||||
maxHeight={50}
|
</Center>
|
||||||
showLabel="tampilkan"
|
</td>
|
||||||
>
|
<td>
|
||||||
{e.deskripsi}
|
<Center c={AccentColor.white}>{e?.Author?.Profile?.name}</Center>
|
||||||
</Spoiler>
|
</td>
|
||||||
</Center>
|
<td>
|
||||||
</td>
|
<Center c={AccentColor.white}>{e.title}</Center>
|
||||||
<th>
|
</td>
|
||||||
<Stack>
|
<td>
|
||||||
{e.Voting_DaftarNamaVote.map((v) => (
|
<Center c={"white"}>
|
||||||
<Box key={v.id}>
|
<Spoiler
|
||||||
<Text c={AccentColor.white}>- {v.value}</Text>
|
hideLabel="sembunyikan"
|
||||||
</Box>
|
maw={400}
|
||||||
))}
|
maxHeight={50}
|
||||||
</Stack>
|
showLabel="tampilkan"
|
||||||
</th>
|
>
|
||||||
<td>
|
{e.deskripsi}
|
||||||
<Center c={AccentColor.white}>
|
</Spoiler>
|
||||||
{e.awalVote.toLocaleDateString("id-ID", { dateStyle: "long" })}
|
</Center>
|
||||||
</Center>
|
</td>
|
||||||
</td>
|
<td>
|
||||||
<td>
|
<Stack>
|
||||||
<Center c={AccentColor.white}>
|
{e.Voting_DaftarNamaVote.map((v) => (
|
||||||
{e.akhirVote.toLocaleDateString("id-ID", { dateStyle: "long" })}
|
<Box key={v.id}>
|
||||||
</Center>
|
<Text c={AccentColor.white}>- {v.value}</Text>
|
||||||
</td>
|
</Box>
|
||||||
</tr>
|
))}
|
||||||
));
|
</Stack>
|
||||||
|
</td>
|
||||||
|
|
||||||
|
<td>
|
||||||
|
<Center c={AccentColor.white}>
|
||||||
|
{new Intl.DateTimeFormat("id-ID", {
|
||||||
|
dateStyle: "long",
|
||||||
|
}).format(new Date(e?.awalVote))}
|
||||||
|
</Center>
|
||||||
|
</td>
|
||||||
|
<td>
|
||||||
|
<Center c={AccentColor.white}>
|
||||||
|
{new Intl.DateTimeFormat("id-ID", {
|
||||||
|
dateStyle: "long",
|
||||||
|
}).format(new Date(e?.akhirVote))}
|
||||||
|
</Center>
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
|
));
|
||||||
|
};
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<>
|
<>
|
||||||
<Stack spacing={"xs"} h={"100%"}>
|
<Stack spacing={"xs"} h={"100%"}>
|
||||||
{/* <pre>{JSON.stringify(listUser, null, 2)}</pre> */}
|
|
||||||
<ComponentAdminGlobal_TitlePage
|
<ComponentAdminGlobal_TitlePage
|
||||||
name="Reject"
|
name="Reject"
|
||||||
color={AdminColor.softBlue}
|
color={AdminColor.softBlue}
|
||||||
component={
|
component={
|
||||||
<TextInput
|
<TextInput
|
||||||
icon={<IconSearch size={20} />}
|
icon={<IconSearch size={20} />}
|
||||||
radius={"xl"}
|
radius={"xl"}
|
||||||
placeholder="Masukan judul"
|
placeholder="Masukan judul"
|
||||||
onChange={(val) => {
|
|
||||||
onSearch(val.currentTarget.value);
|
|
||||||
}}
|
|
||||||
/>
|
|
||||||
}
|
|
||||||
/>
|
|
||||||
{/* <Group
|
|
||||||
position="apart"
|
|
||||||
bg={"red.4"}
|
|
||||||
p={"xs"}
|
|
||||||
style={{ borderRadius: "6px" }}
|
|
||||||
>
|
|
||||||
<Title order={4}>Reject</Title>
|
|
||||||
<TextInput
|
|
||||||
icon={<IconSearch size={20} />}
|
|
||||||
radius={"xl"}
|
|
||||||
placeholder="Masukan judul"
|
|
||||||
onChange={(val) => {
|
|
||||||
onSearch(val.currentTarget.value);
|
|
||||||
}}
|
|
||||||
/>
|
|
||||||
</Group> */}
|
|
||||||
|
|
||||||
<Paper p={"md"} bg={AdminColor.softBlue} shadow="lg" h={"80vh"}>
|
|
||||||
<ScrollArea w={"100%"} h={"90%"}>
|
|
||||||
<Table
|
|
||||||
verticalSpacing={"md"}
|
|
||||||
horizontalSpacing={"md"}
|
|
||||||
p={"md"}
|
|
||||||
w={1500}
|
|
||||||
|
|
||||||
>
|
|
||||||
<thead>
|
|
||||||
<tr>
|
|
||||||
<th>
|
|
||||||
<Center c={AccentColor.white}>Aksi</Center>
|
|
||||||
</th>
|
|
||||||
<th>
|
|
||||||
<Center c={AccentColor.white}>Catatan</Center>
|
|
||||||
</th>
|
|
||||||
<th>
|
|
||||||
<Center c={AccentColor.white}>Author</Center>
|
|
||||||
</th>
|
|
||||||
<th>
|
|
||||||
<Center c={AccentColor.white}>Judul</Center>
|
|
||||||
</th>
|
|
||||||
<th>
|
|
||||||
<Center c={AccentColor.white}>Deskripsi</Center>
|
|
||||||
</th>
|
|
||||||
<th>
|
|
||||||
<Center c={AccentColor.white}>Pilihan</Center>
|
|
||||||
</th>
|
|
||||||
<th>
|
|
||||||
<Center c={AccentColor.white}>Mulai Vote</Center>
|
|
||||||
</th>
|
|
||||||
<th>
|
|
||||||
<Center c={AccentColor.white}>Selesai Vote</Center>
|
|
||||||
</th>
|
|
||||||
</tr>
|
|
||||||
</thead>
|
|
||||||
<tbody>{TableRows}</tbody>
|
|
||||||
</Table>
|
|
||||||
</ScrollArea>
|
|
||||||
|
|
||||||
<Center mt={"xl"}>
|
|
||||||
<Pagination
|
|
||||||
value={isActivePage}
|
|
||||||
total={isNPage}
|
|
||||||
onChange={(val) => {
|
onChange={(val) => {
|
||||||
onPageClick(val);
|
onSearch(val.currentTarget.value);
|
||||||
}}
|
}}
|
||||||
/>
|
/>
|
||||||
</Center>
|
}
|
||||||
</Paper>
|
/>
|
||||||
|
|
||||||
|
{!data ? (
|
||||||
|
<CustomSkeleton height={"80vh"} width="100%" />
|
||||||
|
) : _.isEmpty(data) ? (
|
||||||
|
<ComponentAdminGlobal_IsEmptyData />
|
||||||
|
) : (
|
||||||
|
<Paper p={"md"} bg={AdminColor.softBlue} shadow="lg" h={"80vh"}>
|
||||||
|
<ScrollArea w={"100%"} h={"90%"}>
|
||||||
|
<Table
|
||||||
|
verticalSpacing={"md"}
|
||||||
|
horizontalSpacing={"md"}
|
||||||
|
p={"md"}
|
||||||
|
w={1500}
|
||||||
|
>
|
||||||
|
<thead>
|
||||||
|
<tr>
|
||||||
|
<th>
|
||||||
|
<Center c={AccentColor.white}>Aksi</Center>
|
||||||
|
</th>
|
||||||
|
<th>
|
||||||
|
<Center c={AccentColor.white}>Catatan</Center>
|
||||||
|
</th>
|
||||||
|
<th>
|
||||||
|
<Center c={AccentColor.white}>Author</Center>
|
||||||
|
</th>
|
||||||
|
<th>
|
||||||
|
<Center c={AccentColor.white}>Judul</Center>
|
||||||
|
</th>
|
||||||
|
<th>
|
||||||
|
<Center c={AccentColor.white}>Deskripsi</Center>
|
||||||
|
</th>
|
||||||
|
<th>
|
||||||
|
<Center c={AccentColor.white}>Pilihan</Center>
|
||||||
|
</th>
|
||||||
|
<th>
|
||||||
|
<Center c={AccentColor.white}>Mulai Vote</Center>
|
||||||
|
</th>
|
||||||
|
<th>
|
||||||
|
<Center c={AccentColor.white}>Selesai Vote</Center>
|
||||||
|
</th>
|
||||||
|
</tr>
|
||||||
|
</thead>
|
||||||
|
<tbody>{renderTableBody()}</tbody>
|
||||||
|
</Table>
|
||||||
|
</ScrollArea>
|
||||||
|
|
||||||
|
<Center mt={"xl"}>
|
||||||
|
<Pagination
|
||||||
|
value={isActivePage}
|
||||||
|
total={nPage}
|
||||||
|
onChange={(val) => {
|
||||||
|
onPageClick(val);
|
||||||
|
}}
|
||||||
|
/>
|
||||||
|
</Center>
|
||||||
|
</Paper>
|
||||||
|
)}
|
||||||
</Stack>
|
</Stack>
|
||||||
|
|
||||||
<Modal
|
<Modal
|
||||||
@@ -281,10 +305,11 @@ function TableStatus({ listData }: { listData: any }) {
|
|||||||
Batal
|
Batal
|
||||||
</Button>
|
</Button>
|
||||||
<Button
|
<Button
|
||||||
|
loading={isLoading}
|
||||||
|
loaderPosition="center"
|
||||||
radius={"xl"}
|
radius={"xl"}
|
||||||
onClick={() => {
|
onClick={() => {
|
||||||
onReject(votingId, catatan, close, setData);
|
onReject();
|
||||||
console.log(catatan);
|
|
||||||
}}
|
}}
|
||||||
>
|
>
|
||||||
Simpan
|
Simpan
|
||||||
|
|||||||
@@ -48,28 +48,33 @@ import { AdminVote_funEditStatusPublishById } from "../../fun/edit/fun_edit_stat
|
|||||||
import { AdminEvent_funEditCatatanById } from "../../fun/edit/fun_edit_status_reject_by_id";
|
import { AdminEvent_funEditCatatanById } from "../../fun/edit/fun_edit_status_reject_by_id";
|
||||||
import { ComponentAdminGlobal_TitlePage } from "@/app_modules/admin/_admin_global/_component";
|
import { ComponentAdminGlobal_TitlePage } from "@/app_modules/admin/_admin_global/_component";
|
||||||
import { AdminColor } from "@/app_modules/_global/color/color_pallet";
|
import { AdminColor } from "@/app_modules/_global/color/color_pallet";
|
||||||
|
import { clientLogger } from "@/util/clientLogger";
|
||||||
|
import { apiGetAdminVotingByStatus } from "../../lib/api_fetch_admin_voting";
|
||||||
|
import _ from "lodash";
|
||||||
|
import CustomSkeleton from "@/app_modules/components/CustomSkeleton";
|
||||||
|
import ComponentAdminGlobal_IsEmptyData from "@/app_modules/admin/_admin_global/is_empty_data";
|
||||||
|
|
||||||
export default function AdminVote_TableReview({
|
export default function AdminVote_TableReview() {
|
||||||
listVote,
|
|
||||||
}: {
|
|
||||||
listVote: MODEL_VOTING[];
|
|
||||||
}) {
|
|
||||||
return (
|
return (
|
||||||
<>
|
<>
|
||||||
<Stack>
|
<Stack>
|
||||||
<ComponentAdminGlobal_HeaderTamplate name="Voting" />
|
<ComponentAdminGlobal_HeaderTamplate name="Voting" />
|
||||||
<TableStatus listData={listVote} />
|
<TableStatus />
|
||||||
</Stack>
|
</Stack>
|
||||||
</>
|
</>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
function TableStatus({ listData }: { listData: any }) {
|
function TableStatus() {
|
||||||
const [openedReject, { open: openReject, close: closeReject }] = useDisclosure(false);
|
const [openedReject, { open: openReject, close: closeReject }] =
|
||||||
const [openedPublish, { open: openPublish, close: closePublish }] = useDisclosure(false);
|
useDisclosure(false);
|
||||||
const [data, setData] = useState<MODEL_VOTING[]>(listData.data);
|
const [openedPublish, { open: openPublish, close: closePublish }] =
|
||||||
const [isNPage, setNPage] = useState(listData.nPage);
|
useDisclosure(false);
|
||||||
const [votingId, setVotingId] = useState("");
|
|
||||||
|
const [data, setData] = useState<MODEL_VOTING[] | null>(null);
|
||||||
|
const [nPage, setNPage] = useState(1);
|
||||||
|
const [dataId, setDataId] = useState("");
|
||||||
|
const [tanggalMulai, setTanggalMulai] = useState<Date>();
|
||||||
const [catatan, setCatatan] = useState("");
|
const [catatan, setCatatan] = useState("");
|
||||||
const [isLoadingPublish, setLoadingPublish] = useState(false);
|
const [isLoadingPublish, setLoadingPublish] = useState(false);
|
||||||
const [isSaveLoading, setSaveLoading] = useState(false);
|
const [isSaveLoading, setSaveLoading] = useState(false);
|
||||||
@@ -90,126 +95,232 @@ function TableStatus({ listData }: { listData: any }) {
|
|||||||
}
|
}
|
||||||
}, [isAdminVoting_TriggerReview, setIsShowReload]);
|
}, [isAdminVoting_TriggerReview, setIsShowReload]);
|
||||||
|
|
||||||
async function onLoadData() {
|
useShallowEffect(() => {
|
||||||
const loadData = await adminVote_funGetListReview({ page: 1 });
|
handleLoadData();
|
||||||
|
}, [isActivePage, isSearch]);
|
||||||
|
|
||||||
setData(loadData.data as any);
|
const handleLoadData = async () => {
|
||||||
setNPage(loadData.nPage);
|
try {
|
||||||
|
const response = await apiGetAdminVotingByStatus({
|
||||||
|
name: "Review",
|
||||||
|
page: `${isActivePage}`,
|
||||||
|
search: isSearch,
|
||||||
|
});
|
||||||
|
|
||||||
|
if (response?.success && response?.data?.data) {
|
||||||
|
setData(response.data.data);
|
||||||
|
setNPage(response.data.nPage || 1);
|
||||||
|
} else {
|
||||||
|
console.error("Invalid data format received:", response);
|
||||||
|
setData([]);
|
||||||
|
}
|
||||||
|
} catch (error) {
|
||||||
|
clientLogger.error("Error get data table publish", error);
|
||||||
|
setData([]);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
async function onSearch(s: string) {
|
||||||
|
setSearch(s);
|
||||||
|
}
|
||||||
|
|
||||||
|
async function onPageClick(p: any) {
|
||||||
|
setActivePage(p);
|
||||||
|
}
|
||||||
|
|
||||||
|
async function onLoadData() {
|
||||||
|
handleLoadData();
|
||||||
setIsLoading(false);
|
setIsLoading(false);
|
||||||
setIsShowReload(false);
|
setIsShowReload(false);
|
||||||
setIsAdminVoting_TriggerReview(false);
|
setIsAdminVoting_TriggerReview(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
async function onSearch(s: string) {
|
|
||||||
setSearch(s);
|
async function onReject() {
|
||||||
const loadData = await adminVote_funGetListReview({
|
const data = {
|
||||||
page: 1,
|
id: dataId,
|
||||||
search: s,
|
catatan: catatan,
|
||||||
});
|
};
|
||||||
setData(loadData.data as any);
|
|
||||||
setNPage(loadData.nPage);
|
try {
|
||||||
|
setSaveLoading(true);
|
||||||
|
const res = await AdminEvent_funEditCatatanById(data as any);
|
||||||
|
if (res.status === 200) {
|
||||||
|
const dataNotifikasi: IRealtimeData = {
|
||||||
|
appId: res.data?.id as string,
|
||||||
|
status: res.data?.Voting_Status?.name as any,
|
||||||
|
userId: res.data?.authorId as any,
|
||||||
|
pesan: res.data?.title as any,
|
||||||
|
kategoriApp: "VOTING",
|
||||||
|
title: "Voting anda di tolak !",
|
||||||
|
};
|
||||||
|
|
||||||
|
const notif = await adminNotifikasi_funCreateToUser({
|
||||||
|
data: dataNotifikasi as any,
|
||||||
|
});
|
||||||
|
|
||||||
|
if (notif.status === 201) {
|
||||||
|
WibuRealtime.setData({
|
||||||
|
type: "notification",
|
||||||
|
pushNotificationTo: "USER",
|
||||||
|
dataMessage: dataNotifikasi,
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
handleLoadData();
|
||||||
|
ComponentGlobal_NotifikasiBerhasil(res.message);
|
||||||
|
} else {
|
||||||
|
ComponentGlobal_NotifikasiGagal(res.message);
|
||||||
|
}
|
||||||
|
} catch (error) {
|
||||||
|
console.error("Error update voting admin", error);
|
||||||
|
} finally {
|
||||||
|
closeReject();
|
||||||
|
setSaveLoading(false);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
async function onPageClick(p: any) {
|
async function onPublish() {
|
||||||
setActivePage(p);
|
const hariIni = new Date();
|
||||||
const loadData = await adminVote_funGetListReview({
|
const cekHari = moment(tanggalMulai).diff(hariIni, "days");
|
||||||
search: isSearch,
|
|
||||||
page: p,
|
if (cekHari < 0)
|
||||||
});
|
return ComponentGlobal_NotifikasiPeringatan("Tanggal Voting Lewat");
|
||||||
setData(loadData.data as any);
|
|
||||||
setNPage(loadData.nPage);
|
try {
|
||||||
|
setLoadingPublish(true);
|
||||||
|
const res = await AdminVote_funEditStatusPublishById(dataId);
|
||||||
|
if (res.status === 200) {
|
||||||
|
const dataNotifikasi: IRealtimeData = {
|
||||||
|
appId: res.data?.id as string,
|
||||||
|
status: res.data?.Voting_Status?.name as any,
|
||||||
|
userId: res.data?.authorId as any,
|
||||||
|
pesan: res.data?.title as any,
|
||||||
|
kategoriApp: "VOTING",
|
||||||
|
title: "Voting publish",
|
||||||
|
};
|
||||||
|
const notif = await adminNotifikasi_funCreateToUser({
|
||||||
|
data: dataNotifikasi as any,
|
||||||
|
});
|
||||||
|
if (notif.status === 201) {
|
||||||
|
WibuRealtime.setData({
|
||||||
|
type: "notification",
|
||||||
|
pushNotificationTo: "USER",
|
||||||
|
dataMessage: dataNotifikasi,
|
||||||
|
});
|
||||||
|
WibuRealtime.setData({
|
||||||
|
type: "trigger",
|
||||||
|
pushNotificationTo: "USER",
|
||||||
|
dataMessage: dataNotifikasi,
|
||||||
|
});
|
||||||
|
}
|
||||||
|
handleLoadData();
|
||||||
|
ComponentGlobal_NotifikasiBerhasil(res.message);
|
||||||
|
closePublish()
|
||||||
|
} else {
|
||||||
|
ComponentGlobal_NotifikasiGagal(res.message);
|
||||||
|
}
|
||||||
|
} catch (error) {
|
||||||
|
console.log("Error get data voting", error);
|
||||||
|
} finally {
|
||||||
|
setLoadingPublish(false);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
const TableRows = data.map((e, i) => (
|
const renderTableBody = () => {
|
||||||
<tr key={i}>
|
if (!Array.isArray(data) || data.length === 0) {
|
||||||
<td>
|
return (
|
||||||
<Center c={AccentColor.white}>{e?.Author?.username}</Center>
|
<tr>
|
||||||
</td>
|
<td colSpan={12}>
|
||||||
<td>
|
<Center>
|
||||||
<Center c={AccentColor.white}>{e.title}</Center>
|
<Text color={"gray"}>Tidak ada data</Text>
|
||||||
</td>
|
</Center>
|
||||||
<td>
|
</td>
|
||||||
<Center c={AccentColor.white}>
|
</tr>
|
||||||
<Spoiler
|
);
|
||||||
hideLabel="sembunyikan"
|
}
|
||||||
maw={400}
|
|
||||||
maxHeight={50}
|
|
||||||
showLabel="tampilkan"
|
|
||||||
>
|
|
||||||
{e.deskripsi}
|
|
||||||
</Spoiler>
|
|
||||||
</Center>
|
|
||||||
</td>
|
|
||||||
<th>
|
|
||||||
<Stack>
|
|
||||||
{e.Voting_DaftarNamaVote.map((v) => (
|
|
||||||
<Box key={v.id}>
|
|
||||||
<Text c={AccentColor.white}>- {v.value}</Text>
|
|
||||||
</Box>
|
|
||||||
))}
|
|
||||||
</Stack>
|
|
||||||
</th>
|
|
||||||
<td>
|
|
||||||
<Center c={AccentColor.white}>
|
|
||||||
{e.awalVote.toLocaleDateString("id-ID", { dateStyle: "long" })}
|
|
||||||
</Center>
|
|
||||||
</td>
|
|
||||||
<td>
|
|
||||||
<Center c={AccentColor.white}>
|
|
||||||
{e.akhirVote.toLocaleDateString("id-ID", { dateStyle: "long" })}
|
|
||||||
</Center>
|
|
||||||
</td>
|
|
||||||
|
|
||||||
<td>
|
return data?.map((e, i) => (
|
||||||
<Stack align="center">
|
<tr key={i}>
|
||||||
<Button
|
<td>
|
||||||
// loaderPosition="center"
|
<Center c={AccentColor.white}>{e?.Author?.username}</Center>
|
||||||
// loading={
|
</td>
|
||||||
// e?.id === votingId ? (isLoadingPublish ? true : false) : false
|
<td>
|
||||||
// }
|
<Center c={AccentColor.white}>{e.title}</Center>
|
||||||
w={120}
|
</td>
|
||||||
color={"green"}
|
<td>
|
||||||
leftIcon={<IconCircleCheck />}
|
<Center c={AccentColor.white}>
|
||||||
radius={"xl"}
|
<Spoiler
|
||||||
onClick={() => {
|
hideLabel="sembunyikan"
|
||||||
openPublish();
|
maw={400}
|
||||||
setVotingId(e.id);
|
maxHeight={50}
|
||||||
}
|
showLabel="tampilkan"
|
||||||
// onPublish({
|
>
|
||||||
// // voteId: e.id,
|
{e.deskripsi}
|
||||||
// // awalVote: e.awalVote,
|
</Spoiler>
|
||||||
// // setLoadingPublish: setLoadingPublish,
|
</Center>
|
||||||
// // setVotingId: setVotingId,
|
</td>
|
||||||
// // setData(val) {
|
<td>
|
||||||
// // setData(val.data);
|
<Stack>
|
||||||
// // setNPage(val.nPage);
|
{e.Voting_DaftarNamaVote.map((v) => (
|
||||||
// // },
|
<Box key={v.id}>
|
||||||
// })
|
<Text c={AccentColor.white}>- {v.value}</Text>
|
||||||
}
|
</Box>
|
||||||
>
|
))}
|
||||||
Publish
|
</Stack>
|
||||||
</Button>
|
</td>
|
||||||
<Button
|
|
||||||
w={120}
|
<td>
|
||||||
color={"red"}
|
<Center c={AccentColor.white}>
|
||||||
leftIcon={<IconBan />}
|
{new Intl.DateTimeFormat("id-ID", {
|
||||||
radius={"xl"}
|
dateStyle: "long",
|
||||||
onClick={() => {
|
}).format(new Date(e?.awalVote))}
|
||||||
openReject();
|
</Center>
|
||||||
setVotingId(e.id);
|
</td>
|
||||||
}}
|
<td>
|
||||||
>
|
<Center c={AccentColor.white}>
|
||||||
Reject
|
{new Intl.DateTimeFormat("id-ID", {
|
||||||
</Button>
|
dateStyle: "long",
|
||||||
</Stack>
|
}).format(new Date(e?.akhirVote))}
|
||||||
</td>
|
</Center>
|
||||||
</tr>
|
</td>
|
||||||
));
|
|
||||||
|
<td>
|
||||||
|
<Stack align="center">
|
||||||
|
<Button
|
||||||
|
w={120}
|
||||||
|
color={"green"}
|
||||||
|
leftIcon={<IconCircleCheck />}
|
||||||
|
radius={"xl"}
|
||||||
|
onClick={() => {
|
||||||
|
openPublish();
|
||||||
|
setDataId(e.id);
|
||||||
|
setTanggalMulai(e.awalVote);
|
||||||
|
}}
|
||||||
|
>
|
||||||
|
Publish
|
||||||
|
</Button>
|
||||||
|
<Button
|
||||||
|
w={120}
|
||||||
|
color={"red"}
|
||||||
|
leftIcon={<IconBan />}
|
||||||
|
radius={"xl"}
|
||||||
|
onClick={() => {
|
||||||
|
openReject();
|
||||||
|
setDataId(e.id);
|
||||||
|
}}
|
||||||
|
>
|
||||||
|
Reject
|
||||||
|
</Button>
|
||||||
|
</Stack>
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
|
));
|
||||||
|
};
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<>
|
<>
|
||||||
<Stack spacing={"xs"} h={"100%"}>
|
<Stack spacing={"xs"} h={"100%"}>
|
||||||
{/* <pre>{JSON.stringify(listUser, null, 2)}</pre> */}
|
|
||||||
<ComponentAdminGlobal_TitlePage
|
<ComponentAdminGlobal_TitlePage
|
||||||
name="Review"
|
name="Review"
|
||||||
color={AdminColor.softBlue}
|
color={AdminColor.softBlue}
|
||||||
@@ -224,94 +335,82 @@ function TableStatus({ listData }: { listData: any }) {
|
|||||||
/>
|
/>
|
||||||
}
|
}
|
||||||
/>
|
/>
|
||||||
{/* <Group
|
|
||||||
position="apart"
|
|
||||||
bg={"orange.4"}
|
|
||||||
p={"xs"}
|
|
||||||
style={{ borderRadius: "6px" }}
|
|
||||||
>
|
|
||||||
<Title order={4}>Review</Title>
|
|
||||||
<TextInput
|
|
||||||
icon={<IconSearch size={20} />}
|
|
||||||
radius={"xl"}
|
|
||||||
placeholder="Masukan judul"
|
|
||||||
onChange={(val) => {
|
|
||||||
onSearch(val.currentTarget.value);
|
|
||||||
}}
|
|
||||||
/>
|
|
||||||
</Group> */}
|
|
||||||
|
|
||||||
<Paper p={"md"} bg={AdminColor.softBlue} shadow="lg" h={"80vh"}>
|
{!data ? (
|
||||||
{isShowReload && (
|
<CustomSkeleton height={"80vh"} width="100%" />
|
||||||
<Affix position={{ top: rem(200) }} w={"100%"}>
|
) : _.isEmpty(data) ? (
|
||||||
<Center>
|
<ComponentAdminGlobal_IsEmptyData />
|
||||||
<Button
|
) : (
|
||||||
style={{
|
<Paper p={"md"} bg={AdminColor.softBlue} shadow="lg" h={"80vh"}>
|
||||||
transition: "0.5s",
|
{isShowReload && (
|
||||||
border: `1px solid ${AccentColor.skyblue}`,
|
<Affix position={{ top: rem(200) }} w={"100%"}>
|
||||||
}}
|
<Center>
|
||||||
bg={AccentColor.blue}
|
<Button
|
||||||
loaderPosition="center"
|
style={{
|
||||||
loading={isLoading}
|
transition: "0.5s",
|
||||||
radius={"xl"}
|
border: `1px solid ${AccentColor.skyblue}`,
|
||||||
opacity={0.8}
|
}}
|
||||||
onClick={() => onLoadData()}
|
bg={AccentColor.blue}
|
||||||
leftIcon={<IconRefresh />}
|
loaderPosition="center"
|
||||||
>
|
loading={isLoading}
|
||||||
Update Data
|
radius={"xl"}
|
||||||
</Button>
|
opacity={0.8}
|
||||||
</Center>
|
onClick={() => onLoadData()}
|
||||||
</Affix>
|
leftIcon={<IconRefresh />}
|
||||||
)}
|
>
|
||||||
|
Update Data
|
||||||
|
</Button>
|
||||||
|
</Center>
|
||||||
|
</Affix>
|
||||||
|
)}
|
||||||
|
|
||||||
<ScrollArea w={"100%"} h={"90%"}>
|
<ScrollArea w={"100%"} h={"90%"}>
|
||||||
<Table
|
<Table
|
||||||
verticalSpacing={"md"}
|
verticalSpacing={"md"}
|
||||||
horizontalSpacing={"md"}
|
horizontalSpacing={"md"}
|
||||||
p={"md"}
|
p={"md"}
|
||||||
w={1500}
|
w={1500}
|
||||||
|
>
|
||||||
|
<thead>
|
||||||
|
<tr>
|
||||||
|
<th>
|
||||||
|
<Center c={AccentColor.white}>Username</Center>
|
||||||
|
</th>
|
||||||
|
<th>
|
||||||
|
<Center c={AccentColor.white}>Judul</Center>
|
||||||
|
</th>
|
||||||
|
<th>
|
||||||
|
<Center c={AccentColor.white}>Deskripsi</Center>
|
||||||
|
</th>
|
||||||
|
<th>
|
||||||
|
<Center c={AccentColor.white}>Pilihan</Center>
|
||||||
|
</th>
|
||||||
|
<th>
|
||||||
|
<Center c={AccentColor.white}>Mulai Vote</Center>
|
||||||
|
</th>
|
||||||
|
<th>
|
||||||
|
<Center c={AccentColor.white}>Selesai Vote</Center>
|
||||||
|
</th>
|
||||||
|
<th>
|
||||||
|
<Center c={AccentColor.white}>Aksi</Center>
|
||||||
|
</th>
|
||||||
|
</tr>
|
||||||
|
</thead>
|
||||||
|
<tbody>{renderTableBody()}</tbody>
|
||||||
|
</Table>
|
||||||
|
</ScrollArea>
|
||||||
|
|
||||||
>
|
<Center mt={"xl"}>
|
||||||
<thead>
|
<Pagination
|
||||||
<tr>
|
value={isActivePage}
|
||||||
<th>
|
total={nPage}
|
||||||
<Center c={AccentColor.white}>Username</Center>
|
onChange={(val) => {
|
||||||
</th>
|
onPageClick(val);
|
||||||
<th>
|
}}
|
||||||
<Center c={AccentColor.white}>Judul</Center>
|
/>
|
||||||
</th>
|
</Center>
|
||||||
<th>
|
</Paper>
|
||||||
<Center c={AccentColor.white}>Deskripsi</Center>
|
)}
|
||||||
</th>
|
|
||||||
<th>
|
|
||||||
<Center c={AccentColor.white}>Pilihan</Center>
|
|
||||||
</th>
|
|
||||||
<th>
|
|
||||||
<Center c={AccentColor.white}>Mulai Vote</Center>
|
|
||||||
</th>
|
|
||||||
<th>
|
|
||||||
<Center c={AccentColor.white}>Selesai Vote</Center>
|
|
||||||
</th>
|
|
||||||
|
|
||||||
<th>
|
|
||||||
<Center c={AccentColor.white}>Aksi</Center>
|
|
||||||
</th>
|
|
||||||
</tr>
|
|
||||||
</thead>
|
|
||||||
<tbody>{TableRows}</tbody>
|
|
||||||
</Table>
|
|
||||||
</ScrollArea>
|
|
||||||
|
|
||||||
<Center mt={"xl"}>
|
|
||||||
<Pagination
|
|
||||||
value={isActivePage}
|
|
||||||
total={isNPage}
|
|
||||||
onChange={(val) => {
|
|
||||||
onPageClick(val);
|
|
||||||
}}
|
|
||||||
/>
|
|
||||||
</Center>
|
|
||||||
</Paper>
|
|
||||||
</Stack>
|
</Stack>
|
||||||
|
|
||||||
<Modal
|
<Modal
|
||||||
@@ -342,23 +441,10 @@ function TableStatus({ listData }: { listData: any }) {
|
|||||||
loading={isSaveLoading ? true : false}
|
loading={isSaveLoading ? true : false}
|
||||||
radius={"xl"}
|
radius={"xl"}
|
||||||
onClick={() => {
|
onClick={() => {
|
||||||
onReject({
|
onReject();
|
||||||
catatan: catatan,
|
|
||||||
voteId: votingId,
|
|
||||||
setData(val) {
|
|
||||||
setData(val.data);
|
|
||||||
setNPage(val.nPage);
|
|
||||||
},
|
|
||||||
close: () => {
|
|
||||||
closeReject();
|
|
||||||
},
|
|
||||||
setSaveLoading(val) {
|
|
||||||
setSaveLoading(val);
|
|
||||||
},
|
|
||||||
});
|
|
||||||
}}
|
}}
|
||||||
style={{
|
style={{
|
||||||
backgroundColor: MainColor.green
|
backgroundColor: MainColor.green,
|
||||||
}}
|
}}
|
||||||
>
|
>
|
||||||
Simpan
|
Simpan
|
||||||
@@ -384,23 +470,7 @@ function TableStatus({ listData }: { listData: any }) {
|
|||||||
loading={isLoadingPublish ? true : false}
|
loading={isLoadingPublish ? true : false}
|
||||||
radius={"xl"}
|
radius={"xl"}
|
||||||
onClick={() => {
|
onClick={() => {
|
||||||
onPublish({
|
onPublish();
|
||||||
awalVote: data[0].awalVote,
|
|
||||||
voteId: votingId,
|
|
||||||
setData(val) {
|
|
||||||
setData(val.data);
|
|
||||||
setNPage(val.nPage);
|
|
||||||
},
|
|
||||||
close: () => {
|
|
||||||
closePublish();
|
|
||||||
},
|
|
||||||
setLoadingPublish: (val) => {
|
|
||||||
setLoadingPublish(val);
|
|
||||||
},
|
|
||||||
setVotingId: (val) => {
|
|
||||||
setVotingId(val);
|
|
||||||
},
|
|
||||||
});
|
|
||||||
}}
|
}}
|
||||||
style={{
|
style={{
|
||||||
backgroundColor: MainColor.green,
|
backgroundColor: MainColor.green,
|
||||||
@@ -414,132 +484,3 @@ function TableStatus({ listData }: { listData: any }) {
|
|||||||
</>
|
</>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
async function onPublish({
|
|
||||||
close,
|
|
||||||
voteId,
|
|
||||||
setData,
|
|
||||||
awalVote,
|
|
||||||
setLoadingPublish,
|
|
||||||
setVotingId,
|
|
||||||
}: {
|
|
||||||
close: any,
|
|
||||||
voteId: string;
|
|
||||||
setData: (val: { data: any[]; nPage: number }) => void;
|
|
||||||
awalVote: Date;
|
|
||||||
setLoadingPublish: (val: boolean) => void;
|
|
||||||
setVotingId: (val: string) => void;
|
|
||||||
}) {
|
|
||||||
const hariIni = new Date();
|
|
||||||
const cekHari = moment(awalVote).diff(hariIni, "days");
|
|
||||||
|
|
||||||
if (cekHari < 0)
|
|
||||||
return ComponentGlobal_NotifikasiPeringatan("Tanggal Voting Lewat");
|
|
||||||
|
|
||||||
setVotingId(voteId);
|
|
||||||
const res = await AdminVote_funEditStatusPublishById(voteId);
|
|
||||||
if (res.status === 200) {
|
|
||||||
setLoadingPublish(true);
|
|
||||||
|
|
||||||
const dataNotifikasi: IRealtimeData = {
|
|
||||||
appId: res.data?.id as string,
|
|
||||||
status: res.data?.Voting_Status?.name as any,
|
|
||||||
userId: res.data?.authorId as any,
|
|
||||||
pesan: res.data?.title as any,
|
|
||||||
kategoriApp: "VOTING",
|
|
||||||
title: "Voting publish",
|
|
||||||
};
|
|
||||||
|
|
||||||
const notif = await adminNotifikasi_funCreateToUser({
|
|
||||||
data: dataNotifikasi as any,
|
|
||||||
});
|
|
||||||
|
|
||||||
if (notif.status === 201) {
|
|
||||||
WibuRealtime.setData({
|
|
||||||
type: "notification",
|
|
||||||
pushNotificationTo: "USER",
|
|
||||||
dataMessage: dataNotifikasi,
|
|
||||||
});
|
|
||||||
|
|
||||||
WibuRealtime.setData({
|
|
||||||
type: "trigger",
|
|
||||||
pushNotificationTo: "USER",
|
|
||||||
dataMessage: dataNotifikasi,
|
|
||||||
});
|
|
||||||
}
|
|
||||||
const loadData = await adminVote_funGetListReview({ page: 1 });
|
|
||||||
setData({
|
|
||||||
data: loadData.data,
|
|
||||||
nPage: loadData.nPage,
|
|
||||||
});
|
|
||||||
|
|
||||||
ComponentGlobal_NotifikasiBerhasil(res.message);
|
|
||||||
setLoadingPublish(false);
|
|
||||||
} else {
|
|
||||||
ComponentGlobal_NotifikasiGagal(res.message);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
async function onReject({
|
|
||||||
voteId,
|
|
||||||
catatan,
|
|
||||||
close,
|
|
||||||
setSaveLoading,
|
|
||||||
setData,
|
|
||||||
}: {
|
|
||||||
voteId: string;
|
|
||||||
catatan: string;
|
|
||||||
close: any;
|
|
||||||
setSaveLoading: (val: boolean) => void;
|
|
||||||
setData: (val: { data: any[]; nPage: number }) => void;
|
|
||||||
}) {
|
|
||||||
const data = {
|
|
||||||
id: voteId,
|
|
||||||
catatan: catatan,
|
|
||||||
};
|
|
||||||
|
|
||||||
const res = await AdminEvent_funEditCatatanById(data as any);
|
|
||||||
if (res.status === 200) {
|
|
||||||
setSaveLoading(true);
|
|
||||||
// const dataNotif = {
|
|
||||||
// appId: res.data?.id,
|
|
||||||
// status: res.data?.Voting_Status?.name as any,
|
|
||||||
// userId: res.data?.authorId as any,
|
|
||||||
// pesan: res.data?.title as any,
|
|
||||||
// kategoriApp: "VOTING",
|
|
||||||
// title: "Voting anda di tolak !",
|
|
||||||
// };
|
|
||||||
|
|
||||||
const dataNotifikasi: IRealtimeData = {
|
|
||||||
appId: res.data?.id as string,
|
|
||||||
status: res.data?.Voting_Status?.name as any,
|
|
||||||
userId: res.data?.authorId as any,
|
|
||||||
pesan: res.data?.title as any,
|
|
||||||
kategoriApp: "VOTING",
|
|
||||||
title: "Voting anda di tolak !",
|
|
||||||
};
|
|
||||||
|
|
||||||
const notif = await adminNotifikasi_funCreateToUser({
|
|
||||||
data: dataNotifikasi as any,
|
|
||||||
});
|
|
||||||
|
|
||||||
if (notif.status === 201) {
|
|
||||||
WibuRealtime.setData({
|
|
||||||
type: "notification",
|
|
||||||
pushNotificationTo: "USER",
|
|
||||||
dataMessage: dataNotifikasi,
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
const loadData = await adminVote_funGetListReview({ page: 1 });
|
|
||||||
setData({
|
|
||||||
data: loadData.data,
|
|
||||||
nPage: loadData.nPage,
|
|
||||||
});
|
|
||||||
setSaveLoading(false);
|
|
||||||
ComponentGlobal_NotifikasiBerhasil(res.message);
|
|
||||||
close();
|
|
||||||
} else {
|
|
||||||
ComponentGlobal_NotifikasiGagal(res.message);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,64 +1,135 @@
|
|||||||
export {
|
export {
|
||||||
apiGetAdminVoteStatusCountDashboard,
|
apiGetAdminVoteStatusCountDashboard,
|
||||||
apiGetAdminVoteRiwayatCount,
|
apiGetAdminVoteRiwayatCount,
|
||||||
apiGetAdminVotingByStatus
|
apiGetAdminVotingByStatus,
|
||||||
}
|
apiGetAdminVotingRiwayat,
|
||||||
const apiGetAdminVoteStatusCountDashboard = async ({ name }: {
|
};
|
||||||
name: "Publish" | "Review" | "Reject";
|
const apiGetAdminVoteStatusCountDashboard = async ({
|
||||||
|
name,
|
||||||
|
}: {
|
||||||
|
name: "Publish" | "Review" | "Reject";
|
||||||
}) => {
|
}) => {
|
||||||
const { token } = await fetch("/api/get-cookie").then((res) => res.json());
|
const { token } = await fetch("/api/get-cookie").then((res) => res.json());
|
||||||
if (!token) return await token.json().catch(() => null);
|
if (!token) return await token.json().catch(() => null);
|
||||||
|
|
||||||
|
const response = await fetch(`/api/admin/vote/dashboard/${name}`, {
|
||||||
|
method: "GET",
|
||||||
|
headers: {
|
||||||
|
"Content-Type": "application/json",
|
||||||
|
Accept: "application/json",
|
||||||
|
"Access-Control-Allow-Origin": "*",
|
||||||
|
Authorization: `Bearer ${token}`,
|
||||||
|
},
|
||||||
|
});
|
||||||
|
return await response.json().catch(() => null);
|
||||||
|
};
|
||||||
|
|
||||||
const response = await fetch(`/api/admin/vote/dashboard/${name}`, {
|
|
||||||
method: "GET",
|
|
||||||
headers: {
|
|
||||||
"Content-Type": "application/json",
|
|
||||||
Accept: "application/json",
|
|
||||||
"Access-Control-Allow-Origin": "*",
|
|
||||||
Authorization: `Bearer ${token}`,
|
|
||||||
}
|
|
||||||
});
|
|
||||||
return await response.json().catch(() => null);
|
|
||||||
}
|
|
||||||
const apiGetAdminVoteRiwayatCount = async () => {
|
const apiGetAdminVoteRiwayatCount = async () => {
|
||||||
const { token } = await fetch("/api/get-cookie").then((res) => res.json());
|
const { token } = await fetch("/api/get-cookie").then((res) => res.json());
|
||||||
if (!token) return await token.json().catch(() => null);
|
if (!token) return await token.json().catch(() => null);
|
||||||
|
|
||||||
const response = await fetch(`/api/admin/vote/dashboard/riwayat`, {
|
const response = await fetch(`/api/admin/vote/dashboard/riwayat`, {
|
||||||
method: "GET",
|
method: "GET",
|
||||||
headers: {
|
headers: {
|
||||||
"Content-Type": "application/json",
|
"Content-Type": "application/json",
|
||||||
Accept: "application/json",
|
Accept: "application/json",
|
||||||
"Access-Control-Allow-Origin": "*",
|
"Access-Control-Allow-Origin": "*",
|
||||||
Authorization: `Bearer ${token}`,
|
Authorization: `Bearer ${token}`,
|
||||||
}
|
},
|
||||||
});
|
});
|
||||||
return await response.json().catch(() => null);
|
return await response.json().catch(() => null);
|
||||||
}
|
};
|
||||||
|
|
||||||
const apiGetAdminVotingByStatus = async ({
|
const apiGetAdminVotingByStatus = async ({
|
||||||
name,
|
name,
|
||||||
page,
|
page,
|
||||||
search }: {
|
search,
|
||||||
name: "Publish" | "Review" | "Reject";
|
}: {
|
||||||
page: string;
|
name: "Publish" | "Review" | "Reject";
|
||||||
search: string;
|
page: string;
|
||||||
}) => {
|
search: string;
|
||||||
|
}) => {
|
||||||
|
try {
|
||||||
|
// Fetch token from cookie
|
||||||
const { token } = await fetch("/api/get-cookie").then((res) => res.json());
|
const { token } = await fetch("/api/get-cookie").then((res) => res.json());
|
||||||
if (!token) return await token.json().catch(() => null);
|
if (!token) {
|
||||||
|
console.error("No token found");
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
const isPage = page ? `?page=${page}` : "";
|
const isPage = page ? `?page=${page}` : "";
|
||||||
const isSearch = search ? `&search=${search}` : "";
|
const isSearch = search ? `&search=${search}` : "";
|
||||||
const response = await fetch(
|
const response = await fetch(
|
||||||
`/api/admin/vote/status/${name}${isPage}${isSearch}`,
|
`/api/admin/vote/status/${name}${isPage}${isSearch}`,
|
||||||
{
|
{
|
||||||
headers: {
|
headers: {
|
||||||
"Content-Type": "application/json",
|
"Content-Type": "application/json",
|
||||||
Accept: "application/json",
|
Accept: "application/json",
|
||||||
"Access-Control-Allow-Origin": "*",
|
Authorization: `Bearer ${token}`,
|
||||||
Authorization: `Bearer ${token}`
|
},
|
||||||
}
|
}
|
||||||
}
|
);
|
||||||
)
|
|
||||||
return await response.json().catch(() => null);
|
// Check if the response is OK
|
||||||
}
|
if (!response.ok) {
|
||||||
|
const errorData = await response.json().catch(() => null);
|
||||||
|
console.error(
|
||||||
|
"Error get data voting admin",
|
||||||
|
errorData?.message || "Unknown error"
|
||||||
|
);
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
return response.json();
|
||||||
|
} catch (error) {
|
||||||
|
console.log("Error get data voting admin", error);
|
||||||
|
throw error;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
const apiGetAdminVotingRiwayat = async ({
|
||||||
|
page,
|
||||||
|
search,
|
||||||
|
}: {
|
||||||
|
page: string;
|
||||||
|
search: string;
|
||||||
|
}) => {
|
||||||
|
try {
|
||||||
|
// Fetch token from cookie
|
||||||
|
const { token } = await fetch("/api/get-cookie").then((res) => res.json());
|
||||||
|
if (!token) {
|
||||||
|
console.error("No token found");
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
const isPage = page ? `?page=${page}` : "";
|
||||||
|
const isSearch = search ? `&search=${search}` : "";
|
||||||
|
const response = await fetch(
|
||||||
|
`/api/admin/vote/status/riwayat${isPage}${isSearch}`,
|
||||||
|
{
|
||||||
|
headers: {
|
||||||
|
"Content-Type": "application/json",
|
||||||
|
Accept: "application/json",
|
||||||
|
Authorization: `Bearer ${token}`,
|
||||||
|
},
|
||||||
|
}
|
||||||
|
);
|
||||||
|
|
||||||
|
// Check if the response is OK
|
||||||
|
if (!response.ok) {
|
||||||
|
const errorData = await response.json().catch(() => null);
|
||||||
|
console.error(
|
||||||
|
"Error get data voting admin",
|
||||||
|
errorData?.message || "Unknown error"
|
||||||
|
);
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
return response.json();
|
||||||
|
} catch (error) {
|
||||||
|
console.log("Error get data voting admin", error);
|
||||||
|
throw error;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
|||||||
@@ -37,7 +37,7 @@ const apiPostVerifikasiCodeOtp = async ({ nomor }: { nomor: string }) => {
|
|||||||
};
|
};
|
||||||
|
|
||||||
const apiDeleteAktivasiKodeOtpByNomor = async ({ id }: { id: string }) => {
|
const apiDeleteAktivasiKodeOtpByNomor = async ({ id }: { id: string }) => {
|
||||||
const respone = await fetch(`/api/auth/code/${id}/peserta`, {
|
const respone = await fetch(`/api/auth/code/${id}`, {
|
||||||
method: "DELETE",
|
method: "DELETE",
|
||||||
headers: {
|
headers: {
|
||||||
"Content-Type": "application/json",
|
"Content-Type": "application/json",
|
||||||
|
|||||||
Reference in New Issue
Block a user