diff --git a/src/pages/dashboard/DashboardPage.tsx b/src/pages/dashboard/DashboardPage.tsx index da27361..03e5549 100644 --- a/src/pages/dashboard/DashboardPage.tsx +++ b/src/pages/dashboard/DashboardPage.tsx @@ -2,65 +2,178 @@ import "./styles.css"; import "react-tiles-dnd/esm/index.css"; import { TilesContainer, RenderTileFunction } from "react-tiles-dnd"; import useWindowDimensions from "../../hooks/WindowDimensionsHook.tsx"; -import {Link} from "react-router-dom"; import {Header} from "../../components/Header.tsx"; -import {Sidebar} from "../../components/Sidebar.tsx"; -import { Button } from "react-bootstrap"; -import { CSVUpload } from "../../components/transactions/CSVUpload.tsx"; -import { InputTransaction } from "../../components/transactions/InputTransaction.tsx"; -import { useState } from "react"; +import React, {ReactNode, useEffect, useState} from "react"; +import { getTransactionsFilterOrderBy, Transaction } from "../../utils/transaction.ts" +import {auth} from "../../utils/firebase.ts"; +import {orderBy} from "firebase/firestore"; +import {getCurrentBalance} from "../../utils/transaction_utils.ts"; +import { User } from "firebase/auth"; +import {FullscreenCenter} from "../../components/FullscreenCenter.tsx"; +import {Button} from "react-bootstrap"; +import {CSVUpload} from "../../components/transactions/CSVUpload.tsx"; +import {InputTransaction} from "../../components/transactions/InputTransaction.tsx"; +import Graphs from "./Graphs.tsx" +import test from "./test.tsx" -// ? Lot of code obtained from here for testing: https://codesandbox.io/p/sandbox/react-tiles-dnd-responsive-bd0ly?file=%2Fsrc%2Findex.tsx +type transactionPoint = { date: string; amount: number } +type tsxContents = ReactNode; -interface Props { - tiles: Array<{ text: string; rows: number; cols: number }> +class TileElement { + private graph?: transactionPoint[]; + private TSX?: () => tsxContents; + + constructor(graph: transactionPoint[] | undefined, TSX: (() => tsxContents) | undefined) { + this.graph = graph; + this.TSX = TSX; + } + + static newGraph(graph: transactionPoint[]): TileElement { + return new TileElement(graph, undefined); + } + static newTSX(TSX: () => tsxContents): TileElement { + return new TileElement(undefined, TSX); + } + + isGraph(): boolean { + return typeof this.graph !== "undefined"; + } + + forceGetGraph(): transactionPoint[] { + return this.graph!; + } + forceGetTSX(): () => tsxContents { + return this.TSX!; + } } -const render: RenderTileFunction<{ text: string; rows: number; cols: number }> = ({ data, isDragging }) => ( -
Go back
-