Fix UI Sosial Media Landing Page in User #35

Merged
nicoarya20 merged 1 commits from nico/2-des-25 into staggingweb 2025-12-02 16:46:50 +08:00

View File

@@ -1,7 +1,9 @@
import { ActionIcon, Card, Flex, Image, Text, Tooltip } from "@mantine/core"; /* eslint-disable @typescript-eslint/no-explicit-any */
import { sosmedMap } from "@/app/admin/(dashboard)/landing-page/profil/_lib/sosmed";
import colors from "@/con/colors";
import { ActionIcon, Box, Card, Flex, Image, Text, Tooltip } from "@mantine/core";
import { Prisma } from "@prisma/client"; import { Prisma } from "@prisma/client";
import { useTransitionRouter } from "next-view-transitions"; import { useTransitionRouter } from "next-view-transitions";
import { IconBrandInstagram, IconBrandFacebook, IconBrandTwitter, IconWorld } from "@tabler/icons-react";
function SosmedView({ function SosmedView({
data, data,
@@ -10,17 +12,12 @@ function SosmedView({
}) { }) {
const router = useTransitionRouter(); const router = useTransitionRouter();
const fallbackIcon = (platform?: string) => { const getIconSource = (item: any) => {
switch (platform?.toLowerCase()) { if (item.image?.link) return item.image.link;
case "instagram": if (item.icon && sosmedMap[item.icon as keyof typeof sosmedMap]?.src) {
return <IconBrandInstagram size={22} />; return sosmedMap[item.icon as keyof typeof sosmedMap].src;
case "facebook":
return <IconBrandFacebook size={22} />;
case "twitter":
return <IconBrandTwitter size={22} />;
default:
return <IconWorld size={22} />;
} }
return null;
}; };
return ( return (
@@ -44,18 +41,22 @@ function SosmedView({
boxShadow: "0 0 12px rgba(28, 110, 164, 0.6)", boxShadow: "0 0 12px rgba(28, 110, 164, 0.6)",
}} }}
> >
{item.image?.link ? ( {(() => {
const src = getIconSource(item);
if (src) {
return (
<Image <Image
src={item.image.link}
alt={item.name || "ikon"}
w={24}
h={24}
fit="contain"
loading="lazy" loading="lazy"
src={src}
alt={item.name}
fit={item.image?.link ? "cover" : "contain"}
/> />
) : ( );
fallbackIcon(item.name) }
)}
return <Box bg={colors['blue-button']} w="100%" h="100%" />;
})()}
</ActionIcon> </ActionIcon>
</Tooltip> </Tooltip>
)) ))