forked from Prompt-Hash-Stellar/prompt-hash
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathNetworkSwitcher.tsx
More file actions
40 lines (35 loc) · 1.39 KB
/
Copy pathNetworkSwitcher.tsx
File metadata and controls
40 lines (35 loc) · 1.39 KB
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
import React from "react";
import { stellarNetwork } from "@/lib/env";
/**
* Shows a prominent "TESTNET" badge when the app is running against the
* Stellar test network (#334). On Mainnet/Public this renders nothing so it
* never clutters the production UI.
*
* Network selection is driven entirely by the PUBLIC_STELLAR_NETWORK
* environment variable set at build time (see .env.example for all options).
* The component is intentionally read-only — switching networks requires
* redeployment with different env vars, which prevents accidental mainnet
* interaction in a development build.
*/
const NetworkSwitcher: React.FC = () => {
const isTestnet =
stellarNetwork === "TESTNET" ||
stellarNetwork === "FUTURENET" ||
stellarNetwork === "LOCAL";
if (!isTestnet) return null;
const label =
stellarNetwork === "LOCAL"
? "Local"
: stellarNetwork.charAt(0) + stellarNetwork.slice(1).toLowerCase();
return (
<div
className="flex items-center gap-1.5 rounded-full border border-amber-400/40 bg-amber-400/10 px-3 py-1 text-xs font-bold uppercase tracking-widest text-amber-300"
title={`App is connected to the Stellar ${label}. Real assets are NOT involved.`}
aria-label={`Connected to Stellar ${label}`}
>
<span className="h-1.5 w-1.5 rounded-full bg-amber-400 animate-pulse" />
{label}
</div>
);
};
export default NetworkSwitcher;