Fix: Job
Deskripsi: - Fix router status job - Fix hapus job beserta image di server
This commit is contained in:
@@ -28,7 +28,7 @@ export async function job_funCreateNoFile({ data }: { data: MODEL_JOB }) {
|
||||
});
|
||||
|
||||
if (!createNoImage) return { status: 400, message: "Gagal Disimpan" };
|
||||
revalidatePath("/dev/job/main/status");
|
||||
revalidatePath("/dev/job/main/status/2");
|
||||
return {
|
||||
status: 201,
|
||||
message: "Berhasil Disimpan",
|
||||
|
||||
@@ -4,16 +4,13 @@ import prisma from "@/app/lib/prisma";
|
||||
import { revalidatePath } from "next/cache";
|
||||
|
||||
export async function Job_funDeleteById(jobId: string) {
|
||||
const del = await prisma.job.update({
|
||||
const del = await prisma.job.delete({
|
||||
where: {
|
||||
id: jobId,
|
||||
},
|
||||
data: {
|
||||
isActive: false,
|
||||
},
|
||||
});
|
||||
|
||||
if (!del) return { status: 400, message: "Gagal hapus" };
|
||||
revalidatePath("/dev/job/main/status");
|
||||
revalidatePath("/dev/job/main/status/");
|
||||
return { status: 200, message: "Berhasil hapus" };
|
||||
}
|
||||
|
||||
@@ -24,7 +24,7 @@ export async function job_EditById({
|
||||
},
|
||||
});
|
||||
if (!updt) return { status: 400, message: "Gagal Update" };
|
||||
revalidatePath(RouterJob.status);
|
||||
revalidatePath("/dev/job/detail/draft");
|
||||
|
||||
return {
|
||||
status: 200,
|
||||
@@ -43,7 +43,7 @@ export async function job_EditById({
|
||||
},
|
||||
});
|
||||
if (!updtWithFile) return { status: 400, message: "Gagal Update" };
|
||||
revalidatePath(RouterJob.status);
|
||||
revalidatePath("/dev/job/detail/draft");
|
||||
|
||||
return {
|
||||
status: 200,
|
||||
|
||||
9
src/app_modules/job/fun/get/get_master_status.ts
Normal file
9
src/app_modules/job/fun/get/get_master_status.ts
Normal file
@@ -0,0 +1,9 @@
|
||||
"use server";
|
||||
|
||||
import { prisma } from "@/app/lib";
|
||||
|
||||
export async function job_funGetMasterStatus() {
|
||||
const data = await prisma.masterStatus.findMany({});
|
||||
|
||||
return data
|
||||
}
|
||||
50
src/app_modules/job/fun/get/status/get_all_by_status_id.ts
Normal file
50
src/app_modules/job/fun/get/status/get_all_by_status_id.ts
Normal file
@@ -0,0 +1,50 @@
|
||||
"use server";
|
||||
|
||||
import { prisma } from "@/app/lib";
|
||||
import { funGetUserIdByToken } from "@/app_modules/_global/fun/get";
|
||||
|
||||
export async function job_funGetAllByStatusId({
|
||||
page,
|
||||
statusId,
|
||||
}: {
|
||||
page: number;
|
||||
statusId: string;
|
||||
}) {
|
||||
const userLoginId = await funGetUserIdByToken();
|
||||
|
||||
const takeData = 10;
|
||||
const skipData = page * takeData - takeData;
|
||||
|
||||
if (statusId == "1") {
|
||||
const data = await prisma.job.findMany({
|
||||
take: takeData,
|
||||
skip: skipData,
|
||||
orderBy: {
|
||||
updatedAt: "desc",
|
||||
},
|
||||
where: {
|
||||
masterStatusId: "1",
|
||||
authorId: userLoginId,
|
||||
isActive: true,
|
||||
isArsip: false,
|
||||
},
|
||||
});
|
||||
|
||||
return data;
|
||||
} else {
|
||||
const data = await prisma.job.findMany({
|
||||
take: takeData,
|
||||
skip: skipData,
|
||||
orderBy: {
|
||||
updatedAt: "desc",
|
||||
},
|
||||
where: {
|
||||
masterStatusId: statusId,
|
||||
authorId: userLoginId,
|
||||
isActive: true,
|
||||
},
|
||||
});
|
||||
|
||||
return data;
|
||||
}
|
||||
}
|
||||
@@ -1,5 +1,7 @@
|
||||
import { job_funCreateNoFile } from "./create/fun_create_no_file";
|
||||
import { job_funCreateWithFile } from "./create/fun_create_with_file";
|
||||
import { job_funGetAllByStatusId } from "./get/status/get_all_by_status_id";
|
||||
|
||||
export { job_funCreateWithFile };
|
||||
export { job_funCreateNoFile };
|
||||
export { job_funGetAllByStatusId };
|
||||
|
||||
Reference in New Issue
Block a user