-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(molecules-link): dateScopeLink 추가 (#334)
- Loading branch information
Showing
1 changed file
with
39 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
import { useRouter } from "next/router"; | ||
|
||
import LinkTo from "@Components/common/atom/LinkTo"; | ||
import routerHelper from "@Library/utility/routerHelper"; | ||
|
||
import GetPostRequestDto from "@Library/api/post/interface/getPostRequestDto"; | ||
|
||
const DateScopeLink = ({ | ||
dateScope, | ||
}: { | ||
dateScope: GetPostRequestDto["dateScope"]; | ||
}) => { | ||
const router = useRouter(); | ||
|
||
if (router.query.dateScope !== dateScope) { | ||
return ( | ||
<LinkTo | ||
scroll={false} | ||
href={{ | ||
pathname: router.pathname, | ||
query: { ...router.query, dateScope }, | ||
}} | ||
className="p-2 text-base font-semibold hover:no-underline text-neutral-400 dark:text-neutral-50" | ||
> | ||
{dateScope} | ||
</LinkTo> | ||
); | ||
} | ||
return ( | ||
<LinkTo | ||
scroll={false} | ||
href={routerHelper(router.asPath, "dateScope", dateScope)} | ||
className="p-2 text-base font-semibold hover:no-underline text-neutral-800 dark:text-neutral-400" | ||
> | ||
{dateScope} | ||
</LinkTo> | ||
); | ||
}; | ||
export default DateScopeLink; |