vega-frontend-monorepo/apps/trading/components/footer/footer.tsx
Matthew Russell 9b360af2c1
feat(#862): show current node and button to open node switcher (#1894)
* feat: add node url to footer, add link to change node

* feat: add test for trading footer

* chore: add comment about url manipulation

* fix: #862 fix cypress tests

* fix: #862 remove constant link

Co-authored-by: Madalina Raicu <madalina@raygroup.uk>
2022-11-07 16:53:43 -08:00

29 lines
890 B
TypeScript

import { useEnvironment } from '@vegaprotocol/environment';
import { t } from '@vegaprotocol/react-helpers';
import { ButtonLink, Link } from '@vegaprotocol/ui-toolkit';
export const Footer = () => {
const { VEGA_URL, setNodeSwitcherOpen } = useEnvironment();
return (
<footer className="px-4 py-1 text-xs border-t border-default">
<div className="flex justify-between">
<div className="flex gap-2">
{VEGA_URL && <NodeUrl url={VEGA_URL} />}
<ButtonLink onClick={setNodeSwitcherOpen}>{t('Change')}</ButtonLink>
</div>
</div>
</footer>
);
};
const NodeUrl = ({ url }: { url: string }) => {
// get base url from api url, api sub domain
const urlObj = new URL(url);
const nodeUrl = urlObj.origin.replace(/^[^.]+\./g, '');
return (
<Link href={'https://' + nodeUrl} target="_blank">
{nodeUrl}
</Link>
);
};