Files
twenty_crm/front/src/modules/favorites/components/Favorites.tsx
Thaïs f8ddf7f32c fix: several Navigation Bar and Drawer fixes (#2845)
* fix: several Navigation Bar and Drawer fixes

Fixes #2821

- Fix navigation drawer animations
- Fix navigation bar positioning
- Do not display navigation drawer collapse button on mobile
- Refactor code and rename componentst

* Fix storybook test

* fix: fix NavigationDrawerHeader elements space-between

---------

Co-authored-by: Charles Bochet <charles@twenty.com>
2023-12-06 10:36:10 +01:00

71 lines
2.1 KiB
TypeScript

import styled from '@emotion/styled';
import { DraggableItem } from '@/ui/layout/draggable-list/components/DraggableItem';
import { DraggableList } from '@/ui/layout/draggable-list/components/DraggableList';
import { NavigationDrawerItem } from '@/ui/navigation/navigation-drawer/components/NavigationDrawerItem';
import { NavigationDrawerSectionTitle } from '@/ui/navigation/navigation-drawer/components/NavigationDrawerSectionTitle';
import { Avatar } from '@/users/components/Avatar';
import { useFavorites } from '../hooks/useFavorites';
const StyledContainer = styled.div`
display: flex;
flex-direction: column;
overflow-x: auto;
width: 100%;
`;
export const Favorites = () => {
const { favorites, handleReorderFavorite } = useFavorites({
objectNamePlural: 'companies',
});
if (!favorites || favorites.length === 0) return <></>;
return (
<StyledContainer>
<NavigationDrawerSectionTitle label="Favorites" />
<DraggableList
onDragEnd={handleReorderFavorite}
draggableItems={
<>
{favorites.map((favorite, index) => {
const {
id,
labelIdentifier,
avatarUrl,
avatarType,
link,
recordId,
} = favorite;
return (
<DraggableItem
key={id}
draggableId={id}
index={index}
itemComponent={
<NavigationDrawerItem
key={id}
label={labelIdentifier}
Icon={() => (
<Avatar
colorId={recordId}
avatarUrl={avatarUrl}
type={avatarType}
placeholder={labelIdentifier}
/>
)}
to={link}
/>
}
/>
);
})}
</>
}
/>
</StyledContainer>
);
};