Browse Source

Re-organize frontend modules

1. "Components" refers to React components. "Types" and "HttpError"
are not React components and should thus be moved out.
2. Only components use JSX syntax, other files can/should have a regular
.ts extension.
3. If a file only exports one thing, make it a default export.
debug-collab-settlement
Thomas Eizinger 3 years ago
parent
commit
32b3031455
No known key found for this signature in database GPG Key ID: 651AC83A6C6C8B96
  1. 4
      taker-frontend/src/App.tsx
  2. 2
      taker-frontend/src/HttpError.ts
  3. 2
      taker-frontend/src/components/ErrorToast.tsx
  4. 2
      taker-frontend/src/components/History.tsx
  5. 2
      taker-frontend/src/components/NavBar.tsx
  6. 2
      taker-frontend/src/components/Timestamp.tsx
  7. 2
      taker-frontend/src/components/Trade.tsx
  8. 2
      taker-frontend/src/components/Wallet.tsx
  9. 0
      taker-frontend/src/types.ts

4
taker-frontend/src/App.tsx

@ -20,6 +20,7 @@ import Footer from "./components/Footer";
import History from "./components/History"; import History from "./components/History";
import Nav from "./components/NavBar"; import Nav from "./components/NavBar";
import Trade from "./components/Trade"; import Trade from "./components/Trade";
import { Wallet, WalletInfoBar } from "./components/Wallet";
import { import {
BXBTData, BXBTData,
Cfd, Cfd,
@ -31,8 +32,7 @@ import {
Order, Order,
StateGroupKey, StateGroupKey,
WalletInfo, WalletInfo,
} from "./components/Types"; } from "./types";
import { Wallet, WalletInfoBar } from "./components/Wallet";
import useLatestEvent from "./useLatestEvent"; import useLatestEvent from "./useLatestEvent";
import usePostRequest from "./usePostRequest"; import usePostRequest from "./usePostRequest";

2
taker-frontend/src/components/HttpError.tsx → taker-frontend/src/HttpError.ts

@ -1,6 +1,6 @@
// A wrapper to parse RFC 7807 // A wrapper to parse RFC 7807
// Pass result of `await response.json()` into the constructor. // Pass result of `await response.json()` into the constructor.
export class HttpError extends Error { export default class HttpError extends Error {
title: string; title: string;
detail?: string; detail?: string;

2
taker-frontend/src/components/ErrorToast.tsx

@ -1,4 +1,4 @@
import { HttpError } from "./HttpError"; import HttpError from "../HttpError";
// A generic way of creating an error toast // A generic way of creating an error toast
// TODO: Don't use any (`toast: typeof useToast` did not work :( ) // TODO: Don't use any (`toast: typeof useToast` did not work :( )

2
taker-frontend/src/components/History.tsx

@ -28,8 +28,8 @@ import {
VStack, VStack,
} from "@chakra-ui/react"; } from "@chakra-ui/react";
import * as React from "react"; import * as React from "react";
import { Cfd, StateGroupKey, StateKey, Tx, TxLabel } from "../types";
import usePostRequest from "../usePostRequest"; import usePostRequest from "../usePostRequest";
import { Cfd, StateGroupKey, StateKey, Tx, TxLabel } from "./Types";
interface HistoryProps { interface HistoryProps {
cfds: Cfd[]; cfds: Cfd[];

2
taker-frontend/src/components/NavBar.tsx

@ -17,7 +17,7 @@ import * as React from "react";
import { useNavigate } from "react-router-dom"; import { useNavigate } from "react-router-dom";
import logoBlack from "../images/logo_nav_bar_black.svg"; import logoBlack from "../images/logo_nav_bar_black.svg";
import logoWhite from "../images/logo_nav_bar_white.svg"; import logoWhite from "../images/logo_nav_bar_white.svg";
import { WalletInfo } from "./Types"; import { WalletInfo } from "../types";
interface NavProps { interface NavProps {
walletInfo: WalletInfo | null; walletInfo: WalletInfo | null;

2
taker-frontend/src/components/Timestamp.tsx

@ -1,6 +1,6 @@
import { Text } from "@chakra-ui/react"; import { Text } from "@chakra-ui/react";
import React from "react"; import React from "react";
import { unixTimestampToDate } from "./Types"; import { unixTimestampToDate } from "../types";
interface Props { interface Props {
timestamp: number; timestamp: number;

2
taker-frontend/src/components/Trade.tsx

@ -45,7 +45,7 @@ import {
} from "@chakra-ui/react"; } from "@chakra-ui/react";
import { motion } from "framer-motion"; import { motion } from "framer-motion";
import * as React from "react"; import * as React from "react";
import { CfdOrderRequestPayload } from "./Types"; import { CfdOrderRequestPayload } from "../types";
const MotionBox = motion<BoxProps>(Box); const MotionBox = motion<BoxProps>(Box);

2
taker-frontend/src/components/Wallet.tsx

@ -26,9 +26,9 @@ import {
import * as React from "react"; import * as React from "react";
import { useState } from "react"; import { useState } from "react";
import { useNavigate } from "react-router-dom"; import { useNavigate } from "react-router-dom";
import { WalletInfo, WithdrawRequest } from "../types";
import usePostRequest from "../usePostRequest"; import usePostRequest from "../usePostRequest";
import Timestamp from "./Timestamp"; import Timestamp from "./Timestamp";
import { WalletInfo, WithdrawRequest } from "./Types";
interface WalletProps { interface WalletProps {
walletInfo: WalletInfo | null; walletInfo: WalletInfo | null;

0
taker-frontend/src/components/Types.tsx → taker-frontend/src/types.ts

Loading…
Cancel
Save