diff --git a/app/[locale]/(public)/document/detail/[slug]/page.tsx b/app/[locale]/(public)/document/detail/[slug]/page.tsx index f762713b..a9d3a4ce 100644 --- a/app/[locale]/(public)/document/detail/[slug]/page.tsx +++ b/app/[locale]/(public)/document/detail/[slug]/page.tsx @@ -140,11 +140,19 @@ const DetailDocument = () => { } }; - const sizes = [ - { label: "DOC", value: "...KB" }, - { label: "PPT", value: "...KB" }, - { label: "PDF", value: "...KB" }, - ]; + const size = [{ label: "DOC" }, { label: "PPT" }, { label: "PDF" }]; + + function formatBytes(kb: any, decimals = 2) { + if (kb == 0 || kb == null) return "0 KB"; + + const k = 1024; + const dm = decimals < 0 ? 0 : decimals; + const sizes = ["KB", "MB", "GB", "TB", "PB", "EB", "ZB", "YB"]; + + const i = Math.floor(Math.log(kb) / Math.log(k)); + + return `${parseFloat((kb / k ** i).toFixed(dm))} ${sizes[i]}`; + } async function sendActivityLog(activityTypeId: number) { const data = { @@ -499,14 +507,14 @@ const DetailDocument = () => {

{t("docSize")}

- {sizes.map((size: any) => ( + {size.map((size: any) => (
setSelectedSize(size.label)} className="text-red-600 focus:ring-red-600" />
{size.label}
-
{size.value}
+
{formatBytes(size?.size)}
))} diff --git a/app/[locale]/(public)/image/detail/[slug]/page.tsx b/app/[locale]/(public)/image/detail/[slug]/page.tsx index 53d4b3a2..6e74dac7 100644 --- a/app/[locale]/(public)/image/detail/[slug]/page.tsx +++ b/app/[locale]/(public)/image/detail/[slug]/page.tsx @@ -22,6 +22,11 @@ import { Skeleton } from "@/components/ui/skeleton"; import { useTranslations } from "next-intl"; import Image from "next/image"; +interface Size { + label: string; + value: string; +} + const DetailInfo = () => { const MySwal = withReactContent(Swal); const [selectedSize, setSelectedSize] = useState("L"); @@ -56,6 +61,7 @@ const DetailInfo = () => { let typeString = "image"; const t = useTranslations("LandingPage"); + useEffect(() => { const timer = setTimeout(() => { setIsLoading(false); @@ -149,13 +155,34 @@ const DetailInfo = () => { } }; - const sizes = [ - { label: "XL", value: "3198 x 1798 px" }, - { label: "L", value: "2399 x 1349 px" }, - { label: "M", value: "1599 x 899 px" }, - { label: "S", value: "1066 x 599 px" }, - { label: "XS", value: "800 x 450 px" }, - ]; + // const sizes = [ + // { label: "XL", value: "3198 x 1798 px" }, + // { label: "L", value: "2399 x 1349 px" }, + // { label: "M", value: "1599 x 899 px" }, + // { label: "S", value: "1066 x 599 px" }, + // { label: "XS", value: "800 x 450 px" }, + // ]; + + const scaleFactors = { + XL: 2, + L: 1.5, + M: 1.25, + S: 1, + XS: 0.75, + }; + const sizes: Size[] = Object.entries(scaleFactors).map(([label, factor]) => { + const width = Number(main?.widthPixel); + const height = Number(main?.heightPixel); + + if (isNaN(width) || isNaN(height) || width === 0) { + return { label, value: "Invalid size" }; + } + + const newWidth = Math.round(width * factor); + const newHeight = Math.round((width * factor) / (width / height)); + + return { label, value: `${newWidth} x ${newHeight} px` }; + }); async function sendActivityLog(activityTypeId: number) { const data = { @@ -540,13 +567,11 @@ const DetailInfo = () => {
{sizes.map((size: any) => (
-
- setImageSizeSelected(e.target.value)} className="text-red-600 focus:ring-red-600" /> -
{size.label}
-
-
-
{size.value}
+
+ setImageSizeSelected(e.target.value)} className="text-red-600 focus:ring-red-600" /> +
{size?.label}
+
{size?.value}
))}
diff --git a/app/[locale]/(public)/schedule/page.tsx b/app/[locale]/(public)/schedule/page.tsx index adc6ec29..585c58de 100644 --- a/app/[locale]/(public)/schedule/page.tsx +++ b/app/[locale]/(public)/schedule/page.tsx @@ -505,7 +505,7 @@ const Schedule = (props: any) => { - + Filter @@ -856,8 +856,8 @@ const Schedule = (props: any) => {

-

- +

+ {detail?.address}

diff --git a/app/[locale]/(public)/video/detail/[slug]/page.tsx b/app/[locale]/(public)/video/detail/[slug]/page.tsx index 9f96118b..21cd37eb 100644 --- a/app/[locale]/(public)/video/detail/[slug]/page.tsx +++ b/app/[locale]/(public)/video/detail/[slug]/page.tsx @@ -22,6 +22,11 @@ import parse from "html-react-parser"; import { useTranslations } from "next-intl"; import Image from "next/image"; +interface Size { + label: string; + value: string; +} + const DetailVideo = () => { const [selectedSize, setSelectedSize] = useState("L"); const [selectedTab, setSelectedTab] = useState("video"); @@ -140,11 +145,10 @@ const DetailVideo = () => { }; const sizes = [ - { label: "XL", value: "3198 x 1798 px" }, - { label: "L", value: "2399 x 1349 px" }, - { label: "M", value: "1599 x 899 px" }, - { label: "S", value: "1066 x 599 px" }, - { label: "XS", value: "800 x 450 px" }, + { label: "FULL HD", value: "1920 x 1080 px" }, + { label: "HD", value: "1280 x 720 px" }, + { label: "SD", value: "720 x 480 px" }, + { label: "WEB", value: "640 x 360 px" }, ]; async function sendActivityLog(activityTypeId: number) { diff --git a/app/[locale]/auth/forgot-password/page.tsx b/app/[locale]/auth/forgot-password/page.tsx index 45f2f7d0..7aaa1ffe 100644 --- a/app/[locale]/auth/forgot-password/page.tsx +++ b/app/[locale]/auth/forgot-password/page.tsx @@ -21,9 +21,9 @@ const ForgotPassPage = () => {
- + {/* - + */}

Forgot Your Password?

diff --git a/components/landing-page/hero.tsx b/components/landing-page/hero.tsx index c6126c84..16dafb3b 100644 --- a/components/landing-page/hero.tsx +++ b/components/landing-page/hero.tsx @@ -68,7 +68,7 @@ const Hero: React.FC = () => { {heroData?.map((list: any) => (
- gambar-utama + gambar-utama
{list?.categoryName} @@ -89,8 +89,8 @@ const Hero: React.FC = () => { ))} - - + + )} diff --git a/components/landing-page/navbar.tsx b/components/landing-page/navbar.tsx index d2cf5e21..37f5b6d1 100644 --- a/components/landing-page/navbar.tsx +++ b/components/landing-page/navbar.tsx @@ -708,7 +708,7 @@ const Navbar = () => { {/* Mobile Menu */} {menuOpen && ( -
+
diff --git a/components/landing-page/new-content.tsx b/components/landing-page/new-content.tsx index 3301eecf..284317cb 100644 --- a/components/landing-page/new-content.tsx +++ b/components/landing-page/new-content.tsx @@ -129,8 +129,8 @@ const NewContent = (props: { group: string; type: string }) => { ))} - - + + ) : (

diff --git a/components/ui/carousel.tsx b/components/ui/carousel.tsx index a56cc9de..e97c697a 100644 --- a/components/ui/carousel.tsx +++ b/components/ui/carousel.tsx @@ -1,9 +1,7 @@ "use client"; import * as React from "react"; -import useEmblaCarousel, { - type UseEmblaCarouselType, -} from "embla-carousel-react"; +import useEmblaCarousel, { type UseEmblaCarouselType } from "embla-carousel-react"; import { ArrowLeft, ArrowRight } from "lucide-react"; import { cn } from "@/lib/utils"; @@ -42,162 +40,109 @@ function useCarousel() { return context; } -const Carousel = React.forwardRef< - HTMLDivElement, - React.HTMLAttributes & CarouselProps ->( - ( +const Carousel = React.forwardRef & CarouselProps>(({ orientation = "horizontal", opts, setApi, plugins, className, children, ...props }, ref) => { + const [carouselRef, api] = useEmblaCarousel( { - orientation = "horizontal", - opts, - setApi, - plugins, - className, - children, - ...props + ...opts, + axis: orientation === "horizontal" ? "x" : "y", }, - ref - ) => { - const [carouselRef, api] = useEmblaCarousel( - { - ...opts, - axis: orientation === "horizontal" ? "x" : "y", - }, - plugins - ); - const [canScrollPrev, setCanScrollPrev] = React.useState(false); - const [canScrollNext, setCanScrollNext] = React.useState(false); + plugins + ); + const [canScrollPrev, setCanScrollPrev] = React.useState(false); + const [canScrollNext, setCanScrollNext] = React.useState(false); - const onSelect = React.useCallback((api: CarouselApi) => { - if (!api) { - return; + const onSelect = React.useCallback((api: CarouselApi) => { + if (!api) { + return; + } + + setCanScrollPrev(api.canScrollPrev()); + setCanScrollNext(api.canScrollNext()); + }, []); + + const scrollPrev = React.useCallback(() => { + api?.scrollPrev(); + }, [api]); + + const scrollNext = React.useCallback(() => { + api?.scrollNext(); + }, [api]); + + const handleKeyDown = React.useCallback( + (event: React.KeyboardEvent) => { + if (event.key === "ArrowLeft") { + event.preventDefault(); + scrollPrev(); + } else if (event.key === "ArrowRight") { + event.preventDefault(); + scrollNext(); } + }, + [scrollPrev, scrollNext] + ); - setCanScrollPrev(api.canScrollPrev()); - setCanScrollNext(api.canScrollNext()); - }, []); + React.useEffect(() => { + if (!api || !setApi) { + return; + } - const scrollPrev = React.useCallback(() => { - api?.scrollPrev(); - }, [api]); + setApi(api); + }, [api, setApi]); - const scrollNext = React.useCallback(() => { - api?.scrollNext(); - }, [api]); + React.useEffect(() => { + if (!api) { + return; + } - const handleKeyDown = React.useCallback( - (event: React.KeyboardEvent) => { - if (event.key === "ArrowLeft") { - event.preventDefault(); - scrollPrev(); - } else if (event.key === "ArrowRight") { - event.preventDefault(); - scrollNext(); - } - }, - [scrollPrev, scrollNext] - ); + onSelect(api); + api.on("reInit", onSelect); + api.on("select", onSelect); - React.useEffect(() => { - if (!api || !setApi) { - return; - } + return () => { + api?.off("select", onSelect); + }; + }, [api, onSelect]); - setApi(api); - }, [api, setApi]); - - React.useEffect(() => { - if (!api) { - return; - } - - onSelect(api); - api.on("reInit", onSelect); - api.on("select", onSelect); - - return () => { - api?.off("select", onSelect); - }; - }, [api, onSelect]); - - return ( - -

- {children} -
- - ); - } -); + return ( + +
+ {children} +
+
+ ); +}); Carousel.displayName = "Carousel"; -const CarouselContent = React.forwardRef< - HTMLDivElement, - React.HTMLAttributes ->(({ className, ...props }, ref) => { +const CarouselContent = React.forwardRef>(({ className, ...props }, ref) => { const { carouselRef, orientation } = useCarousel(); return (
-
+
); }); CarouselContent.displayName = "CarouselContent"; -const CarouselItem = React.forwardRef< - HTMLDivElement, - React.HTMLAttributes ->(({ className, ...props }, ref) => { +const CarouselItem = React.forwardRef>(({ className, ...props }, ref) => { const { orientation } = useCarousel(); - return ( -
- ); + return
; }); CarouselItem.displayName = "CarouselItem"; -const CarouselPrevious = React.forwardRef< - HTMLButtonElement, - React.ComponentProps ->(({ className, variant = "outline", size = "icon", ...props }, ref) => { +const CarouselPrevious = React.forwardRef>(({ className, variant = "outline", size = "icon", ...props }, ref) => { const { orientation, scrollPrev, canScrollPrev } = useCarousel(); return ( @@ -205,13 +150,7 @@ const CarouselPrevious = React.forwardRef< ref={ref} variant={variant} size={size} - className={cn( - "absolute h-6 w-6 rounded-full text-white bg-black -ml-6", - orientation === "horizontal" - ? "-left-0 top-1/2 -translate-y-1/2" - : "-top-0 left-1/2 -translate-x-1/2 rotate-90", - className - )} + className={cn("absolute h-6 w-6 rounded-full text-white bg-black -ml-6", orientation === "horizontal" ? "-left-0 top-1/2 -translate-y-1/2" : "-top-0 left-1/2 -translate-x-1/2 rotate-90", className)} disabled={!canScrollPrev} onClick={scrollPrev} {...props} @@ -223,10 +162,7 @@ const CarouselPrevious = React.forwardRef< }); CarouselPrevious.displayName = "CarouselPrevious"; -const CarouselNext = React.forwardRef< - HTMLButtonElement, - React.ComponentProps ->(({ className, variant = "outline", size = "icon", ...props }, ref) => { +const CarouselNext = React.forwardRef>(({ className, variant = "outline", size = "icon", ...props }, ref) => { const { orientation, scrollNext, canScrollNext } = useCarousel(); return ( @@ -234,13 +170,7 @@ const CarouselNext = React.forwardRef< ref={ref} variant={variant} size={size} - className={cn( - "absolute h-6 w-6 rounded-full bg-black text-white -mr-4", - orientation === "horizontal" - ? "-right-0 top-1/2 -translate-y-1/2" - : "-bottom-0 left-1/2 -translate-x-1/2 rotate-90", - className - )} + className={cn("absolute h-6 w-6 rounded-full bg-black text-white -mr-6", orientation === "horizontal" ? "-right-0 top-1/2 -translate-y-1/2" : "-bottom-0 left-1/2 -translate-x-1/2 rotate-90", className)} disabled={!canScrollNext} onClick={scrollNext} {...props} @@ -252,11 +182,4 @@ const CarouselNext = React.forwardRef< }); CarouselNext.displayName = "CarouselNext"; -export { - type CarouselApi, - Carousel, - CarouselContent, - CarouselItem, - CarouselPrevious, - CarouselNext, -}; +export { type CarouselApi, Carousel, CarouselContent, CarouselItem, CarouselPrevious, CarouselNext };