Skip to content

Commit 2a654a7

Browse files
committed
update
1 parent c52f133 commit 2a654a7

File tree

8 files changed

+106
-25
lines changed

8 files changed

+106
-25
lines changed

.github/workflows/nextjs-app-ci.yml

Lines changed: 62 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,62 @@
1+
name: Next.js App CI
2+
on:
3+
push:
4+
branches: ["*"]
5+
paths-ignore:
6+
- "README.md"
7+
- "docs/**"
8+
pull_request:
9+
branches: [master]
10+
paths-ignore:
11+
- "README.md"
12+
- "docs/**"
13+
jobs:
14+
all-cli-checks:
15+
runs-on: ubuntu-latest
16+
defaults:
17+
run:
18+
working-directory: ./apps/nextjs-app
19+
steps:
20+
- uses: actions/checkout@v4
21+
- uses: actions/setup-node@v4
22+
with:
23+
node-version: lts/*
24+
- name: Set environment variables
25+
run: mv .env.example .env
26+
- name: Install dependencies
27+
run: yarn install
28+
- name: Build application
29+
run: yarn build
30+
- name: Run tests
31+
run: yarn test
32+
- name: Run linter
33+
run: yarn lint
34+
- name: Check types
35+
run: yarn check-types
36+
e2e:
37+
timeout-minutes: 60
38+
runs-on: ubuntu-latest
39+
defaults:
40+
run:
41+
working-directory: ./apps/nextjs-app
42+
steps:
43+
- uses: actions/checkout@v4
44+
- uses: actions/setup-node@v4
45+
with:
46+
node-version: lts/*
47+
- name: Set environment variables
48+
run: mv .env.example-e2e .env
49+
- name: Install dependencies
50+
run: npm install -g yarn && yarn
51+
- name: Install Playwright Browsers
52+
run: yarn playwright install --with-deps
53+
- name: Run Playwright tests
54+
run: yarn test-e2e
55+
- uses: actions/upload-artifact@v4
56+
if: always()
57+
with:
58+
name: playwright-report
59+
path: |
60+
playwright-report/
61+
mocked-db.json
62+
retention-days: 30

.husky/pre-commit

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
yarn --cwd apps/react-vite lint-staged && yarn --cwd apps/nextjs-pages lint-staged
1+
yarn --cwd apps/nextjs-app lint-staged && yarn --cwd apps/nextjs-pages lint-staged && yarn --cwd apps/react-vite lint-staged

apps/nextjs-app/src/app/app/layout.tsx

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@ import { ReactNode } from 'react';
22

33
import { DashboardLayout } from '@/components/layouts';
44

5-
export default function AppLayout({ children }: { children: ReactNode }) {
5+
const AppLayout = ({ children }: { children: ReactNode }) => {
66
return <DashboardLayout>{children}</DashboardLayout>;
7-
}
7+
};
8+
9+
export default AppLayout;

apps/nextjs-app/src/app/auth/layout.tsx

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,12 +5,14 @@ import { ReactNode } from 'react';
55

66
import { AuthLayout as AuthLayoutComponent } from '@/components/layouts/auth-layout';
77

8-
export default function AuthLayout({ children }: { children: ReactNode }) {
8+
const AuthLayout = ({ children }: { children: ReactNode }) => {
99
const pathname = usePathname();
1010
const isLoginPage = pathname === '/auth/login';
1111
const title = isLoginPage
1212
? 'Log in to your account'
1313
: 'Register your account';
1414

1515
return <AuthLayoutComponent title={title}>{children}</AuthLayoutComponent>;
16-
}
16+
};
17+
18+
export default AuthLayout;

apps/nextjs-app/src/app/layout.tsx

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,12 +4,14 @@ import { AppProvider } from '@/app/provider';
44

55
import '@/styles/globals.css';
66

7-
export default function RootLayout({ children }: { children: ReactNode }) {
7+
const RootLayout = ({ children }: { children: ReactNode }) => {
88
return (
99
<html lang="en">
1010
<body>
1111
<AppProvider>{children}</AppProvider>
1212
</body>
1313
</html>
1414
);
15-
}
15+
};
16+
17+
export default RootLayout;

apps/nextjs-app/src/app/page.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ import { useUser } from '@/lib/auth';
99
// description: 'Welcome to bulletproof react',
1010
// };
1111

12-
export const HomePage = () => {
12+
const HomePage = () => {
1313
const router = useRouter();
1414
const user = useUser();
1515

Lines changed: 29 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,12 @@
11
'use client';
22

3-
import { useRouter } from 'next/navigation';
3+
import { useRouter, usePathname } from 'next/navigation';
44
import * as React from 'react';
55
import { useEffect } from 'react';
6+
import { ErrorBoundary } from 'react-error-boundary';
67

78
import { Link } from '@/components/ui/link';
9+
import { Spinner } from '@/components/ui/spinner';
810
import { useUser } from '@/lib/auth';
911

1012
type LayoutProps = {
@@ -21,6 +23,7 @@ export const AuthLayout = ({ children, title }: LayoutProps) => {
2123
const user = useUser();
2224

2325
const router = useRouter();
26+
const pathname = usePathname();
2427

2528
useEffect(() => {
2629
if (user.data) {
@@ -29,24 +32,34 @@ export const AuthLayout = ({ children, title }: LayoutProps) => {
2932
}, [user.data, router]);
3033

3134
return (
32-
<div className="flex min-h-screen flex-col justify-center bg-gray-50 py-12 sm:px-6 lg:px-8">
33-
<div className="sm:mx-auto sm:w-full sm:max-w-md">
34-
<div className="flex justify-center">
35-
<Link className="flex items-center text-white" href="/">
36-
<img className="h-24 w-auto" src="/logo.svg" alt="Workflow" />
37-
</Link>
35+
<React.Suspense
36+
fallback={
37+
<div className="flex size-full items-center justify-center">
38+
<Spinner size="xl" />
3839
</div>
40+
}
41+
>
42+
<ErrorBoundary key={pathname} fallback={<div>Something went wrong!</div>}>
43+
<div className="flex min-h-screen flex-col justify-center bg-gray-50 py-12 sm:px-6 lg:px-8">
44+
<div className="sm:mx-auto sm:w-full sm:max-w-md">
45+
<div className="flex justify-center">
46+
<Link className="flex items-center text-white" href="/">
47+
<img className="h-24 w-auto" src="/logo.svg" alt="Workflow" />
48+
</Link>
49+
</div>
3950

40-
<h2 className="mt-3 text-center text-3xl font-extrabold text-gray-900">
41-
{title}
42-
</h2>
43-
</div>
51+
<h2 className="mt-3 text-center text-3xl font-extrabold text-gray-900">
52+
{title}
53+
</h2>
54+
</div>
4455

45-
<div className="mt-8 sm:mx-auto sm:w-full sm:max-w-md">
46-
<div className="bg-white px-4 py-8 shadow sm:rounded-lg sm:px-10">
47-
{children}
56+
<div className="mt-8 sm:mx-auto sm:w-full sm:max-w-md">
57+
<div className="bg-white px-4 py-8 shadow sm:rounded-lg sm:px-10">
58+
{children}
59+
</div>
60+
</div>
4861
</div>
49-
</div>
50-
</div>
62+
</ErrorBoundary>
63+
</React.Suspense>
5164
);
5265
};

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
"version": "1.0.0",
55
"description": "A simple, scalable, and powerful architecture for building production ready React applications.",
66
"scripts": {
7-
"prepare": "cd ./apps/nextjs-pages && yarn && cd ../react-vite && yarn"
7+
"prepare": "cd ./apps/nextjs-app && yarn && cd ../nextjs-pages && yarn && cd ../react-vite && yarn"
88
},
99
"author": "alan2207",
1010
"license": "MIT"

0 commit comments

Comments
 (0)