Skip to content

Commit

Permalink
feat(molecules-link): dateScopeLink 추가 (#334)
Browse files Browse the repository at this point in the history
  • Loading branch information
MINJE-98 authored Aug 12, 2022
1 parent 8e3b27b commit 1d65764
Showing 1 changed file with 39 additions and 0 deletions.
39 changes: 39 additions & 0 deletions src/components/common/molecules/link/DateScopeLink.tsx
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;

0 comments on commit 1d65764

Please sign in to comment.