diff --git a/apps/stats-web/src/app/graph/[snapshot]/GraphContainer.tsx b/apps/stats-web/src/app/graph/[snapshot]/GraphContainer.tsx index bf73b139b..72e1c7ad0 100644 --- a/apps/stats-web/src/app/graph/[snapshot]/GraphContainer.tsx +++ b/apps/stats-web/src/app/graph/[snapshot]/GraphContainer.tsx @@ -9,7 +9,7 @@ import dynamic from "next/dynamic"; import { DiffNumber } from "@/components/DiffNumber"; import { DiffPercentageChip } from "@/components/DiffPercentageChip"; import { TimeRange } from "@/components/graph/TimeRange"; -import { selectedRangeValues } from "@/lib/constants"; +import { SELECTED_RANGE_VALUES } from "@/config/date.config"; import { percIncrease, udenomToDenom } from "@/lib/mathHelpers"; import { SNAPSHOT_NOT_FOUND } from "@/lib/snapshotsUrlHelpers"; import { bytesToShrink } from "@/lib/unitUtils"; @@ -25,7 +25,7 @@ export interface IGraphProps { } export default function GraphContainer({ snapshot }: IGraphProps) { - const [selectedRange, setSelectedRange] = useState(selectedRangeValues["7D"]); + const [selectedRange, setSelectedRange] = useState(SELECTED_RANGE_VALUES["7D"]); const { data: snapshotData, status } = useGraphSnapshot(snapshot); const snapshotMetadata = snapshotData && getSnapshotMetadata(snapshot as Snapshots); const rangedData = snapshotData && snapshotData.snapshots.slice(Math.max(snapshotData.snapshots.length - selectedRange, 0), snapshotData.snapshots.length); @@ -50,7 +50,7 @@ export default function GraphContainer({ snapshot }: IGraphProps) { const csvContent = parser.parse(rangedData.map(d => ({ date: d.date, value: snapshotMetadata.unitFn(d.value).value }))); const datePart = new Date().toISOString().substring(0, 10).replaceAll("-", ""); - const rangePart = Object.keys(selectedRangeValues).find(key => selectedRangeValues[key] === selectedRange); + const rangePart = Object.keys(SELECTED_RANGE_VALUES).find(key => SELECTED_RANGE_VALUES[key] === selectedRange); const fileName = `${snapshot}-${datePart}-${rangePart}.csv`; const encodedUri = encodeURI("data:text/csv;charset=utf-8," + csvContent); diff --git a/apps/stats-web/src/app/provider-graph/[snapshot]/GraphContainer.tsx b/apps/stats-web/src/app/provider-graph/[snapshot]/GraphContainer.tsx index ecec6a618..4d4234525 100644 --- a/apps/stats-web/src/app/provider-graph/[snapshot]/GraphContainer.tsx +++ b/apps/stats-web/src/app/provider-graph/[snapshot]/GraphContainer.tsx @@ -9,7 +9,7 @@ import dynamic from "next/dynamic"; import { DiffNumber } from "@/components/DiffNumber"; import { DiffPercentageChip } from "@/components/DiffPercentageChip"; import { TimeRange } from "@/components/graph/TimeRange"; -import { selectedRangeValues } from "@/lib/constants"; +import { SELECTED_RANGE_VALUES } from "@/config/date.config"; import { percIncrease } from "@/lib/mathHelpers"; import { getProviderSnapshotMetadata } from "@/lib/providerUtils"; import { SNAPSHOT_NOT_FOUND } from "@/lib/snapshotsUrlHelpers"; @@ -25,7 +25,7 @@ export interface IGraphProps { } export default function GraphContainer({ snapshot }: IGraphProps) { - const [selectedRange, setSelectedRange] = useState(selectedRangeValues["7D"]); + const [selectedRange, setSelectedRange] = useState(SELECTED_RANGE_VALUES["7D"]); const { data: snapshotData, status } = useProviderGraphSnapshot(snapshot); const snapshotMetadata = snapshotData && getProviderSnapshotMetadata(snapshot as ProviderSnapshots); const rangedData = snapshotData && snapshotData.snapshots.slice(Math.max(snapshotData.snapshots.length - selectedRange, 0), snapshotData.snapshots.length); @@ -50,7 +50,7 @@ export default function GraphContainer({ snapshot }: IGraphProps) { const csvContent = parser.parse(rangedData.map(d => ({ date: d.date, value: snapshotMetadata.unitFn(d.value).value }))); const datePart = new Date().toISOString().substring(0, 10).replaceAll("-", ""); - const rangePart = Object.keys(selectedRangeValues).find(key => selectedRangeValues[key] === selectedRange); + const rangePart = Object.keys(SELECTED_RANGE_VALUES).find(key => SELECTED_RANGE_VALUES[key] === selectedRange); const fileName = `${snapshot}-${datePart}-${rangePart}.csv`; const encodedUri = encodeURI("data:text/csv;charset=utf-8," + csvContent); diff --git a/apps/stats-web/src/components/graph/TimeRange.tsx b/apps/stats-web/src/components/graph/TimeRange.tsx index f1bd6ec76..aae2d5a4b 100644 --- a/apps/stats-web/src/components/graph/TimeRange.tsx +++ b/apps/stats-web/src/components/graph/TimeRange.tsx @@ -2,7 +2,7 @@ import { ReactNode } from "react"; import { ToggleGroup, ToggleGroupItem } from "@akashnetwork/ui/components"; -import { selectedRangeValues } from "@/lib/constants"; +import { SELECTED_RANGE_VALUES } from "@/config/date.config"; import { cn } from "@/lib/utils"; type Props = { @@ -20,24 +20,24 @@ export const TimeRange: React.FunctionComponent = ({ selectedRange, onRan _onRangeChange(selectedRangeValues["7D"])} + className={cn({ ["!bg-primary font-bold !text-white"]: selectedRange === SELECTED_RANGE_VALUES["7D"] })} + onClick={() => _onRangeChange(SELECTED_RANGE_VALUES["7D"])} size="sm" > 7D _onRangeChange(selectedRangeValues["1M"])} + className={cn({ ["!bg-primary font-bold !text-white"]: selectedRange === SELECTED_RANGE_VALUES["1M"] })} + onClick={() => _onRangeChange(SELECTED_RANGE_VALUES["1M"])} size="sm" > 1M _onRangeChange(selectedRangeValues["ALL"])} + className={cn({ ["!bg-primary font-bold !text-white"]: selectedRange === SELECTED_RANGE_VALUES["ALL"] })} + onClick={() => _onRangeChange(SELECTED_RANGE_VALUES["ALL"])} size="sm" > ALL diff --git a/apps/stats-web/src/config/date.config.ts b/apps/stats-web/src/config/date.config.ts new file mode 100644 index 000000000..de6acce2e --- /dev/null +++ b/apps/stats-web/src/config/date.config.ts @@ -0,0 +1,5 @@ +export const SELECTED_RANGE_VALUES: Record = { + "7D": 7, + "1M": 30, + ALL: Number.MAX_SAFE_INTEGER +}; diff --git a/apps/stats-web/src/lib/constants.ts b/apps/stats-web/src/lib/constants.ts index ca6ca930f..3c0974c6b 100644 --- a/apps/stats-web/src/lib/constants.ts +++ b/apps/stats-web/src/lib/constants.ts @@ -1,11 +1,5 @@ import { MAINNET_ID, SANDBOX_ID, TESTNET_ID } from "@akashnetwork/network-store"; -export const selectedRangeValues: { [key: string]: number } = { - "7D": 7, - "1M": 30, - ALL: Number.MAX_SAFE_INTEGER -}; - const productionMainnetApiUrl = "https://console-api.akash.network"; const productionTestnetApiUrl = "https://console-api-testnet.akash.network"; const productionSandboxApiUrl = "https://console-api-sandbox.akash.network"; diff --git a/package-lock.json b/package-lock.json index e5ab20bb3..ed7f9310f 100644 --- a/package-lock.json +++ b/package-lock.json @@ -36526,6 +36526,141 @@ "peerDependencies": { "react": ">=16.13.1" } + }, + "node_modules/@next/swc-darwin-arm64": { + "version": "14.2.6", + "resolved": "https://registry.npmjs.org/@next/swc-darwin-arm64/-/swc-darwin-arm64-14.2.6.tgz", + "integrity": "sha512-BtJZb+hYXGaVJJivpnDoi3JFVn80SHKCiiRUW3kk1SY6UCUy5dWFFSbh+tGi5lHAughzeduMyxbLt3pspvXNSg==", + "cpu": [ + "arm64" + ], + "optional": true, + "os": [ + "darwin" + ], + "engines": { + "node": ">= 10" + } + }, + "node_modules/@next/swc-darwin-x64": { + "version": "14.2.6", + "resolved": "https://registry.npmjs.org/@next/swc-darwin-x64/-/swc-darwin-x64-14.2.6.tgz", + "integrity": "sha512-ZHRbGpH6KHarzm6qEeXKSElSXh8dS2DtDPjQt3IMwY8QVk7GbdDYjvV4NgSnDA9huGpGgnyy3tH8i5yHCqVkiQ==", + "cpu": [ + "x64" + ], + "optional": true, + "os": [ + "darwin" + ], + "engines": { + "node": ">= 10" + } + }, + "node_modules/@next/swc-linux-arm64-gnu": { + "version": "14.2.6", + "resolved": "https://registry.npmjs.org/@next/swc-linux-arm64-gnu/-/swc-linux-arm64-gnu-14.2.6.tgz", + "integrity": "sha512-O4HqUEe3ZvKshXHcDUXn1OybN4cSZg7ZdwHJMGCXSUEVUqGTJVsOh17smqilIjooP/sIJksgl+1kcf2IWMZWHg==", + "cpu": [ + "arm64" + ], + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": ">= 10" + } + }, + "node_modules/@next/swc-linux-arm64-musl": { + "version": "14.2.6", + "resolved": "https://registry.npmjs.org/@next/swc-linux-arm64-musl/-/swc-linux-arm64-musl-14.2.6.tgz", + "integrity": "sha512-xUcdhr2hfalG8RDDGSFxQ75yOG894UlmFS4K2M0jLrUhauRBGOtUOxoDVwiIIuZQwZ3Y5hDsazNjdYGB0cQ9yQ==", + "cpu": [ + "arm64" + ], + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": ">= 10" + } + }, + "node_modules/@next/swc-linux-x64-gnu": { + "version": "14.2.6", + "resolved": "https://registry.npmjs.org/@next/swc-linux-x64-gnu/-/swc-linux-x64-gnu-14.2.6.tgz", + "integrity": "sha512-InosKxw8UMcA/wEib5n2QttwHSKHZHNSbGcMepBM0CTcNwpxWzX32KETmwbhKod3zrS8n1vJ+DuJKbL9ZAB0Ag==", + "cpu": [ + "x64" + ], + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": ">= 10" + } + }, + "node_modules/@next/swc-linux-x64-musl": { + "version": "14.2.6", + "resolved": "https://registry.npmjs.org/@next/swc-linux-x64-musl/-/swc-linux-x64-musl-14.2.6.tgz", + "integrity": "sha512-d4QXfJmt5pGJ7cG8qwxKSBnO5AXuKAFYxV7qyDRHnUNvY/dgDh+oX292gATpB2AAHgjdHd5ks1wXxIEj6muLUQ==", + "cpu": [ + "x64" + ], + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": ">= 10" + } + }, + "node_modules/@next/swc-win32-arm64-msvc": { + "version": "14.2.6", + "resolved": "https://registry.npmjs.org/@next/swc-win32-arm64-msvc/-/swc-win32-arm64-msvc-14.2.6.tgz", + "integrity": "sha512-AlgIhk4/G+PzOG1qdF1b05uKTMsuRatFlFzAi5G8RZ9h67CVSSuZSbqGHbJDlcV1tZPxq/d4G0q6qcHDKWf4aQ==", + "cpu": [ + "arm64" + ], + "optional": true, + "os": [ + "win32" + ], + "engines": { + "node": ">= 10" + } + }, + "node_modules/@next/swc-win32-ia32-msvc": { + "version": "14.2.6", + "resolved": "https://registry.npmjs.org/@next/swc-win32-ia32-msvc/-/swc-win32-ia32-msvc-14.2.6.tgz", + "integrity": "sha512-hNukAxq7hu4o5/UjPp5jqoBEtrpCbOmnUqZSKNJG8GrUVzfq0ucdhQFVrHcLRMvQcwqqDh1a5AJN9ORnNDpgBQ==", + "cpu": [ + "ia32" + ], + "optional": true, + "os": [ + "win32" + ], + "engines": { + "node": ">= 10" + } + }, + "node_modules/@next/swc-win32-x64-msvc": { + "version": "14.2.6", + "resolved": "https://registry.npmjs.org/@next/swc-win32-x64-msvc/-/swc-win32-x64-msvc-14.2.6.tgz", + "integrity": "sha512-NANtw+ead1rSDK1jxmzq3TYkl03UNK2KHqUYf1nIhNci6NkeqBD4s1njSzYGIlSHxCK+wSaL8RXZm4v+NF/pMw==", + "cpu": [ + "x64" + ], + "optional": true, + "os": [ + "win32" + ], + "engines": { + "node": ">= 10" + } } } }