fix:
Deksripsi: - Progress investasi - Tampilan voting ## No issue
This commit is contained in:
@@ -1,14 +1,14 @@
|
||||
"use server";
|
||||
|
||||
import prisma from "@/app/lib/prisma";
|
||||
import { user_getOneUserId } from "@/app_modules/fun_global/get_user_token";
|
||||
import { user_funGetOneUserId } from "@/app_modules/fun_global/get_user_token";
|
||||
import { revalidatePath } from "next/cache";
|
||||
|
||||
export async function Vote_funCreateHasil(
|
||||
pilihanVotingId: string,
|
||||
votingId: string
|
||||
) {
|
||||
const authorId = await user_getOneUserId();
|
||||
const authorId = await user_funGetOneUserId();
|
||||
|
||||
const get = await prisma.voting_DaftarNamaVote.findFirst({
|
||||
where: {
|
||||
|
||||
@@ -1,14 +1,14 @@
|
||||
"use server";
|
||||
|
||||
import prisma from "@/app/lib/prisma";
|
||||
import { user_getOneUserId } from "@/app_modules/fun_global/get_user_token";
|
||||
import { user_funGetOneUserId } from "@/app_modules/fun_global/get_user_token";
|
||||
import { revalidatePath } from "next/cache";
|
||||
|
||||
export async function Vote_funCreatePilihanVotingById(
|
||||
namaVotingId: string,
|
||||
votingId: string
|
||||
) {
|
||||
const authorId = await user_getOneUserId();
|
||||
const authorId = await user_funGetOneUserId();
|
||||
|
||||
const create = await prisma.voting_Kontributor.create({
|
||||
data: {
|
||||
|
||||
@@ -1,16 +1,17 @@
|
||||
"use server";
|
||||
|
||||
import { user_getOneUserId } from "@/app_modules/fun_global/get_user_token";
|
||||
import { user_funGetOneUserId } from "@/app_modules/fun_global/get_user_token";
|
||||
import { MODEL_VOTING } from "../../model/interface";
|
||||
import prisma from "@/app/lib/prisma";
|
||||
import { revalidatePath } from "next/cache";
|
||||
import _ from "lodash";
|
||||
|
||||
export async function Vote_funCreate(req: MODEL_VOTING, listVote: any[]) {
|
||||
const authorId = await user_getOneUserId();
|
||||
const authorId = await user_funGetOneUserId();
|
||||
|
||||
const create = await prisma.voting.create({
|
||||
data: {
|
||||
title: req.title,
|
||||
title: _.startCase(req.title),
|
||||
deskripsi: req.deskripsi,
|
||||
awalVote: req.awalVote,
|
||||
akhirVote: req.akhirVote,
|
||||
|
||||
28
src/app_modules/vote/fun/edit/fun_update_is_arsip_by_id.ts
Normal file
28
src/app_modules/vote/fun/edit/fun_update_is_arsip_by_id.ts
Normal file
@@ -0,0 +1,28 @@
|
||||
"use server";
|
||||
|
||||
import prisma from "@/app/lib/prisma";
|
||||
import { RouterVote } from "@/app/lib/router_hipmi/router_vote";
|
||||
import { revalidatePath } from "next/cache";
|
||||
|
||||
export async function voting_funUpdateIsArsipById({
|
||||
votingId,
|
||||
isArsip,
|
||||
}: {
|
||||
votingId: string;
|
||||
isArsip: boolean;
|
||||
}) {
|
||||
const updt = await prisma.voting.update({
|
||||
where: {
|
||||
id: votingId,
|
||||
},
|
||||
data: {
|
||||
isArsip: isArsip,
|
||||
},
|
||||
});
|
||||
|
||||
if (!updt) return { status: 400, message: "Gagal Update" };
|
||||
revalidatePath(RouterVote.main_detail);
|
||||
revalidatePath(RouterVote.detail_publish);
|
||||
|
||||
return { status: 200, message: "Berhasil Update" };
|
||||
}
|
||||
@@ -1,10 +1,10 @@
|
||||
"use server";
|
||||
|
||||
import prisma from "@/app/lib/prisma";
|
||||
import { user_getOneUserId } from "@/app_modules/fun_global/get_user_token";
|
||||
import { user_funGetOneUserId } from "@/app_modules/fun_global/get_user_token";
|
||||
|
||||
export async function Vote_cekKontributorById(votingId: string) {
|
||||
const UserId = await user_getOneUserId()
|
||||
const UserId = await user_funGetOneUserId()
|
||||
|
||||
const cek = await prisma.voting_Kontributor.count({
|
||||
where: {
|
||||
|
||||
@@ -2,23 +2,12 @@
|
||||
|
||||
import prisma from "@/app/lib/prisma";
|
||||
|
||||
export async function Vote_getOnebyId(voteId: string) {
|
||||
export async function voting_funGetOneVotingbyId(voteId: string) {
|
||||
const data = await prisma.voting.findFirst({
|
||||
where: {
|
||||
id: voteId,
|
||||
},
|
||||
select: {
|
||||
id: true,
|
||||
title: true,
|
||||
isActive: true,
|
||||
createdAt: true,
|
||||
updatedAt: true,
|
||||
deskripsi: true,
|
||||
awalVote: true,
|
||||
akhirVote: true,
|
||||
catatan: true,
|
||||
authorId: true,
|
||||
voting_StatusId: true,
|
||||
include: {
|
||||
Voting_DaftarNamaVote: {
|
||||
orderBy: {
|
||||
createdAt: "asc",
|
||||
@@ -1,9 +1,15 @@
|
||||
"use server";
|
||||
|
||||
import prisma from "@/app/lib/prisma";
|
||||
import { user_getOneUserId } from "@/app_modules/fun_global/get_user_token";
|
||||
import { user_funGetOneUserId } from "@/app_modules/fun_global/get_user_token";
|
||||
|
||||
export async function vote_getAllListPublish({ page }: { page: number }) {
|
||||
export async function vote_getAllListPublish({
|
||||
page,
|
||||
search,
|
||||
}: {
|
||||
page: number;
|
||||
search?: string;
|
||||
}) {
|
||||
const takeData = 5;
|
||||
const skipData = page * takeData - takeData;
|
||||
|
||||
@@ -15,10 +21,15 @@ export async function vote_getAllListPublish({ page }: { page: number }) {
|
||||
},
|
||||
where: {
|
||||
voting_StatusId: "1",
|
||||
isArsip: false,
|
||||
isActive: true,
|
||||
akhirVote: {
|
||||
gte: new Date(),
|
||||
},
|
||||
title: {
|
||||
contains: search,
|
||||
mode: "insensitive",
|
||||
},
|
||||
},
|
||||
select: {
|
||||
id: true,
|
||||
@@ -36,6 +47,13 @@ export async function vote_getAllListPublish({ page }: { page: number }) {
|
||||
orderBy: {
|
||||
createdAt: "asc",
|
||||
},
|
||||
include: {
|
||||
Voting_Kontributor: {
|
||||
include: {
|
||||
Author: true,
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
Author: {
|
||||
select: {
|
||||
|
||||
@@ -1,10 +1,10 @@
|
||||
"use server";
|
||||
|
||||
import { user_getOneUserId } from "@/app_modules/fun_global/get_user_token";
|
||||
import { user_funGetOneUserId } from "@/app_modules/fun_global/get_user_token";
|
||||
import prisma from "@/app/lib/prisma";
|
||||
|
||||
export async function Vote_getAllListRiwayatSaya({ page }: { page: number }) {
|
||||
const authorId = await user_getOneUserId();
|
||||
const authorId = await user_funGetOneUserId();
|
||||
const takeData = 5;
|
||||
const skipData = page * takeData - takeData;
|
||||
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
"use server";
|
||||
|
||||
import prisma from "@/app/lib/prisma";
|
||||
import { user_getOneUserId } from "@/app_modules/fun_global/get_user_token";
|
||||
import { user_funGetOneUserId } from "@/app_modules/fun_global/get_user_token";
|
||||
|
||||
export async function vote_getAllListKontribusiByAuthorId({
|
||||
page,
|
||||
@@ -11,7 +11,7 @@ export async function vote_getAllListKontribusiByAuthorId({
|
||||
const takeData = 5;
|
||||
const skipData = page * takeData - takeData;
|
||||
|
||||
const authorId = await user_getOneUserId();
|
||||
const authorId = await user_funGetOneUserId();
|
||||
const data = await prisma.voting_Kontributor.findMany({
|
||||
take: takeData,
|
||||
skip: skipData,
|
||||
|
||||
@@ -7,10 +7,9 @@ export async function Vote_getListKontributorById(votingId: string) {
|
||||
where: {
|
||||
votingId: votingId,
|
||||
},
|
||||
select: {
|
||||
id: true,
|
||||
include: {
|
||||
Author: {
|
||||
select: {
|
||||
include: {
|
||||
Profile: true,
|
||||
},
|
||||
},
|
||||
|
||||
@@ -1,10 +1,10 @@
|
||||
"use server";
|
||||
|
||||
import prisma from "@/app/lib/prisma";
|
||||
import { user_getOneUserId } from "@/app_modules/fun_global/get_user_token";
|
||||
import { user_funGetOneUserId } from "@/app_modules/fun_global/get_user_token";
|
||||
|
||||
export async function Vote_getOnePilihanVotingByUserId(votingId: string) {
|
||||
const userId = await user_getOneUserId();
|
||||
const userId = await user_funGetOneUserId();
|
||||
const get = await prisma.voting_Kontributor.findFirst({
|
||||
where: {
|
||||
authorId: userId,
|
||||
|
||||
3
src/app_modules/vote/fun/get/index.ts
Normal file
3
src/app_modules/vote/fun/get/index.ts
Normal file
@@ -0,0 +1,3 @@
|
||||
import { voting_funGetOneVotingbyId } from "./fun_get_one_by_id";
|
||||
|
||||
export { voting_funGetOneVotingbyId as Voting_funGetOneVotingbyId };
|
||||
@@ -1,10 +1,10 @@
|
||||
"use server";
|
||||
|
||||
import prisma from "@/app/lib/prisma";
|
||||
import { user_getOneUserId } from "@/app_modules/fun_global/get_user_token";
|
||||
import { user_funGetOneUserId } from "@/app_modules/fun_global/get_user_token";
|
||||
|
||||
export async function vote_getAllDraft({ page }: { page: number }) {
|
||||
const authorId = await user_getOneUserId();
|
||||
const authorId = await user_funGetOneUserId();
|
||||
|
||||
const takeData = 10;
|
||||
const skipData = page * takeData - takeData;
|
||||
|
||||
@@ -1,10 +1,10 @@
|
||||
"use server";
|
||||
|
||||
import prisma from "@/app/lib/prisma";
|
||||
import { user_getOneUserId } from "@/app_modules/fun_global/get_user_token";
|
||||
import { user_funGetOneUserId } from "@/app_modules/fun_global/get_user_token";
|
||||
|
||||
export async function vote_getAllPublish({ page }: { page: number }) {
|
||||
const authorId = await user_getOneUserId();
|
||||
const authorId = await user_funGetOneUserId();
|
||||
|
||||
const takeData = 5;
|
||||
const skipData = page * takeData - takeData;
|
||||
@@ -23,18 +23,7 @@ export async function vote_getAllPublish({ page }: { page: number }) {
|
||||
gte: new Date(),
|
||||
},
|
||||
},
|
||||
select: {
|
||||
id: true,
|
||||
title: true,
|
||||
isActive: true,
|
||||
createdAt: true,
|
||||
updatedAt: true,
|
||||
deskripsi: true,
|
||||
awalVote: true,
|
||||
akhirVote: true,
|
||||
catatan: true,
|
||||
authorId: true,
|
||||
voting_StatusId: true,
|
||||
include: {
|
||||
Voting_DaftarNamaVote: {
|
||||
orderBy: {
|
||||
createdAt: "asc",
|
||||
@@ -43,5 +32,6 @@ export async function vote_getAllPublish({ page }: { page: number }) {
|
||||
},
|
||||
});
|
||||
|
||||
|
||||
return data;
|
||||
}
|
||||
|
||||
@@ -1,10 +1,10 @@
|
||||
"use server";
|
||||
|
||||
import prisma from "@/app/lib/prisma";
|
||||
import { user_getOneUserId } from "@/app_modules/fun_global/get_user_token";
|
||||
import { user_funGetOneUserId } from "@/app_modules/fun_global/get_user_token";
|
||||
|
||||
export async function vote_getAllReject({ page }: { page: number }) {
|
||||
const authorId = await user_getOneUserId();
|
||||
const authorId = await user_funGetOneUserId();
|
||||
|
||||
const takeData = 10;
|
||||
const skipData = page * takeData - takeData;
|
||||
|
||||
@@ -1,10 +1,10 @@
|
||||
"use server";
|
||||
|
||||
import prisma from "@/app/lib/prisma";
|
||||
import { user_getOneUserId } from "@/app_modules/fun_global/get_user_token";
|
||||
import { user_funGetOneUserId } from "@/app_modules/fun_global/get_user_token";
|
||||
|
||||
export async function vote_getAllReview({ page }: { page: number }) {
|
||||
const authorId = await user_getOneUserId();
|
||||
const authorId = await user_funGetOneUserId();
|
||||
|
||||
const takeData = 10;
|
||||
const skipData = page * takeData - takeData;
|
||||
|
||||
3
src/app_modules/vote/fun/index.ts
Normal file
3
src/app_modules/vote/fun/index.ts
Normal file
@@ -0,0 +1,3 @@
|
||||
import { voting_funUpdateIsArsipById } from "./edit/fun_update_is_arsip_by_id";
|
||||
|
||||
export { voting_funUpdateIsArsipById };
|
||||
Reference in New Issue
Block a user