Skip to content

Commit

Permalink
Merge pull request #926 from cultuurnet/feature/III-6356
Browse files Browse the repository at this point in the history
III-6356 - Add page ownership
  • Loading branch information
vhande authored Oct 16, 2024
2 parents 84e94d4 + fed3e04 commit 56302a4
Show file tree
Hide file tree
Showing 4 changed files with 37 additions and 2 deletions.
9 changes: 8 additions & 1 deletion src/middleware.api.ts
Original file line number Diff line number Diff line change
Expand Up @@ -44,8 +44,15 @@ export const middleware = async (request: NextRequest) => {
const url = new URL('/beta-version', request.url);
return NextResponse.redirect(url);
}

const isOwnershipPage = request.nextUrl.pathname.endsWith('ownership');

if (isOwnershipPage && !process.env.NEXT_PUBLIC_OWNERSHIP_ENABLED) {
const url = new URL('/404', request.url);
return NextResponse.redirect(url);
}
};

export const config = {
matcher: ['/event', '/login'],
matcher: ['/event', '/login', '/organizers/:id/ownership'],
};
6 changes: 5 additions & 1 deletion src/pages/[...params].page.js
Original file line number Diff line number Diff line change
Expand Up @@ -60,12 +60,16 @@ const Fallback = () => {

const legacyPath = useMemo(() => {
const path = new URL(`http://localhost${asPath}`).pathname;

const ownershipPaths =
router.asPath.startsWith('/organizer') ||
router.asPath.startsWith('/search');
const queryString = prefixWhenNotEmpty(
new URLSearchParams({
...queryWithoutParams,
jwt: cookies.token,
lang: cookies['udb-language'],
...(ownershipPaths &&
publicRuntimeConfig.ownershipEnabled && { ownership: 'true' }),
}),
'?',
);
Expand Down
19 changes: 19 additions & 0 deletions src/pages/organizers/[organizerId]/ownership/index.page.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
import { Page } from '@/ui/Page';

const Ownership = () => {
return (
<Page>
<Page.Title>Hello world</Page.Title>
<Page.Content>
<div>
Lorem ipsum dolor sit amet consectetur adipisicing elit. Dolore eos
nisi maiores. Doloribus molestias magnam facilis! Eum rerum ea fugit
excepturi doloribus, assumenda quod vitae magni tempore voluptatum
adipisci aliquam.
</div>
</Page.Content>
</Page>
);
};

export default Ownership;
5 changes: 5 additions & 0 deletions src/redirects.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,11 @@ const getRedirects = (
destination: '/organizers/:organizerId/edit',
permanent: false,
},
{
source: '/organizer/:organizerId/ownership',
destination: '/organizers/:organizerId/ownership',
permanent: false,
},
{
source: '/:language/copyright',
destination: '/copyright',
Expand Down

0 comments on commit 56302a4

Please sign in to comment.