mirror of
https://github.com/docmost/docmost.git
synced 2025-11-10 07:02:06 +10:00
47 lines
1.3 KiB
TypeScript
47 lines
1.3 KiB
TypeScript
import { Text, Group, Stack, UnstyledButton, Divider } from '@mantine/core';
|
|
import { format } from 'date-fns';
|
|
import classes from './home.module.css';
|
|
import { Link } from 'react-router-dom';
|
|
import PageListSkeleton from '@/features/home/components/page-list-skeleton';
|
|
import { useRecentChangesQuery } from '@/features/page/queries/page-query';
|
|
|
|
function RecentChanges() {
|
|
const { data, isLoading, isError } = useRecentChangesQuery();
|
|
|
|
if (isLoading) {
|
|
return <PageListSkeleton />;
|
|
}
|
|
|
|
if (isError) {
|
|
return <Text>Failed to fetch recent pages</Text>;
|
|
}
|
|
|
|
return (
|
|
<div>
|
|
{data
|
|
.map((page) => (
|
|
<div key={page.id}>
|
|
<UnstyledButton component={Link} to={`/p/${page.id}`}
|
|
className={classes.page} p="xs">
|
|
<Group wrap="nowrap">
|
|
|
|
<Stack gap="xs" style={{ flex: 1 }}>
|
|
<Text fw={500} size="md" lineClamp={1}>
|
|
{page.title || 'Untitled'}
|
|
</Text>
|
|
</Stack>
|
|
|
|
<Text c="dimmed" size="xs" fw={500}>
|
|
{format(new Date(page.updatedAt), 'PP')}
|
|
</Text>
|
|
</Group>
|
|
</UnstyledButton>
|
|
<Divider />
|
|
</div>
|
|
))}
|
|
</div>
|
|
);
|
|
}
|
|
|
|
export default RecentChanges;
|