📚 Added volume card stacks to the dashboard
This commit is contained in:
@@ -2,6 +2,7 @@ import React, { ReactElement, useEffect } from "react";
|
||||
import { useDispatch, useSelector } from "react-redux";
|
||||
import ZeroState from "./ZeroState";
|
||||
import { RecentlyImported } from "./RecentlyImported";
|
||||
import { VolumeGroups } from "./VolumeGroups";
|
||||
import { getComicBooks } from "../actions/fileops.actions";
|
||||
import { isEmpty } from "lodash";
|
||||
|
||||
@@ -28,11 +29,8 @@ export const Dashboard = (): ReactElement => {
|
||||
|
||||
{!isEmpty(recentComics) && !isEmpty(recentComics.docs) ? (
|
||||
<>
|
||||
<h2 className="subtitle">Recently Imported</h2>
|
||||
<RecentlyImported comicBookCovers={recentComics} />
|
||||
<section>
|
||||
<div className="paper">asdas</div>
|
||||
</section>
|
||||
<VolumeGroups />
|
||||
</>
|
||||
) : (
|
||||
<ZeroState
|
||||
|
||||
@@ -16,53 +16,56 @@ type RecentlyImportedProps = {
|
||||
export const RecentlyImported = ({
|
||||
comicBookCovers,
|
||||
}: RecentlyImportedProps): ReactElement => (
|
||||
<section className="card-container">
|
||||
{map(comicBookCovers.docs, ({ _id, rawFileDetails, sourcedMetadata }) => {
|
||||
let imagePath = "";
|
||||
let comicName = "";
|
||||
if (!isNil(rawFileDetails)) {
|
||||
const encodedFilePath = encodeURI(
|
||||
"http://localhost:3000" + removeLeadingPeriod(rawFileDetails.path),
|
||||
<>
|
||||
<h2 className="subtitle">Recently Imported</h2>
|
||||
<section className="card-container">
|
||||
{map(comicBookCovers.docs, ({ _id, rawFileDetails, sourcedMetadata }) => {
|
||||
let imagePath = "";
|
||||
let comicName = "";
|
||||
if (!isNil(rawFileDetails)) {
|
||||
const encodedFilePath = encodeURI(
|
||||
"http://localhost:3000" + removeLeadingPeriod(rawFileDetails.path),
|
||||
);
|
||||
imagePath = escapePoundSymbol(encodedFilePath);
|
||||
comicName = rawFileDetails.name;
|
||||
} else if (!isNil(sourcedMetadata)) {
|
||||
imagePath = sourcedMetadata.comicvine.image.small_url;
|
||||
comicName = sourcedMetadata.comicvine.name;
|
||||
}
|
||||
const titleElement = (
|
||||
<Link to={"/comic/details/" + _id}>{ellipsize(comicName, 18)}</Link>
|
||||
);
|
||||
imagePath = escapePoundSymbol(encodedFilePath);
|
||||
comicName = rawFileDetails.name;
|
||||
} else if (!isNil(sourcedMetadata)) {
|
||||
imagePath = sourcedMetadata.comicvine.image.small_url;
|
||||
comicName = sourcedMetadata.comicvine.name;
|
||||
}
|
||||
const titleElement = (
|
||||
<Link to={"/comic/details/" + _id}>{ellipsize(comicName, 18)}</Link>
|
||||
);
|
||||
return (
|
||||
<Card
|
||||
key={_id}
|
||||
orientation={"vertical"}
|
||||
imageUrl={imagePath}
|
||||
hasDetails
|
||||
title={comicName ? titleElement : null}
|
||||
>
|
||||
<div className="content is-flex is-flex-direction-row">
|
||||
{!isNil(sourcedMetadata.comicvine) && (
|
||||
<span className="icon cv-icon is-small">
|
||||
<img src="/dist/img/cvlogo.svg" />
|
||||
</span>
|
||||
)}
|
||||
{isNil(rawFileDetails) && (
|
||||
<span className="icon has-text-info">
|
||||
<i className="fas fa-adjust" />
|
||||
</span>
|
||||
)}
|
||||
{!isNil(sourcedMetadata.comicvine) &&
|
||||
!isEmpty(
|
||||
detectTradePaperbacks(
|
||||
sourcedMetadata.comicvine.volumeInformation.description,
|
||||
),
|
||||
) ? (
|
||||
<span className="tag is-warning">TPB</span>
|
||||
) : null}
|
||||
</div>
|
||||
</Card>
|
||||
);
|
||||
})}
|
||||
</section>
|
||||
return (
|
||||
<Card
|
||||
key={_id}
|
||||
orientation={"vertical"}
|
||||
imageUrl={imagePath}
|
||||
hasDetails
|
||||
title={comicName ? titleElement : null}
|
||||
>
|
||||
<div className="content is-flex is-flex-direction-row">
|
||||
{!isNil(sourcedMetadata.comicvine) && (
|
||||
<span className="icon cv-icon is-small">
|
||||
<img src="/dist/img/cvlogo.svg" />
|
||||
</span>
|
||||
)}
|
||||
{isNil(rawFileDetails) && (
|
||||
<span className="icon has-text-info">
|
||||
<i className="fas fa-adjust" />
|
||||
</span>
|
||||
)}
|
||||
{!isNil(sourcedMetadata.comicvine) &&
|
||||
!isEmpty(
|
||||
detectTradePaperbacks(
|
||||
sourcedMetadata.comicvine.volumeInformation.description,
|
||||
),
|
||||
) ? (
|
||||
<span className="tag is-warning">TPB</span>
|
||||
) : null}
|
||||
</div>
|
||||
</Card>
|
||||
);
|
||||
})}
|
||||
</section>
|
||||
</>
|
||||
);
|
||||
|
||||
@@ -1,7 +1,46 @@
|
||||
import React, { ReactElement } from "react";
|
||||
import { isNil, map } from "lodash";
|
||||
import React, { ReactElement, useEffect } from "react";
|
||||
import { useSelector, useDispatch } from "react-redux";
|
||||
import ellipsize from "ellipsize";
|
||||
import { fetchVolumeGroups } from "../actions/fileops.actions";
|
||||
|
||||
export const VolumeGroups = (): ReactElement => {
|
||||
return <div className="paper"></div>;
|
||||
const dispatch = useDispatch();
|
||||
useEffect(() => {
|
||||
dispatch(fetchVolumeGroups());
|
||||
}, [dispatch]);
|
||||
const volumeGroups = useSelector(
|
||||
(state: RootState) => state.fileOps.comicVolumeGroups,
|
||||
);
|
||||
return (
|
||||
<>
|
||||
<h2 className="subtitle">Volumes</h2>
|
||||
<div className="stack-card-container">
|
||||
{!isNil(volumeGroups) &&
|
||||
volumeGroups &&
|
||||
map(volumeGroups.data, (group) => {
|
||||
if (!isNil(group)) {
|
||||
return (
|
||||
<div className="stack">
|
||||
<img src={group.results.image.small_url} />
|
||||
<div className="content">
|
||||
{ellipsize(group.results.name, 18)}
|
||||
<div className="control">
|
||||
<span className="tags has-addons">
|
||||
<span className="tag is-primary is-light">Issues</span>
|
||||
<span className="tag">
|
||||
{group.results.count_of_issues}
|
||||
</span>
|
||||
</span>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
})}
|
||||
</div>
|
||||
</>
|
||||
);
|
||||
};
|
||||
|
||||
export default VolumeGroups;
|
||||
|
||||
Reference in New Issue
Block a user