Skip to content

Commit e42c09d

Browse files
authored
Merge pull request #37 from hammer-code/refactor-files
refactor components file and name
2 parents 9760ff7 + 84acfdc commit e42c09d

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

60 files changed

+315
-270
lines changed

.editorconfig

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
# http://editorconfig.org
2+
root = true
3+
4+
[*]
5+
indent_style = space
6+
indent_size = 2
7+
end_of_line = lf
8+
charset = utf-8
9+
trim_trailing_whitespace = true
10+
insert_final_newline = true
11+
12+
# Use 4 spaces for the Python files
13+
[*.py]
14+
indent_size = 4
15+
max_line_length = 80
16+
17+
# The JSON files contain newlines inconsistently
18+
[*.json]
19+
insert_final_newline = ignore
20+
21+
# Minified JavaScript files shouldn't be changed
22+
[**.min.js]
23+
indent_style = ignore
24+
insert_final_newline = ignore
25+
26+
# Makefiles always use tabs for indentation
27+
[Makefile]
28+
indent_style = tab
29+
30+
# Batch files use tabs for indentation
31+
[*.bat]
32+
indent_style = tab
33+
34+
[*.md]
35+
trim_trailing_whitespace = false
36+

src/app/[locale]/about/page.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import AboutPage from "@/features/about";
1+
import { AboutPage } from "@/features/about";
22

33
const About = () => {
44
return <AboutPage />;
Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,24 @@
11
import { notFound } from "next/navigation";
2+
import { EventCertificate, CertificatePage } from "@/features/certificate";
23

3-
import Certificate from "@/features/certificate/Certificate";
4-
import { CertificateType } from "@/features/certificate/types";
4+
function getCertificateData(slug: string): Promise<EventCertificate> {
5+
return fetch(`https://moonlight.hammercode.org/v1/certificates/${slug}`).then((res) => res.json());
6+
}
57

6-
type Props = {
8+
type CertificateDetailProps = {
79
params: {
810
slug: string;
911
};
1012
};
1113

12-
const CertificateDetail = async ({ params }: Props) => {
13-
const data = await fetch(`https://moonlight.hammercode.org/v1/certificates/${params.slug}`);
14-
const certificateDetail: CertificateType = await data.json();
14+
const CertificateDetail = async ({ params }: CertificateDetailProps) => {
15+
const data = await getCertificateData(params.slug);
1516

16-
if (!certificateDetail.name) {
17+
if (!data.name) {
1718
return notFound();
1819
}
1920

20-
return <Certificate certificate={certificateDetail} />;
21+
return <CertificatePage certificate={data} />;
2122
};
2223

2324
export default CertificateDetail;

src/app/[locale]/events/[id]/page.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
1-
import EventDetail from "@/features/events/components/EventDetail";
1+
import { EventDetailPage } from "@/features/events";
22

33
const EventsDetail = ({ params }: { params: { id: string } }) => {
4-
return <EventDetail params={params} />;
4+
return <EventDetailPage eventId={params.id} />;
55
};
66

77
export default EventsDetail;

src/app/[locale]/events/page.tsx

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
1-
import EventsPage from "@/features/events";
1+
import { EventListPage } from "@/features/events";
22

3-
const Events = () => {
4-
return <EventsPage />;
3+
const EventList = () => {
4+
return <EventListPage />;
55
};
6-
export default Events;
6+
7+
export default EventList;

src/app/[locale]/layout.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ import { NextIntlClientProvider } from "next-intl";
33
import { getMessages, getTranslations, unstable_setRequestLocale } from "next-intl/server";
44
import { Sora } from "next/font/google";
55
import "./globals.css";
6-
import Wrapper from "@/components/layout/wrapper";
6+
import WrapperLayout from "@/components/layout/WrapperLayout";
77
import { locales } from "@/lib/config";
88
import { notFound } from "next/navigation";
99
const sora = Sora({ subsets: ["latin"] });
@@ -42,7 +42,7 @@ export default async function LocaleRootLayout({ children, params: { locale } }:
4242
</head>
4343
<body className={`${sora.className} pt-8`}>
4444
<NextIntlClientProvider messages={messages}>
45-
<Wrapper>{children}</Wrapper>
45+
<WrapperLayout>{children}</WrapperLayout>
4646
</NextIntlClientProvider>
4747
</body>
4848
</html>

src/app/[locale]/page.tsx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/* eslint-disable @typescript-eslint/no-explicit-any */
2-
import Home from "@/features/home";
2+
import { HomePage } from "@/features/home";
33
import { locales } from "@/lib/config";
44
import { unstable_setRequestLocale } from "next-intl/server";
55
import { notFound } from "next/navigation";
@@ -10,9 +10,9 @@ type Props = {
1010
};
1111
};
1212

13-
export default function HomePage({ params: { locale } }: Props) {
13+
export default function Home({ params: { locale } }: Props) {
1414
if (!locales.includes(locale as any)) notFound();
1515
unstable_setRequestLocale(locale);
1616

17-
return <Home />;
17+
return <HomePage />;
1818
}

src/components/common/locale-toggle/index.tsx renamed to src/components/common/LocaleToggle/index.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import { useParams } from "next/navigation";
44

55
import { usePathname, useRouter } from "@/lib/navigation";
66
import { Locale } from "@/lib/i18n";
7-
import { Button } from "@/components/ui/button";
7+
import { Button } from "@/components/ui/Button";
88

99
const LocaleToggle = () => {
1010
const locale = useLocale();

src/components/common/mode-toggle/index.tsx renamed to src/components/common/ThemeToggle/index.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,9 @@ import * as React from "react";
22
import { Moon, Sun } from "lucide-react";
33
import { useTheme } from "next-themes";
44

5-
import { Button } from "@/components/ui/button";
5+
import { Button } from "@/components/ui/Button";
66

7-
export function ModeToggle() {
7+
export function ThemeToggle() {
88
const { theme, setTheme } = useTheme();
99

1010
const handleSetTheme = () => {

src/components/common/footer/Footer.tsx renamed to src/components/common/footer/index.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import React from "react";
22
import { dataFooter } from "./constants";
33
import { Link } from "@/lib/navigation";
4-
import { Button } from "@/components/ui/button";
4+
import { Button } from "@/components/ui/Button";
55
import { useTranslations } from "next-intl";
66

77
const Footer = () => {

0 commit comments

Comments
 (0)