fix ( upload & api )
deksripsi: - fix upload image pada berita investasi - fix api berita investasi
This commit is contained in:
@@ -6,17 +6,13 @@ import {
|
||||
} from "@/app_modules/_global/ui";
|
||||
import { Investasi_ViewCreateBerita } from "../../_view";
|
||||
|
||||
export function Investasi_UiCreateBerita({
|
||||
investasiId,
|
||||
}: {
|
||||
investasiId: string;
|
||||
}) {
|
||||
export function Investasi_UiCreateBerita() {
|
||||
return (
|
||||
<>
|
||||
<UIGlobal_LayoutTamplate
|
||||
header={<UIGlobal_LayoutHeaderTamplate title="Tambah Berita" />}
|
||||
>
|
||||
<Investasi_ViewCreateBerita investasiId={investasiId} />
|
||||
<Investasi_ViewCreateBerita />
|
||||
</UIGlobal_LayoutTamplate>
|
||||
</>
|
||||
);
|
||||
|
||||
@@ -10,40 +10,82 @@ import {
|
||||
UIGlobal_DrawerCustom,
|
||||
UIGlobal_LayoutHeaderTamplate,
|
||||
UIGlobal_LayoutTamplate,
|
||||
UIGlobal_Modal
|
||||
UIGlobal_Modal,
|
||||
} from "@/app_modules/_global/ui";
|
||||
import { ActionIcon, Button, Center, Stack, Text } from "@mantine/core";
|
||||
import { IconDotsVertical, IconTrash } from "@tabler/icons-react";
|
||||
import { useRouter } from "next/navigation";
|
||||
import { useParams, useRouter } from "next/navigation";
|
||||
import { useState } from "react";
|
||||
import { investasi_funDeleteBerita } from "../../_fun";
|
||||
import { Investasi_ViewDetailBerita } from "../../_view";
|
||||
import { DIRECTORY_ID } from "@/app/lib";
|
||||
import { clientLogger } from "@/util/clientLogger";
|
||||
import { useShallowEffect } from "@mantine/hooks";
|
||||
import { apiGetBeritaInvestasiById } from "../../_lib/api_interface";
|
||||
import CustomSkeleton from "@/app_modules/components/CustomSkeleton";
|
||||
|
||||
export function Investasi_UiDetailBerita({
|
||||
userLoginId,
|
||||
}: {
|
||||
userLoginId: string;
|
||||
}) {
|
||||
const params = useParams<{ id: string }>();
|
||||
const id = params.id;
|
||||
|
||||
export function Investasi_UiDetailBerita({ dataBerita }: { dataBerita: any }) {
|
||||
const router = useRouter();
|
||||
const [openDrawer, setOpenDrawer] = useState(false);
|
||||
const [openModal, setOpenModal] = useState(false);
|
||||
const [data, setData] = useState(dataBerita);
|
||||
const [data, setData] = useState<any | null>(null);
|
||||
const [isLoading, setLoading] = useState(false);
|
||||
|
||||
async function onDelete() {
|
||||
const del = await investasi_funDeleteBerita({
|
||||
beritaId: dataBerita.id,
|
||||
});
|
||||
useShallowEffect(() => {
|
||||
onLoadData();
|
||||
}, []);
|
||||
|
||||
if (del.status === 200) {
|
||||
const deleteImage = await funGlobal_DeleteFileById({
|
||||
fileId: data.imageId,
|
||||
async function onLoadData() {
|
||||
try {
|
||||
const respone = await apiGetBeritaInvestasiById({
|
||||
id: id,
|
||||
});
|
||||
|
||||
if (!deleteImage.success) {
|
||||
ComponentGlobal_NotifikasiPeringatan("Gagal hapus gambar ");
|
||||
if (respone) {
|
||||
setData(respone.data);
|
||||
}
|
||||
} catch (error) {
|
||||
clientLogger.error("Error get detail berita", error);
|
||||
}
|
||||
}
|
||||
|
||||
ComponentGlobal_NotifikasiBerhasil(del.message);
|
||||
setOpenModal(false);
|
||||
router.back();
|
||||
} else {
|
||||
ComponentGlobal_NotifikasiGagal(del.message);
|
||||
async function onDelete() {
|
||||
try {
|
||||
setLoading(true);
|
||||
const del = await investasi_funDeleteBerita({
|
||||
beritaId: id,
|
||||
});
|
||||
|
||||
if (del.status === 200) {
|
||||
if (data.imageId != null) {
|
||||
const deleteImage = await funGlobal_DeleteFileById({
|
||||
fileId: data.imageId,
|
||||
dirId: DIRECTORY_ID.investasi_berita,
|
||||
});
|
||||
|
||||
if (!deleteImage.success) {
|
||||
setLoading(false);
|
||||
ComponentGlobal_NotifikasiPeringatan("Gagal hapus gambar ");
|
||||
}
|
||||
}
|
||||
|
||||
router.back();
|
||||
ComponentGlobal_NotifikasiBerhasil(del.message);
|
||||
setOpenModal(false);
|
||||
} else {
|
||||
setLoading(false);
|
||||
ComponentGlobal_NotifikasiGagal(del.message);
|
||||
}
|
||||
} catch (error) {
|
||||
setLoading(false);
|
||||
clientLogger.error("Error delete berita", error);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -54,17 +96,21 @@ export function Investasi_UiDetailBerita({ dataBerita }: { dataBerita: any }) {
|
||||
<UIGlobal_LayoutHeaderTamplate
|
||||
title="Detail Berita"
|
||||
customButtonRight={
|
||||
<ActionIcon
|
||||
variant="transparent"
|
||||
onClick={() => setOpenDrawer(true)}
|
||||
>
|
||||
<IconDotsVertical color="white" />
|
||||
</ActionIcon>
|
||||
data && userLoginId === data.investasi.authorId ? (
|
||||
<ActionIcon
|
||||
variant="transparent"
|
||||
onClick={() => setOpenDrawer(true)}
|
||||
>
|
||||
<IconDotsVertical color="white" />
|
||||
</ActionIcon>
|
||||
) : (
|
||||
""
|
||||
)
|
||||
}
|
||||
/>
|
||||
}
|
||||
>
|
||||
<Investasi_ViewDetailBerita dataBerita={data} />
|
||||
<Investasi_ViewDetailBerita />
|
||||
</UIGlobal_LayoutTamplate>
|
||||
|
||||
<UIGlobal_DrawerCustom
|
||||
@@ -100,6 +146,8 @@ export function Investasi_UiDetailBerita({ dataBerita }: { dataBerita: any }) {
|
||||
}
|
||||
buttonKanan={
|
||||
<Button
|
||||
loaderPosition="center"
|
||||
loading={isLoading}
|
||||
radius="xl"
|
||||
color="red"
|
||||
onClick={() => {
|
||||
|
||||
@@ -6,16 +6,12 @@ import {
|
||||
} from "@/app_modules/_global/ui";
|
||||
import { Investasi_ViewDaftarBerita } from "../../_view";
|
||||
|
||||
export function Investasi_UiDaftarBerita({
|
||||
dataBerita,
|
||||
}: {
|
||||
dataBerita: any[];
|
||||
}) {
|
||||
export function Investasi_UiDaftarBerita() {
|
||||
return (
|
||||
<UIGlobal_LayoutTamplate
|
||||
header={<UIGlobal_LayoutHeaderTamplate title="Daftar Berita" />}
|
||||
>
|
||||
<Investasi_ViewDaftarBerita dataBerita={dataBerita} />
|
||||
<Investasi_ViewDaftarBerita />
|
||||
</UIGlobal_LayoutTamplate>
|
||||
);
|
||||
}
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
"use client";
|
||||
|
||||
import { NEW_RouterInvestasi } from "@/app/lib/router_hipmi/router_investasi";
|
||||
import {
|
||||
UIGlobal_Drawer,
|
||||
UIGlobal_LayoutHeaderTamplate,
|
||||
@@ -7,19 +8,13 @@ import {
|
||||
} from "@/app_modules/_global/ui";
|
||||
import { ActionIcon } from "@mantine/core";
|
||||
import { IconCirclePlus, IconDotsVertical } from "@tabler/icons-react";
|
||||
import { useRouter } from "next/navigation";
|
||||
import { useParams } from "next/navigation";
|
||||
import { useState } from "react";
|
||||
import { Investasi_ViewRekapBerita } from "../../_view";
|
||||
import { NEW_RouterInvestasi } from "@/app/lib/router_hipmi/router_investasi";
|
||||
|
||||
export function Investasi_UiRekapBerita({
|
||||
investasiId,
|
||||
dataBerita,
|
||||
}: {
|
||||
investasiId: string;
|
||||
dataBerita: any[]
|
||||
}) {
|
||||
const router = useRouter();
|
||||
export function Investasi_UiRekapBerita() {
|
||||
const params = useParams<{ id: string }>();
|
||||
const investasiId = params.id;
|
||||
const [openDrawer, setOpenDrawer] = useState(false);
|
||||
|
||||
const listPage = [
|
||||
@@ -32,32 +27,32 @@ export function Investasi_UiRekapBerita({
|
||||
];
|
||||
|
||||
return (
|
||||
<UIGlobal_LayoutTamplate
|
||||
header={
|
||||
<UIGlobal_LayoutHeaderTamplate
|
||||
title="Rekap Berita"
|
||||
customButtonRight={
|
||||
<ActionIcon
|
||||
variant="transparent"
|
||||
onClick={() => {
|
||||
setOpenDrawer(true);
|
||||
}}
|
||||
>
|
||||
<IconDotsVertical color="white" />
|
||||
</ActionIcon>
|
||||
}
|
||||
/>
|
||||
}
|
||||
>
|
||||
|
||||
|
||||
<Investasi_ViewRekapBerita dataBerita={dataBerita} />
|
||||
<>
|
||||
<UIGlobal_LayoutTamplate
|
||||
header={
|
||||
<UIGlobal_LayoutHeaderTamplate
|
||||
title="Rekap Berita"
|
||||
customButtonRight={
|
||||
<ActionIcon
|
||||
variant="transparent"
|
||||
onClick={() => {
|
||||
setOpenDrawer(true);
|
||||
}}
|
||||
>
|
||||
<IconDotsVertical color="white" />
|
||||
</ActionIcon>
|
||||
}
|
||||
/>
|
||||
}
|
||||
>
|
||||
<Investasi_ViewRekapBerita />
|
||||
</UIGlobal_LayoutTamplate>
|
||||
|
||||
<UIGlobal_Drawer
|
||||
opened={openDrawer}
|
||||
close={() => setOpenDrawer(false)}
|
||||
component={listPage}
|
||||
/>
|
||||
</UIGlobal_LayoutTamplate>
|
||||
</>
|
||||
);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user