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 { useShallowEffect } from "@mantine/hooks";
|
||||
import SkeletonCeritaPenggalangDonasi from "./skeleton_cerita_penggalang";
|
||||
import { funReplaceHtml } from "@/app_modules/_global/fun/fun_replace_html";
|
||||
|
||||
export default function ComponentDonasi_CeritaPenggalangMainNew() {
|
||||
const router = useRouter();
|
||||
@@ -39,51 +40,55 @@ export default function ComponentDonasi_CeritaPenggalangMainNew() {
|
||||
|
||||
|
||||
return (
|
||||
<>
|
||||
<Stack
|
||||
spacing={"xs"}
|
||||
style={{
|
||||
color: MainColor.white,
|
||||
}}
|
||||
<>
|
||||
<Stack
|
||||
spacing={"xs"}
|
||||
style={{
|
||||
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>
|
||||
<Paper
|
||||
style={{
|
||||
padding: "15px",
|
||||
backgroundColor: AccentColor.darkblue,
|
||||
border: `2px solid ${AccentColor.blue}`,
|
||||
borderRadius: "10px",
|
||||
color: MainColor.white,
|
||||
}}
|
||||
>
|
||||
{
|
||||
loading ? <SkeletonCeritaPenggalangDonasi />
|
||||
:
|
||||
<Stack>
|
||||
<Group position="apart">
|
||||
<Text>
|
||||
{new Intl.DateTimeFormat("id-ID", { dateStyle: "full" }).format(
|
||||
new Date(donasi?.createdAt)
|
||||
)}
|
||||
</Text>
|
||||
<ActionIcon
|
||||
variant="transparent"
|
||||
onClick={() => {
|
||||
router.push(RouterDonasi.cerita_penggalang + `${donasi?.id}`);
|
||||
}}
|
||||
>
|
||||
<IconCircleChevronRight
|
||||
style={{
|
||||
color: MainColor.yellow,
|
||||
}}
|
||||
/>
|
||||
</ActionIcon>
|
||||
</Group>
|
||||
<Text lineClamp={4}>{donasi?.CeritaDonasi.cerita}</Text>
|
||||
</Stack>
|
||||
}
|
||||
</Paper>
|
||||
</Stack>
|
||||
</>
|
||||
{loading ? (
|
||||
<SkeletonCeritaPenggalangDonasi />
|
||||
) : (
|
||||
<Stack>
|
||||
<Group position="apart">
|
||||
<Text>
|
||||
{new Intl.DateTimeFormat("id-ID", {
|
||||
dateStyle: "full",
|
||||
}).format(new Date(donasi?.createdAt))}
|
||||
</Text>
|
||||
<ActionIcon
|
||||
variant="transparent"
|
||||
onClick={() => {
|
||||
router.push(
|
||||
RouterDonasi.cerita_penggalang + `${donasi?.id}`
|
||||
);
|
||||
}}
|
||||
>
|
||||
<IconCircleChevronRight
|
||||
style={{
|
||||
color: MainColor.yellow,
|
||||
}}
|
||||
/>
|
||||
</ActionIcon>
|
||||
</Group>
|
||||
<Text lineClamp={4}>
|
||||
{funReplaceHtml({ html: donasi?.CeritaDonasi.cerita })}
|
||||
</Text>
|
||||
</Stack>
|
||||
)}
|
||||
</Paper>
|
||||
</Stack>
|
||||
</>
|
||||
);
|
||||
}
|
||||
|
||||
@@ -1,31 +1,27 @@
|
||||
"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_NotifikasiPeringatan } from "@/app_modules/_global/notif_global/notifikasi_peringatan";
|
||||
import { UIGlobal_Modal } from "@/app_modules/_global/ui";
|
||||
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 { useRouter } from "next/navigation";
|
||||
import { useState } from "react";
|
||||
import { WibuRealtime } from "wibu-pkg";
|
||||
import { Donasi_ComponentButtonDeleteDonasiById } from "../../component";
|
||||
import ComponentDonasi_DetailDataGalangDana from "../../component/detail_galang_dana/detail_data_donasi";
|
||||
import ComponentDonasi_CeritaPenggalangMain from "../../component/detail_main/cerita_penggalang";
|
||||
import { Donasi_funGantiStatus } from "../../fun/update/fun_ganti_status";
|
||||
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({
|
||||
dataDonasi,
|
||||
}: {
|
||||
dataDonasi: MODEL_DONASI;
|
||||
dataDonasi: MODEL_DONASI;
|
||||
}) {
|
||||
const [data, setData] = useState(dataDonasi);
|
||||
|
||||
@@ -49,65 +45,61 @@ export default function DetailDraftDonasi({
|
||||
|
||||
function ButtonAjukanPenggalangan({
|
||||
dataDonasi,
|
||||
|
||||
}: {
|
||||
dataDonasi: MODEL_DONASI;
|
||||
|
||||
}) {
|
||||
const router = useRouter();
|
||||
const [isLoadingAjukan, setLoadingAjukan] = useState(false);
|
||||
const [isLoadingDelete, setLoadingDelete] = useState(false);
|
||||
const [openModal, setOpenModal] = useState(false);
|
||||
|
||||
async function onChangeStatus() {
|
||||
setLoadingAjukan(true);
|
||||
const res = await Donasi_funGantiStatus(dataDonasi.id, "2");
|
||||
try {
|
||||
if (res.status === 200) {
|
||||
try {
|
||||
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 = {
|
||||
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 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",
|
||||
});
|
||||
|
||||
setLoadingAjukan(true);
|
||||
ComponentGlobal_NotifikasiBerhasil("Berhasil Diajukan");
|
||||
router.push(RouterDonasi.status_galang_dana({ id: "2" }));
|
||||
WibuRealtime.setData({
|
||||
type: "trigger",
|
||||
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);
|
||||
ComponentGlobal_NotifikasiPeringatan(res.message);
|
||||
clientLogger.error("Error ajukan donasi", error);
|
||||
}
|
||||
} catch (error) {
|
||||
setLoadingAjukan(false);
|
||||
clientLogger.error("Error ajukan donasi", error);
|
||||
}
|
||||
}
|
||||
return (
|
||||
<>
|
||||
<Button
|
||||
radius={"xl"}
|
||||
style={{
|
||||
backgroundColor: AccentColor.yellow
|
||||
backgroundColor: AccentColor.yellow,
|
||||
}}
|
||||
c={MainColor.darkblue}
|
||||
onClick={() => setOpenModal(true)}
|
||||
@@ -120,15 +112,19 @@ function ButtonAjukanPenggalangan({
|
||||
opened={openModal}
|
||||
close={() => setOpenModal(false)}
|
||||
buttonKiri={
|
||||
<Button style={{ backgroundColor: AccentColor.blue }}
|
||||
c={AccentColor.white} radius={"xl"} onClick={() => setOpenModal(false)}>
|
||||
<Button
|
||||
style={{ backgroundColor: AccentColor.blue }}
|
||||
c={AccentColor.white}
|
||||
radius={"xl"}
|
||||
onClick={() => setOpenModal(false)}
|
||||
>
|
||||
Batal
|
||||
</Button>
|
||||
}
|
||||
buttonKanan={
|
||||
<Button
|
||||
style={{
|
||||
backgroundColor: AccentColor.yellow
|
||||
backgroundColor: AccentColor.yellow,
|
||||
}}
|
||||
loaderPosition="center"
|
||||
loading={isLoadingAjukan}
|
||||
|
||||
Reference in New Issue
Block a user