Skip to content

Commit

Permalink
Use tsx for jsx files
Browse files Browse the repository at this point in the history
  • Loading branch information
nekiro committed Nov 24, 2024
1 parent 1948cdc commit 78f7330
Show file tree
Hide file tree
Showing 25 changed files with 214 additions and 287 deletions.
9 changes: 5 additions & 4 deletions .prettierrc
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
{
"semi": true,
"trailingComma": "es5",
"singleQuote": false,
"useTabs": true
"semi": true,
"trailingComma": "all",
"singleQuote": false,
"useTabs": true,
"printWidth": 150
}
10 changes: 10 additions & 0 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@
"@types/mercadopago": "^1.5.11",
"@types/node-cron": "^3.0.11",
"@types/react": "^18.3.12",
"@types/sanitize-html": "^2.13.0",
"@types/speakeasy": "^2.0.10",
"@types/yup": "^0.29.14",
"autoprefixer": "^10.4.20",
Expand Down
10 changes: 5 additions & 5 deletions src/components/Button.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,9 @@ export interface ButtonProps {
type?: ButtonType;
href?: string;
btnColorType?: ButtonColorType;
isLoading: boolean;
isActive: boolean;
loadingText: string;
isLoading?: boolean;
isActive?: boolean;
loadingText?: string;
}

const Button = ({
Expand All @@ -24,8 +24,8 @@ const Button = ({
btnColorType = "primary",
size = "md",
href,
isLoading,
isActive,
isLoading = false,
isActive = false,
loadingText,
}: ButtonProps) => {
const btn = (
Expand Down
13 changes: 3 additions & 10 deletions src/components/DropdownButton.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,22 +5,15 @@ import { IoChevronDown } from "react-icons/io5";
import { Menu, MenuButton, MenuList, MenuItem, Button } from "@chakra-ui/react";

export interface DropdownButtonProps {
hasMenu: boolean;
hasMenu?: boolean;
text: string;
href?: string;
list?: { text: string; url: string; isActive?: boolean }[];
}

const DropdownButton = ({
hasMenu = false,
text,
href,
list,
}: DropdownButtonProps) => {
const DropdownButton = ({ hasMenu = false, text, href, list }: DropdownButtonProps) => {
const router = useRouter();
const isActive = hasMenu
? list?.some((item) => router.asPath.startsWith(item.url))
: router.asPath === href;
const isActive = hasMenu ? list?.some((item) => router.asPath.startsWith(item.url)) : router.asPath === href;

if (hasMenu) {
return (
Expand Down
2 changes: 1 addition & 1 deletion src/components/FormWrapper.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ export interface FormField {
name: string;
label: { text: string };
placeholder?: string;
as?: JSX.Element;
as?: any;
options?: { value: string; text: string }[];
}

Expand Down
9 changes: 7 additions & 2 deletions src/components/Link.jsx → src/components/Link.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,15 @@ import React from "react";
import { Link as ChakraLink } from "@chakra-ui/react";
import NextLink from "next/link";

const Link = ({ href, text }) => {
export interface LinkProps {
href: string;
text?: string;
}

const Link = ({ href, text }: LinkProps) => {
return (
<NextLink href={href} passHref>
<ChakraLink color="violet.500">{text ? text : href}</ChakraLink>
<ChakraLink color="violet.500">{text ?? href}</ChakraLink>
</NextLink>
);
};
Expand Down
18 changes: 0 additions & 18 deletions src/layout/Footer.jsx

This file was deleted.

12 changes: 12 additions & 0 deletions src/layout/Footer.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
import React from "react";
import { Box } from "@chakra-ui/react";

const Footer = () => {
return (
<Box bgColor="#f5f5f5" border="1px" borderRadius="md" padding="10px" textAlign="center">
Copyright © 2021-2023 Shibaac
</Box>
);
};

export default Footer;
17 changes: 5 additions & 12 deletions src/layout/Head.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,24 +3,17 @@ import React from "react";
import NextHead from "next/head";
import { NextSeo } from "next-seo";

type HeadProps = {
title: string;
export interface HeadProps {
title?: string;
description?: string;
};
}

const Head = ({
title = "shibaac",
description = "Automatic Account Creator",
}: HeadProps) => {
const Head = ({ title = "shibaac", description = "Automatic Account Creator" }: HeadProps) => {
return (
<>
<NextHead>
<meta charSet="UTF-8" key="charset" />
<meta
name="viewport"
content="width=device-width,initial-scale=1"
key="viewport"
/>
<meta name="viewport" content="width=device-width,initial-scale=1" key="viewport" />
<link rel="icon" href={`/favicon.ico`} key="favicon" />
</NextHead>
<NextSeo
Expand Down
40 changes: 5 additions & 35 deletions src/layout/NavBar.jsx → src/layout/NavBar.tsx
Original file line number Diff line number Diff line change
@@ -1,19 +1,7 @@
import React from "react";
import { useRouter } from "next/router";
import { useUser } from "../hooks/useUser";
import {
Flex,
Spacer,
Box,
Menu,
MenuButton,
MenuList,
MenuItem,
MenuGroup,
IconButton,
Link,
useBreakpointValue,
} from "@chakra-ui/react";
import { Flex, Spacer, Box, Menu, MenuButton, MenuList, MenuItem, MenuGroup, IconButton, Link, useBreakpointValue } from "@chakra-ui/react";
import DropdownButton from "../components/DropdownButton";
import TextInput from "../components/TextInput";
import { RxHamburgerMenu } from "react-icons/rx";
Expand Down Expand Up @@ -43,13 +31,7 @@ const navigationItems = [

const MobileNavigation = ({ user }) => {
return (
<Flex
bgColor="violet.400"
height="fit-content"
marginBottom="1.5em"
flexDir="row"
borderRadius="md"
>
<Flex bgColor="violet.400" height="fit-content" marginBottom="1.5em" flexDir="row" borderRadius="md">
<Menu>
<MenuButton
as={IconButton}
Expand Down Expand Up @@ -103,21 +85,9 @@ const DesktopNavigation = ({ user }) => {
const router = useRouter();

return (
<Flex
bgColor="violet.400"
height="fit-content"
marginBottom="1.5em"
flexDir="row"
borderRadius="md"
>
<Flex bgColor="violet.400" height="fit-content" marginBottom="1.5em" flexDir="row" borderRadius="md">
{navigationItems.map((item) => (
<DropdownButton
key={item.text}
text={item.text}
hasMenu={item.hasMenu}
list={item.menuItems}
href={item.href}
/>
<DropdownButton key={item.text} text={item.text} hasMenu={item.hasMenu} list={item.menuItems} href={item.href} />
))}

<Box alignSelf="center">
Expand Down Expand Up @@ -164,7 +134,7 @@ const NavBar = () => {
},
{
fallback: "md",
}
},
);

return <NavComponent user={user} />;
Expand Down
23 changes: 5 additions & 18 deletions src/layout/SideBar.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ const SideBar = (props: LayoutProps) => {
setIsLoading(true);

const [players, status] = await Promise.all([
fetchApi<{ players: player[] }>("GET", `/api/player/top5`),
fetchApi<{ players: any[] }>("GET", `/api/player/top5`),
fetchApi<{ status: ProtocolStatusCache }>("GET", `/api/status`),
]);

Expand All @@ -38,23 +38,10 @@ const SideBar = (props: LayoutProps) => {
<table className="table table-condensed table-content table-striped">
<tbody>
<tr>
<td>
{serverStatus?.online ? (
<Label colorScheme="green">ONLINE</Label>
) : (
<Label colorScheme="red">OFFLINE</Label>
)}
</td>
<td>{serverStatus?.online ? <Label colorScheme="green">ONLINE</Label> : <Label colorScheme="red">OFFLINE</Label>}</td>
</tr>
<tr>
<td>
{serverStatus && (
<Link
href="/online"
text={`${serverStatus.onlineCount} players online`}
/>
)}
</td>
<td>{serverStatus && <Link href="/online" text={`${serverStatus.onlineCount} players online`} />}</td>
</tr>
</tbody>
</table>
Expand All @@ -73,15 +60,15 @@ const SideBar = (props: LayoutProps) => {
{
text: player.level,
},
])
])
: [
[
{
text: "There is no data to show",
colspan: 2,
},
],
]
]
}
/>
</Panel>
Expand Down
25 changes: 4 additions & 21 deletions src/layout/index.jsx → src/layout/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,33 +3,16 @@ import Head from "./Head";
import NavBar from "./NavBar";
import SideBar from "./SideBar";
import Footer from "./Footer";

import { Box, Image, Flex } from "@chakra-ui/react";

const Layout = ({ children }) => {
return (
<Box
w={{ base: "95%", md: "70%" }}
marginX={"auto"}
marginY={{ base: "1em", md: 0 }}
>
<Head />
<Image
width="15%"
marginLeft="auto"
marginRight="auto"
marginBottom="15px"
marginTop="15px"
src="/images/header.png"
alt="shibaac"
/>
<Box w={{ base: "95%", md: "70%" }} marginX={"auto"} marginY={{ base: "1em", md: 0 }}>
<Head title="layout" />
<Image width="15%" marginLeft="auto" marginRight="auto" marginBottom="15px" marginTop="15px" src="/images/header.png" alt="shibaac" />
<NavBar />
<Flex flexDirection={{ base: "column", md: "row" }}>
<Box
flexGrow="1"
marginRight={{ base: 0, md: "3em" }}
order={{ base: 2, md: 1 }}
>
<Box flexGrow="1" marginRight={{ base: 0, md: "3em" }} order={{ base: 2, md: 1 }}>
{children}
<Footer />
</Box>
Expand Down
2 changes: 1 addition & 1 deletion src/lib/request.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ export type ResponseData = {
args?: any;
};

export const fetchApi = async <T = void>(
export const fetchApi = async <T = any>(
method: FetchMethods,
url: string,
options?: FetchOptions
Expand Down
File renamed without changes.
7 changes: 4 additions & 3 deletions src/pages/_app.jsx → src/pages/_app.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
import Layout from "src/layout";
import { UserContextWrapper } from "src/hooks/useUser";
import Layout from "../layout";
import { UserContextWrapper } from "../hooks/useUser";
import { ChakraProvider } from "@chakra-ui/react";
import { Theme, Fonts } from "src/layout/theme";
import { Theme, Fonts } from "../layout/theme";
import React from "react";

// @ts-ignore
BigInt.prototype.toJSON = function () {
Expand Down
Loading

0 comments on commit 78f7330

Please sign in to comment.