File tree Expand file tree Collapse file tree
packages/devextreme-cli/src/templates/nextjs/application/src/app Expand file tree Collapse file tree Original file line number Diff line number Diff line change 1+ 'use client'
2+ import { use } from 'react' ;
3+ import { notFound } from 'next/navigation' ;
4+ import { SingleCard } from '@/layouts' ;
5+ import { LoginForm , CreateAccountForm , ResetPasswordForm } from '@/components'
6+
7+ const formText = {
8+ 'login' : {
9+ title : 'Sign In'
10+ } ,
11+ 'create-account' : {
12+ title : 'Sign Up'
13+ } ,
14+ 'reset-password' : {
15+ title : 'Reset Password' ,
16+ description : 'Please enter the email address that you used to register, and we will send you a link to reset your password via Email.'
17+ }
18+ }
19+
20+ function AuthForm ( { name} ) {
21+ switch ( name ) {
22+ case 'login' : return < LoginForm /> ;
23+ case 'create-account' : return < CreateAccountForm /> ;
24+ case 'reset-password' : return < ResetPasswordForm /> ;
25+ }
26+ }
27+
28+ export default function AuthPage ( { params } ) {
29+ const { type } = use ( params )
30+
31+ if ( ! formText [ type ] ) {
32+ notFound ( ) ;
33+ }
34+
35+ const { title, description } = formText [ type ] ;
36+
37+ return < SingleCard title = { title } description = { description } >
38+ < AuthForm name = { type } />
39+ </ SingleCard >
40+ }
Load Diff This file was deleted.
Load Diff This file was deleted.
Load Diff This file was deleted.
Original file line number Diff line number Diff line change 11'use client'
22
3- import { useEffect } from 'react' ;
4- import { useRouter , usePathname } from 'next/navigation' ;
3+ import { usePathname } from 'next/navigation' ;
54import LoadPanel from 'devextreme-react/load-panel' ;
65import { AuthProvider , useAuth } from '../contexts/auth' ;
76import { NavigationProvider } from '../contexts/navigation' ;
87import { useScreenSizeClass } from '../utils/media-query' ;
98import { ThemeContext , useThemeContext } from "../theme" ;
109
1110function Page ( { children } ) {
12- const { user, loading } = useAuth ( ) ;
13- const router = useRouter ( ) ;
14-
15- useEffect ( ( ) => {
16- if ( ! loading && ! user ) {
17- router . push ( '/auth/login' ) ;
18- }
19- } , [ user , loading , router ] ) ;
11+ const { loading } = useAuth ( ) ;
2012
2113 if ( loading ) {
2214 return < LoadPanel visible = { true } /> ;
@@ -33,7 +25,7 @@ export default function RootLayout({ children }) {
3325 return (
3426 < html lang = "en" >
3527 < title > NextJs Dx App</ title >
36- < body class = "dx-viewport" >
28+ < body className = "dx-viewport" >
3729 < ThemeContext . Provider value = { themeContext } >
3830 < AuthProvider >
3931 < NavigationProvider >
Original file line number Diff line number Diff line change 11'use client'
2+ import { useEffect } from 'react' ;
3+ import { useRouter } from 'next/navigation' ;
4+ import { useAuth } from '@/contexts/auth' ;
25import appInfo from '@/app-info' ;
36import { Footer } from '@/components' ;
47import { < %= layout % > as SideNavBarLayout } from '@/layouts' ;
58
69export default function Content ( { children} ) {
10+ const { user, loading } = useAuth ( ) ;
11+ const router = useRouter ( ) ;
12+
13+ useEffect ( ( ) => {
14+ if ( ! loading && ! user ) {
15+ router . push ( '/auth/login' ) ;
16+ }
17+ } , [ user , loading , router ] ) ;
18+
719 return (
820 < SideNavBarLayout title = { appInfo . title } >
921 { children }
You can’t perform that action at this time.
0 commit comments