Skip to content

Commit

Permalink
small refactor
Browse files Browse the repository at this point in the history
  • Loading branch information
alan2207 committed Oct 28, 2024
1 parent ae90720 commit 0a0a1dc
Show file tree
Hide file tree
Showing 5 changed files with 12 additions and 9 deletions.
8 changes: 5 additions & 3 deletions apps/nextjs-app/src/config/paths.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,14 +27,16 @@ export const paths = {
discussion: {
getHref: (id: string) => `/app/discussions/${id}`,
},
publicDiscussion: {
getHref: (id: string) => `/public/discussions/${id}`,
},
users: {
getHref: () => '/app/users',
},
profile: {
getHref: () => '/app/profile',
},
},
public: {
discussion: {
getHref: (id: string) => `/public/discussions/${id}`,
},
},
} as const;
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ export const DiscussionView = ({ discussionId }: { discussionId: string }) => {
{!isPublicView && discussion.public && (
<Link
className="ml-2 flex items-center gap-2 text-sm font-bold"
href={paths.app.publicDiscussion.getHref(discussionId)}
href={paths.public.discussion.getHref(discussionId)}
target="_blank"
>
View Public Version <LinkIcon size={16} />
Expand Down
1 change: 0 additions & 1 deletion apps/nextjs-app/src/lib/auth.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,6 @@ export const ProtectedRoute = ({ children }: { children: React.ReactNode }) => {

useEffect(() => {
if (!user.data) {
console.log('pathname', pathname);
router.replace(paths.auth.login.getHref(pathname));
}
}, [user.data, router, pathname]);
Expand Down
8 changes: 5 additions & 3 deletions apps/nextjs-pages/src/config/paths.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,14 +27,16 @@ export const paths = {
discussion: {
getHref: (id: string) => `/app/discussions/${id}`,
},
publicDiscussion: {
getHref: (id: string) => `/public/discussions/${id}`,
},
users: {
getHref: () => '/app/users',
},
profile: {
getHref: () => '/app/profile',
},
},
public: {
discussion: {
getHref: (id: string) => `/public/discussions/${id}`,
},
},
} as const;
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ export const DiscussionView = ({ discussionId }: { discussionId: string }) => {
{!isPublicView && discussion.public && (
<Link
className="ml-2 flex items-center gap-2 text-sm font-bold"
href={paths.app.publicDiscussion.getHref(discussionId)}
href={paths.public.discussion.getHref(discussionId)}
target="_blank"
>
View Public Version <LinkIcon size={16} />
Expand Down

0 comments on commit 0a0a1dc

Please sign in to comment.