Skip to content
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

556-feat: Widget not found #667

Merged
merged 5 commits into from
Dec 6, 2024
Merged
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
43 changes: 0 additions & 43 deletions src/app/[...mentorship]/page.tsx

This file was deleted.

31 changes: 31 additions & 0 deletions src/app/mentorship/[course]/page.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
import { Metadata } from 'next';
import { Mentorship } from '@/views/mentorship';
import { MentorshipCourseRouteKeys, mentorshipCourses, mentorshipCoursesDefault } from 'data';

export async function generateMetadata(): Promise<Metadata> {
const title = `Mentorship Β· The Rolling Scopes School`;

return { title };
}
SpaNb4 marked this conversation as resolved.
Show resolved Hide resolved
export async function generateStaticParams(): Promise<{ course: MentorshipCourseRouteKeys }[]> {
return [
{ course: 'reactjs' },
{ course: 'angular' },
{ course: 'javascript' },
{ course: 'javascript-ru' },
];
}
SpaNb4 marked this conversation as resolved.
Show resolved Hide resolved
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 <Mentorship mentorshipData={mentorshipCourse} />;
}
13 changes: 13 additions & 0 deletions src/app/mentorship/page.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
import { Metadata } from 'next';
import { Mentorship } from '@/views/mentorship';
import { mentorshipCoursesDefault } from 'data';

export async function generateMetadata(): Promise<Metadata> {
const title = `Mentorship Β· The Rolling Scopes School`;

return { title };
}

export default async function MentorshipRoute() {
return <Mentorship mentorshipData={mentorshipCoursesDefault} />;
}
2 changes: 1 addition & 1 deletion src/app/not-found.tsx
Original file line number Diff line number Diff line change
@@ -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<Metadata> {
const title = '404 Not Found';
Expand Down
19 changes: 19 additions & 0 deletions src/shared/__tests__/visual/not-found.spec.ts
Original file line number Diff line number Diff line change
@@ -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');
});
SpaNb4 marked this conversation as resolved.
Show resolved Hide resolved

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);
});
SpaNb4 marked this conversation as resolved.
Show resolved Hide resolved
3 changes: 0 additions & 3 deletions src/views/not-found.tsx

This file was deleted.

19 changes: 19 additions & 0 deletions src/views/not-found/not-found.module.scss
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
.not-found {
display: flex;
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;
}
}
28 changes: 28 additions & 0 deletions src/views/not-found/not-found.tsx
Original file line number Diff line number Diff line change
@@ -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 (
<main className={cx('container', 'not-found')}>
<Image
className={cx('not-found-image')}
src={notFoundImg}
alt="Sloth mascot in an RS-branded T-shirt sits on a chair, looking puzzled, symbolizing that the page was not found"
/>
<Paragraph className={cx('not-found-paragraph')}>
The page you are looking for doesn&apos;t exist or has been moved. Please go back to the
homepage.
</Paragraph>
<LinkCustom href="/" variant="primary" data-testid="home-link">
Go back home
</LinkCustom>
</main>
);
};
SpaNb4 marked this conversation as resolved.
Show resolved Hide resolved
3 changes: 0 additions & 3 deletions src/widgets/not-found/index.ts

This file was deleted.

38 changes: 0 additions & 38 deletions src/widgets/not-found/ui/not-found.scss

This file was deleted.

25 changes: 0 additions & 25 deletions src/widgets/not-found/ui/not-found.tsx

This file was deleted.

Loading