From d197ee272c623e261697c0e2a36e764709a6f68e Mon Sep 17 00:00:00 2001 From: YulikK Date: Thu, 28 Nov 2024 12:03:56 +0100 Subject: [PATCH 1/5] refactor: 556 - not found page delete widget --- src/app/not-found.tsx | 2 +- src/views/not-found.tsx | 3 -- src/views/not-found/not-found.module.scss | 18 +++++++++++ src/views/not-found/not-found.tsx | 28 +++++++++++++++++ src/widgets/not-found/index.ts | 3 -- src/widgets/not-found/ui/not-found.scss | 38 ----------------------- src/widgets/not-found/ui/not-found.tsx | 25 --------------- 7 files changed, 47 insertions(+), 70 deletions(-) delete mode 100644 src/views/not-found.tsx create mode 100644 src/views/not-found/not-found.module.scss create mode 100644 src/views/not-found/not-found.tsx delete mode 100644 src/widgets/not-found/index.ts delete mode 100644 src/widgets/not-found/ui/not-found.scss delete mode 100644 src/widgets/not-found/ui/not-found.tsx diff --git a/src/app/not-found.tsx b/src/app/not-found.tsx index 126bd64f4..c783adab2 100644 --- a/src/app/not-found.tsx +++ b/src/app/not-found.tsx @@ -1,5 +1,5 @@ import { Metadata } from 'next'; -import { NotFound } from '@/views/not-found'; +import { NotFound } from '@/views/not-found/not-found'; export async function generateMetadata(): Promise { const title = '404 Not Found'; diff --git a/src/views/not-found.tsx b/src/views/not-found.tsx deleted file mode 100644 index 8e230e0f4..000000000 --- a/src/views/not-found.tsx +++ /dev/null @@ -1,3 +0,0 @@ -import { NotFound as NotFoundEl } from '@/widgets/not-found'; - -export const NotFound = () => ; diff --git a/src/views/not-found/not-found.module.scss b/src/views/not-found/not-found.module.scss new file mode 100644 index 000000000..bb4cc5bd9 --- /dev/null +++ b/src/views/not-found/not-found.module.scss @@ -0,0 +1,18 @@ +.not-found { + flex-direction: column; + gap: 30px; + min-height: 100vh; +} + +.not-found-image { + max-width: 170px; + height: auto; +} + +.not-found-paragraph { + max-width: 480px; + + @include media-mobile-landscape { + text-align: center; + } +} diff --git a/src/views/not-found/not-found.tsx b/src/views/not-found/not-found.tsx new file mode 100644 index 000000000..9ee08bfe6 --- /dev/null +++ b/src/views/not-found/not-found.tsx @@ -0,0 +1,28 @@ +import classNames from 'classnames/bind'; +import Image from 'next/image'; +import notFoundImg from '@/shared/assets/404.webp'; +import { LinkCustom } from '@/shared/ui/link-custom'; +import { Paragraph } from '@/shared/ui/paragraph'; + +import styles from './not-found.module.scss'; + +const cx = classNames.bind(styles); + +export const NotFound = () => { + return ( +
+ Sloth mascot in an RS-branded T-shirt sits on a chair, looking puzzled, symbolizing that the page was not found + + The page you are looking for doesn't exist or has been moved. Please go back to the + homepage. + + + Go back home + +
+ ); +}; diff --git a/src/widgets/not-found/index.ts b/src/widgets/not-found/index.ts deleted file mode 100644 index 5b43b3c71..000000000 --- a/src/widgets/not-found/index.ts +++ /dev/null @@ -1,3 +0,0 @@ -import NotFound from './ui/not-found'; - -export { NotFound }; diff --git a/src/widgets/not-found/ui/not-found.scss b/src/widgets/not-found/ui/not-found.scss deleted file mode 100644 index b4a1edc9a..000000000 --- a/src/widgets/not-found/ui/not-found.scss +++ /dev/null @@ -1,38 +0,0 @@ -.not-found { - display: flex; - flex-direction: column; - gap: 30px; - align-items: center; - justify-content: center; - - min-height: 100vh; - - & > .image-wrapper { - max-width: 170px; - height: auto; - - img { - width: 100%; - height: auto; - } - } - - .not-found-paragraph { - max-width: 480px; - text-align: left; - - @include media-mobile-landscape { - text-align: center; - } - } - - .button { - @include media-tablet { - width: min-content; - } - - @include media-mobile { - display: none; - } - } -} diff --git a/src/widgets/not-found/ui/not-found.tsx b/src/widgets/not-found/ui/not-found.tsx deleted file mode 100644 index 35de4a51a..000000000 --- a/src/widgets/not-found/ui/not-found.tsx +++ /dev/null @@ -1,25 +0,0 @@ -import Image from 'next/image'; -import notFoundImg from '@/shared/assets/404.webp'; -import { LinkCustom } from '@/shared/ui/link-custom'; -import { Paragraph } from '@/shared/ui/paragraph'; - -import './not-found.scss'; - -const NotFound = () => { - return ( -
-
- not found -
- - The page you are looking for doesn't exist or has been moved. Please go back to the - homepage. - - - Go back home - -
- ); -}; - -export default NotFound; From 0cd52fee71505ebaa8f2c1eb9b9e19dd0db25353 Mon Sep 17 00:00:00 2001 From: YulikK Date: Fri, 29 Nov 2024 12:46:40 +0100 Subject: [PATCH 2/5] feat: 556 - add test for page --- src/shared/__tests__/visual/not-found.spec.ts | 19 +++++++++++++++++++ src/views/not-found/not-found.tsx | 2 +- 2 files changed, 20 insertions(+), 1 deletion(-) create mode 100644 src/shared/__tests__/visual/not-found.spec.ts diff --git a/src/shared/__tests__/visual/not-found.spec.ts b/src/shared/__tests__/visual/not-found.spec.ts new file mode 100644 index 000000000..fd38c09c2 --- /dev/null +++ b/src/shared/__tests__/visual/not-found.spec.ts @@ -0,0 +1,19 @@ +import { expect, test } from '@playwright/test'; +import { takeScreenshot } from './utils'; +import { ROUTES } from '@/core/const'; + +test('Not-found page', async ({ page }) => { + await page.goto(ROUTES.NOT_FOUND); + + await takeScreenshot(page, 'Not-found page'); +}); + +test('Not-found home button', async ({ page }) => { + await page.goto(ROUTES.NOT_FOUND); + + const homeButton = await page.getByTestId('home-link'); + + expect(homeButton).toBeVisible(); + await homeButton.click(); + await expect(page).toHaveURL(ROUTES.HOME); +}); diff --git a/src/views/not-found/not-found.tsx b/src/views/not-found/not-found.tsx index 9ee08bfe6..e62dd8eff 100644 --- a/src/views/not-found/not-found.tsx +++ b/src/views/not-found/not-found.tsx @@ -20,7 +20,7 @@ export const NotFound = () => { The page you are looking for doesn't exist or has been moved. Please go back to the homepage. - + Go back home From 1a768ca31479f69a2e2331af051e037ef158ef46 Mon Sep 17 00:00:00 2001 From: YulikK Date: Fri, 29 Nov 2024 15:26:51 +0100 Subject: [PATCH 3/5] refactor: 556 - update structure mentorship routes --- src/app/[...mentorship]/page.tsx | 43 ---------------------------- src/app/mentorship/[course]/page.tsx | 31 ++++++++++++++++++++ src/app/mentorship/page.tsx | 12 ++++++++ 3 files changed, 43 insertions(+), 43 deletions(-) delete mode 100644 src/app/[...mentorship]/page.tsx create mode 100644 src/app/mentorship/[course]/page.tsx create mode 100644 src/app/mentorship/page.tsx diff --git a/src/app/[...mentorship]/page.tsx b/src/app/[...mentorship]/page.tsx deleted file mode 100644 index e0e4b3506..000000000 --- a/src/app/[...mentorship]/page.tsx +++ /dev/null @@ -1,43 +0,0 @@ -import { Metadata } from 'next'; -import { Mentorship } from '@/views/mentorship'; -import { - MentorshipCourseRouteKeys, - MentorshipDefaultRouteKeys, - mentorshipCourses, - mentorshipCoursesDefault, -} from 'data'; - -export async function generateMetadata(): Promise { - const title = `Mentorship · The Rolling Scopes School`; - - return { title }; -} - -export const dynamicParams = false; - -export async function generateStaticParams(): Promise< - { mentorship: (MentorshipDefaultRouteKeys | MentorshipCourseRouteKeys)[] }[] -> { - return [ - { mentorship: ['mentorship'] }, - { mentorship: ['mentorship', 'reactjs'] }, - { mentorship: ['mentorship', 'angular'] }, - { mentorship: ['mentorship', 'javascript'] }, - { mentorship: ['mentorship', 'javascript-ru'] }, - ]; -} - -type PageParams = Promise<{ - mentorship: (MentorshipDefaultRouteKeys | MentorshipCourseRouteKeys)[]; -}>; - -export default async function MentorshipRoute(props: { params: PageParams }) { - const { mentorship } = await props.params; - - const mentorshipCourse = - mentorshipCourses.find((item) => - item.detailsUrl.includes(`/${mentorship[0]}/${mentorship[1]}`), - ) || mentorshipCoursesDefault; - - return ; -} diff --git a/src/app/mentorship/[course]/page.tsx b/src/app/mentorship/[course]/page.tsx new file mode 100644 index 000000000..ff5d5fa88 --- /dev/null +++ b/src/app/mentorship/[course]/page.tsx @@ -0,0 +1,31 @@ +import { Metadata } from 'next'; +import { Mentorship } from '@/views/mentorship'; +import { MentorshipCourseRouteKeys, mentorshipCourses, mentorshipCoursesDefault } from 'data'; + +export async function generateMetadata(): Promise { + const title = `Mentorship · The Rolling Scopes School`; + + return { title }; +} +export async function generateStaticParams(): Promise<{ course: MentorshipCourseRouteKeys }[]> { + return [ + { course: 'reactjs' }, + { course: 'angular' }, + { course: 'javascript' }, + { course: 'javascript-ru' }, + ]; +} +export default async function MentorshipRoute({ + params, +}: { + params: Promise<{ + course: MentorshipCourseRouteKeys; + }>; +}) { + const { course } = await params; + const mentorshipCourse = + mentorshipCourses.find((item) => item.detailsUrl.includes(`/${course}`)) + || mentorshipCoursesDefault; + + return ; +} diff --git a/src/app/mentorship/page.tsx b/src/app/mentorship/page.tsx new file mode 100644 index 000000000..fa52be3c0 --- /dev/null +++ b/src/app/mentorship/page.tsx @@ -0,0 +1,12 @@ +import { Metadata } from 'next'; +import { Mentorship } from '@/views/mentorship'; +import { mentorshipCoursesDefault } from 'data'; + +export async function generateMetadata(): Promise { + const title = `Mentorship · The Rolling Scopes School`; + + return { title }; +} +export default async function MentorshipRoute() { + return ; +} From 2799556bfcbc04425fb3879d3652641817aa5605 Mon Sep 17 00:00:00 2001 From: YulikK Date: Wed, 4 Dec 2024 13:08:45 +0100 Subject: [PATCH 4/5] refactor: 556 - add blank line --- src/app/mentorship/page.tsx | 1 + 1 file changed, 1 insertion(+) diff --git a/src/app/mentorship/page.tsx b/src/app/mentorship/page.tsx index fa52be3c0..2cbd1826f 100644 --- a/src/app/mentorship/page.tsx +++ b/src/app/mentorship/page.tsx @@ -7,6 +7,7 @@ export async function generateMetadata(): Promise { return { title }; } + export default async function MentorshipRoute() { return ; } From 250b2832e706004f0e18507a7e8951f759b029da Mon Sep 17 00:00:00 2001 From: YulikK Date: Fri, 6 Dec 2024 12:01:39 +0100 Subject: [PATCH 5/5] refactor: 556 - add style --- src/views/not-found/not-found.module.scss | 1 + 1 file changed, 1 insertion(+) diff --git a/src/views/not-found/not-found.module.scss b/src/views/not-found/not-found.module.scss index bb4cc5bd9..26b735b12 100644 --- a/src/views/not-found/not-found.module.scss +++ b/src/views/not-found/not-found.module.scss @@ -1,4 +1,5 @@ .not-found { + display: flex; flex-direction: column; gap: 30px; min-height: 100vh;