-
Notifications
You must be signed in to change notification settings - Fork 6
/
AgentsTableBase.tsx
63 lines (53 loc) · 1.89 KB
/
AgentsTableBase.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
// SPDX-License-Identifier: AGPL-3.0-or-later
// Copyright (C) 2022-2023 Dyne.org foundation <[email protected]>.
//
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU Affero General Public License as
// published by the Free Software Foundation, either version 3 of the
// License, or (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU Affero General Public License for more details.
//
// You should have received a copy of the GNU Affero General Public License
// along with this program. If not, see <https://www.gnu.org/licenses/>.
import { useTranslation } from "next-i18next";
// Components
import { GetAgentsQuery } from "lib/types";
import AgentsTableRow from "./AgentsTableRow";
import BrTable from "./brickroom/BrTable";
//
export interface ProjectsTableBaseProps {
data: GetAgentsQuery;
hidePagination?: boolean;
onLoadMore?: () => void;
}
//
export default function AgentsTableBase(props: ProjectsTableBaseProps) {
const { data, hidePagination = false, onLoadMore = () => {} } = props;
const { t } = useTranslation("common");
const agents = data.people?.edges;
const hasNextPage = data.people?.pageInfo.hasNextPage;
//
return (
<div>
<BrTable headArray={[t(""), t("name"), t("id"), t("location")]}>
{agents?.map(e => (
<AgentsTableRow agent={e.node} key={e.cursor} />
))}
</BrTable>
{/* Pagination */}
{!hidePagination && (
<div className="w-full pt-4 text-center">
{hasNextPage && (
<button className="text-center btn btn-primary" onClick={onLoadMore}>
{t("Load more")}
</button>
)}
</div>
)}
</div>
);
}