@microcosmmoney/portal-react 1.5.0 → 2.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
@@ -4,6 +4,7 @@
|
|
|
4
4
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
5
5
|
exports.MicrocosmDashboardOverview = MicrocosmDashboardOverview;
|
|
6
6
|
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
7
|
+
const react_1 = require("react");
|
|
7
8
|
const market_overview_bar_1 = require("./market-overview-bar");
|
|
8
9
|
const quick_actions_1 = require("./quick-actions");
|
|
9
10
|
const assets_summary_1 = require("./assets-summary");
|
|
@@ -11,6 +12,14 @@ const price_chart_1 = require("./price-chart");
|
|
|
11
12
|
const minting_stats_1 = require("./minting-stats");
|
|
12
13
|
const mining_weight_1 = require("./mining-weight");
|
|
13
14
|
const lock_periods_1 = require("./lock-periods");
|
|
15
|
+
class SafeRender extends react_1.Component {
|
|
16
|
+
constructor() {
|
|
17
|
+
super(...arguments);
|
|
18
|
+
this.state = { hasError: false };
|
|
19
|
+
}
|
|
20
|
+
static getDerivedStateFromError() { return { hasError: true }; }
|
|
21
|
+
render() { return this.state.hasError ? null : this.props.children; }
|
|
22
|
+
}
|
|
14
23
|
function MicrocosmDashboardOverview({ basePath = '', onNavigate, showHeader = true, headerText = 'SHARED NETWORK · SHARED FUTURE', }) {
|
|
15
|
-
return ((0, jsx_runtime_1.jsxs)("div", { className: "max-w-7xl mx-auto font-mono p-6 space-y-6", children: [showHeader && ((0, jsx_runtime_1.jsx)("div", { className: "text-center", children: (0, jsx_runtime_1.jsx)("h1", { className: "text-2xl sm:text-3xl md:text-4xl lg:text-5xl font-bold tracking-tight text-transparent bg-clip-text bg-gradient-to-r from-cyan-400 to-cyan-200", children: headerText }) })), (0, jsx_runtime_1.jsx)(market_overview_bar_1.MicrocosmMarketBar, {}), (0, jsx_runtime_1.jsx)(quick_actions_1.MicrocosmQuickActions, { basePath: basePath, onNavigate: onNavigate }), (0, jsx_runtime_1.jsxs)("div", { className: "grid lg:grid-cols-2 gap-6", children: [(0, jsx_runtime_1.jsx)(assets_summary_1.MicrocosmAssetsSummary, { basePath: basePath, onNavigate: onNavigate }), (0, jsx_runtime_1.jsx)(price_chart_1.MicrocosmPriceChart, {})] }), (0, jsx_runtime_1.jsxs)("div", { className: "grid lg:grid-cols-2 gap-6", children: [(0, jsx_runtime_1.jsx)(minting_stats_1.MicrocosmMintingStats, {}), (0, jsx_runtime_1.jsx)(mining_weight_1.MicrocosmMiningWeight, {})] }), (0, jsx_runtime_1.jsx)(lock_periods_1.MicrocosmLockPeriods, {})] }));
|
|
24
|
+
return ((0, jsx_runtime_1.jsxs)("div", { className: "max-w-7xl mx-auto font-mono p-6 space-y-6", children: [showHeader && ((0, jsx_runtime_1.jsx)("div", { className: "text-center", children: (0, jsx_runtime_1.jsx)("h1", { className: "text-2xl sm:text-3xl md:text-4xl lg:text-5xl font-bold tracking-tight text-transparent bg-clip-text bg-gradient-to-r from-cyan-400 to-cyan-200", children: headerText }) })), (0, jsx_runtime_1.jsx)(SafeRender, { children: (0, jsx_runtime_1.jsx)(market_overview_bar_1.MicrocosmMarketBar, {}) }), (0, jsx_runtime_1.jsx)(SafeRender, { children: (0, jsx_runtime_1.jsx)(quick_actions_1.MicrocosmQuickActions, { basePath: basePath, onNavigate: onNavigate }) }), (0, jsx_runtime_1.jsxs)("div", { className: "grid lg:grid-cols-2 gap-6", children: [(0, jsx_runtime_1.jsx)(SafeRender, { children: (0, jsx_runtime_1.jsx)(assets_summary_1.MicrocosmAssetsSummary, { basePath: basePath, onNavigate: onNavigate }) }), (0, jsx_runtime_1.jsx)(SafeRender, { children: (0, jsx_runtime_1.jsx)(price_chart_1.MicrocosmPriceChart, {}) })] }), (0, jsx_runtime_1.jsxs)("div", { className: "grid lg:grid-cols-2 gap-6", children: [(0, jsx_runtime_1.jsx)(SafeRender, { children: (0, jsx_runtime_1.jsx)(minting_stats_1.MicrocosmMintingStats, {}) }), (0, jsx_runtime_1.jsx)(SafeRender, { children: (0, jsx_runtime_1.jsx)(mining_weight_1.MicrocosmMiningWeight, {}) })] }), (0, jsx_runtime_1.jsx)(SafeRender, { children: (0, jsx_runtime_1.jsx)(lock_periods_1.MicrocosmLockPeriods, {}) })] }));
|
|
16
25
|
}
|
|
@@ -20,7 +20,9 @@ function daysRemaining(endTime) {
|
|
|
20
20
|
}
|
|
21
21
|
function MicrocosmLockPeriods() {
|
|
22
22
|
const { data } = (0, auth_react_1.useMCCLocks)();
|
|
23
|
-
const
|
|
23
|
+
const raw = data;
|
|
24
|
+
const locks = Array.isArray(raw) ? raw : raw?.locks ?? [];
|
|
25
|
+
const activeLocks = locks.filter((p) => p.status === 'locked');
|
|
24
26
|
if (activeLocks.length === 0)
|
|
25
27
|
return null;
|
|
26
28
|
return ((0, jsx_runtime_1.jsx)("div", { className: "bg-neutral-900 border border-neutral-700 rounded-lg hover:border-cyan-400/50 transition-colors", children: (0, jsx_runtime_1.jsx)("div", { className: "p-6", children: (0, jsx_runtime_1.jsx)("div", { className: "space-y-3", children: activeLocks.map((lock) => ((0, jsx_runtime_1.jsxs)("div", { className: "bg-neutral-800 rounded p-4", children: [(0, jsx_runtime_1.jsxs)("div", { className: "flex justify-between items-start mb-2", children: [(0, jsx_runtime_1.jsxs)("div", { children: [(0, jsx_runtime_1.jsx)("div", { className: "text-neutral-400 text-xs font-mono tracking-wider", children: lock.reason }), (0, jsx_runtime_1.jsxs)("div", { className: "text-xl font-bold font-mono text-cyan-400 mt-1", children: [(lock.amount ?? 0).toLocaleString(), " MCC"] })] }), (0, jsx_runtime_1.jsx)("span", { className: "px-2 py-0.5 bg-cyan-400/20 text-cyan-400 text-xs font-mono rounded", children: "LOCKED" })] }), (0, jsx_runtime_1.jsxs)("div", { className: "text-xs text-neutral-500 space-y-1 font-mono", children: [(0, jsx_runtime_1.jsxs)("div", { children: ["unlock_at: ", formatDateTime(lock.lock_end)] }), (0, jsx_runtime_1.jsxs)("div", { children: ["remaining: ", (0, jsx_runtime_1.jsx)("span", { className: "text-cyan-400", children: daysRemaining(lock.lock_end) })] })] })] }, lock.lock_id))) }) }) }));
|
|
@@ -15,10 +15,12 @@ const timeRanges = [
|
|
|
15
15
|
function MicrocosmPriceChart() {
|
|
16
16
|
const [range, setRange] = (0, react_1.useState)('7D');
|
|
17
17
|
const { data, loading } = (0, auth_react_1.usePriceHistory)(range);
|
|
18
|
-
const
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
18
|
+
const raw = data;
|
|
19
|
+
const items = Array.isArray(raw) ? raw : raw?.records ?? [];
|
|
20
|
+
const chartData = items.map((item) => ({
|
|
21
|
+
time: typeof item.timestamp === 'number' ? item.timestamp * 1000 : new Date(item.timestamp).getTime(),
|
|
22
|
+
price: item.price ?? item.close ?? 0,
|
|
23
|
+
}));
|
|
22
24
|
const prices = chartData.map((d) => d.price);
|
|
23
25
|
const minPrice = prices.length > 0 ? Math.min(...prices) * 0.995 : 0;
|
|
24
26
|
const maxPrice = prices.length > 0 ? Math.max(...prices) * 1.005 : 1;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@microcosmmoney/portal-react",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "2.0.0",
|
|
4
4
|
"description": "Microcosm Portal UI components for React/Next.js",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"types": "dist/index.d.ts",
|
|
@@ -17,8 +17,8 @@
|
|
|
17
17
|
"recharts": ">=2.0.0"
|
|
18
18
|
},
|
|
19
19
|
"dependencies": {
|
|
20
|
-
"@microcosmmoney/auth-core": "^
|
|
21
|
-
"@microcosmmoney/auth-react": "^
|
|
20
|
+
"@microcosmmoney/auth-core": "^2.0.0",
|
|
21
|
+
"@microcosmmoney/auth-react": "^2.0.0",
|
|
22
22
|
"lucide-react": ">=0.300.0"
|
|
23
23
|
},
|
|
24
24
|
"devDependencies": {
|