forked from getAlby/lightning-browser-extension
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.tsx
67 lines (61 loc) · 1.96 KB
/
index.tsx
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
import { CaretLeftIcon } from "@bitcoin-design/bitcoin-icons-react/filled";
import Header from "@components/Header";
import IconButton from "@components/IconButton";
import { useEffect, useState } from "react";
import { useTranslation } from "react-i18next";
import { Outlet, useMatch, useNavigate, useParams } from "react-router-dom";
import Avatar from "~/app/components/Avatar";
import api, { GetAccountRes } from "~/common/lib/api";
function AccountDetailLayout() {
const navigate = useNavigate();
const isRoot = useMatch("accounts/:id");
const { t } = useTranslation("translation", {
keyPrefix: "accounts.account_view",
});
const [account, setAccount] = useState<GetAccountRes>();
const { id } = useParams() as { id: string };
useEffect(() => {
(async () => {
const account = await api.getAccount(id);
setAccount(account);
})();
}, [id]);
function back() {
if (isRoot) {
navigate("/accounts");
} else {
navigate(`/accounts/${id}`);
}
}
return (
<>
<Header
title={t("title1")}
headerLeft={
<IconButton
onClick={back}
icon={<CaretLeftIcon className="w-4 h-4" />}
/>
}
/>
{account && (
<div className="border-b border-gray-200 dark:border-neutral-500 bg-white dark:bg-surface-02dp p-4">
<div className="flex-row justify-center space-x-2 flex items-center">
<Avatar name={account.id} size={32} />
<h2
title={account.name}
className="text-xl font-semibold dark:text-white overflow-hidden text-ellipsis whitespace-nowrap leading-1 my-2"
>
{account.name}
</h2>
</div>
<div className="flex-row justify-center flex items-center text-gray-500 text-sm dark:text-neutral-500">
{account.connectorType}
</div>
</div>
)}
<Outlet />
</>
);
}
export default AccountDetailLayout;