From 560e872b6a028fec314f48d33a32a952ef6c3e63 Mon Sep 17 00:00:00 2001 From: nico Date: Wed, 9 Oct 2024 17:31:48 +0800 Subject: [PATCH] Perbaikan Di Bagian Skeleton --- .../_global/components/skeleton_banner.tsx | 35 ++++ src/module/banner/ui/create_banner.tsx | 14 +- src/module/banner/ui/list_banner.tsx | 168 ++++++++---------- 3 files changed, 121 insertions(+), 96 deletions(-) create mode 100644 src/module/_global/components/skeleton_banner.tsx diff --git a/src/module/_global/components/skeleton_banner.tsx b/src/module/_global/components/skeleton_banner.tsx new file mode 100644 index 0000000..4267665 --- /dev/null +++ b/src/module/_global/components/skeleton_banner.tsx @@ -0,0 +1,35 @@ +import { useHookstate } from '@hookstate/core'; +import { Box, Flex, Group, Paper, Skeleton } from '@mantine/core'; +import { TEMA } from '../bin/val_global'; + +export default function SkeletonBanner() { + const tema = useHookstate(TEMA) + return ( + + + + + + + + + + + + + + + + ); +} \ No newline at end of file diff --git a/src/module/banner/ui/create_banner.tsx b/src/module/banner/ui/create_banner.tsx index 51a50ee..fbd4afe 100644 --- a/src/module/banner/ui/create_banner.tsx +++ b/src/module/banner/ui/create_banner.tsx @@ -158,12 +158,18 @@ function CreateBanner() { /> -
- +
+ Klik Untuk Upload Image - - Ukuran Foto Tidak Boleh Lebih Dari 1 MB + + Mohon unggah gambar dalam resolusi + + + 1535 x 450 piksel untuk memastikan + + + tampilan sesuai dengan kebutuhan desain.
diff --git a/src/module/banner/ui/list_banner.tsx b/src/module/banner/ui/list_banner.tsx index 7859b60..05b2c2b 100644 --- a/src/module/banner/ui/list_banner.tsx +++ b/src/module/banner/ui/list_banner.tsx @@ -1,22 +1,21 @@ 'use client' -import { currentScroll, LayoutDrawer, LayoutModalViewFile, TEMA, WARNA } from '@/module/_global'; +import { LayoutDrawer, LayoutModalViewFile, TEMA, WARNA } from '@/module/_global'; +import SkeletonBanner from '@/module/_global/components/skeleton_banner'; import LayoutModal from '@/module/_global/layout/layout_modal'; import { useHookstate } from '@hookstate/core'; -import { ActionIcon, Anchor, Box, Flex, Group, Image, Paper, SimpleGrid, Stack, Text, TextInput } from '@mantine/core'; -import { useParams, useRouter } from 'next/navigation'; -import { useEffect, useState } from 'react'; -import { FaFile, FaPencil, FaTrash } from 'react-icons/fa6'; -import { IDataBanner } from '../lib/type_banner'; -import toast from 'react-hot-toast'; +import { ActionIcon, Box, Flex, Group, Image, Paper, SimpleGrid, Stack, Text } from '@mantine/core'; import { useShallowEffect } from '@mantine/hooks'; -import { funDeleteBanner, funGetAllBanner, funGetOneBanner } from '../lib/api_banner'; -import { HiMagnifyingGlass } from 'react-icons/hi2'; +import { useParams, useRouter } from 'next/navigation'; +import { useState } from 'react'; +import toast from 'react-hot-toast'; +import { FaFile, FaPencil, FaTrash } from 'react-icons/fa6'; +import { funDeleteBanner, funGetAllBanner } from '../lib/api_banner'; +import { IDataBanner } from '../lib/type_banner'; function ListBanner() { - const [isList, setIsList] = useState(false) + const tema = useHookstate(TEMA) const router = useRouter(); - const param = useParams<{ id: string }>() const [isOpenModalView, setOpenModalView] = useState(false) const [isOpenModal, setOpenModal] = useState(false) const [openDrawer, setOpenDrawer] = useState(false); @@ -26,7 +25,6 @@ function ListBanner() { const [isData, setData] = useState([]) const [idData, setIdData] = useState('') const [isPage, setPage] = useState(1) - const [searchQuerry, setSearchQuerry] = useState('') const fetchData = async (loading: boolean) => { try { @@ -47,14 +45,9 @@ function ListBanner() { } } - function searchBanner(search: string) { - setSearchQuerry(search) - setPage(1) - } - - useShallowEffect(() => { fetchData(true) + setPage(1) }, [isPage]) useShallowEffect(() => { @@ -87,45 +80,61 @@ function ListBanner() { return ( - {isData.length == 0 ? - - Tidak ada Banner - - : - isData.map((v, i) => { - return ( - { - setIdData(v.id); - setIdDataStorage(v.image); - setExtension(v.extension); - setOpenDrawer(true) - } - } - style={{ - width: '100%', - maxWidth: 550, - height: 85, - backgroundColor: 'transparent', - border: `1px solid ${tema.get().bgTotalKegiatan}` + {loading + ? + Array(7) + .fill(null) + .map((_, i) => ( + + + + )) + : + - }}> - - - - - {v.title} - - - )}) - - } - + {isData.length == 0 ? + + Tidak ada Banner + + : + isData.map((v, i) => { + return ( + + { + setIdData(v.id); + setIdDataStorage(v.image); + setExtension(v.extension); + setOpenDrawer(true) + } + } + style={{ + width: '100%', + maxWidth: 550, + height: 85, + backgroundColor: 'transparent', + border: `1px solid ${tema.get().bgTotalKegiatan}` + + }}> + + + + + {v.title} + + + + ) + }) + } + + } + setOpenDrawer(false)}> @@ -136,22 +145,22 @@ function ListBanner() { alignItems: "flex-start" }} > - router.push(`/banner/edit/${idData}`)} direction="column" align="center" justify="center" pb={20}> - - - - - Edit - - - + router.push(`/banner/edit/${idData}`)} direction="column" align="center" justify="center" pb={20}> + + + + + Edit + + + { setOpenModalView(true) }} direction={"column"} align={"center"} justify={"center"}> - Lihat File + Lihat File @@ -160,7 +169,7 @@ function ListBanner() { - Hapus + Hapus @@ -185,28 +194,3 @@ function ListBanner() { } export default ListBanner; - - - - -// useEffect(() => { -// const handleScroll = async () => { -// if (containerRef && containerRef.current) { -// const scrollTop = containerRef.current.scrollTop; -// const containerHeight = containerRef.current.clientHeight; -// const scrollHeight = containerRef.current.scrollHeight; - -// if (scrollTop + containerHeight + 1 >= scrollHeight) { -// setPage(isPage + 1) -// } -// } -// }; - -// const container = containerRef?.current; -// container?.addEventListener("scroll", handleScroll); - -// return () => { -// container?.removeEventListener("scroll", handleScroll); -// }; -// }, [containerRef, isPage]); -