upd: view file project

Deskripsi
- install package pdf
- layout modal file
- ganti route api image

No Issues
This commit is contained in:
amel
2024-09-03 16:24:18 +08:00
parent 10d9cd54f9
commit 6638d719f3
31 changed files with 461 additions and 40 deletions

View File

@@ -0,0 +1,34 @@
'use client'
import { Image, Modal } from '@mantine/core';
import dynamic from 'next/dynamic';
import React, { useState } from 'react';
const PdfToImage = dynamic(() => import('./../components/pdf_viewer').then((mod) => mod.default), { ssr: false });
export default function LayoutModal({ opened, onClose, extension, fitur, file }: { opened: boolean, onClose: () => void, extension: string, fitur: string, file: string }) {
const [isValModal, setValModal] = useState(opened)
const filePdf = '/file/' + fitur + '/' + file
return (
<Modal styles={{
body: {
margin: 10,
},
content: {
border: `2px solid ${'#828AFC'}`,
borderRadius: 10
}
}} opened={opened} onClose={onClose} withCloseButton={true} centered closeOnClickOutside={false}>
{
extension === 'pdf' ? <PdfToImage md={filePdf} /> :
<Image
radius="md"
h={200}
w="auto"
fit="contain"
src={`/api/file/img?cat=${fitur}&file=${file}&jenis=file`}
/>
}
</Modal>
);
}