File size: 2,943 Bytes
6512187
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
import { useState } from "react";
import CatalogView from "./components/CatalogView.jsx";
import WatchlistTable from "./components/WatchlistTable.jsx";
import ItemDetail from "./components/ItemDetail.jsx";
import SummaryChart from "./components/SummaryChart.jsx";

const TABS = [
  { id: "catalog", label: "Catalog" },
  { id: "watchlist", label: "Watchlist" },
  { id: "summary", label: "Dashboard" },
];

export default function App() {
  const [tab, setTab] = useState("catalog");
  const [detailSlug, setDetailSlug] = useState(null);
  const [priceMin, setPriceMin] = useState(0);
  const [priceMax, setPriceMax] = useState(99999);

  if (detailSlug) {
    return (
      <div className="app">
        <header>
          <h1>Warframe Market Tracker</h1>
        </header>
        <ItemDetail slug={detailSlug} onBack={() => setDetailSlug(null)} />
      </div>
    );
  }

  return (
    <div className="app">
      <header>
        <h1>Warframe Market Tracker</h1>
      </header>
      <div className="tabs">
        {TABS.map((t) => (
          <button
            key={t.id}
            className={`tab-btn${tab === t.id ? " active" : ""}`}
            onClick={() => setTab(t.id)}
          >
            {t.label}
          </button>
        ))}
      </div>
      <div style={{ display: tab === "catalog" ? "block" : "none" }}>
        <CatalogView />
      </div>
      {tab === "watchlist" && (
        <>
          <div className="controls">
            <div className="range-filter">
              <label>Min platinum:</label>
              <input
                type="number"
                value={priceMin}
                onChange={(e) => setPriceMin(Number(e.target.value) || 0)}
                min={0}
              />
              <label>Max platinum:</label>
              <input
                type="number"
                value={priceMax}
                onChange={(e) => setPriceMax(Number(e.target.value) || 99999)}
                min={0}
              />
            </div>
          </div>
          <WatchlistTable
            priceMin={priceMin}
            priceMax={priceMax}
            onItemSelect={setDetailSlug}
          />
        </>
      )}
      {tab === "summary" && (
        <>
          <div className="controls">
            <div className="range-filter">
              <label>Min platinum:</label>
              <input
                type="number"
                value={priceMin}
                onChange={(e) => setPriceMin(Number(e.target.value) || 0)}
                min={0}
              />
              <label>Max platinum:</label>
              <input
                type="number"
                value={priceMax}
                onChange={(e) => setPriceMax(Number(e.target.value) || 99999)}
                min={0}
              />
            </div>
          </div>
          <SummaryChart priceMin={priceMin} priceMax={priceMax} />
        </>
      )}
    </div>
  );
}