Dokumen investasi
# feat: - Tampilan upload dokuman - Function upload - Function delete - Function get data dokumen ### No issue
This commit is contained in:
@@ -1,17 +1,29 @@
|
||||
"use client";
|
||||
|
||||
import { RouterInvestasi } from "@/app/lib/router_hipmi/router_investasi";
|
||||
import HeaderTamplate from "@/app_modules/component/header_tamplate";
|
||||
import { AppShell } from "@mantine/core";
|
||||
import { IconEdit } from "@tabler/icons-react";
|
||||
import React from "react";
|
||||
|
||||
export default function LayoutEditDokumenInvestasi({
|
||||
children,
|
||||
idInves,
|
||||
}: {
|
||||
children: React.ReactNode;
|
||||
idInves: string
|
||||
}) {
|
||||
return (
|
||||
<>
|
||||
<AppShell header={<HeaderTamplate title="Edit Dokumen" />}>
|
||||
<AppShell
|
||||
header={
|
||||
<HeaderTamplate
|
||||
title="Edit Dokumen"
|
||||
icon={<IconEdit />}
|
||||
route2={RouterInvestasi.upload_dokumen + `${idInves}`}
|
||||
/>
|
||||
}
|
||||
>
|
||||
{children}
|
||||
</AppShell>
|
||||
</>
|
||||
|
||||
@@ -1,22 +1,57 @@
|
||||
"use client"
|
||||
"use client";
|
||||
|
||||
import { Paper, Grid, Center, Title, Divider, Button, Text } from "@mantine/core";
|
||||
import { IconChevronRight } from "@tabler/icons-react";
|
||||
import {
|
||||
Paper,
|
||||
Grid,
|
||||
Center,
|
||||
Title,
|
||||
Divider,
|
||||
Button,
|
||||
Text,
|
||||
ActionIcon,
|
||||
Group,
|
||||
} from "@mantine/core";
|
||||
import {
|
||||
IconChevronRight,
|
||||
IconTrash,
|
||||
IconWorldShare,
|
||||
} from "@tabler/icons-react";
|
||||
import Link from "next/link";
|
||||
import { useState } from "react";
|
||||
import { MODEL_Investasi } from "../model/model_investasi";
|
||||
import _ from "lodash";
|
||||
import funDeleteDokumenInvestasi from "../fun/fun_delete_dokumen";
|
||||
import toast from "react-simple-toasts";
|
||||
import funLoadDataInvestasi from "../fun/fun_load_data";
|
||||
|
||||
export default function EditDokumenInvestasi(){
|
||||
const [edit, setEdit] = useState(false);
|
||||
export default function EditDokumenInvestasi({
|
||||
dataInvestasi,
|
||||
}: {
|
||||
dataInvestasi: MODEL_Investasi;
|
||||
}) {
|
||||
const [dokumen, setDokumen] = useState(dataInvestasi);
|
||||
|
||||
async function onDelete(id: string) {
|
||||
await funDeleteDokumenInvestasi(id)
|
||||
.then( async (res) => {
|
||||
if(res.status === 200){
|
||||
toast(res.message)
|
||||
const load = await funLoadDataInvestasi(dokumen.id)
|
||||
setDokumen(load as any)
|
||||
|
||||
} else {
|
||||
toast(res.message)
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
return (
|
||||
<>
|
||||
{edit ? (
|
||||
<Link
|
||||
href={"https://pii.or.id/uploads/dummies.pdf"}
|
||||
target="_blank"
|
||||
style={{ textDecorationLine: "none" }}
|
||||
>
|
||||
<Paper w={"100%"} h={50} bg={"gray"} mb={"md"}>
|
||||
{/* <pre>{JSON.stringify(dokukem, null, 2)}</pre> */}
|
||||
|
||||
{!_.isEmpty(dokumen.DokumenInvestasi) ? (
|
||||
dokumen.DokumenInvestasi.map((e) => (
|
||||
<Paper key={e.id} w={"100%"} h={50} bg={"gray"} mb={"md"}>
|
||||
<Grid
|
||||
align="center"
|
||||
justify="center"
|
||||
@@ -24,17 +59,29 @@ export default function EditDokumenInvestasi(){
|
||||
px={"sm"}
|
||||
onClick={() => ""}
|
||||
>
|
||||
<Grid.Col span={10}>
|
||||
<Text>Nama File.pdf</Text>
|
||||
<Grid.Col span={8}>
|
||||
<Text>{e.title}</Text>
|
||||
</Grid.Col>
|
||||
<Grid.Col span={2}>
|
||||
<Center>
|
||||
<IconChevronRight />
|
||||
</Center>
|
||||
|
||||
<Grid.Col span={4}>
|
||||
<Group position="center">
|
||||
<Link
|
||||
href={`/file/${e.url}`}
|
||||
target="_blank"
|
||||
|
||||
>
|
||||
<ActionIcon variant="transparent">
|
||||
<IconWorldShare color="green" />
|
||||
</ActionIcon>
|
||||
</Link>
|
||||
<ActionIcon variant="transparent" onClick={() => onDelete(e.id)}>
|
||||
<IconTrash color="red" />
|
||||
</ActionIcon>
|
||||
</Group>
|
||||
</Grid.Col>
|
||||
</Grid>
|
||||
</Paper>
|
||||
</Link>
|
||||
))
|
||||
) : (
|
||||
<Center>
|
||||
<Title order={4}>Tidak ada file</Title>
|
||||
@@ -42,12 +89,6 @@ export default function EditDokumenInvestasi(){
|
||||
)}
|
||||
|
||||
<Divider mt={"lg"} />
|
||||
|
||||
<Center>
|
||||
<Button mt={"md"} compact radius={50}>
|
||||
Upload
|
||||
</Button>
|
||||
</Center>
|
||||
</>
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user