Skip to content

Fix CRUD page titles in several examples #4930

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions examples/core/auth-nextjs-themed/app/(dashboard)/layout.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,10 @@ export default function Layout(props: { children: React.ReactNode }) {
const [employeeId] = params.segments ?? [];

const title = React.useMemo(() => {
if (pathname === '/employees/new') {
if (pathname.endsWith('/employees/new')) {
return 'New Employee';
}
if (employeeId && pathname.includes('/edit')) {
if (employeeId && pathname.endsWith('/employees/edit')) {
return `Employee ${employeeId} - Edit`;
}
if (employeeId) {
Expand Down
6 changes: 4 additions & 2 deletions examples/core/crud-nextjs-pages/src/pages/_app.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -46,10 +46,12 @@ function DefaultLayout({ page }: { page: React.ReactElement<any> }) {
const [employeeId] = segments;

const title = React.useMemo(() => {
if (router.asPath.split('?')[0] === '/employees/new') {
const pathname = router.asPath.split('?')[0];

if (pathname.endsWith('/employees/new')) {
return 'New Employee';
}
if (employeeId && router.asPath.includes('/edit')) {
if (employeeId && pathname.endsWith('/employees/edit')) {
return `Employee ${employeeId} - Edit`;
}
if (employeeId) {
Expand Down
4 changes: 2 additions & 2 deletions examples/core/crud-nextjs/src/app/(dashboard)/layout.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,10 @@ export default function DashboardPagesLayout(props: { children: React.ReactNode
const [employeeId] = params.segments ?? [];

const title = React.useMemo(() => {
if (pathname === '/employees/new') {
if (pathname.endsWith('/employees/new')) {
return 'New Employee';
}
if (employeeId && pathname.includes('/edit')) {
if (employeeId && pathname.endsWith('/employees/edit')) {
return `Employee ${employeeId} - Edit`;
}
if (employeeId) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,10 @@ const pathname = usePathname();
const [employeeId] = params.segments ?? [];

const title = React.useMemo(() => {
if (pathname === '/employees/new') {
if (pathname.endsWith('/employees/new')) {
return 'New Employee';
}
if (employeeId && pathname.includes('/edit')) {
if (employeeId && pathname.endsWith('/employees/edit')) {
return \`Employee \${employeeId} - Edit\`;
}
if (employeeId) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -97,10 +97,12 @@ function DefaultLayout({ page }: { page: React.ReactElement<any> }) {
const [employeeId] = segments;

const title = React.useMemo(() => {
if (router.asPath.split('?')[0] === '/employees/new') {
const pathname = router.asPath.split('?')[0];

if (pathname.endsWith('/employees/new')) {
return 'New Employee';
}
if (employeeId && router.asPath.includes('/edit')) {
if (employeeId && pathname.endsWith('/employees/edit')) {
return \`Employee \${employeeId} - Edit\`;
}
if (employeeId) {
Expand Down
6 changes: 4 additions & 2 deletions playground/nextjs-pages/src/pages/_app.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -54,10 +54,12 @@ function DefaultLayout({ page }: { page: React.ReactElement<any> }) {
const [orderId] = segments;

const title = React.useMemo(() => {
if (router.asPath.split('?')[0] === '/orders/new') {
const pathname = router.asPath.split('?')[0];

if (pathname.endsWith('/orders/new')) {
return 'New Order';
}
if (orderId && router.asPath.includes('/edit')) {
if (orderId && pathname.endsWith('/orders/edit')) {
return `Order ${orderId} - Edit`;
}
if (orderId) {
Expand Down
4 changes: 2 additions & 2 deletions playground/nextjs/src/app/(dashboard)/layout.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -163,10 +163,10 @@ export default function DashboardPagesLayout(props: { children: React.ReactNode
const [orderId] = params.segments ?? [];

const title = React.useMemo(() => {
if (pathname === '/orders/new') {
if (pathname.endsWith('/orders/new')) {
return 'New Order';
}
if (orderId && pathname.includes('/edit')) {
if (orderId && pathname.endsWith('/orders/edit')) {
return `Order ${orderId} - Edit`;
}
if (orderId) {
Expand Down