-
Notifications
You must be signed in to change notification settings - Fork 2.6k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* next app router improvements * upgrade vite
- Loading branch information
Showing
43 changed files
with
1,260 additions
and
968 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
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
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
34 changes: 34 additions & 0 deletions
34
apps/nextjs-app/src/app/app/_components/dashboard-info.tsx
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,34 @@ | ||
'use client'; | ||
|
||
import { useUser } from '@/lib/auth'; | ||
|
||
export const DashboardInfo = () => { | ||
const user = useUser(); | ||
|
||
return ( | ||
<> | ||
<h1 className="text-xl"> | ||
Welcome <b>{`${user.data?.firstName} ${user.data?.lastName}`}</b> | ||
</h1> | ||
<h4 className="my-3"> | ||
Your role is : <b>{user.data?.role}</b> | ||
</h4> | ||
<p className="font-medium">In this application you can:</p> | ||
{user.data?.role === 'USER' && ( | ||
<ul className="my-4 list-inside list-disc"> | ||
<li>Create comments in discussions</li> | ||
<li>Delete own comments</li> | ||
</ul> | ||
)} | ||
{user.data?.role === 'ADMIN' && ( | ||
<ul className="my-4 list-inside list-disc"> | ||
<li>Create discussions</li> | ||
<li>Edit discussions</li> | ||
<li>Delete discussions</li> | ||
<li>Comment on discussions</li> | ||
<li>Delete all comments</li> | ||
</ul> | ||
)} | ||
</> | ||
); | ||
}; |
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
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
27 changes: 27 additions & 0 deletions
27
apps/nextjs-app/src/app/app/discussions/[discussionId]/_components/discussion.tsx
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,27 @@ | ||
'use client'; | ||
|
||
import { ErrorBoundary } from 'react-error-boundary'; | ||
|
||
import { ContentLayout } from '@/components/layouts/content-layout'; | ||
import { Comments } from '@/features/comments/components/comments'; | ||
import { useDiscussion } from '@/features/discussions/api/get-discussion'; | ||
import { DiscussionView } from '@/features/discussions/components/discussion-view'; | ||
|
||
export const Discussion = ({ discussionId }: { discussionId: string }) => { | ||
const discussion = useDiscussion({ discussionId }); | ||
|
||
return ( | ||
<ContentLayout title={discussion?.data?.data?.title}> | ||
<DiscussionView discussionId={discussionId} /> | ||
<div className="mt-8"> | ||
<ErrorBoundary | ||
fallback={ | ||
<div>Failed to load comments. Try to refresh the page.</div> | ||
} | ||
> | ||
<Comments discussionId={discussionId} /> | ||
</ErrorBoundary> | ||
</div> | ||
</ContentLayout> | ||
); | ||
}; |
94 changes: 59 additions & 35 deletions
94
apps/nextjs-app/src/app/app/discussions/[discussionId]/page.tsx
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
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
30 changes: 30 additions & 0 deletions
30
apps/nextjs-app/src/app/app/discussions/_components/discussions.tsx
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,30 @@ | ||
'use client'; | ||
|
||
import { useQueryClient } from '@tanstack/react-query'; | ||
|
||
import { ContentLayout } from '@/components/layouts/content-layout'; | ||
import { getInfiniteCommentsQueryOptions } from '@/features/comments/api/get-comments'; | ||
import { CreateDiscussion } from '@/features/discussions/components/create-discussion'; | ||
import { DiscussionsList } from '@/features/discussions/components/discussions-list'; | ||
|
||
export const Discussions = () => { | ||
const queryClient = useQueryClient(); | ||
|
||
return ( | ||
<ContentLayout title="Discussions"> | ||
<div className="flex justify-end"> | ||
<CreateDiscussion /> | ||
</div> | ||
<div className="mt-4"> | ||
<DiscussionsList | ||
onDiscussionPrefetch={(id) => { | ||
// Prefetch the comments data when the user hovers over the link in the list | ||
queryClient.prefetchInfiniteQuery( | ||
getInfiniteCommentsQueryOptions(id), | ||
); | ||
}} | ||
/> | ||
</div> | ||
</ContentLayout> | ||
); | ||
}; |
Oops, something went wrong.