Merge pull request #230 from bipproduction/Nico/09Jan2025
Button Loading Collab, Voting & Investasi
This commit is contained in:
@@ -8,8 +8,8 @@ export const NEW_RouterInvestasi = {
|
||||
* @param param status id | 1: Publish, 2: Review, 3: Draft, 4: Reject
|
||||
* @type string
|
||||
*/
|
||||
portofolio: ({ id }: { id: "1" | "2" | "3" | "4" }) =>
|
||||
`/dev/investasi/main/portofolio/${id}`,
|
||||
portofolio: ({ id }: { id: "1" | "2" | "3" | "4" }) => `/dev/investasi/main/portofolio/${id}`,
|
||||
// portofolio: ({ id }: { id?: string }) => `/dev/investasi/main/portofolio/${id}`,
|
||||
|
||||
// TRANSAKSI
|
||||
pembelian: "/dev/investasi/transaksi/pembelian/",
|
||||
|
||||
@@ -195,13 +195,21 @@ function ButtonAction({ value }: { value: any }) {
|
||||
return ComponentGlobal_NotifikasiPeringatan("Pilih Industri");
|
||||
|
||||
const res = await colab_funCreateProyek(value);
|
||||
if (res.status === 201) {
|
||||
setLoading(true);
|
||||
router.back();
|
||||
ComponentGlobal_NotifikasiBerhasil(res.message);
|
||||
} else {
|
||||
ComponentGlobal_NotifikasiGagal(res.message);
|
||||
try {
|
||||
setLoading(true)
|
||||
if (res.status === 201) {
|
||||
setLoading(true);
|
||||
router.back();
|
||||
ComponentGlobal_NotifikasiBerhasil(res.message);
|
||||
} else {
|
||||
setLoading(false)
|
||||
ComponentGlobal_NotifikasiGagal(res.message);
|
||||
}
|
||||
} catch (error) {
|
||||
setLoading(false)
|
||||
clientLogger.error("Error create proyek", error);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -13,6 +13,7 @@ import {
|
||||
MODEL_COLLABORATION,
|
||||
MODEL_COLLABORATION_MASTER,
|
||||
} from "../model/interface";
|
||||
import { clientLogger } from "@/util/clientLogger";
|
||||
|
||||
export default function Colab_Edit({
|
||||
selectedData,
|
||||
@@ -211,12 +212,18 @@ function ButtonAction({ value }: { value: any }) {
|
||||
// return ComponentGlobal_NotifikasiPeringatan("Minimal Ada 2 Partisipan");
|
||||
|
||||
await colab_funEditById(value as any).then((res) => {
|
||||
if (res.status === 200) {
|
||||
try {
|
||||
setLoading(true);
|
||||
router.back();
|
||||
ComponentGlobal_NotifikasiBerhasil(res.message);
|
||||
} else {
|
||||
ComponentGlobal_NotifikasiGagal(res.message);
|
||||
if (res.status === 200) {
|
||||
router.back();
|
||||
ComponentGlobal_NotifikasiBerhasil(res.message);
|
||||
} else {
|
||||
setLoading(false)
|
||||
ComponentGlobal_NotifikasiGagal(res.message);
|
||||
}
|
||||
} catch (error) {
|
||||
setLoading(false)
|
||||
clientLogger.error("Error update proyek", error);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@@ -26,5 +26,5 @@ export default async function colab_funCreateProyek(
|
||||
|
||||
if (!data) return { status: 400, message: "Gagal Membuat Proyek" };
|
||||
revalidatePath(RouterColab.beranda);
|
||||
return { data, status: 201, message: "Berhasil Membuar Proyek" };
|
||||
return { data, status: 201, message: "Berhasil Membuat Proyek" };
|
||||
}
|
||||
|
||||
@@ -18,6 +18,7 @@ import { ComponentInvestasi_DetailDataNonPublish } from "../../component/detail/
|
||||
import { investasi_funEditStatusById } from "../../fun/edit/fun_edit_status_by_id";
|
||||
import { gs_investasi_status } from "../../g_state";
|
||||
import { MODEL_INVESTASI } from "../../_lib/interface";
|
||||
import { clientLogger } from "@/util/clientLogger";
|
||||
export default function DetailDraftInvestasi({
|
||||
dataInvestasi,
|
||||
}: {
|
||||
@@ -33,37 +34,43 @@ export default function DetailDraftInvestasi({
|
||||
statusId: "2",
|
||||
});
|
||||
|
||||
if (res.status === 200) {
|
||||
const dataNotif = {
|
||||
appId: res.data?.id,
|
||||
userId: res.data?.authorId,
|
||||
pesan: res.data?.title,
|
||||
status: res.data?.MasterStatusInvestasi?.name,
|
||||
kategoriApp: "INVESTASI",
|
||||
title: "Mengajukan review",
|
||||
};
|
||||
try {
|
||||
setIsLoading(true);
|
||||
if (res.status === 200) {
|
||||
const dataNotif = {
|
||||
appId: res.data?.id,
|
||||
userId: res.data?.authorId,
|
||||
pesan: res.data?.title,
|
||||
status: res.data?.MasterStatusInvestasi?.name,
|
||||
kategoriApp: "INVESTASI",
|
||||
title: "Mengajukan review",
|
||||
};
|
||||
|
||||
const notif = await notifikasiToAdmin_funCreate({
|
||||
data: dataNotif as any,
|
||||
});
|
||||
const notif = await notifikasiToAdmin_funCreate({
|
||||
data: dataNotif as any,
|
||||
});
|
||||
|
||||
if (notif.status === 201) {
|
||||
mqtt_client.publish("ADMIN", JSON.stringify({ count: 1 }));
|
||||
if (notif.status === 201) {
|
||||
mqtt_client.publish("ADMIN", JSON.stringify({ count: 1 }));
|
||||
|
||||
setIsLoading(true);
|
||||
ComponentGlobal_NotifikasiBerhasil("Review Berhasil Diajukan");
|
||||
router.push(RouterInvestasi_OLD.portofolio);
|
||||
setActiveTab("Review");
|
||||
ComponentGlobal_NotifikasiBerhasil("Review Berhasil Diajukan");
|
||||
router.push(RouterInvestasi_OLD.portofolio);
|
||||
setActiveTab("Review");
|
||||
}
|
||||
} else {
|
||||
setIsLoading(false);
|
||||
ComponentGlobal_NotifikasiGagal(res.message);
|
||||
}
|
||||
} else {
|
||||
ComponentGlobal_NotifikasiGagal(res.message);
|
||||
} catch (error) {
|
||||
setIsLoading(false);
|
||||
clientLogger.error("Error ajukan review", error);
|
||||
}
|
||||
}
|
||||
|
||||
return (
|
||||
<>
|
||||
<Stack mb={"lg"}>
|
||||
{dataInvestasi.catatan && <ComponentGlobal_BoxInformation informasi={dataInvestasi.catatan} isReport/>}
|
||||
{dataInvestasi.catatan && <ComponentGlobal_BoxInformation informasi={dataInvestasi.catatan} isReport />}
|
||||
<ComponentInvestasi_DetailDataNonPublish data={dataInvestasi} />
|
||||
<Stack>
|
||||
<Button
|
||||
|
||||
@@ -14,6 +14,8 @@ import { ComponentInvestasi_DetailDataNonPublish } from "../../component/detail/
|
||||
import { investasi_funEditStatusById } from "../../fun/edit/fun_edit_status_by_id";
|
||||
import funDeleteInvestasi from "../../fun/fun_delete_investasi";
|
||||
import { gs_investasi_status } from "../../g_state";
|
||||
import { clientLogger } from "@/util/clientLogger";
|
||||
import { AccentColor } from "@/app_modules/_global/color";
|
||||
|
||||
export default function DetailRejectInvestasi({
|
||||
dataInvestasi,
|
||||
@@ -22,8 +24,10 @@ export default function DetailRejectInvestasi({
|
||||
}) {
|
||||
const router = useRouter();
|
||||
const [investasi, setInvestasi] = useState(dataInvestasi);
|
||||
const [activeTab, setActiveTab] = useAtom(gs_investasi_status);
|
||||
const [openModal, setOpenModal] = useState(false);
|
||||
const [isLoading, setLoading] = useState(false);
|
||||
const [isLoading2, setLoading2] = useState(false);
|
||||
const [openModal1, setOpenModal1] = useState(false);
|
||||
const [openModal2, setOpenModal2] = useState(false);
|
||||
|
||||
async function onAjukan() {
|
||||
const res = await investasi_funEditStatusById({
|
||||
@@ -31,23 +35,37 @@ export default function DetailRejectInvestasi({
|
||||
statusId: "3",
|
||||
});
|
||||
|
||||
if (res.status === 200) {
|
||||
ComponentGlobal_NotifikasiBerhasil("Project Diajukan Kembali");
|
||||
setActiveTab("Draft");
|
||||
router.push(RouterInvestasi_OLD.portofolio);
|
||||
} else {
|
||||
ComponentGlobal_NotifikasiGagal("Gagal Pengajuan");
|
||||
try {
|
||||
setLoading(true);
|
||||
if (res.status === 200) {
|
||||
ComponentGlobal_NotifikasiBerhasil("Project Diajukan Kembali");
|
||||
setOpenModal2(false);
|
||||
router.push(RouterInvestasi_OLD.portofolio);
|
||||
} else {
|
||||
setLoading(false);
|
||||
ComponentGlobal_NotifikasiGagal("Gagal Pengajuan");
|
||||
}
|
||||
} catch (error) {
|
||||
setLoading(false);
|
||||
clientLogger.error("Error ajukan kembali", error);
|
||||
}
|
||||
}
|
||||
|
||||
async function onDelete() {
|
||||
await funDeleteInvestasi(investasi.id).then((res) => {
|
||||
if (res.status === 200) {
|
||||
ComponentGlobal_NotifikasiBerhasil(res.message);
|
||||
setOpenModal(false);
|
||||
router.push(RouterInvestasi_OLD.portofolio);
|
||||
} else {
|
||||
ComponentGlobal_NotifikasiGagal(res.message);
|
||||
try {
|
||||
setLoading2(true);
|
||||
if (res.status === 200) {
|
||||
ComponentGlobal_NotifikasiBerhasil(res.message);
|
||||
setOpenModal1(false);
|
||||
router.push(RouterInvestasi_OLD.portofolio);
|
||||
} else {
|
||||
setLoading2(false);
|
||||
ComponentGlobal_NotifikasiGagal(res.message);
|
||||
}
|
||||
} catch (error) {
|
||||
setLoading2(false);
|
||||
clientLogger.error("Error delete investasi", error);
|
||||
}
|
||||
});
|
||||
// setActiveTab("Reject");
|
||||
@@ -59,20 +77,48 @@ export default function DetailRejectInvestasi({
|
||||
|
||||
<UIGlobal_Modal
|
||||
title={"Anda Yakin Menghapus Data?"}
|
||||
opened={openModal}
|
||||
close={() => setOpenModal(false)}
|
||||
opened={openModal1}
|
||||
close={() => setOpenModal1(false)}
|
||||
buttonKiri={
|
||||
<Button radius={"xl"} onClick={() => setOpenModal(false)}>
|
||||
<Button radius={"xl"} onClick={() => setOpenModal1(false)}>
|
||||
Batal
|
||||
</Button>
|
||||
}
|
||||
buttonKanan={
|
||||
<Button bg={"red"} radius={"xl"} onClick={() => onDelete()}>
|
||||
<Button
|
||||
bg={"red"}
|
||||
loading={isLoading2 ? true : false}
|
||||
loaderPosition="center"
|
||||
radius={"xl"}
|
||||
onClick={() => onDelete()}>
|
||||
Hapus
|
||||
</Button>
|
||||
}
|
||||
/>
|
||||
|
||||
<UIGlobal_Modal
|
||||
title={"Anda Yakin Mengajukan Kembali?"}
|
||||
opened={openModal2}
|
||||
close={() => setOpenModal2(false)}
|
||||
buttonKiri={
|
||||
<Button
|
||||
radius={"xl"}
|
||||
onClick={() => setOpenModal2(false)}>
|
||||
Batal
|
||||
</Button>
|
||||
}
|
||||
buttonKanan={
|
||||
<Button
|
||||
loading={isLoading ? true : false}
|
||||
loaderPosition="center"
|
||||
bg={AccentColor.yellow}
|
||||
radius={"xl"}
|
||||
onClick={() => onAjukan()}>
|
||||
Ajukan
|
||||
</Button>
|
||||
}
|
||||
/>
|
||||
|
||||
<Stack>
|
||||
{/* Alasan */}
|
||||
<ComponentGlobal_BoxInformation
|
||||
@@ -89,18 +135,19 @@ export default function DetailRejectInvestasi({
|
||||
radius={50}
|
||||
bg={"orange.7"}
|
||||
color="yellow"
|
||||
onClick={() => onAjukan()}
|
||||
onClick={() => setOpenModal2(true)}
|
||||
>
|
||||
Edit Kembali
|
||||
</Button>
|
||||
|
||||
|
||||
{/* Tombol Hapus */}
|
||||
<Button
|
||||
mb={"xl"}
|
||||
radius={50}
|
||||
bg={"red.7"}
|
||||
color="yellow"
|
||||
onClick={() => setOpenModal(true)}
|
||||
onClick={() => setOpenModal1(true)}
|
||||
>
|
||||
Hapus
|
||||
</Button>
|
||||
|
||||
@@ -22,6 +22,7 @@ import { WibuRealtime } from "wibu-pkg";
|
||||
import { useShallowEffect } from "@mantine/hooks";
|
||||
import { voting_funGetOneVotingbyId } from "../../fun/get/fun_get_one_by_id";
|
||||
import _ from "lodash";
|
||||
import { clientLogger } from "@/util/clientLogger";
|
||||
|
||||
export default function Vote_DetailDraft({
|
||||
dataVote,
|
||||
@@ -109,12 +110,19 @@ function ButtonAction({
|
||||
|
||||
async function onDelete() {
|
||||
await Vote_funDeleteById(voteId).then((res) => {
|
||||
if (res.status === 200) {
|
||||
setOpenModal2(false);
|
||||
ComponentGlobal_NotifikasiBerhasil("Berhasil Hapus Vote", 2000);
|
||||
router.replace(RouterVote.status({ id: "3" }));
|
||||
} else {
|
||||
ComponentGlobal_NotifikasiGagal(res.message);
|
||||
try {
|
||||
setIsLoading(true);
|
||||
if (res.status === 200) {
|
||||
setOpenModal2(false);
|
||||
ComponentGlobal_NotifikasiBerhasil("Berhasil Hapus Vote", 2000);
|
||||
router.replace(RouterVote.status({ id: "3" }));
|
||||
} else {
|
||||
setIsLoading(false);
|
||||
ComponentGlobal_NotifikasiGagal(res.message);
|
||||
}
|
||||
} catch (error) {
|
||||
setIsLoading(false);
|
||||
clientLogger.error("Error delete vote", error);
|
||||
}
|
||||
});
|
||||
}
|
||||
@@ -194,6 +202,8 @@ function ButtonAction({
|
||||
buttonKanan={
|
||||
<Button
|
||||
radius={"xl"}
|
||||
loaderPosition="center"
|
||||
loading={isLoading ? true : false}
|
||||
onClick={() => {
|
||||
onDelete();
|
||||
}}
|
||||
|
||||
@@ -15,6 +15,7 @@ import { gs_vote_status } from "../../global_state";
|
||||
import { MODEL_VOTING } from "../../model/interface";
|
||||
import { RouterVote } from "@/app/lib/router_hipmi/router_vote";
|
||||
import { AccentColor, MainColor } from "@/app_modules/_global/color";
|
||||
import { clientLogger } from "@/util/clientLogger";
|
||||
|
||||
export default function Vote_DetailReject({
|
||||
dataVote,
|
||||
@@ -42,24 +43,37 @@ function ButtonAction({ voteId }: { voteId: string }) {
|
||||
|
||||
async function onUpdate() {
|
||||
await Vote_funEditStatusByStatusId(voteId, "3").then((res) => {
|
||||
if (res.status === 200) {
|
||||
try {
|
||||
setIsLoading(true);
|
||||
ComponentGlobal_NotifikasiBerhasil("Berhasil Masuk Draft", 2000);
|
||||
router.replace(RouterVote.status({ id: "3" }));
|
||||
} else {
|
||||
ComponentGlobal_NotifikasiGagal(res.message);
|
||||
if (res.status === 200) {
|
||||
ComponentGlobal_NotifikasiBerhasil("Berhasil Masuk Draft", 2000);
|
||||
router.replace(RouterVote.status({ id: "3" }));
|
||||
} else {
|
||||
setIsLoading(false);
|
||||
ComponentGlobal_NotifikasiGagal(res.message);
|
||||
}
|
||||
} catch (error) {
|
||||
setIsLoading(false);
|
||||
clientLogger.error("Error update voting", error);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
async function onDelete() {
|
||||
await Vote_funDeleteById(voteId).then((res) => {
|
||||
if (res.status === 200) {
|
||||
setOpenModal2(false);
|
||||
ComponentGlobal_NotifikasiBerhasil("Berhasil Hapus Vote", 2000);
|
||||
router.replace(RouterVote.status({ id: "4" }));
|
||||
} else {
|
||||
ComponentGlobal_NotifikasiGagal(res.message);
|
||||
try {
|
||||
setIsLoading(true);
|
||||
if (res.status === 200) {
|
||||
setOpenModal2(false);
|
||||
ComponentGlobal_NotifikasiBerhasil("Berhasil Hapus Vote", 2000);
|
||||
router.replace(RouterVote.status({ id: "4" }));
|
||||
} else {
|
||||
setIsLoading(false);
|
||||
ComponentGlobal_NotifikasiGagal(res.message);
|
||||
}
|
||||
} catch (error) {
|
||||
setIsLoading(false);
|
||||
clientLogger.error("Error delete vote", error);
|
||||
}
|
||||
});
|
||||
}
|
||||
@@ -69,10 +83,10 @@ function ButtonAction({ voteId }: { voteId: string }) {
|
||||
<SimpleGrid cols={2}>
|
||||
<Button
|
||||
radius={"xl"}
|
||||
style={{ backgroundColor: AccentColor.yellow, fontWeight:"bold" }}
|
||||
style={{ backgroundColor: AccentColor.yellow, fontWeight: "bold" }}
|
||||
c={MainColor.darkblue}
|
||||
onClick={() => {
|
||||
setOpenModal1(true);
|
||||
setOpenModal1(true);
|
||||
}}
|
||||
>
|
||||
Edit Kembali
|
||||
@@ -80,7 +94,7 @@ function ButtonAction({ voteId }: { voteId: string }) {
|
||||
<Button
|
||||
radius={"xl"}
|
||||
c={AccentColor.white}
|
||||
style={{ backgroundColor: MainColor.red, fontWeight:"bold" }}
|
||||
style={{ backgroundColor: MainColor.red, fontWeight: "bold" }}
|
||||
onClick={() => {
|
||||
setOpenModal2(true);
|
||||
}}
|
||||
@@ -137,6 +151,8 @@ function ButtonAction({ voteId }: { voteId: string }) {
|
||||
}
|
||||
buttonKanan={
|
||||
<Button
|
||||
loading={isLoading ? true : false}
|
||||
loaderPosition="center"
|
||||
radius={"xl"}
|
||||
onClick={() => {
|
||||
onDelete();
|
||||
|
||||
@@ -118,7 +118,6 @@ function ButtonAction({
|
||||
c={MainColor.darkblue}
|
||||
onClick={() => {
|
||||
onUpdate();
|
||||
console.log(statusId);
|
||||
}}
|
||||
>
|
||||
Simpan
|
||||
|
||||
Reference in New Issue
Block a user