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 { useTransitionRouter } from "next-view-transitions";
import { IconBrandInstagram, IconBrandFacebook, IconBrandTwitter, IconWorld } from "@tabler/icons-react";
function SosmedView({
data,
@@ -10,17 +12,12 @@ function SosmedView({
}) {
const router = useTransitionRouter();
const fallbackIcon = (platform?: string) => {
switch (platform?.toLowerCase()) {
case "instagram":
return <IconBrandInstagram size={22} />;
case "facebook":
return <IconBrandFacebook size={22} />;
case "twitter":
return <IconBrandTwitter size={22} />;
default:
return <IconWorld size={22} />;
const getIconSource = (item: any) => {
if (item.image?.link) return item.image.link;
if (item.icon && sosmedMap[item.icon as keyof typeof sosmedMap]?.src) {
return sosmedMap[item.icon as keyof typeof sosmedMap].src;
}
return null;
};
return (
@@ -44,18 +41,22 @@ function SosmedView({
boxShadow: "0 0 12px rgba(28, 110, 164, 0.6)",
}}
>
{item.image?.link ? (
<Image
src={item.image.link}
alt={item.name || "ikon"}
w={24}
h={24}
fit="contain"
loading="lazy"
/>
) : (
fallbackIcon(item.name)
)}
{(() => {
const src = getIconSource(item);
if (src) {
return (
<Image
loading="lazy"
src={src}
alt={item.name}
fit={item.image?.link ? "cover" : "contain"}
/>
);
}
return <Box bg={colors['blue-button']} w="100%" h="100%" />;
})()}
</ActionIcon>
</Tooltip>
))