Fix UI Sosial Media Landing Page in User
This commit is contained in:
@@ -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 ? (
|
{(() => {
|
||||||
<Image
|
const src = getIconSource(item);
|
||||||
src={item.image.link}
|
|
||||||
alt={item.name || "ikon"}
|
if (src) {
|
||||||
w={24}
|
return (
|
||||||
h={24}
|
<Image
|
||||||
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>
|
||||||
))
|
))
|
||||||
|
|||||||
Reference in New Issue
Block a user