-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Update patron stats and factor out more components.
- Loading branch information
Showing
8 changed files
with
250 additions
and
161 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
import React = require("react"); | ||
import StatsGroup from "./StatsGroup"; | ||
import SingleStatListItem from "./SingleStatListItem"; | ||
import { CollectionInventory } from "../interfaces"; | ||
import StatsCollectionsBarChart from "./StatsCollectionsBarChart"; | ||
import StatsCollectionsList from "./StatsCollectionsList"; | ||
|
||
type Props = { | ||
heading?: string; | ||
description?: string; | ||
collections: CollectionInventory[]; | ||
showBarChart: boolean; | ||
}; | ||
|
||
const StatsCollectionsGroup = ({ | ||
heading = "Collections", | ||
description = "Collections configured for your library(ies) in the Palace System.", | ||
collections, | ||
showBarChart, | ||
}: Props) => { | ||
const content = | ||
collections.length === 0 ? ( | ||
<span className="no-collections">No associated collections.</span> | ||
) : showBarChart ? ( | ||
<StatsCollectionsBarChart collections={collections} /> | ||
) : ( | ||
<StatsCollectionsList collections={collections} /> | ||
); | ||
return ( | ||
<StatsGroup heading={heading} description={description}> | ||
{content} | ||
</StatsGroup> | ||
); | ||
}; | ||
|
||
export default StatsCollectionsGroup; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,90 @@ | ||
import React = require("react"); | ||
import { Button } from "library-simplified-reusable-components"; | ||
import StatsGroup from "./StatsGroup"; | ||
import SingleStatListItem from "./SingleStatListItem"; | ||
import { InventoryStatistics } from "../interfaces"; | ||
import InventoryReportRequestModal from "./InventoryReportRequestModal"; | ||
import { inventoryKeyToLabelMap } from "./LibraryStats"; | ||
import { useState } from "react"; | ||
|
||
type Props = { | ||
heading?: string; | ||
description?: string; | ||
inventory: InventoryStatistics; | ||
inventoryReportsEnabled: boolean; | ||
library?: string; | ||
}; | ||
|
||
const StatsInventoryGroup = ({ | ||
heading = "Inventory", | ||
description = "Real-time item inventory.", | ||
inventory, | ||
inventoryReportsEnabled, | ||
library = undefined, | ||
}: Props) => { | ||
const [showReportForm, setShowReportForm] = useState(false); | ||
|
||
return ( | ||
<> | ||
{inventoryReportsEnabled && library && ( | ||
<InventoryReportRequestModal | ||
show={showReportForm} | ||
onHide={() => setShowReportForm(false)} | ||
library={library} | ||
/> | ||
)} | ||
<StatsGroup | ||
heading={heading} | ||
description={description} | ||
headingAdditionalContent={ | ||
inventoryReportsEnabled && | ||
library && ( | ||
<Button | ||
callback={(() => setShowReportForm(true)) as any} | ||
content="⬇︎" | ||
title="Request an inventory report" | ||
style={{ | ||
borderRadius: "50%", | ||
marginLeft: "10px", | ||
marginBottom: "0", | ||
marginTop: "-0.7rem", | ||
}} | ||
className="inline small" | ||
disabled={showReportForm} | ||
/> | ||
) | ||
} | ||
> | ||
<ul> | ||
<SingleStatListItem | ||
label={inventoryKeyToLabelMap.titles} | ||
value={inventory.titles} | ||
tooltip="Total number of books." | ||
/> | ||
<SingleStatListItem | ||
label={inventoryKeyToLabelMap.availableTitles} | ||
value={inventory.availableTitles} | ||
tooltip="Number of books available for lending." | ||
/> | ||
<SingleStatListItem | ||
label={inventoryKeyToLabelMap.meteredLicenseTitles} | ||
value={inventory.meteredLicenseTitles} | ||
tooltip="Number of books with a metered (counted) license." | ||
/> | ||
<SingleStatListItem | ||
label={inventoryKeyToLabelMap.unlimitedLicenseTitles} | ||
value={inventory.unlimitedLicenseTitles} | ||
tooltip="Number of books for which there is no limit on the number of loans." | ||
/> | ||
<SingleStatListItem | ||
label={inventoryKeyToLabelMap.openAccessTitles} | ||
value={inventory.openAccessTitles} | ||
tooltip="Number of books for which there are no limits on use." | ||
/> | ||
</ul> | ||
</StatsGroup> | ||
</> | ||
); | ||
}; | ||
|
||
export default StatsInventoryGroup; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
import React = require("react"); | ||
import StatsGroup from "./StatsGroup"; | ||
import SingleStatListItem from "./SingleStatListItem"; | ||
|
||
type Props = { | ||
heading?: string; | ||
description?: string; | ||
total?: number; | ||
withActiveLoan: number; | ||
withActiveLoanOrHold: number; | ||
}; | ||
|
||
const StatsPatronGroup = ({ | ||
heading = "Patrons", | ||
description = "Real-time patron information for the Palace System.", | ||
total = undefined, | ||
withActiveLoan, | ||
withActiveLoanOrHold, | ||
}: Props) => { | ||
return ( | ||
<StatsGroup heading={heading} description={description}> | ||
<ul> | ||
{total && ( | ||
<SingleStatListItem | ||
label="Total Patrons" | ||
value={total} | ||
tooltip="Total number of patrons in the Palace System." | ||
/> | ||
)} | ||
<SingleStatListItem | ||
label="Patrons With Active Loans" | ||
value={withActiveLoan} | ||
tooltip="Number of patrons with at least one active loan." | ||
/> | ||
<SingleStatListItem | ||
label="Patrons With Active Loans or Holds" | ||
value={withActiveLoanOrHold} | ||
tooltip="Number of patrons with at least one active loan or at least one hold." | ||
/> | ||
</ul> | ||
</StatsGroup> | ||
); | ||
}; | ||
|
||
export default StatsPatronGroup; |
Oops, something went wrong.