Fix Button Loader All Status in Event
This commit is contained in:
@@ -28,6 +28,7 @@ import { useState } from "react";
|
||||
import { WibuRealtime } from "wibu-pkg";
|
||||
import { Vote_funCreate } from "../fun/create/create_vote";
|
||||
import { gs_vote_hotMenu } from "../global_state";
|
||||
import { clientLogger } from "@/util/clientLogger";
|
||||
|
||||
export default function Vote_Create() {
|
||||
const router = useRouter();
|
||||
@@ -69,40 +70,49 @@ export default function Vote_Create() {
|
||||
|
||||
// console.log("berhasil");
|
||||
|
||||
const res = await Vote_funCreate(data as any, listVote);
|
||||
if (res.status === 201) {
|
||||
const dataNotifikasi: IRealtimeData = {
|
||||
appId: res.data?.id as any,
|
||||
status: res.data?.Voting_Status?.name as any,
|
||||
userId: res.data?.authorId as any,
|
||||
pesan: res.data?.title as any,
|
||||
kategoriApp: "VOTING",
|
||||
title: "Voting baru",
|
||||
};
|
||||
try {
|
||||
setIsLoading(true);
|
||||
const res = await Vote_funCreate(data as any, listVote);
|
||||
if (res.status === 201) {
|
||||
const dataNotifikasi: IRealtimeData = {
|
||||
appId: res.data?.id as any,
|
||||
status: res.data?.Voting_Status?.name as any,
|
||||
userId: res.data?.authorId as any,
|
||||
pesan: res.data?.title as any,
|
||||
kategoriApp: "VOTING",
|
||||
title: "Voting baru",
|
||||
};
|
||||
|
||||
const notif = await notifikasiToAdmin_funCreate({
|
||||
data: dataNotifikasi as any,
|
||||
});
|
||||
|
||||
if (notif.status === 201) {
|
||||
WibuRealtime.setData({
|
||||
type: "notification",
|
||||
pushNotificationTo: "ADMIN",
|
||||
const notif = await notifikasiToAdmin_funCreate({
|
||||
data: dataNotifikasi as any,
|
||||
});
|
||||
|
||||
WibuRealtime.setData({
|
||||
type: "trigger",
|
||||
pushNotificationTo: "ADMIN",
|
||||
dataMessage: dataNotifikasi,
|
||||
});
|
||||
if (notif.status === 201) {
|
||||
WibuRealtime.setData({
|
||||
type: "notification",
|
||||
pushNotificationTo: "ADMIN",
|
||||
});
|
||||
|
||||
setHotMenu(2);
|
||||
router.replace(RouterVote.status({ id: "2" }));
|
||||
ComponentGlobal_NotifikasiBerhasil(res.message);
|
||||
setIsLoading(true);
|
||||
WibuRealtime.setData({
|
||||
type: "trigger",
|
||||
pushNotificationTo: "ADMIN",
|
||||
dataMessage: dataNotifikasi,
|
||||
});
|
||||
|
||||
setHotMenu(2);
|
||||
router.replace(RouterVote.status({ id: "2" }));
|
||||
ComponentGlobal_NotifikasiBerhasil(res.message);
|
||||
|
||||
}
|
||||
} else {
|
||||
setIsLoading(false);
|
||||
ComponentGlobal_NotifikasiGagal(res.message);
|
||||
}
|
||||
} else {
|
||||
ComponentGlobal_NotifikasiGagal(res.message);
|
||||
|
||||
} catch (error) {
|
||||
setIsLoading(false);
|
||||
clientLogger.error("Error create voting", error);
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -273,10 +283,10 @@ export default function Vote_Create() {
|
||||
<Button
|
||||
disabled={
|
||||
!data.title ||
|
||||
!data.deskripsi ||
|
||||
!data.awalVote ||
|
||||
!data.akhirVote ||
|
||||
listVote.map((e, i) => e.value).includes("")
|
||||
!data.deskripsi ||
|
||||
!data.awalVote ||
|
||||
!data.akhirVote ||
|
||||
listVote.map((e, i) => e.value).includes("")
|
||||
? true
|
||||
: false
|
||||
}
|
||||
|
||||
@@ -31,6 +31,7 @@ import {
|
||||
MODEL_VOTING,
|
||||
MODEL_VOTING_DAFTAR_NAMA_VOTE,
|
||||
} from "../model/interface";
|
||||
import { clientLogger } from "@/util/clientLogger";
|
||||
|
||||
export default function Vote_Edit({
|
||||
dataVote,
|
||||
@@ -270,17 +271,24 @@ function ButtonAction({
|
||||
async function onUpdate() {
|
||||
// console.log(listVoting);
|
||||
|
||||
await Vote_funEditById(data, listVoting).then((res) => {
|
||||
if (res.status === 200) {
|
||||
ComponentGlobal_NotifikasiBerhasil("Berhasil Update");
|
||||
// setHotMenu(1);
|
||||
// setTabsStatus("Draft");
|
||||
router.back();
|
||||
setIsLoading(true);
|
||||
} else {
|
||||
ComponentGlobal_NotifikasiGagal(res.message);
|
||||
}
|
||||
});
|
||||
try {
|
||||
setIsLoading(true);
|
||||
await Vote_funEditById(data, listVoting).then((res) => {
|
||||
if (res.status === 200) {
|
||||
ComponentGlobal_NotifikasiBerhasil("Berhasil Update");
|
||||
// setHotMenu(1);
|
||||
// setTabsStatus("Draft");
|
||||
router.back();
|
||||
} else {
|
||||
setIsLoading(false);
|
||||
ComponentGlobal_NotifikasiGagal(res.message);
|
||||
}
|
||||
});
|
||||
|
||||
} catch (error) {
|
||||
setIsLoading(false);
|
||||
clientLogger.error("Error update voting", error);
|
||||
}
|
||||
}
|
||||
|
||||
return (
|
||||
|
||||
Reference in New Issue
Block a user