Skip to content

Commit

Permalink
added style to the share work button
Browse files Browse the repository at this point in the history
  • Loading branch information
jasondev01 committed Sep 10, 2023
1 parent 2e9d8e7 commit 9af5bca
Show file tree
Hide file tree
Showing 2 changed files with 37 additions and 37 deletions.
67 changes: 32 additions & 35 deletions components/LoadMore.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
'use client'
"use client";

import { useRouter } from 'next/navigation'
import Button from './Button'
import { useRouter } from "next/navigation";

import Button from "./Button";

type Props = {
startCursor: string
Expand All @@ -13,41 +14,37 @@ type Props = {
const LoadMore = ({ startCursor, endCursor, hasPreviousPage, hasNextPage }: Props) => {
const router = useRouter();

const handleNavigation = (direction: string) => {
const currentParams = new URLSearchParams(window.location.search)

if(direction === 'next' && hasNextPage) {
currentParams.delete('startcursor')
currentParams.set('endcursor', endCursor)
} else if (direction === 'first' && hasPreviousPage) {
currentParams.delete('endcursor')
currentParams.delete('startcursor', startCursor)
const handleNavigation = (type: string) => {
const currentParams = new URLSearchParams(window.location.search);
if (type === "prev" && hasPreviousPage) {
currentParams.delete("endcursor");
currentParams.set("startcursor", startCursor);
} else if (type === "next" && hasNextPage) {
currentParams.delete("startcursor");
currentParams.set("endcursor", endCursor);
}

const newSearchParams = currentParams.toString();
const newPathname = `${window.location.pathname}?${newSearchParams}`

router.push(newPathname)
}
const newPathname = `${window.location.pathname}?${newSearchParams}`;
router.push(newPathname);
};

return (
<div className='flexCenter w-full gap-5 mt-10'>
{
hasPreviousPage &&
<Button
title='First Page'
handleClick={() => handleNavigation('first')}
/>
}
{
hasNextPage &&
<Button
title='Next Page'
handleClick={() => handleNavigation('next')}
/>
}
<div className="w-full flexCenter gap-5 mt-10">
{
hasPreviousPage && (
<Button title="First Page" handleClick={() => handleNavigation('prev')} />
)
}
{
hasNextPage && (
<Button title="Next Shots" handleClick={() => handleNavigation('next')} />
)
}
</div>
)
}
);
};

export default LoadMore
export default LoadMore;
7 changes: 5 additions & 2 deletions components/Navbar.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import Link from 'next/link'
import AuthProviders from './AuthProviders'
import { getCurrentUser } from '@/lib/session'
import ProfileMenu from './ProfileMenu'
import Button from './Button'

const Navbar = async () => {
const session = await getCurrentUser()
Expand Down Expand Up @@ -39,8 +40,10 @@ const Navbar = async () => {
session={session}
/>

<Link href='/create-project'>
Share Work
<Link href='/create-project' className=''>
<Button
title='Share Work'
/>
</Link>
</>
) : (
Expand Down

0 comments on commit 9af5bca

Please sign in to comment.