-
Notifications
You must be signed in to change notification settings - Fork 4
/
StatsUsageReportsGroup.tsx
93 lines (89 loc) · 2.81 KB
/
StatsUsageReportsGroup.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
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
import React = require("react");
import { Button } from "library-simplified-reusable-components";
import StatsGroup from "./StatsGroup";
import InventoryReportRequestModal from "./InventoryReportRequestModal";
import { useState } from "react";
type Props = {
heading?: string;
description?: string;
inventoryReportsEnabled: boolean;
quicksightLinkEnabled: boolean;
library?: string;
usageDataHref?: string;
usageDataLabel?: string;
usageDataTarget?: string;
};
const StatsUsageReportsGroup = ({
heading = "Usage and Reports",
description = `
Access historical circulation and usage data of the Palace system
and request inventory and holds reports to be sent via email.
`,
usageDataHref = "https://thepalaceproject.org",
usageDataLabel = "View Usage",
usageDataTarget = "_self",
inventoryReportsEnabled,
quicksightLinkEnabled,
library = undefined,
}: Props) => {
const [showReportForm, setShowReportForm] = useState(false);
return (
<>
{inventoryReportsEnabled && library && (
<InventoryReportRequestModal
show={showReportForm}
onHide={() => setShowReportForm(false)}
library={library}
/>
)}
<ul className="stat-usage-reports">
<li>
<StatsGroup heading={heading} description={description}>
<>
{!inventoryReportsEnabled && !quicksightLinkEnabled && (
<span className="no-content">
Usage reporting is not available.
</span>
)}
{inventoryReportsEnabled && library && (
<>
<Button
callback={(() => setShowReportForm(true)) as any}
content={
<>
Request Report
<i className="fa fa-regular fa-envelope" />
</>
}
title="Request an inventory report."
disabled={showReportForm}
/>
<div className="stat-group-description">
These reports provide up-to-date data on both inventory and
holds for library at the time of the request.
</div>
</>
)}
</>
</StatsGroup>
</li>
{quicksightLinkEnabled && (
<li>
<div className="stat-link">
<a
href={usageDataHref}
target={usageDataTarget}
rel="noopener noreferrer"
>
{usageDataLabel}
</a>
<i className="fa fa-external-link" />
</div>
</li>
)}
</ul>
</>
);
};
export default StatsUsageReportsGroup;