Files
twenty/packages/twenty-front/src/modules/activities/timelineActivities/components/TimelineActivities.tsx
Weiko 39af374de0 fix timeline activity pagination overflow (#5861)
## Before
<img width="250" alt="Screenshot 2024-06-13 at 18 51 56"
src="https://github.com/twentyhq/twenty/assets/1834158/d6c7f5fa-3cc7-48bc-a711-29345e93af92">


## After
<img width="284" alt="Screenshot 2024-06-13 at 18 51 41"
src="https://github.com/twentyhq/twenty/assets/1834158/25029e0a-c1b0-4458-b715-dbab217eeee0">
2024-06-13 19:04:53 +02:00

74 lines
2.6 KiB
TypeScript

import styled from '@emotion/styled';
import { isNonEmptyArray } from '@sniptt/guards';
import { CustomResolverFetchMoreLoader } from '@/activities/components/CustomResolverFetchMoreLoader';
import { TimelineCreateButtonGroup } from '@/activities/timeline/components/TimelineCreateButtonGroup';
import { EventList } from '@/activities/timelineActivities/components/EventList';
import { useTimelineActivities } from '@/activities/timelineActivities/hooks/useTimelineActivities';
import { ActivityTargetableObject } from '@/activities/types/ActivityTargetableEntity';
import AnimatedPlaceholder from '@/ui/layout/animated-placeholder/components/AnimatedPlaceholder';
import {
AnimatedPlaceholderEmptyContainer,
AnimatedPlaceholderEmptySubTitle,
AnimatedPlaceholderEmptyTextContainer,
AnimatedPlaceholderEmptyTitle,
} from '@/ui/layout/animated-placeholder/components/EmptyPlaceholderStyled';
import { useIsMobile } from '@/ui/utilities/responsive/hooks/useIsMobile';
const StyledMainContainer = styled.div`
align-items: flex-start;
align-self: stretch;
border-top: ${({ theme }) =>
useIsMobile() ? `1px solid ${theme.border.color.medium}` : 'none'};
display: flex;
flex-direction: column;
height: 100%;
overflow: auto;
justify-content: center;
padding-top: ${({ theme }) => theme.spacing(6)};
padding-right: ${({ theme }) => theme.spacing(6)};
padding-left: ${({ theme }) => theme.spacing(6)};
gap: ${({ theme }) => theme.spacing(4)};
`;
export const TimelineActivities = ({
targetableObject,
}: {
targetableObject: ActivityTargetableObject;
}) => {
const { timelineActivities, loading, fetchMoreRecords } =
useTimelineActivities(targetableObject);
if (!isNonEmptyArray(timelineActivities)) {
return (
<AnimatedPlaceholderEmptyContainer>
<AnimatedPlaceholder type="emptyTimeline" />
<AnimatedPlaceholderEmptyTextContainer>
<AnimatedPlaceholderEmptyTitle>
Add your first Activity
</AnimatedPlaceholderEmptyTitle>
<AnimatedPlaceholderEmptySubTitle>
There are no activities associated with this record.{' '}
</AnimatedPlaceholderEmptySubTitle>
</AnimatedPlaceholderEmptyTextContainer>
<TimelineCreateButtonGroup targetableObject={targetableObject} />
</AnimatedPlaceholderEmptyContainer>
);
}
return (
<StyledMainContainer>
<EventList
targetableObject={targetableObject}
title="All"
events={timelineActivities ?? []}
/>
<CustomResolverFetchMoreLoader
loading={loading}
onLastRowVisible={fetchMoreRecords}
/>
</StyledMainContainer>
);
};