Skip to content

Commit

Permalink
feat: add prev/next post functionality
Browse files Browse the repository at this point in the history
  • Loading branch information
blushi committed Jun 24, 2024
1 parent d2f91e6 commit 9149650
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,8 @@ export type Post = {
}
| undefined;
error?: string;
prevIri?: string;
nextIri?: string;
};

export type ReactQueryGetPostQueryResponse = QueryObserverOptions<Post | null>;
Expand Down
36 changes: 26 additions & 10 deletions web-marketplace/src/pages/Post/Post.Footer.tsx
Original file line number Diff line number Diff line change
@@ -1,21 +1,37 @@
import { useNavigate } from 'react-router-dom';

import OutlinedButton from 'web-components/src/components/buttons/OutlinedButton';
import ArrowDownIcon from 'web-components/src/components/icons/ArrowDownIcon';
import Section from 'web-components/src/components/section';

import { NEXT, PREV } from './Post.constants';

export const PostFooter = () => {
// TODO add button features (APP-23)
type Props = {
prevIri?: string;
nextIri?: string;
};
export const PostFooter = ({ prevIri, nextIri }: Props) => {
const navigate = useNavigate();
return (
<Section className="flex justify-between sm:px-0 pb-[100px] py-0 max-w-[750px] m-auto">
<OutlinedButton className="text-sm">
<ArrowDownIcon className="w-[24px] h-[24px] mr-10" direction="prev" />
{PREV}
</OutlinedButton>
<OutlinedButton className="text-sm">
{NEXT}
<ArrowDownIcon className="w-[24px] h-[24px] ml-10" direction="next" />
</OutlinedButton>
{prevIri && (
<OutlinedButton
className="text-sm"
onClick={() => navigate(`/post/${prevIri}`)}
>
<ArrowDownIcon className="w-[24px] h-[24px] mr-10" direction="prev" />
{PREV}
</OutlinedButton>
)}
{nextIri && (
<OutlinedButton
className="text-sm"
onClick={() => navigate(`/post/${nextIri}`)}
>
{NEXT}
<ArrowDownIcon className="w-[24px] h-[24px] ml-10" direction="next" />
</OutlinedButton>
)}
</Section>
);
};
2 changes: 1 addition & 1 deletion web-marketplace/src/pages/Post/Post.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -159,7 +159,7 @@ function Post(): JSX.Element {
}
/>

<PostFooter />
<PostFooter prevIri={data?.prevIri} nextIri={data?.nextIri} />
</>
)}
</>
Expand Down

0 comments on commit 9149650

Please sign in to comment.