rev: divisi detail
Deskripsi: - menampilkan file share pada dokumen terkini No Issues
This commit is contained in:
@@ -133,7 +133,43 @@ export async function GET(request: Request, context: { params: { id: string } })
|
||||
projectTitle: v.DivisionProject.title
|
||||
}))
|
||||
} else if (kategori == "new-file") {
|
||||
allData = await prisma.divisionDocumentFolderFile.findMany({
|
||||
const dataShare = await prisma.divisionDocumentShare.findMany({
|
||||
skip: 0,
|
||||
take: 5,
|
||||
where: {
|
||||
isActive: true,
|
||||
idDivision: String(id),
|
||||
DivisionDocumentFolderFile: {
|
||||
isActive: true,
|
||||
category: "FILE"
|
||||
}
|
||||
},
|
||||
select: {
|
||||
DivisionDocumentFolderFile: {
|
||||
select: {
|
||||
id: true,
|
||||
name: true,
|
||||
extension: true,
|
||||
path: true,
|
||||
}
|
||||
},
|
||||
createdAt: true
|
||||
},
|
||||
orderBy: {
|
||||
createdAt: 'desc'
|
||||
}
|
||||
})
|
||||
|
||||
const fixShare = dataShare.map((v: any) => ({
|
||||
..._.omit(v, ["DivisionDocumentFolderFile"]),
|
||||
id: v.DivisionDocumentFolderFile.id,
|
||||
name: v.DivisionDocumentFolderFile.name,
|
||||
extension: v.DivisionDocumentFolderFile.extension,
|
||||
path: 'home',
|
||||
share: true
|
||||
}))
|
||||
|
||||
const dataDokumen = await prisma.divisionDocumentFolderFile.findMany({
|
||||
skip: 0,
|
||||
take: 5,
|
||||
where: {
|
||||
@@ -146,11 +182,24 @@ export async function GET(request: Request, context: { params: { id: string } })
|
||||
name: true,
|
||||
extension: true,
|
||||
path: true,
|
||||
createdAt: true
|
||||
},
|
||||
orderBy: {
|
||||
createdAt: "desc"
|
||||
}
|
||||
})
|
||||
|
||||
const fixData = dataDokumen.map((v: any) => ({
|
||||
..._.omit(v, [""]),
|
||||
share: false
|
||||
}))
|
||||
|
||||
if (fixShare.length > 0) {
|
||||
fixData.push(...fixShare)
|
||||
}
|
||||
|
||||
allData = _.orderBy(fixData, ['createdAt'], ['desc']);
|
||||
|
||||
} else if (kategori == "new-discussion") {
|
||||
const diskusi = await prisma.divisionDisscussion.findMany({
|
||||
skip: 0,
|
||||
|
||||
@@ -42,7 +42,8 @@ export interface IDataKalenderOnDetailDivision {
|
||||
id: string,
|
||||
name: string,
|
||||
extension: string,
|
||||
path: string
|
||||
path: string,
|
||||
share:boolean
|
||||
}
|
||||
|
||||
export interface IDataDiscussionOnDetailDivision {
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
import { TEMA, } from "@/module/_global";
|
||||
import { useHookstate } from "@hookstate/core";
|
||||
import { Carousel } from "@mantine/carousel";
|
||||
import { Box, Center, Group, Image, Skeleton, Stack, Text, UnstyledButton } from "@mantine/core";
|
||||
import { Box, Center, Flex, Group, Image, Indicator, Skeleton, Stack, Text, UnstyledButton } from "@mantine/core";
|
||||
import { useMediaQuery, useShallowEffect } from "@mantine/hooks";
|
||||
import { useParams, useRouter } from "next/navigation";
|
||||
import { useState } from "react";
|
||||
@@ -10,6 +10,7 @@ import toast from "react-hot-toast";
|
||||
import { funGetDetailDivisionById } from "../lib/api_division";
|
||||
import * as ICON from '../lib/file_icon';
|
||||
import { IDataKalenderOnDetailDivision } from "../lib/type_division";
|
||||
import { FaShare } from "react-icons/fa6";
|
||||
|
||||
const iconContainer = (icon: string) => 'data:image/svg+xml;base64,' + btoa(icon)
|
||||
|
||||
@@ -44,7 +45,7 @@ export default function ListDocumentOnDetailDivision() {
|
||||
|
||||
return (
|
||||
<Box pt={10}>
|
||||
<Text c={tema.get().utama} mb={10} fw={'bold'} fz={16}>Dokumen Terbaru</Text>
|
||||
<Text c={tema.get().utama} mb={10} fw={'bold'} fz={16}>Dokumen Terkini</Text>
|
||||
<Group justify="center" grow>
|
||||
{
|
||||
loading
|
||||
@@ -70,11 +71,31 @@ export default function ListDocumentOnDetailDivision() {
|
||||
<Carousel.Slide key={v.id}>
|
||||
<UnstyledButton onClick={() => router.push(`/division/${param.id}/document?path=${v.path}`)}>
|
||||
<Stack gap={0} w={isMobile ? 100 : 170}>
|
||||
<Box bg={"white"} style={{ borderRadius: 10, border: `1px solid ${"#D6D8F6"}` }} >
|
||||
<Center p={"md"}>
|
||||
<Image w={isMobile ? 50 : 75} src={(v.extension == "pdf") ? iconContainer(ICON.PDF) : iconContainer(ICON.IMAGE)} alt="image" />
|
||||
</Center>
|
||||
</Box>
|
||||
{
|
||||
v.share ?
|
||||
<Indicator
|
||||
offset={15}
|
||||
withBorder
|
||||
inline
|
||||
color={'#D6D8F6'}
|
||||
position="bottom-end"
|
||||
label={<FaShare />}
|
||||
size={25}
|
||||
>
|
||||
<Box bg={"white"} style={{ borderRadius: 10, border: `1px solid ${"#D6D8F6"}` }} >
|
||||
<Center p={"md"}>
|
||||
<Image w={isMobile ? 50 : 75} src={(v.extension == "pdf") ? iconContainer(ICON.PDF) : iconContainer(ICON.IMAGE)} alt="image" />
|
||||
</Center>
|
||||
</Box>
|
||||
</Indicator>
|
||||
:
|
||||
<Box bg={"white"} style={{ borderRadius: 10, border: `1px solid ${"#D6D8F6"}` }} >
|
||||
<Center p={"md"}>
|
||||
<Image w={isMobile ? 50 : 75} src={(v.extension == "pdf") ? iconContainer(ICON.PDF) : iconContainer(ICON.IMAGE)} alt="image" />
|
||||
</Center>
|
||||
</Box>
|
||||
}
|
||||
|
||||
<Box>
|
||||
<Text c={"dimmed"} ta={"center"} lineClamp={1} fz={isMobile ? 14 : 16}>{v.name + '.' + v.extension}</Text>
|
||||
</Box>
|
||||
|
||||
Reference in New Issue
Block a user