Fix favorite button (#9001)

Closes #8977
This commit is contained in:
Raphaël Bosi
2024-12-10 15:20:37 +01:00
committed by GitHub
parent afd3252cbe
commit 90d47a8fca

View File

@ -1,5 +1,5 @@
import { useIsFeatureEnabled } from '@/workspace/hooks/useIsFeatureEnabled'; import { useIsFeatureEnabled } from '@/workspace/hooks/useIsFeatureEnabled';
import { Button, IconButton, IconHeart } from 'twenty-ui'; import { Button, IconButton, IconHeart, IconHeartOff } from 'twenty-ui';
type PageFavoriteButtonProps = { type PageFavoriteButtonProps = {
isFavorite: boolean; isFavorite: boolean;
@ -11,18 +11,20 @@ export const PageFavoriteButton = ({
onClick, onClick,
}: PageFavoriteButtonProps) => { }: PageFavoriteButtonProps) => {
const title = isFavorite ? 'Remove from favorites' : 'Add to favorites'; const title = isFavorite ? 'Remove from favorites' : 'Add to favorites';
const isPageHeaderV2Enabled = useIsFeatureEnabled( const isPageHeaderV2Enabled = useIsFeatureEnabled(
'IS_PAGE_HEADER_V2_ENABLED', 'IS_PAGE_HEADER_V2_ENABLED',
); );
return ( return (
<> <>
{isPageHeaderV2Enabled ? ( {isPageHeaderV2Enabled ? (
<Button <Button
Icon={IconHeart} Icon={isFavorite ? IconHeartOff : IconHeart}
dataTestId="favorite-button" dataTestId="favorite-button"
size="small" size="small"
variant="secondary" variant="secondary"
accent={isFavorite ? 'danger' : 'default'} accent="default"
title={title} title={title}
onClick={onClick} onClick={onClick}
ariaLabel={title} ariaLabel={title}