-
Notifications
You must be signed in to change notification settings - Fork 2.7k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
45 changed files
with
394 additions
and
470 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,5 @@ | ||
/// <reference types="next" /> | ||
/// <reference types="next/image-types/global" /> | ||
/// <reference types="next/navigation-types/compat/navigation" /> | ||
|
||
// NOTE: This file should not be edited | ||
// see https://nextjs.org/docs/basic-features/typescript for more information. |
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
49 changes: 49 additions & 0 deletions
49
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
'use client'; | ||
|
||
import { useParams } from 'next/navigation'; | ||
import { ErrorBoundary } from 'react-error-boundary'; | ||
|
||
import { ContentLayout } from '@/components/layouts'; | ||
import { Spinner } from '@/components/ui/spinner'; | ||
|
||
import { Comments } from '@/features/comments/components/comments'; | ||
import { useDiscussion } from '@/features/discussions/api/get-discussion'; | ||
import { DiscussionView } from '@/features/discussions/components/discussion-view'; | ||
|
||
const DiscussionPage = () => { | ||
const params = useParams(); | ||
const discussionId = params?.discussionId as string; | ||
|
||
const discussionQuery = useDiscussion({ | ||
discussionId, | ||
}); | ||
|
||
if (discussionQuery.isLoading) { | ||
return ( | ||
<div className="flex h-48 w-full items-center justify-center"> | ||
<Spinner size="lg" /> | ||
</div> | ||
); | ||
} | ||
|
||
const discussion = discussionQuery.data?.data; | ||
|
||
if (!discussion) return null; | ||
|
||
return ( | ||
<ContentLayout title={discussion.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> | ||
); | ||
}; | ||
|
||
export default DiscussionPage; |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
import { ReactNode } from 'react'; | ||
|
||
import { DashboardLayout } from '@/components/layouts'; | ||
|
||
export default function AppLayout({ children }: { children: ReactNode }) { | ||
return <DashboardLayout>{children}</DashboardLayout>; | ||
} |
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
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,16 @@ | ||
'use client'; | ||
|
||
import { usePathname } from 'next/navigation'; | ||
import { ReactNode } from 'react'; | ||
|
||
import { AuthLayout as AuthLayoutComponent } from '@/components/layouts/auth-layout'; | ||
|
||
export default function AuthLayout({ children }: { children: ReactNode }) { | ||
const pathname = usePathname(); | ||
const isLoginPage = pathname === '/auth/login'; | ||
const title = isLoginPage | ||
? 'Log in to your account' | ||
: 'Register your account'; | ||
|
||
return <AuthLayoutComponent title={title}>{children}</AuthLayoutComponent>; | ||
} |
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,26 @@ | ||
'use client'; | ||
|
||
import { useRouter, useSearchParams } from 'next/navigation'; | ||
|
||
import { LoginForm } from '@/features/auth/components/login-form'; | ||
|
||
// export const metadata = { | ||
// title: 'Log in to your account', | ||
// description: 'Log in to your account', | ||
// }; | ||
|
||
const LoginPage = () => { | ||
const router = useRouter(); | ||
const searchParams = useSearchParams(); | ||
const redirectTo = searchParams?.get('redirectTo'); | ||
|
||
return ( | ||
<LoginForm | ||
onSuccess={() => | ||
router.replace(`${redirectTo ? `${redirectTo}` : '/app'}`) | ||
} | ||
/> | ||
); | ||
}; | ||
|
||
export default LoginPage; |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
import { ReactNode } from 'react'; | ||
|
||
import { AppProvider } from '@/app/provider'; | ||
|
||
import '@/styles/globals.css'; | ||
|
||
export default function RootLayout({ children }: { children: ReactNode }) { | ||
return ( | ||
<html lang="en"> | ||
<body> | ||
<AppProvider>{children}</AppProvider> | ||
</body> | ||
</html> | ||
); | ||
} |
File renamed without changes.
Oops, something went wrong.