Skip to content

Commit 4ad4554

Browse files
committed
code cleanup
1 parent da5f331 commit 4ad4554

File tree

10 files changed

+27
-29
lines changed

10 files changed

+27
-29
lines changed

app/components/ErrorMessage.tsx

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import React, { PropsWithChildren } from "react";
22
import { Text } from "@radix-ui/themes";
33

4-
const ErrorMessage = ({ children }: PropsWithChildren) => {
4+
export const ErrorMessage = ({ children }: PropsWithChildren) => {
55
if (!children) {
66
return null;
77
}
@@ -11,5 +11,3 @@ const ErrorMessage = ({ children }: PropsWithChildren) => {
1111
</Text>
1212
);
1313
};
14-
15-
export default ErrorMessage;

app/components/IssueStatusBadge.tsx

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -23,10 +23,8 @@ const statusMap: Record<
2323
color: "green",
2424
},
2525
};
26-
const IssueStatusBadge = ({ status }: Props) => {
26+
export const IssueStatusBadge = ({ status }: Props) => {
2727
return (
2828
<Badge color={statusMap[status].color}>{statusMap[status].label}</Badge>
2929
);
3030
};
31-
32-
export default IssueStatusBadge;

app/components/Link.tsx

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ interface Props {
66
href: string;
77
children: string;
88
}
9-
const Link = ({ href, children }: Props) => {
9+
export const Link = ({ href, children }: Props) => {
1010
return (
1111
<NextLink href={href} passHref legacyBehavior>
1212
<RadixLink className="text-blue-500 hover:text-blue-700">
@@ -15,5 +15,3 @@ const Link = ({ href, children }: Props) => {
1515
</NextLink>
1616
);
1717
};
18-
19-
export default Link;

app/components/Skeleton.tsx

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
import React from "react";
2+
import Skeleton from "react-loading-skeleton";
3+
import "react-loading-skeleton/dist/skeleton.css";
4+
5+
export default Skeleton;

app/components/Spinner.tsx

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import React from "react";
22

3-
const Spinner = () => {
3+
export const Spinner = () => {
44
return (
55
<div
66
className="inline-block h-4 w-4 animate-spin rounded-full border-2 border-solid border-current border-e-transparent align-[-0.125em] text-surface motion-reduce:animate-[spin_1.5s_linear_infinite] dark:text-white"
@@ -12,5 +12,3 @@ const Spinner = () => {
1212
</div>
1313
);
1414
};
15-
16-
export default Spinner;

app/components/index.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
export * from "./Link";
2+
export * from "./ErrorMessage";
3+
export * from "./Spinner";
4+
export * from "./IssueStatusBadge";
5+
export { default as Skeleton } from "./Skeleton";

app/issues/loading.tsx

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,7 @@
11
import { Table } from "@radix-ui/themes";
22
import React from "react";
3-
import Skeleton from "react-loading-skeleton";
4-
import "react-loading-skeleton/dist/skeleton.css";
53
import IssueActions from "./issueActions";
4+
import { Skeleton } from "../components";
65

76
const LoadingIssuesPage = () => {
87
const issues = [1, 2, 3, 4, 5];

app/issues/new/page.tsx

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,15 @@
11
"use client";
2-
import SimpleMDE from "react-simplemde-editor";
3-
import "easymde/dist/easymde.min.css";
2+
import { createIssueSchema } from "@/app/createIssueSchema";
3+
import { zodResolver } from "@hookform/resolvers/zod";
44
import { Button, Callout, TextField } from "@radix-ui/themes";
5-
import { useForm, Controller } from "react-hook-form";
65
import axios from "axios";
6+
import "easymde/dist/easymde.min.css";
77
import { useRouter } from "next/navigation";
88
import { useState } from "react";
9-
import { zodResolver } from "@hookform/resolvers/zod";
10-
import { createIssueSchema } from "@/app/createIssueSchema";
9+
import { Controller, useForm } from "react-hook-form";
10+
import SimpleMDE from "react-simplemde-editor";
1111
import { z } from "zod";
12-
import ErrorMessage from "@/app/components/ErrorMessage";
13-
import Spinner from "@/app/components/Spinner";
12+
import { ErrorMessage, Spinner } from "../../components";
1413

1514
type IssueForm = z.infer<typeof createIssueSchema>;
1615

@@ -35,6 +34,7 @@ const NewIssuePage = () => {
3534
} catch (e) {
3635
setSubmitting(false);
3736
setError("Error creating issue");
37+
console.error(e);
3838
}
3939
});
4040
return (

app/issues/page.tsx

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,14 @@
1-
import React from "react";
21
import { Table } from "@radix-ui/themes";
32

4-
import Link from "../components/Link";
5-
63
import prisma from "@/prisma/client";
7-
import IssueStatusBadge from "../components/IssueStatusBadge";
8-
import delay from "delay";
9-
import IssueActions from "./issueActions";
4+
105
import capitalize from "lodash/capitalize";
6+
import IssueActions from "./issueActions";
7+
import { Link, IssueStatusBadge } from "../components";
118

129
const IssuesPage = async () => {
1310
const issues = await prisma.issue.findMany();
14-
await delay(2000);
11+
1512
return (
1613
<div>
1714
<IssueActions />

app/layout.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import type { Metadata } from "next";
44
import { Geist, Geist_Mono } from "next/font/google";
55
import "./globals.css";
66
import NavBar from "./NavBar";
7-
import { Theme, ThemePanel } from "@radix-ui/themes";
7+
import { Theme } from "@radix-ui/themes";
88

99
const geistSans = Geist({
1010
variable: "--font-geist-sans",

0 commit comments

Comments
 (0)