mirror of
https://github.com/OpenBB-finance/OpenBB.git
synced 2026-10-27 12:40:35 +00:00
* fix: new table design * fix: added trillions * fixing some raw data * fix: trying to fix global+resize * feat: improving design * fix: new styling and lot of reorganizing * title fix * feat: new html * fix: bottom bar * fix: table dates * fix: table html * fix: new filtering * fix: new filtering * fix: long * Lint * Lint again * fix: beautiful james suggestions * fix: some more fixes * fix: typo * fix economy bug * feat: added toast to notify user and some more cleanup * fix: more issues * tests * fix: james updates * fix: added banner to charts as well * fixing title * better fix * feat: added column resizing and any number of columns * auto column width - poc * feat: added colors toggle, support to display source, fixed some more issues * fix: table deploy * fix: table issue * fix header * fix: some fixes * fix: remember pagination and default pagination to 30 * mypy * Colins tests * Fix economy test --------- Co-authored-by: James Maslek <jmaslek11@gmail.com> Co-authored-by: teh_coderer <me@tehcoderer.com> Co-authored-by: andrewkenreich <andrew.kenreich@gmail.com>
91 lines
2.4 KiB
TypeScript
Vendored
91 lines
2.4 KiB
TypeScript
Vendored
//@ts-nocheck
|
|
import { useEffect, useState } from "react";
|
|
import Table from "./components/Table";
|
|
import { DndProvider } from "react-dnd";
|
|
import { HTML5Backend } from "react-dnd-html5-backend";
|
|
import {
|
|
cryptoData,
|
|
incomeData,
|
|
longIncomeData,
|
|
performanceData,
|
|
} from "./data/mockup";
|
|
|
|
declare global {
|
|
interface Window {
|
|
json_data: any;
|
|
title: string;
|
|
}
|
|
}
|
|
|
|
function App() {
|
|
const [data, setData] = useState(
|
|
process.env.NODE_ENV === "production" ? null : JSON.parse(cryptoData)
|
|
);
|
|
const [title, setTitle] = useState("Interactive Table");
|
|
const [source, setSource] = useState("");
|
|
|
|
if (process.env.NODE_ENV === "production") {
|
|
useEffect(() => {
|
|
const interval = setInterval(() => {
|
|
if (window.json_data) {
|
|
const data = JSON.parse(window.json_data);
|
|
console.log(data);
|
|
setData(data);
|
|
if (data.title && typeof data.title === "string") {
|
|
setTitle(data.title);
|
|
}
|
|
if (data.source && typeof data.source === "string") {
|
|
setSource(data.source);
|
|
}
|
|
clearInterval(interval);
|
|
}
|
|
}, 100);
|
|
return () => clearInterval(interval);
|
|
}, []);
|
|
}
|
|
|
|
const transformData = (data: any) => {
|
|
if (!data) return null;
|
|
|
|
let filename = data.title?.replace(/<b>|<\/b>/g, "").replace(/ /g, "_");
|
|
let date = new Date().toISOString().slice(0, 10).replace(/-/g, "");
|
|
let time = new Date().toISOString().slice(11, 19).replace(/:/g, "");
|
|
window.title = `openbb_${filename}_${date}_${time}`;
|
|
|
|
const columns = data.columns;
|
|
const index = data.index;
|
|
const newData = data.data;
|
|
const transformedData = newData.map((row: any, index: number) => {
|
|
const transformedRow = {};
|
|
row.forEach((value: any, index: number) => {
|
|
//@ts-ignore
|
|
transformedRow[columns[index]] = value;
|
|
});
|
|
return transformedRow;
|
|
});
|
|
return {
|
|
columns,
|
|
data: transformedData,
|
|
};
|
|
};
|
|
|
|
const transformedData = transformData(data);
|
|
|
|
return (
|
|
<div className="relative h-full bg-black">
|
|
<DndProvider backend={HTML5Backend}>
|
|
{transformedData && (
|
|
<Table
|
|
source={source}
|
|
title={title}
|
|
data={transformedData.data}
|
|
columns={transformedData.columns}
|
|
/>
|
|
)}
|
|
</DndProvider>
|
|
</div>
|
|
);
|
|
}
|
|
|
|
export default App;
|