fix: donasi
deskripsi: - perbaharuan use server menjadi API src/app/api/investasi/saham/[id]/route.ts src/app/dev/(user)/donasi/detail/kabar/[id]/page.tsx src/app/dev/(user)/donasi/edit/kabar/[id]/page.tsx src/app/dev/(user)/donasi/edit/update_kabar/[id]/layout.tsx src/app/dev/(user)/donasi/edit/update_kabar/[id]/page.tsx src/app/dev/(user)/donasi/kabar/[id]/page.tsx src/app_modules/donasi/_ui/edit/ui_edit_kabar.tsx src/app_modules/donasi/_view/edit/view_edit_kabar.tsx src/app_modules/donasi/detail/detail_kabar/index.tsx src/app_modules/donasi/detail/detail_main/kabar/index.tsx src/app_modules/donasi/edit/update_kabar/index.tsx src/app_modules/donasi/edit/update_kabar/layout.tsx No Issue
This commit is contained in:
@@ -1,4 +1,5 @@
|
|||||||
import { NextResponse } from "next/server";
|
import { NextResponse } from "next/server";
|
||||||
|
import { prisma } from "@/lib";
|
||||||
|
|
||||||
export { GET };
|
export { GET };
|
||||||
|
|
||||||
@@ -12,9 +13,9 @@ async function GET(request: Request, { params }: { params: { id: string } }) {
|
|||||||
include: {
|
include: {
|
||||||
MasterBank: true,
|
MasterBank: true,
|
||||||
StatusInvoice: {
|
StatusInvoice: {
|
||||||
where: {
|
where: {
|
||||||
name: "Berhasil",
|
name: "Berhasil",
|
||||||
}
|
},
|
||||||
},
|
},
|
||||||
Investasi: {
|
Investasi: {
|
||||||
include: {
|
include: {
|
||||||
|
|||||||
@@ -1,5 +1,4 @@
|
|||||||
import { DetailKabarDonasi } from "@/app_modules/donasi";
|
import { DetailKabarDonasi } from "@/app_modules/donasi";
|
||||||
import { Donasi_getOneKabar } from "@/app_modules/donasi/fun/get/get_one_kabar";
|
|
||||||
|
|
||||||
export default async function Page({params}: {params: {id: string}}) {
|
export default async function Page({params}: {params: {id: string}}) {
|
||||||
return <DetailKabarDonasi />
|
return <DetailKabarDonasi />
|
||||||
|
|||||||
@@ -1,14 +1,9 @@
|
|||||||
import { Donasi_UiEditKabar } from "@/app_modules/donasi/_ui";
|
import { Donasi_UiEditKabar } from "@/app_modules/donasi/_ui";
|
||||||
import { Donasi_getOneKabar } from "@/app_modules/donasi/fun/get/get_one_kabar";
|
|
||||||
import React from "react";
|
|
||||||
|
|
||||||
async function Page({ params }: { params: { id: string } }) {
|
|
||||||
const kabarId = params.id;
|
|
||||||
const dataKabar = await Donasi_getOneKabar(kabarId);
|
|
||||||
|
|
||||||
|
async function Page() {
|
||||||
return (
|
return (
|
||||||
<>
|
<>
|
||||||
<Donasi_UiEditKabar dataKabar={dataKabar} />
|
<Donasi_UiEditKabar />
|
||||||
</>
|
</>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -3,14 +3,12 @@ import React from "react";
|
|||||||
|
|
||||||
export default async function Layout({
|
export default async function Layout({
|
||||||
children,
|
children,
|
||||||
params
|
|
||||||
}: {
|
}: {
|
||||||
children: React.ReactNode;
|
children: React.ReactNode;
|
||||||
params: {id: string}
|
|
||||||
}) {
|
}) {
|
||||||
return (
|
return (
|
||||||
<>
|
<>
|
||||||
<LayoutUpdateKabarDonasi kabarId={params.id}>{children}</LayoutUpdateKabarDonasi>
|
<LayoutUpdateKabarDonasi>{children}</LayoutUpdateKabarDonasi>
|
||||||
</>
|
</>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,11 +1,10 @@
|
|||||||
import { UpdateKabarDonasi } from "@/app_modules/donasi";
|
import { UpdateKabarDonasi } from "@/app_modules/donasi";
|
||||||
import { Donasi_getOneKabar } from "@/app_modules/donasi/fun/get/get_one_kabar";
|
|
||||||
|
|
||||||
export default async function Page({params}: {params: {id: string}}) {
|
export default async function Page() {
|
||||||
let kabarId = params.id
|
|
||||||
const dataKabar = await Donasi_getOneKabar(kabarId)
|
return (
|
||||||
|
<>
|
||||||
return<>
|
<UpdateKabarDonasi />
|
||||||
<UpdateKabarDonasi dataKabar={dataKabar as any}/>
|
|
||||||
</>
|
</>
|
||||||
}
|
);
|
||||||
|
}
|
||||||
|
|||||||
@@ -1,13 +1,9 @@
|
|||||||
import { KabarDonasi } from "@/app_modules/donasi";
|
import { KabarDonasi } from "@/app_modules/donasi";
|
||||||
import { Donasi_getOneKabar } from "@/app_modules/donasi/fun/get/get_one_kabar";
|
|
||||||
|
|
||||||
export default async function Page({ params }: { params: { id: string } }) {
|
|
||||||
let kabarId = params.id;
|
|
||||||
const dataDonasi = await Donasi_getOneKabar(kabarId);
|
|
||||||
|
|
||||||
|
export default async function Page() {
|
||||||
return (
|
return (
|
||||||
<>
|
<>
|
||||||
<KabarDonasi dataDonasi={dataDonasi as any} />
|
<KabarDonasi />
|
||||||
</>
|
</>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -7,21 +7,15 @@ import UI_NewLayoutTamplate, {
|
|||||||
} from "@/app_modules/_global/ui/V2_layout_tamplate";
|
} from "@/app_modules/_global/ui/V2_layout_tamplate";
|
||||||
import { Donasi_ViewEditKabar } from "../../_view";
|
import { Donasi_ViewEditKabar } from "../../_view";
|
||||||
|
|
||||||
export function Donasi_UiEditKabar({ dataKabar }: { dataKabar: any }) {
|
export function Donasi_UiEditKabar() {
|
||||||
return (
|
return (
|
||||||
<>
|
<>
|
||||||
{/* <UIGlobal_LayoutTamplate
|
|
||||||
header={<UIGlobal_LayoutHeaderTamplate title="Edit Kabar" />}
|
|
||||||
>
|
|
||||||
<Donasi_ViewEditKabar dataKabar={dataKabar as any} />
|
|
||||||
</UIGlobal_LayoutTamplate> */}
|
|
||||||
|
|
||||||
<UI_NewLayoutTamplate>
|
<UI_NewLayoutTamplate>
|
||||||
<UI_NewHeader>
|
<UI_NewHeader>
|
||||||
<Component_Header title="Edit Kabar" />
|
<Component_Header title="Edit Kabar" />
|
||||||
</UI_NewHeader>
|
</UI_NewHeader>
|
||||||
<UI_NewChildren>
|
<UI_NewChildren>
|
||||||
<Donasi_ViewEditKabar dataKabar={dataKabar as any} />
|
<Donasi_ViewEditKabar />
|
||||||
</UI_NewChildren>
|
</UI_NewChildren>
|
||||||
</UI_NewLayoutTamplate>
|
</UI_NewLayoutTamplate>
|
||||||
</>
|
</>
|
||||||
|
|||||||
@@ -28,26 +28,42 @@ import {
|
|||||||
} from "@mantine/core";
|
} from "@mantine/core";
|
||||||
import { IconPhoto } from "@tabler/icons-react";
|
import { IconPhoto } from "@tabler/icons-react";
|
||||||
import _ from "lodash";
|
import _ from "lodash";
|
||||||
import { useRouter } from "next/navigation";
|
import { useParams, useRouter } from "next/navigation";
|
||||||
import { useState } from "react";
|
import { useState } from "react";
|
||||||
import { donasi_funUpdateKabar } from "../../fun";
|
import { donasi_funUpdateKabar } from "../../fun";
|
||||||
import { MODEL_DONASI_KABAR } from "../../model/interface";
|
import { MODEL_DONASI_KABAR } from "../../model/interface";
|
||||||
import { clientLogger } from "@/util/clientLogger";
|
import { clientLogger } from "@/util/clientLogger";
|
||||||
import SkeletonEditDonasi from "../../edit/edit_donasi/skeleton_edit_donasi";
|
import SkeletonEditDonasi from "../../edit/edit_donasi/skeleton_edit_donasi";
|
||||||
|
import { useShallowEffect } from "@mantine/hooks";
|
||||||
|
import { apiGetDonasiKabarById } from "../../lib/api_donasi";
|
||||||
|
import CustomSkeleton from "@/app_modules/components/CustomSkeleton";
|
||||||
|
|
||||||
export function Donasi_ViewEditKabar({
|
export function Donasi_ViewEditKabar() {
|
||||||
dataKabar,
|
const { id } = useParams();
|
||||||
}: {
|
|
||||||
dataKabar: MODEL_DONASI_KABAR;
|
|
||||||
}) {
|
|
||||||
const router = useRouter();
|
const router = useRouter();
|
||||||
const [data, setData] = useState(dataKabar);
|
const [data, setData] = useState<MODEL_DONASI_KABAR | null>(null);
|
||||||
const [file, setFile] = useState<File | null>(null);
|
const [file, setFile] = useState<File | null>(null);
|
||||||
const [img, setImg] = useState<any | null>();
|
const [img, setImg] = useState<any | null>();
|
||||||
const [isLoading, setLoading] = useState(false);
|
const [isLoading, setLoading] = useState(false);
|
||||||
|
|
||||||
|
useShallowEffect(() => {
|
||||||
|
onLoadData();
|
||||||
|
}, []);
|
||||||
|
|
||||||
|
async function onLoadData() {
|
||||||
|
try {
|
||||||
|
const response = await apiGetDonasiKabarById({ id: id as string });
|
||||||
|
// console.log("res >", response)
|
||||||
|
if (response && response.success) {
|
||||||
|
setData(response.data);
|
||||||
|
}
|
||||||
|
} catch (error) {
|
||||||
|
clientLogger.error("Error get data kabar", error);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
async function onUpdate() {
|
async function onUpdate() {
|
||||||
if (data.title === "" || data.deskripsi === "") {
|
if (data?.title === "" || data?.deskripsi === "") {
|
||||||
return ComponentGlobal_NotifikasiPeringatan("Lengkapi data");
|
return ComponentGlobal_NotifikasiPeringatan("Lengkapi data");
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -66,16 +82,16 @@ export function Donasi_ViewEditKabar({
|
|||||||
}
|
}
|
||||||
|
|
||||||
const res = await donasi_funUpdateKabar({
|
const res = await donasi_funUpdateKabar({
|
||||||
data: data,
|
data: data as MODEL_DONASI_KABAR,
|
||||||
fileId: uploadImage.data.id,
|
fileId: uploadImage.data.id,
|
||||||
});
|
});
|
||||||
|
|
||||||
if (res.status === 200) {
|
if (res.status === 200) {
|
||||||
setLoading(false);
|
setLoading(false);
|
||||||
|
|
||||||
if (dataKabar.imageId !== null) {
|
if (data?.imageId !== null) {
|
||||||
const deleteImage = await funGlobal_DeleteFileById({
|
const deleteImage = await funGlobal_DeleteFileById({
|
||||||
fileId: data.imageId,
|
fileId: data?.imageId as string,
|
||||||
});
|
});
|
||||||
|
|
||||||
if (!deleteImage.success) {
|
if (!deleteImage.success) {
|
||||||
@@ -92,7 +108,7 @@ export function Donasi_ViewEditKabar({
|
|||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
const res = await donasi_funUpdateKabar({
|
const res = await donasi_funUpdateKabar({
|
||||||
data: data,
|
data: data as MODEL_DONASI_KABAR,
|
||||||
});
|
});
|
||||||
|
|
||||||
if (res.status === 200) {
|
if (res.status === 200) {
|
||||||
@@ -111,6 +127,8 @@ export function Donasi_ViewEditKabar({
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (!data) return <CustomSkeleton height={300} />;
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<>
|
<>
|
||||||
<Stack px={"lg"} pb={"lg"}>
|
<Stack px={"lg"} pb={"lg"}>
|
||||||
@@ -134,7 +152,7 @@ export function Donasi_ViewEditKabar({
|
|||||||
onChange={(val) => {
|
onChange={(val) => {
|
||||||
setData({
|
setData({
|
||||||
...data,
|
...data,
|
||||||
title: _.startCase(val.target.value),
|
title: val.target.value,
|
||||||
});
|
});
|
||||||
}}
|
}}
|
||||||
/>
|
/>
|
||||||
|
|||||||
@@ -11,6 +11,8 @@ import { apiGetDonasiKabarById } from "../../lib/api_donasi";
|
|||||||
import { useParams } from "next/navigation";
|
import { useParams } from "next/navigation";
|
||||||
import { useShallowEffect } from "@mantine/hooks";
|
import { useShallowEffect } from "@mantine/hooks";
|
||||||
import CustomSkeleton from "@/app_modules/components/CustomSkeleton";
|
import CustomSkeleton from "@/app_modules/components/CustomSkeleton";
|
||||||
|
import moment from "moment";
|
||||||
|
import "moment/locale/id";
|
||||||
|
|
||||||
export default function DetailKabarDonasi() {
|
export default function DetailKabarDonasi() {
|
||||||
const param = useParams<{ id: string }>();
|
const param = useParams<{ id: string }>();
|
||||||
@@ -32,7 +34,7 @@ export default function DetailKabarDonasi() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (!kabar) {
|
if (!kabar) {
|
||||||
return <CustomSkeleton />;
|
return <CustomSkeleton h={300} />;
|
||||||
}
|
}
|
||||||
|
|
||||||
return (
|
return (
|
||||||
@@ -41,9 +43,7 @@ export default function DetailKabarDonasi() {
|
|||||||
<Stack>
|
<Stack>
|
||||||
<Group position="right">
|
<Group position="right">
|
||||||
<Text>
|
<Text>
|
||||||
{new Intl.DateTimeFormat("id-ID", { dateStyle: "medium" }).format(
|
{moment(kabar.createdAt).format("DD MMM YYYY")}
|
||||||
kabar.createdAt
|
|
||||||
)}
|
|
||||||
</Text>
|
</Text>
|
||||||
</Group>
|
</Group>
|
||||||
|
|
||||||
|
|||||||
@@ -4,37 +4,56 @@ import {
|
|||||||
ComponentGlobal_CardStyles,
|
ComponentGlobal_CardStyles,
|
||||||
ComponentGlobal_LoadImageLandscape,
|
ComponentGlobal_LoadImageLandscape,
|
||||||
} from "@/app_modules/_global/component";
|
} from "@/app_modules/_global/component";
|
||||||
|
import CustomSkeleton from "@/app_modules/components/CustomSkeleton";
|
||||||
|
import { apiGetDonasiKabarById } from "@/app_modules/donasi/lib/api_donasi";
|
||||||
import { MODEL_DONASI_KABAR } from "@/app_modules/donasi/model/interface";
|
import { MODEL_DONASI_KABAR } from "@/app_modules/donasi/model/interface";
|
||||||
|
import { clientLogger } from "@/util/clientLogger";
|
||||||
import { Group, Stack, Text, Title } from "@mantine/core";
|
import { Group, Stack, Text, Title } from "@mantine/core";
|
||||||
|
import { useShallowEffect } from "@mantine/hooks";
|
||||||
|
import moment from "moment";
|
||||||
|
import "moment/locale/id";
|
||||||
|
import { useParams } from "next/navigation";
|
||||||
import { useState } from "react";
|
import { useState } from "react";
|
||||||
|
|
||||||
export default function KabarDonasi({
|
export default function KabarDonasi() {
|
||||||
dataDonasi,
|
const { id } = useParams();
|
||||||
}: {
|
const [data, setData] = useState<MODEL_DONASI_KABAR | null>(null);
|
||||||
dataDonasi: MODEL_DONASI_KABAR;
|
|
||||||
}) {
|
useShallowEffect(() => {
|
||||||
const [kabar, setKabar] = useState(dataDonasi);
|
onLoadData();
|
||||||
|
}, []);
|
||||||
|
|
||||||
|
async function onLoadData() {
|
||||||
|
try {
|
||||||
|
const response = await apiGetDonasiKabarById({ id: id as string });
|
||||||
|
console.log("res >", response)
|
||||||
|
if (response && response.success) {
|
||||||
|
setData(response.data);
|
||||||
|
}
|
||||||
|
} catch (error) {
|
||||||
|
clientLogger.error("Error get data kabar", error);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!data) return <CustomSkeleton height={300} />;
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<>
|
<>
|
||||||
<ComponentGlobal_CardStyles>
|
<ComponentGlobal_CardStyles>
|
||||||
<Stack>
|
<Stack>
|
||||||
<Group position="right">
|
<Group position="right">
|
||||||
<Text>
|
<Text>{moment(data.createdAt).format("DD MMM YYYY")}</Text>
|
||||||
{new Intl.DateTimeFormat("id-ID", { dateStyle: "medium" }).format(
|
|
||||||
kabar.createdAt
|
|
||||||
)}
|
|
||||||
</Text>
|
|
||||||
</Group>
|
</Group>
|
||||||
|
|
||||||
{kabar.imageId === null ? (
|
{data.imageId === null ? (
|
||||||
""
|
""
|
||||||
) : (
|
) : (
|
||||||
<ComponentGlobal_LoadImageLandscape fileId={kabar.imageId} />
|
<ComponentGlobal_LoadImageLandscape fileId={data.imageId} />
|
||||||
)}
|
)}
|
||||||
<Title align="center" order={4}>
|
<Title align="center" order={4}>
|
||||||
{kabar.title}
|
{data.title}
|
||||||
</Title>
|
</Title>
|
||||||
<Text>{kabar.deskripsi}</Text>
|
<Text>{data.deskripsi}</Text>
|
||||||
</Stack>
|
</Stack>
|
||||||
</ComponentGlobal_CardStyles>
|
</ComponentGlobal_CardStyles>
|
||||||
</>
|
</>
|
||||||
|
|||||||
@@ -4,37 +4,58 @@ import {
|
|||||||
ComponentGlobal_CardStyles,
|
ComponentGlobal_CardStyles,
|
||||||
ComponentGlobal_LoadImageLandscape,
|
ComponentGlobal_LoadImageLandscape,
|
||||||
} from "@/app_modules/_global/component";
|
} from "@/app_modules/_global/component";
|
||||||
|
import CustomSkeleton from "@/app_modules/components/CustomSkeleton";
|
||||||
|
import { clientLogger } from "@/util/clientLogger";
|
||||||
import { Group, Stack, Text, Title } from "@mantine/core";
|
import { Group, Stack, Text, Title } from "@mantine/core";
|
||||||
|
import { useShallowEffect } from "@mantine/hooks";
|
||||||
|
import moment from "moment";
|
||||||
|
import "moment/locale/id";
|
||||||
|
import { useParams } from "next/navigation";
|
||||||
import { useState } from "react";
|
import { useState } from "react";
|
||||||
|
import { apiGetDonasiKabarById } from "../../lib/api_donasi";
|
||||||
import { MODEL_DONASI_KABAR } from "../../model/interface";
|
import { MODEL_DONASI_KABAR } from "../../model/interface";
|
||||||
|
|
||||||
export default function UpdateKabarDonasi({
|
export default function UpdateKabarDonasi() {
|
||||||
dataKabar,
|
const { id } = useParams();
|
||||||
}: {
|
const [data, setData] = useState<MODEL_DONASI_KABAR | null>(null);
|
||||||
dataKabar: MODEL_DONASI_KABAR;
|
|
||||||
}) {
|
useShallowEffect(() => {
|
||||||
const [kabar, setKabar] = useState(dataKabar);
|
onLoadData();
|
||||||
|
}, []);
|
||||||
|
|
||||||
|
async function onLoadData() {
|
||||||
|
try {
|
||||||
|
const response = await apiGetDonasiKabarById({ id: id as string });
|
||||||
|
// console.log("res >", response)
|
||||||
|
if (response && response.success) {
|
||||||
|
setData(response.data);
|
||||||
|
}
|
||||||
|
} catch (error) {
|
||||||
|
clientLogger.error("Error get data kabar", error);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!data) return <CustomSkeleton height={300} />;
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<>
|
<>
|
||||||
<ComponentGlobal_CardStyles>
|
<ComponentGlobal_CardStyles>
|
||||||
<Stack>
|
<Stack>
|
||||||
<Group position="right">
|
<Group position="right">
|
||||||
<Text>
|
<Text>
|
||||||
{new Intl.DateTimeFormat("id-ID", { dateStyle: "medium" }).format(
|
{moment(data.createdAt).format("DD MMM YYYY")}
|
||||||
kabar.createdAt
|
|
||||||
)}
|
|
||||||
</Text>
|
</Text>
|
||||||
</Group>
|
</Group>
|
||||||
|
|
||||||
{kabar.imageId === null ? (
|
{data.imageId === null ? (
|
||||||
""
|
""
|
||||||
) : (
|
) : (
|
||||||
<ComponentGlobal_LoadImageLandscape fileId={kabar.imageId} />
|
<ComponentGlobal_LoadImageLandscape fileId={data.imageId} />
|
||||||
)}
|
)}
|
||||||
<Title align="center" order={4}>
|
<Title align="center" order={4}>
|
||||||
{kabar.title}
|
{data.title}
|
||||||
</Title>
|
</Title>
|
||||||
<Text>{kabar.deskripsi}</Text>
|
<Text>{data.deskripsi}</Text>
|
||||||
</Stack>
|
</Stack>
|
||||||
</ComponentGlobal_CardStyles>
|
</ComponentGlobal_CardStyles>
|
||||||
</>
|
</>
|
||||||
|
|||||||
@@ -9,62 +9,64 @@ import {
|
|||||||
import { UIGlobal_DrawerCustom } from "@/app_modules/_global/ui";
|
import { UIGlobal_DrawerCustom } from "@/app_modules/_global/ui";
|
||||||
import UIGlobal_LayoutHeaderTamplate from "@/app_modules/_global/ui/ui_header_tamplate";
|
import UIGlobal_LayoutHeaderTamplate from "@/app_modules/_global/ui/ui_header_tamplate";
|
||||||
import UIGlobal_LayoutTamplate from "@/app_modules/_global/ui/ui_layout_tamplate";
|
import UIGlobal_LayoutTamplate from "@/app_modules/_global/ui/ui_layout_tamplate";
|
||||||
import { ActionIcon, Center, SimpleGrid, Stack, Text } from "@mantine/core";
|
import {
|
||||||
|
ActionIcon,
|
||||||
|
Center,
|
||||||
|
SimpleGrid,
|
||||||
|
Stack,
|
||||||
|
Text,
|
||||||
|
Loader,
|
||||||
|
} from "@mantine/core";
|
||||||
import { IconDotsVertical, IconEdit, IconTrash } from "@tabler/icons-react";
|
import { IconDotsVertical, IconEdit, IconTrash } from "@tabler/icons-react";
|
||||||
import { useRouter } from "next/navigation";
|
import { useParams, useRouter } from "next/navigation";
|
||||||
import React from "react";
|
import React from "react";
|
||||||
import { Donasi_funDeleteKabar } from "../../fun/delete/fun_delete.kabar";
|
import { Donasi_funDeleteKabar } from "../../fun/delete/fun_delete.kabar";
|
||||||
import { RouterDonasi } from "@/lib/router_hipmi/router_donasi";
|
import { RouterDonasi } from "@/lib/router_hipmi/router_donasi";
|
||||||
import { Component_Header } from "@/app_modules/_global/component/new/component_header";
|
import { Component_Header } from "@/app_modules/_global/component/new/component_header";
|
||||||
import UI_NewLayoutTamplate, { UI_NewHeader, UI_NewChildren } from "@/app_modules/_global/ui/V2_layout_tamplate";
|
import UI_NewLayoutTamplate, {
|
||||||
|
UI_NewHeader,
|
||||||
|
UI_NewChildren,
|
||||||
|
} from "@/app_modules/_global/ui/V2_layout_tamplate";
|
||||||
|
|
||||||
export default function LayoutUpdateKabarDonasi({
|
export default function LayoutUpdateKabarDonasi({
|
||||||
children,
|
children,
|
||||||
kabarId,
|
|
||||||
}: {
|
}: {
|
||||||
children: React.ReactNode;
|
children: React.ReactNode;
|
||||||
kabarId: string;
|
|
||||||
}) {
|
}) {
|
||||||
|
const { id } = useParams<{ id: string }>();
|
||||||
const router = useRouter();
|
const router = useRouter();
|
||||||
const [openDrawer, setOpenDrawer] = React.useState(false);
|
const [openDrawer, setOpenDrawer] = React.useState(false);
|
||||||
|
const [loadingDelete, setLoadingDelete] = React.useState(false);
|
||||||
|
|
||||||
async function onDelete() {
|
async function onDelete() {
|
||||||
const res = await Donasi_funDeleteKabar(kabarId);
|
try {
|
||||||
if (res.status === 200) {
|
setLoadingDelete(true);
|
||||||
const deleteImage = await funGlobal_DeleteFileById({
|
const res = await Donasi_funDeleteKabar(id);
|
||||||
fileId: res.imageId as any,
|
if (res.status === 200) {
|
||||||
});
|
let deleteImage = null;
|
||||||
|
if (res.imageId) {
|
||||||
|
const deleteImage = await funGlobal_DeleteFileById({
|
||||||
|
fileId: res.imageId as any,
|
||||||
|
});
|
||||||
|
|
||||||
if (!deleteImage.success) {
|
if (!deleteImage.success) {
|
||||||
ComponentGlobal_NotifikasiPeringatan("Gagal hapus gambar ");
|
console.log("Gagal hapus gambar ");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
ComponentGlobal_NotifikasiBerhasil(res.message);
|
||||||
|
router.back();
|
||||||
|
} else {
|
||||||
|
ComponentGlobal_NotifikasiGagal(res.message);
|
||||||
}
|
}
|
||||||
|
} catch (error) {
|
||||||
ComponentGlobal_NotifikasiBerhasil(res.message);
|
console.log("Error delete kabar", error);
|
||||||
router.back();
|
} finally {
|
||||||
} else {
|
setLoadingDelete(false);
|
||||||
ComponentGlobal_NotifikasiGagal(res.message);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return (
|
return (
|
||||||
<>
|
<>
|
||||||
{/* <UIGlobal_LayoutTamplate
|
|
||||||
header={
|
|
||||||
<UIGlobal_LayoutHeaderTamplate
|
|
||||||
title="Update Kabar"
|
|
||||||
customButtonRight={
|
|
||||||
<ActionIcon
|
|
||||||
variant="transparent"
|
|
||||||
onClick={() => setOpenDrawer(true)}
|
|
||||||
>
|
|
||||||
<IconDotsVertical color="white" />
|
|
||||||
</ActionIcon>
|
|
||||||
}
|
|
||||||
/>
|
|
||||||
}
|
|
||||||
>
|
|
||||||
{children}
|
|
||||||
</UIGlobal_LayoutTamplate> */}
|
|
||||||
|
|
||||||
<UI_NewLayoutTamplate>
|
<UI_NewLayoutTamplate>
|
||||||
<UI_NewHeader>
|
<UI_NewHeader>
|
||||||
<Component_Header
|
<Component_Header
|
||||||
@@ -92,7 +94,7 @@ export default function LayoutUpdateKabarDonasi({
|
|||||||
align="center"
|
align="center"
|
||||||
spacing={"xs"}
|
spacing={"xs"}
|
||||||
onClick={() => {
|
onClick={() => {
|
||||||
router.push(RouterDonasi.edit_kabar({ id: kabarId }), {
|
router.push(RouterDonasi.edit_kabar({ id: id }), {
|
||||||
scroll: false,
|
scroll: false,
|
||||||
});
|
});
|
||||||
}}
|
}}
|
||||||
@@ -106,7 +108,11 @@ export default function LayoutUpdateKabarDonasi({
|
|||||||
<Center>
|
<Center>
|
||||||
<Stack align="center" spacing={"xs"} onClick={() => onDelete()}>
|
<Stack align="center" spacing={"xs"} onClick={() => onDelete()}>
|
||||||
<ActionIcon variant="transparent">
|
<ActionIcon variant="transparent">
|
||||||
<IconTrash color="red" />
|
{loadingDelete ? (
|
||||||
|
<Loader size="sm" color="yellow" />
|
||||||
|
) : (
|
||||||
|
<IconTrash color="red" />
|
||||||
|
)}
|
||||||
</ActionIcon>
|
</ActionIcon>
|
||||||
<Text color="red">Hapus kabar</Text>
|
<Text color="red">Hapus kabar</Text>
|
||||||
</Stack>
|
</Stack>
|
||||||
|
|||||||
Reference in New Issue
Block a user