fix donasi
deksripsi: - fix tampilan main detail
This commit is contained in:
@@ -8,6 +8,7 @@ import { useState } from "react";
|
|||||||
import { apiGetOneDonasiById } from "../../lib/api_donasi";
|
import { apiGetOneDonasiById } from "../../lib/api_donasi";
|
||||||
import { useShallowEffect } from "@mantine/hooks";
|
import { useShallowEffect } from "@mantine/hooks";
|
||||||
import SkeletonCeritaPenggalangDonasi from "./skeleton_cerita_penggalang";
|
import SkeletonCeritaPenggalangDonasi from "./skeleton_cerita_penggalang";
|
||||||
|
import { funReplaceHtml } from "@/app_modules/_global/fun/fun_replace_html";
|
||||||
|
|
||||||
export default function ComponentDonasi_CeritaPenggalangMainNew() {
|
export default function ComponentDonasi_CeritaPenggalangMainNew() {
|
||||||
const router = useRouter();
|
const router = useRouter();
|
||||||
@@ -39,51 +40,55 @@ export default function ComponentDonasi_CeritaPenggalangMainNew() {
|
|||||||
|
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<>
|
<>
|
||||||
<Stack
|
<Stack
|
||||||
spacing={"xs"}
|
spacing={"xs"}
|
||||||
style={{
|
style={{
|
||||||
color: MainColor.white,
|
color: MainColor.white,
|
||||||
}}
|
}}
|
||||||
|
>
|
||||||
|
<Title order={4}>Cerita Penggalang Dana</Title>
|
||||||
|
<Paper
|
||||||
|
style={{
|
||||||
|
padding: "15px",
|
||||||
|
backgroundColor: AccentColor.darkblue,
|
||||||
|
border: `2px solid ${AccentColor.blue}`,
|
||||||
|
borderRadius: "10px",
|
||||||
|
color: MainColor.white,
|
||||||
|
}}
|
||||||
>
|
>
|
||||||
<Title order={4}>Cerita Penggalang Dana</Title>
|
{loading ? (
|
||||||
<Paper
|
<SkeletonCeritaPenggalangDonasi />
|
||||||
style={{
|
) : (
|
||||||
padding: "15px",
|
<Stack>
|
||||||
backgroundColor: AccentColor.darkblue,
|
<Group position="apart">
|
||||||
border: `2px solid ${AccentColor.blue}`,
|
<Text>
|
||||||
borderRadius: "10px",
|
{new Intl.DateTimeFormat("id-ID", {
|
||||||
color: MainColor.white,
|
dateStyle: "full",
|
||||||
}}
|
}).format(new Date(donasi?.createdAt))}
|
||||||
>
|
</Text>
|
||||||
{
|
<ActionIcon
|
||||||
loading ? <SkeletonCeritaPenggalangDonasi />
|
variant="transparent"
|
||||||
:
|
onClick={() => {
|
||||||
<Stack>
|
router.push(
|
||||||
<Group position="apart">
|
RouterDonasi.cerita_penggalang + `${donasi?.id}`
|
||||||
<Text>
|
);
|
||||||
{new Intl.DateTimeFormat("id-ID", { dateStyle: "full" }).format(
|
}}
|
||||||
new Date(donasi?.createdAt)
|
>
|
||||||
)}
|
<IconCircleChevronRight
|
||||||
</Text>
|
style={{
|
||||||
<ActionIcon
|
color: MainColor.yellow,
|
||||||
variant="transparent"
|
}}
|
||||||
onClick={() => {
|
/>
|
||||||
router.push(RouterDonasi.cerita_penggalang + `${donasi?.id}`);
|
</ActionIcon>
|
||||||
}}
|
</Group>
|
||||||
>
|
<Text lineClamp={4}>
|
||||||
<IconCircleChevronRight
|
{funReplaceHtml({ html: donasi?.CeritaDonasi.cerita })}
|
||||||
style={{
|
</Text>
|
||||||
color: MainColor.yellow,
|
</Stack>
|
||||||
}}
|
)}
|
||||||
/>
|
</Paper>
|
||||||
</ActionIcon>
|
</Stack>
|
||||||
</Group>
|
</>
|
||||||
<Text lineClamp={4}>{donasi?.CeritaDonasi.cerita}</Text>
|
|
||||||
</Stack>
|
|
||||||
}
|
|
||||||
</Paper>
|
|
||||||
</Stack>
|
|
||||||
</>
|
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,31 +1,27 @@
|
|||||||
"use client";
|
"use client";
|
||||||
|
|
||||||
import { RouterDonasi } from "@/lib/router_hipmi/router_donasi";
|
import { AccentColor, MainColor } from "@/app_modules/_global/color";
|
||||||
import { ComponentGlobal_NotifikasiBerhasil } from "@/app_modules/_global/notif_global/notifikasi_berhasil";
|
import { ComponentGlobal_NotifikasiBerhasil } from "@/app_modules/_global/notif_global/notifikasi_berhasil";
|
||||||
import { ComponentGlobal_NotifikasiPeringatan } from "@/app_modules/_global/notif_global/notifikasi_peringatan";
|
import { ComponentGlobal_NotifikasiPeringatan } from "@/app_modules/_global/notif_global/notifikasi_peringatan";
|
||||||
import { UIGlobal_Modal } from "@/app_modules/_global/ui";
|
import { UIGlobal_Modal } from "@/app_modules/_global/ui";
|
||||||
import notifikasiToAdmin_funCreate from "@/app_modules/notifikasi/fun/create/create_notif_to_admin";
|
import notifikasiToAdmin_funCreate from "@/app_modules/notifikasi/fun/create/create_notif_to_admin";
|
||||||
import mqtt_client from "@/util/mqtt_client";
|
import { IRealtimeData } from "@/lib/global_state";
|
||||||
|
import { RouterDonasi } from "@/lib/router_hipmi/router_donasi";
|
||||||
|
import { clientLogger } from "@/util/clientLogger";
|
||||||
import { Button, Group, Stack } from "@mantine/core";
|
import { Button, Group, Stack } from "@mantine/core";
|
||||||
import { useRouter } from "next/navigation";
|
import { useRouter } from "next/navigation";
|
||||||
import { useState } from "react";
|
import { useState } from "react";
|
||||||
|
import { WibuRealtime } from "wibu-pkg";
|
||||||
import { Donasi_ComponentButtonDeleteDonasiById } from "../../component";
|
import { Donasi_ComponentButtonDeleteDonasiById } from "../../component";
|
||||||
import ComponentDonasi_DetailDataGalangDana from "../../component/detail_galang_dana/detail_data_donasi";
|
import ComponentDonasi_DetailDataGalangDana from "../../component/detail_galang_dana/detail_data_donasi";
|
||||||
import ComponentDonasi_CeritaPenggalangMain from "../../component/detail_main/cerita_penggalang";
|
import ComponentDonasi_CeritaPenggalangMain from "../../component/detail_main/cerita_penggalang";
|
||||||
import { Donasi_funGantiStatus } from "../../fun/update/fun_ganti_status";
|
import { Donasi_funGantiStatus } from "../../fun/update/fun_ganti_status";
|
||||||
import { MODEL_DONASI } from "../../model/interface";
|
import { MODEL_DONASI } from "../../model/interface";
|
||||||
import { IRealtimeData } from "@/lib/global_state";
|
|
||||||
import { WibuRealtime } from "wibu-pkg";
|
|
||||||
import { AccentColor, MainColor } from "@/app_modules/_global/color";
|
|
||||||
import funDeleteDonasi from "@/app_modules/investasi/fun/fun_delete_donasi";
|
|
||||||
import { clientLogger } from "@/util/clientLogger";
|
|
||||||
import { funGlobal_DeleteFileById } from "@/app_modules/_global/fun";
|
|
||||||
import { ComponentGlobal_NotifikasiGagal } from "@/app_modules/_global/notif_global";
|
|
||||||
|
|
||||||
export default function DetailDraftDonasi({
|
export default function DetailDraftDonasi({
|
||||||
dataDonasi,
|
dataDonasi,
|
||||||
}: {
|
}: {
|
||||||
dataDonasi: MODEL_DONASI;
|
dataDonasi: MODEL_DONASI;
|
||||||
}) {
|
}) {
|
||||||
const [data, setData] = useState(dataDonasi);
|
const [data, setData] = useState(dataDonasi);
|
||||||
|
|
||||||
@@ -49,65 +45,61 @@ export default function DetailDraftDonasi({
|
|||||||
|
|
||||||
function ButtonAjukanPenggalangan({
|
function ButtonAjukanPenggalangan({
|
||||||
dataDonasi,
|
dataDonasi,
|
||||||
|
|
||||||
}: {
|
}: {
|
||||||
dataDonasi: MODEL_DONASI;
|
dataDonasi: MODEL_DONASI;
|
||||||
|
|
||||||
}) {
|
}) {
|
||||||
const router = useRouter();
|
const router = useRouter();
|
||||||
const [isLoadingAjukan, setLoadingAjukan] = useState(false);
|
const [isLoadingAjukan, setLoadingAjukan] = useState(false);
|
||||||
const [isLoadingDelete, setLoadingDelete] = useState(false);
|
|
||||||
const [openModal, setOpenModal] = useState(false);
|
const [openModal, setOpenModal] = useState(false);
|
||||||
|
|
||||||
async function onChangeStatus() {
|
async function onChangeStatus() {
|
||||||
|
setLoadingAjukan(true);
|
||||||
const res = await Donasi_funGantiStatus(dataDonasi.id, "2");
|
const res = await Donasi_funGantiStatus(dataDonasi.id, "2");
|
||||||
try {
|
try {
|
||||||
if (res.status === 200) {
|
if (res.status === 200) {
|
||||||
|
const dataNotifikasi: IRealtimeData = {
|
||||||
|
appId: res.data?.id as any,
|
||||||
|
status: res.data?.DonasiMaster_Status?.name as any,
|
||||||
|
userId: res.data?.authorId as any,
|
||||||
|
pesan: res.data?.title as any,
|
||||||
|
kategoriApp: "DONASI",
|
||||||
|
title: "Mengajukan review",
|
||||||
|
};
|
||||||
|
|
||||||
const dataNotifikasi: IRealtimeData = {
|
const notif = await notifikasiToAdmin_funCreate({
|
||||||
appId: res.data?.id as any,
|
data: dataNotifikasi as any,
|
||||||
status: res.data?.DonasiMaster_Status?.name as any,
|
|
||||||
userId: res.data?.authorId as any,
|
|
||||||
pesan: res.data?.title as any,
|
|
||||||
kategoriApp: "DONASI",
|
|
||||||
title: "Mengajukan review",
|
|
||||||
};
|
|
||||||
|
|
||||||
const notif = await notifikasiToAdmin_funCreate({
|
|
||||||
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",
|
||||||
});
|
});
|
||||||
|
|
||||||
setLoadingAjukan(true);
|
WibuRealtime.setData({
|
||||||
ComponentGlobal_NotifikasiBerhasil("Berhasil Diajukan");
|
type: "trigger",
|
||||||
router.push(RouterDonasi.status_galang_dana({ id: "2" }));
|
pushNotificationTo: "ADMIN",
|
||||||
|
dataMessage: dataNotifikasi,
|
||||||
|
});
|
||||||
|
|
||||||
|
ComponentGlobal_NotifikasiBerhasil("Berhasil Diajukan");
|
||||||
|
router.push(RouterDonasi.status_galang_dana({ id: "2" }));
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
setLoadingAjukan(false);
|
||||||
|
ComponentGlobal_NotifikasiPeringatan(res.message);
|
||||||
}
|
}
|
||||||
} else {
|
} catch (error) {
|
||||||
setLoadingAjukan(false);
|
setLoadingAjukan(false);
|
||||||
ComponentGlobal_NotifikasiPeringatan(res.message);
|
clientLogger.error("Error ajukan donasi", error);
|
||||||
}
|
}
|
||||||
} catch (error) {
|
|
||||||
setLoadingAjukan(false);
|
|
||||||
clientLogger.error("Error ajukan donasi", error);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
return (
|
return (
|
||||||
<>
|
<>
|
||||||
<Button
|
<Button
|
||||||
radius={"xl"}
|
radius={"xl"}
|
||||||
style={{
|
style={{
|
||||||
backgroundColor: AccentColor.yellow
|
backgroundColor: AccentColor.yellow,
|
||||||
}}
|
}}
|
||||||
c={MainColor.darkblue}
|
c={MainColor.darkblue}
|
||||||
onClick={() => setOpenModal(true)}
|
onClick={() => setOpenModal(true)}
|
||||||
@@ -120,15 +112,19 @@ function ButtonAjukanPenggalangan({
|
|||||||
opened={openModal}
|
opened={openModal}
|
||||||
close={() => setOpenModal(false)}
|
close={() => setOpenModal(false)}
|
||||||
buttonKiri={
|
buttonKiri={
|
||||||
<Button style={{ backgroundColor: AccentColor.blue }}
|
<Button
|
||||||
c={AccentColor.white} radius={"xl"} onClick={() => setOpenModal(false)}>
|
style={{ backgroundColor: AccentColor.blue }}
|
||||||
|
c={AccentColor.white}
|
||||||
|
radius={"xl"}
|
||||||
|
onClick={() => setOpenModal(false)}
|
||||||
|
>
|
||||||
Batal
|
Batal
|
||||||
</Button>
|
</Button>
|
||||||
}
|
}
|
||||||
buttonKanan={
|
buttonKanan={
|
||||||
<Button
|
<Button
|
||||||
style={{
|
style={{
|
||||||
backgroundColor: AccentColor.yellow
|
backgroundColor: AccentColor.yellow,
|
||||||
}}
|
}}
|
||||||
loaderPosition="center"
|
loaderPosition="center"
|
||||||
loading={isLoadingAjukan}
|
loading={isLoadingAjukan}
|
||||||
|
|||||||
Reference in New Issue
Block a user