From 5080564c92f4841e261aff057e84327f5a4e3e13 Mon Sep 17 00:00:00 2001 From: Vladislav Sokov Date: Wed, 22 May 2024 20:02:02 +0300 Subject: [PATCH] fix redirect --- src/app/not-found.tsx | 18 ------------------ .../showcase-1-stripe-integration/layout.tsx | 14 ++++++++++++++ src/app/showcase-1-stripe-integration/page.tsx | 7 +++++++ .../layout.tsx | 14 ++++++++++++++ .../page.tsx | 7 +++++++ src/app/showcases/[slug]/layout.tsx | 6 +----- src/showcases.tsx | 3 --- 7 files changed, 43 insertions(+), 26 deletions(-) create mode 100644 src/app/showcase-1-stripe-integration/layout.tsx create mode 100644 src/app/showcase-1-stripe-integration/page.tsx create mode 100644 src/app/showcase-2-prevent-account-sharing/layout.tsx create mode 100644 src/app/showcase-2-prevent-account-sharing/page.tsx diff --git a/src/app/not-found.tsx b/src/app/not-found.tsx index c8651ca..54a8ddf 100644 --- a/src/app/not-found.tsx +++ b/src/app/not-found.tsx @@ -1,24 +1,6 @@ -'use client' - -import { useEffect } from 'react'; -import { useRouter } from 'next/navigation'; import Link from 'next/link'; export default function NotFoundPage() { - const router = useRouter(); - - useEffect(() => { - const redirects: { [key: string]: string } = { - '/showcase-1-stripe-integration': '/showcases/stripe-integration', - '/showcase-2-prevent-account-sharing': '/showcases/prevent-account-sharing' - }; - - const path = window.location.pathname; - if (redirects[path]) { - router.replace(redirects[path]); - } - }, [router]); - return (
diff --git a/src/app/showcase-1-stripe-integration/layout.tsx b/src/app/showcase-1-stripe-integration/layout.tsx new file mode 100644 index 0000000..8724cda --- /dev/null +++ b/src/app/showcase-1-stripe-integration/layout.tsx @@ -0,0 +1,14 @@ +export default function StripeIntegrationLayout({ + children, +}: Readonly<{ + children: React.ReactNode; +}>) { + return ( + <> + + + + {children} + + ); +} \ No newline at end of file diff --git a/src/app/showcase-1-stripe-integration/page.tsx b/src/app/showcase-1-stripe-integration/page.tsx new file mode 100644 index 0000000..38565d2 --- /dev/null +++ b/src/app/showcase-1-stripe-integration/page.tsx @@ -0,0 +1,7 @@ +export default function StripeIntegration() { + return ( +
+

Redirect

+
+ ); +}; diff --git a/src/app/showcase-2-prevent-account-sharing/layout.tsx b/src/app/showcase-2-prevent-account-sharing/layout.tsx new file mode 100644 index 0000000..cc0dc44 --- /dev/null +++ b/src/app/showcase-2-prevent-account-sharing/layout.tsx @@ -0,0 +1,14 @@ +export default function PreventAccountSharingLayout({ + children, +}: Readonly<{ + children: React.ReactNode; +}>) { + return ( + <> + + + + {children} + + ); +} \ No newline at end of file diff --git a/src/app/showcase-2-prevent-account-sharing/page.tsx b/src/app/showcase-2-prevent-account-sharing/page.tsx new file mode 100644 index 0000000..900dbe4 --- /dev/null +++ b/src/app/showcase-2-prevent-account-sharing/page.tsx @@ -0,0 +1,7 @@ +export default function PreventAccountSharing() { + return ( +
+

Redirect

+
+ ); +}; diff --git a/src/app/showcases/[slug]/layout.tsx b/src/app/showcases/[slug]/layout.tsx index 6098566..fa9f9ed 100644 --- a/src/app/showcases/[slug]/layout.tsx +++ b/src/app/showcases/[slug]/layout.tsx @@ -39,11 +39,7 @@ export async function generateMetadata({ params } : Props): Promise { } export async function generateStaticParams() { - const slugs = showcases.map(showcase => ( - { - slug: showcase.slug - }) - ); + const slugs = showcases.map(showcase => ({ slug: showcase.slug })); return slugs; } diff --git a/src/showcases.tsx b/src/showcases.tsx index cd0df75..7062311 100644 --- a/src/showcases.tsx +++ b/src/showcases.tsx @@ -62,7 +62,6 @@ export interface ShowcaseBody { } export interface Showcase { - id: number; category: CategoryName; slug: string; preview: ShowcasePreview; @@ -75,7 +74,6 @@ export interface Showcase { const showcases: Showcase[] = [ { - id: 1, slug: "stripe-integration", category: CategoryName.systemsIntegrations, preview: { @@ -174,7 +172,6 @@ const showcases: Showcase[] = [ } }, { - id: 2, slug: "prevent-account-sharing", category: CategoryName.optimisations, preview: {