Fix Button Loader All Status in Event
This commit is contained in:
@@ -254,7 +254,7 @@ export default function ComponentColab_DetailListPartisipasiUser({
|
|||||||
borderRight: `1px solid ${AccentColor.blue}`,
|
borderRight: `1px solid ${AccentColor.blue}`,
|
||||||
borderLeft: `1px solid ${AccentColor.blue}`,
|
borderLeft: `1px solid ${AccentColor.blue}`,
|
||||||
borderRadius: "20px 20px 0px 0px",
|
borderRadius: "20px 20px 0px 0px",
|
||||||
color: "white",
|
color: MainColor.white,
|
||||||
paddingBottom: "5%",
|
paddingBottom: "5%",
|
||||||
},
|
},
|
||||||
}}
|
}}
|
||||||
@@ -262,16 +262,21 @@ export default function ComponentColab_DetailListPartisipasiUser({
|
|||||||
<Stack spacing={"xs"}>
|
<Stack spacing={"xs"}>
|
||||||
<Group position="right">
|
<Group position="right">
|
||||||
<ActionIcon onClick={close} variant="transparent">
|
<ActionIcon onClick={close} variant="transparent">
|
||||||
<IconX color="white" />
|
<IconX color={MainColor.white} />
|
||||||
</ActionIcon>
|
</ActionIcon>
|
||||||
</Group>
|
</Group>
|
||||||
<Textarea
|
<Textarea
|
||||||
maxLength={300}
|
maxLength={300}
|
||||||
label={
|
label={
|
||||||
<Text c={"white"} mb={"sm"} fw={"bold"}>
|
<Text c={MainColor.white} mb={"sm"} fw={"bold"}>
|
||||||
Deskripsi Diri
|
Deskripsi Diri
|
||||||
</Text>
|
</Text>
|
||||||
}
|
}
|
||||||
|
styles={{
|
||||||
|
input: {
|
||||||
|
backgroundColor: MainColor.white
|
||||||
|
}
|
||||||
|
}}
|
||||||
placeholder="Deskripsikan diri anda yang sesuai dengan proyek ini.."
|
placeholder="Deskripsikan diri anda yang sesuai dengan proyek ini.."
|
||||||
minRows={4}
|
minRows={4}
|
||||||
onChange={(val) => {
|
onChange={(val) => {
|
||||||
|
|||||||
@@ -30,8 +30,14 @@ export default function Colab_Edit({
|
|||||||
maxLength={100}
|
maxLength={100}
|
||||||
styles={{
|
styles={{
|
||||||
label: {
|
label: {
|
||||||
color: "white",
|
color: MainColor.white,
|
||||||
},
|
},
|
||||||
|
input: {
|
||||||
|
backgroundColor: MainColor.white,
|
||||||
|
},
|
||||||
|
required: {
|
||||||
|
color: MainColor.red,
|
||||||
|
}
|
||||||
}}
|
}}
|
||||||
label="Judul"
|
label="Judul"
|
||||||
withAsterisk
|
withAsterisk
|
||||||
@@ -49,8 +55,14 @@ export default function Colab_Edit({
|
|||||||
maxLength={100}
|
maxLength={100}
|
||||||
styles={{
|
styles={{
|
||||||
label: {
|
label: {
|
||||||
color: "white",
|
color: MainColor.white,
|
||||||
},
|
},
|
||||||
|
input: {
|
||||||
|
backgroundColor: MainColor.white,
|
||||||
|
},
|
||||||
|
required: {
|
||||||
|
color: MainColor.red,
|
||||||
|
}
|
||||||
}}
|
}}
|
||||||
label="Lokasi"
|
label="Lokasi"
|
||||||
withAsterisk
|
withAsterisk
|
||||||
@@ -67,8 +79,17 @@ export default function Colab_Edit({
|
|||||||
<Select
|
<Select
|
||||||
styles={{
|
styles={{
|
||||||
label: {
|
label: {
|
||||||
color: "white",
|
color: MainColor.white,
|
||||||
},
|
},
|
||||||
|
input: {
|
||||||
|
backgroundColor: MainColor.white,
|
||||||
|
},
|
||||||
|
required: {
|
||||||
|
color: MainColor.red,
|
||||||
|
},
|
||||||
|
dropdown: {
|
||||||
|
backgroundColor: MainColor.white,
|
||||||
|
}
|
||||||
}}
|
}}
|
||||||
placeholder="Pilih kategori industri"
|
placeholder="Pilih kategori industri"
|
||||||
label="Pilih Industri"
|
label="Pilih Industri"
|
||||||
@@ -113,8 +134,14 @@ export default function Colab_Edit({
|
|||||||
<Textarea
|
<Textarea
|
||||||
styles={{
|
styles={{
|
||||||
label: {
|
label: {
|
||||||
color: "white",
|
color: MainColor.white,
|
||||||
},
|
},
|
||||||
|
input: {
|
||||||
|
backgroundColor: MainColor.white,
|
||||||
|
},
|
||||||
|
required: {
|
||||||
|
color: MainColor.red,
|
||||||
|
}
|
||||||
}}
|
}}
|
||||||
label="Tujuan Proyek"
|
label="Tujuan Proyek"
|
||||||
placeholder="Masukan tujuan proyek"
|
placeholder="Masukan tujuan proyek"
|
||||||
@@ -138,7 +165,10 @@ export default function Colab_Edit({
|
|||||||
<Textarea
|
<Textarea
|
||||||
styles={{
|
styles={{
|
||||||
label: {
|
label: {
|
||||||
color: "white",
|
color: MainColor.white,
|
||||||
|
},
|
||||||
|
input: {
|
||||||
|
backgroundColor: MainColor.white,
|
||||||
},
|
},
|
||||||
}}
|
}}
|
||||||
label="Keuntungan "
|
label="Keuntungan "
|
||||||
|
|||||||
@@ -4,6 +4,7 @@ import { ComponentGlobal_CardStyles } from "@/app_modules/_global/component";
|
|||||||
import { Grid, Stack, Text, Title } from "@mantine/core";
|
import { Grid, Stack, Text, Title } from "@mantine/core";
|
||||||
import { MODEL_EVENT } from "../../model/interface";
|
import { MODEL_EVENT } from "../../model/interface";
|
||||||
import { MainColor } from "@/app_modules/_global/color";
|
import { MainColor } from "@/app_modules/_global/color";
|
||||||
|
import { Event_ComponentSkeletonDetailData } from "../skeleton/comp_skeleton_detail_data";
|
||||||
|
|
||||||
export default function ComponentEvent_DetailData({
|
export default function ComponentEvent_DetailData({
|
||||||
data,
|
data,
|
||||||
@@ -84,7 +85,7 @@ export default function ComponentEvent_DetailData({
|
|||||||
<Text c={MainColor.white}>{data ? data?.deskripsi : null}</Text>
|
<Text c={MainColor.white}>{data ? data?.deskripsi : null}</Text>
|
||||||
</Stack>
|
</Stack>
|
||||||
</Stack>
|
</Stack>
|
||||||
</ComponentGlobal_CardStyles>
|
</ComponentGlobal_CardStyles >
|
||||||
</>
|
</>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -19,6 +19,7 @@ import { Event_funDeleteById } from "../../fun/delete/fun_delete";
|
|||||||
import { Event_funEditStatusById } from "../../fun/edit/fun_edit_status_by_id";
|
import { Event_funEditStatusById } from "../../fun/edit/fun_edit_status_by_id";
|
||||||
import { MODEL_EVENT } from "../../model/interface";
|
import { MODEL_EVENT } from "../../model/interface";
|
||||||
import { AccentColor, MainColor } from "@/app_modules/_global/color";
|
import { AccentColor, MainColor } from "@/app_modules/_global/color";
|
||||||
|
import { clientLogger } from "@/util/clientLogger";
|
||||||
|
|
||||||
export default function Event_DetailDraft({
|
export default function Event_DetailDraft({
|
||||||
dataEvent,
|
dataEvent,
|
||||||
@@ -68,12 +69,18 @@ function ButtonAction({
|
|||||||
|
|
||||||
async function onDelete() {
|
async function onDelete() {
|
||||||
const res = await Event_funDeleteById(eventId);
|
const res = await Event_funDeleteById(eventId);
|
||||||
if (res.status === 200) {
|
try {
|
||||||
router.back();
|
|
||||||
ComponentGlobal_NotifikasiBerhasil(res.message, 2000);
|
|
||||||
setLoadingDelete(true);
|
setLoadingDelete(true);
|
||||||
} else {
|
if (res.status === 200) {
|
||||||
ComponentGlobal_NotifikasiGagal(res.message);
|
router.back();
|
||||||
|
ComponentGlobal_NotifikasiBerhasil(res.message, 2000);
|
||||||
|
} else {
|
||||||
|
setLoadingDelete(false);
|
||||||
|
ComponentGlobal_NotifikasiGagal(res.message);
|
||||||
|
}
|
||||||
|
} catch (error) {
|
||||||
|
setLoadingDelete(false);
|
||||||
|
clientLogger.error("Error delete event", error);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -158,7 +165,7 @@ function ButtonAction({
|
|||||||
}
|
}
|
||||||
buttonKanan={
|
buttonKanan={
|
||||||
<Button
|
<Button
|
||||||
style={{ backgroundColor: AccentColor.yellow }}
|
style={{ backgroundColor: AccentColor.yellow }}
|
||||||
loaderPosition="center"
|
loaderPosition="center"
|
||||||
loading={isLoadingAjukan ? true : false}
|
loading={isLoadingAjukan ? true : false}
|
||||||
radius={"xl"}
|
radius={"xl"}
|
||||||
|
|||||||
@@ -16,6 +16,7 @@ import { Event_countTotalPesertaById } from "../../fun/count/count_total_peserta
|
|||||||
import { Event_funJoinEvent } from "../../fun/create/fun_join_event";
|
import { Event_funJoinEvent } from "../../fun/create/fun_join_event";
|
||||||
import { Event_getListPesertaById } from "../../fun/get/get_list_peserta_by_id";
|
import { Event_getListPesertaById } from "../../fun/get/get_list_peserta_by_id";
|
||||||
import { AccentColor, MainColor } from "@/app_modules/_global/color";
|
import { AccentColor, MainColor } from "@/app_modules/_global/color";
|
||||||
|
import { clientLogger } from "@/util/clientLogger";
|
||||||
|
|
||||||
export default function Event_DetailMain({
|
export default function Event_DetailMain({
|
||||||
userLoginId,
|
userLoginId,
|
||||||
@@ -57,7 +58,7 @@ export default function Event_DetailMain({
|
|||||||
Anda Telah Ikut Serta
|
Anda Telah Ikut Serta
|
||||||
</Button>
|
</Button>
|
||||||
) : (
|
) : (
|
||||||
<Button
|
<Button
|
||||||
style={{ backgroundColor: MainColor.green }}
|
style={{ backgroundColor: MainColor.green }}
|
||||||
loaderPosition="center"
|
loaderPosition="center"
|
||||||
loading={isLoading ? true : false}
|
loading={isLoading ? true : false}
|
||||||
@@ -104,40 +105,46 @@ async function onJoin(
|
|||||||
|
|
||||||
const userLoginId = userId;
|
const userLoginId = userId;
|
||||||
|
|
||||||
const res = await Event_funJoinEvent(body as any);
|
try {
|
||||||
if (res.status === 200) {
|
|
||||||
const resPeserta = await Event_getListPesertaById(eventId);
|
|
||||||
setIsNewPeserta(true);
|
|
||||||
|
|
||||||
const resTotal = await Event_countTotalPesertaById(eventId);
|
|
||||||
setTotal(resTotal);
|
|
||||||
|
|
||||||
if (userLoginId !== res.data?.Event?.authorId) {
|
|
||||||
const dataNotifikasi: IRealtimeData = {
|
|
||||||
appId: res?.data?.Event?.id as any,
|
|
||||||
status: "Peserta Event" as any,
|
|
||||||
userId: res.data?.Event?.authorId as any,
|
|
||||||
pesan: res.data?.Event?.title as any,
|
|
||||||
kategoriApp: "EVENT",
|
|
||||||
title: "Peserta baru event anda !",
|
|
||||||
};
|
|
||||||
|
|
||||||
const createNotifikasi = await notifikasiToUser_funCreate({
|
|
||||||
data: dataNotifikasi as any,
|
|
||||||
});
|
|
||||||
|
|
||||||
if (createNotifikasi.status === 201) {
|
|
||||||
WibuRealtime.setData({
|
|
||||||
type: "notification",
|
|
||||||
pushNotificationTo: "USER",
|
|
||||||
dataMessage: dataNotifikasi,
|
|
||||||
});
|
|
||||||
}
|
|
||||||
}
|
|
||||||
setIsJoinSuccess(true);
|
|
||||||
setLoading(true);
|
setLoading(true);
|
||||||
ComponentGlobal_NotifikasiBerhasil(res.message, 2000);
|
const res = await Event_funJoinEvent(body as any);
|
||||||
} else {
|
if (res.status === 200) {
|
||||||
ComponentGlobal_NotifikasiGagal(res.message);
|
const resPeserta = await Event_getListPesertaById(eventId);
|
||||||
|
setIsNewPeserta(true);
|
||||||
|
|
||||||
|
const resTotal = await Event_countTotalPesertaById(eventId);
|
||||||
|
setTotal(resTotal);
|
||||||
|
|
||||||
|
if (userLoginId !== res.data?.Event?.authorId) {
|
||||||
|
const dataNotifikasi: IRealtimeData = {
|
||||||
|
appId: res?.data?.Event?.id as any,
|
||||||
|
status: "Peserta Event" as any,
|
||||||
|
userId: res.data?.Event?.authorId as any,
|
||||||
|
pesan: res.data?.Event?.title as any,
|
||||||
|
kategoriApp: "EVENT",
|
||||||
|
title: "Peserta baru event anda !",
|
||||||
|
};
|
||||||
|
|
||||||
|
const createNotifikasi = await notifikasiToUser_funCreate({
|
||||||
|
data: dataNotifikasi as any,
|
||||||
|
});
|
||||||
|
|
||||||
|
if (createNotifikasi.status === 201) {
|
||||||
|
WibuRealtime.setData({
|
||||||
|
type: "notification",
|
||||||
|
pushNotificationTo: "USER",
|
||||||
|
dataMessage: dataNotifikasi,
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
setIsJoinSuccess(true);
|
||||||
|
ComponentGlobal_NotifikasiBerhasil(res.message, 2000);
|
||||||
|
} else {
|
||||||
|
setLoading(false);
|
||||||
|
ComponentGlobal_NotifikasiGagal(res.message);
|
||||||
|
}
|
||||||
|
} catch (error) {
|
||||||
|
setLoading(false);
|
||||||
|
clientLogger.error("Error join event", error);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -14,6 +14,7 @@ import { Event_funDeleteById } from "../../fun/delete/fun_delete";
|
|||||||
import { Event_funEditStatusById } from "../../fun/edit/fun_edit_status_by_id";
|
import { Event_funEditStatusById } from "../../fun/edit/fun_edit_status_by_id";
|
||||||
import { MODEL_EVENT } from "../../model/interface";
|
import { MODEL_EVENT } from "../../model/interface";
|
||||||
import { AccentColor, MainColor } from "@/app_modules/_global/color";
|
import { AccentColor, MainColor } from "@/app_modules/_global/color";
|
||||||
|
import { clientLogger } from "@/util/clientLogger";
|
||||||
|
|
||||||
export default function Event_DetailReject({
|
export default function Event_DetailReject({
|
||||||
dataEvent,
|
dataEvent,
|
||||||
@@ -21,6 +22,7 @@ export default function Event_DetailReject({
|
|||||||
dataEvent: MODEL_EVENT;
|
dataEvent: MODEL_EVENT;
|
||||||
}) {
|
}) {
|
||||||
const [data, setData] = useState(dataEvent);
|
const [data, setData] = useState(dataEvent);
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<>
|
<>
|
||||||
<Stack spacing={"lg"}>
|
<Stack spacing={"lg"}>
|
||||||
@@ -32,11 +34,50 @@ export default function Event_DetailReject({
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
function ButtonAction({ eventId }: { eventId: string }) {
|
|
||||||
|
function ButtonAction({ eventId, }: { eventId: string }) {
|
||||||
const router = useRouter();
|
const router = useRouter();
|
||||||
const [openModal1, setOpenModal1] = useState(false);
|
const [openModal1, setOpenModal1] = useState(false);
|
||||||
const [openModal2, setOpenModal2] = useState(false);
|
const [openModal2, setOpenModal2] = useState(false);
|
||||||
|
const [isLoading, setLoading] = useState(false);
|
||||||
|
const [isLoading2, setLoading2] = useState(false);
|
||||||
|
|
||||||
|
async function onUpdate(router: AppRouterInstance, eventId: string, setLoading: any) {
|
||||||
|
await Event_funEditStatusById("3", eventId).then((res) => {
|
||||||
|
try {
|
||||||
|
setLoading(true);
|
||||||
|
if (res.status === 200) {
|
||||||
|
ComponentGlobal_NotifikasiBerhasil(res.message);
|
||||||
|
router.push(RouterEvent.status({ id: "3" }));
|
||||||
|
} else {
|
||||||
|
setLoading(false);
|
||||||
|
ComponentGlobal_NotifikasiGagal(res.message);
|
||||||
|
}
|
||||||
|
} catch (error) {
|
||||||
|
setLoading(false);
|
||||||
|
clientLogger.error("Error update event", error);
|
||||||
|
}
|
||||||
|
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
async function onDelete(router: AppRouterInstance, eventId: string, setLoading2: any) {
|
||||||
|
const res = await Event_funDeleteById(eventId);
|
||||||
|
try {
|
||||||
|
setLoading2(true);
|
||||||
|
if (res.status === 200) {
|
||||||
|
ComponentGlobal_NotifikasiBerhasil(res.message, 2000);
|
||||||
|
router.back();
|
||||||
|
} else {
|
||||||
|
setLoading2(false);
|
||||||
|
ComponentGlobal_NotifikasiGagal(res.message);
|
||||||
|
}
|
||||||
|
} catch (error) {
|
||||||
|
setLoading2(false);
|
||||||
|
clientLogger.error("Error delete event", error);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<>
|
<>
|
||||||
<SimpleGrid cols={2}>
|
<SimpleGrid cols={2}>
|
||||||
@@ -74,12 +115,13 @@ function ButtonAction({ eventId }: { eventId: string }) {
|
|||||||
}
|
}
|
||||||
buttonKanan={
|
buttonKanan={
|
||||||
<Button
|
<Button
|
||||||
|
loaderPosition="center"
|
||||||
style={{ backgroundColor: AccentColor.yellow }}
|
style={{ backgroundColor: AccentColor.yellow }}
|
||||||
radius={"xl"}
|
radius={"xl"}
|
||||||
c={MainColor.darkblue}
|
c={MainColor.darkblue}
|
||||||
|
loading={isLoading ? true : false}
|
||||||
onClick={() => {
|
onClick={() => {
|
||||||
onUpdate(router, eventId);
|
onUpdate(router, eventId, setLoading);
|
||||||
setOpenModal1(false);
|
|
||||||
}}
|
}}
|
||||||
>
|
>
|
||||||
Edit
|
Edit
|
||||||
@@ -93,18 +135,19 @@ function ButtonAction({ eventId }: { eventId: string }) {
|
|||||||
opened={openModal2}
|
opened={openModal2}
|
||||||
close={() => setOpenModal2(false)}
|
close={() => setOpenModal2(false)}
|
||||||
buttonKiri={
|
buttonKiri={
|
||||||
<Button style={{ color: "black" }} radius={"xl"} onClick={() => setOpenModal2(false)}>
|
<Button style={{ color: AccentColor.white }} radius={"xl"} onClick={() => setOpenModal2(false)}>
|
||||||
Batal
|
Batal
|
||||||
</Button>
|
</Button>
|
||||||
}
|
}
|
||||||
buttonKanan={
|
buttonKanan={
|
||||||
<Button
|
<Button
|
||||||
style={{ color: "black" }}
|
loading={isLoading2 ? true : false}
|
||||||
|
loaderPosition="center"
|
||||||
|
style={{ color: AccentColor.white }}
|
||||||
radius={"xl"}
|
radius={"xl"}
|
||||||
color={"red"}
|
color={"red"}
|
||||||
onClick={() => {
|
onClick={() => {
|
||||||
onDelete(router, eventId);
|
onDelete(router, eventId, setLoading2);
|
||||||
setOpenModal2(false);
|
|
||||||
}}
|
}}
|
||||||
>
|
>
|
||||||
Hapus
|
Hapus
|
||||||
@@ -115,23 +158,3 @@ function ButtonAction({ eventId }: { eventId: string }) {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
async function onUpdate(router: AppRouterInstance, eventId: string) {
|
|
||||||
await Event_funEditStatusById("3", eventId).then((res) => {
|
|
||||||
if (res.status === 200) {
|
|
||||||
ComponentGlobal_NotifikasiBerhasil(res.message);
|
|
||||||
router.push(RouterEvent.status({ id: "3" }));
|
|
||||||
} else {
|
|
||||||
ComponentGlobal_NotifikasiGagal(res.message);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
async function onDelete(router: AppRouterInstance, eventId: string) {
|
|
||||||
const res = await Event_funDeleteById(eventId);
|
|
||||||
if (res.status === 200) {
|
|
||||||
ComponentGlobal_NotifikasiBerhasil(res.message, 2000);
|
|
||||||
router.back();
|
|
||||||
} else {
|
|
||||||
ComponentGlobal_NotifikasiGagal(res.message);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|||||||
@@ -55,7 +55,7 @@ function ButtonAction({ eventId }: { eventId: string }) {
|
|||||||
}
|
}
|
||||||
buttonKanan={
|
buttonKanan={
|
||||||
<Button
|
<Button
|
||||||
style={{ backgroundColor: MainColor.orange }}
|
style={{ backgroundColor: AccentColor.yellow }}
|
||||||
loaderPosition="center"
|
loaderPosition="center"
|
||||||
loading={isLoading}
|
loading={isLoading}
|
||||||
radius={"xl"}
|
radius={"xl"}
|
||||||
|
|||||||
@@ -24,6 +24,7 @@ import { useState } from "react";
|
|||||||
import { Event_funEditById } from "../fun/edit/fun_edit_by_id";
|
import { Event_funEditById } from "../fun/edit/fun_edit_by_id";
|
||||||
import { MODEL_EVENT } from "../model/interface";
|
import { MODEL_EVENT } from "../model/interface";
|
||||||
import ComponentEvent_ErrorMaximalInput from "../component/error_maksimal_input";
|
import ComponentEvent_ErrorMaximalInput from "../component/error_maksimal_input";
|
||||||
|
import { clientLogger } from "@/util/clientLogger";
|
||||||
|
|
||||||
export default function Event_Edit({
|
export default function Event_Edit({
|
||||||
dataEvent,
|
dataEvent,
|
||||||
@@ -320,14 +321,19 @@ async function onUpdate(
|
|||||||
if (_.values(value).includes(""))
|
if (_.values(value).includes(""))
|
||||||
return ComponentGlobal_NotifikasiPeringatan("Lengkapi Data");
|
return ComponentGlobal_NotifikasiPeringatan("Lengkapi Data");
|
||||||
|
|
||||||
const res = await Event_funEditById(value);
|
try {
|
||||||
setLoading(true);
|
setLoading(true);
|
||||||
|
const res = await Event_funEditById(value);
|
||||||
|
|
||||||
if (res.status === 200) {
|
if (res.status === 200) {
|
||||||
ComponentGlobal_NotifikasiBerhasil(res.message);
|
ComponentGlobal_NotifikasiBerhasil(res.message);
|
||||||
router.back();
|
router.back();
|
||||||
setLoading(false);
|
|
||||||
} else {
|
} else {
|
||||||
|
setLoading(false);
|
||||||
ComponentGlobal_NotifikasiGagal(res.message);
|
ComponentGlobal_NotifikasiGagal(res.message);
|
||||||
}
|
}
|
||||||
|
} catch (error) {
|
||||||
|
setLoading(false);
|
||||||
|
clientLogger.error("Error update event", error);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -28,6 +28,7 @@ import { useState } from "react";
|
|||||||
import { WibuRealtime } from "wibu-pkg";
|
import { WibuRealtime } from "wibu-pkg";
|
||||||
import { Vote_funCreate } from "../fun/create/create_vote";
|
import { Vote_funCreate } from "../fun/create/create_vote";
|
||||||
import { gs_vote_hotMenu } from "../global_state";
|
import { gs_vote_hotMenu } from "../global_state";
|
||||||
|
import { clientLogger } from "@/util/clientLogger";
|
||||||
|
|
||||||
export default function Vote_Create() {
|
export default function Vote_Create() {
|
||||||
const router = useRouter();
|
const router = useRouter();
|
||||||
@@ -69,40 +70,49 @@ export default function Vote_Create() {
|
|||||||
|
|
||||||
// console.log("berhasil");
|
// console.log("berhasil");
|
||||||
|
|
||||||
const res = await Vote_funCreate(data as any, listVote);
|
try {
|
||||||
if (res.status === 201) {
|
setIsLoading(true);
|
||||||
const dataNotifikasi: IRealtimeData = {
|
const res = await Vote_funCreate(data as any, listVote);
|
||||||
appId: res.data?.id as any,
|
if (res.status === 201) {
|
||||||
status: res.data?.Voting_Status?.name as any,
|
const dataNotifikasi: IRealtimeData = {
|
||||||
userId: res.data?.authorId as any,
|
appId: res.data?.id as any,
|
||||||
pesan: res.data?.title as any,
|
status: res.data?.Voting_Status?.name as any,
|
||||||
kategoriApp: "VOTING",
|
userId: res.data?.authorId as any,
|
||||||
title: "Voting baru",
|
pesan: res.data?.title as any,
|
||||||
};
|
kategoriApp: "VOTING",
|
||||||
|
title: "Voting baru",
|
||||||
|
};
|
||||||
|
|
||||||
const notif = await notifikasiToAdmin_funCreate({
|
const notif = await notifikasiToAdmin_funCreate({
|
||||||
data: dataNotifikasi as any,
|
data: dataNotifikasi as any,
|
||||||
});
|
|
||||||
|
|
||||||
if (notif.status === 201) {
|
|
||||||
WibuRealtime.setData({
|
|
||||||
type: "notification",
|
|
||||||
pushNotificationTo: "ADMIN",
|
|
||||||
});
|
});
|
||||||
|
|
||||||
WibuRealtime.setData({
|
if (notif.status === 201) {
|
||||||
type: "trigger",
|
WibuRealtime.setData({
|
||||||
pushNotificationTo: "ADMIN",
|
type: "notification",
|
||||||
dataMessage: dataNotifikasi,
|
pushNotificationTo: "ADMIN",
|
||||||
});
|
});
|
||||||
|
|
||||||
setHotMenu(2);
|
WibuRealtime.setData({
|
||||||
router.replace(RouterVote.status({ id: "2" }));
|
type: "trigger",
|
||||||
ComponentGlobal_NotifikasiBerhasil(res.message);
|
pushNotificationTo: "ADMIN",
|
||||||
setIsLoading(true);
|
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
|
<Button
|
||||||
disabled={
|
disabled={
|
||||||
!data.title ||
|
!data.title ||
|
||||||
!data.deskripsi ||
|
!data.deskripsi ||
|
||||||
!data.awalVote ||
|
!data.awalVote ||
|
||||||
!data.akhirVote ||
|
!data.akhirVote ||
|
||||||
listVote.map((e, i) => e.value).includes("")
|
listVote.map((e, i) => e.value).includes("")
|
||||||
? true
|
? true
|
||||||
: false
|
: false
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -31,6 +31,7 @@ import {
|
|||||||
MODEL_VOTING,
|
MODEL_VOTING,
|
||||||
MODEL_VOTING_DAFTAR_NAMA_VOTE,
|
MODEL_VOTING_DAFTAR_NAMA_VOTE,
|
||||||
} from "../model/interface";
|
} from "../model/interface";
|
||||||
|
import { clientLogger } from "@/util/clientLogger";
|
||||||
|
|
||||||
export default function Vote_Edit({
|
export default function Vote_Edit({
|
||||||
dataVote,
|
dataVote,
|
||||||
@@ -270,17 +271,24 @@ function ButtonAction({
|
|||||||
async function onUpdate() {
|
async function onUpdate() {
|
||||||
// console.log(listVoting);
|
// console.log(listVoting);
|
||||||
|
|
||||||
await Vote_funEditById(data, listVoting).then((res) => {
|
try {
|
||||||
if (res.status === 200) {
|
setIsLoading(true);
|
||||||
ComponentGlobal_NotifikasiBerhasil("Berhasil Update");
|
await Vote_funEditById(data, listVoting).then((res) => {
|
||||||
// setHotMenu(1);
|
if (res.status === 200) {
|
||||||
// setTabsStatus("Draft");
|
ComponentGlobal_NotifikasiBerhasil("Berhasil Update");
|
||||||
router.back();
|
// setHotMenu(1);
|
||||||
setIsLoading(true);
|
// setTabsStatus("Draft");
|
||||||
} else {
|
router.back();
|
||||||
ComponentGlobal_NotifikasiGagal(res.message);
|
} else {
|
||||||
}
|
setIsLoading(false);
|
||||||
});
|
ComponentGlobal_NotifikasiGagal(res.message);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
} catch (error) {
|
||||||
|
setIsLoading(false);
|
||||||
|
clientLogger.error("Error update voting", error);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return (
|
return (
|
||||||
|
|||||||
Reference in New Issue
Block a user