🙋🏽♂️ Wanted comics section on dashboard
This commit is contained in:
@@ -2,16 +2,21 @@ import React, { ReactElement, useEffect } from "react";
|
||||
import { useDispatch, useSelector } from "react-redux";
|
||||
import ZeroState from "./ZeroState";
|
||||
import { RecentlyImported } from "./RecentlyImported";
|
||||
import { WantedComicsList } from "./WantedComicsList";
|
||||
import { VolumeGroups } from "./VolumeGroups";
|
||||
import { PullList } from "./PullList";
|
||||
import { getComicBooks } from "../../actions/fileops.actions";
|
||||
import {
|
||||
fetchVolumeGroups,
|
||||
getComicBooks,
|
||||
} from "../../actions/fileops.actions";
|
||||
import { getLibraryStatistics } from "../../actions/comicinfo.actions";
|
||||
import { isEmpty, isNil, isUndefined, map } from "lodash";
|
||||
import { isEmpty, isUndefined, map } from "lodash";
|
||||
import prettyBytes from "pretty-bytes";
|
||||
|
||||
export const Dashboard = (): ReactElement => {
|
||||
const dispatch = useDispatch();
|
||||
useEffect(() => {
|
||||
dispatch(fetchVolumeGroups());
|
||||
dispatch(
|
||||
getComicBooks({
|
||||
paginationOptions: {
|
||||
@@ -19,13 +24,30 @@ export const Dashboard = (): ReactElement => {
|
||||
limit: 5,
|
||||
sort: { updatedAt: "-1" },
|
||||
},
|
||||
predicate: { "acquisition.wanted": false },
|
||||
comicStatus: "recent",
|
||||
}),
|
||||
);
|
||||
dispatch(
|
||||
getComicBooks({
|
||||
paginationOptions: {
|
||||
page: 0,
|
||||
limit: 5,
|
||||
sort: { updatedAt: "-1" },
|
||||
},
|
||||
predicate: { "acquisition.wanted": true },
|
||||
comicStatus: "wanted",
|
||||
}),
|
||||
);
|
||||
dispatch(getLibraryStatistics());
|
||||
}, [dispatch]);
|
||||
}, []);
|
||||
|
||||
const recentComics = useSelector(
|
||||
(state: RootState) => state.fileOps.recentComics,
|
||||
);
|
||||
const wantedComics = useSelector(
|
||||
(state: RootState) => state.fileOps.wantedComics,
|
||||
);
|
||||
const volumeGroups = useSelector(
|
||||
(state: RootState) => state.fileOps.comicVolumeGroups,
|
||||
);
|
||||
@@ -153,8 +175,9 @@ export const Dashboard = (): ReactElement => {
|
||||
</dl>
|
||||
</div>
|
||||
</div>
|
||||
<WantedComicsList comics={wantedComics} />
|
||||
<RecentlyImported comicBookCovers={recentComics} />
|
||||
{!isNil(volumeGroups) ? <VolumeGroups /> : null}
|
||||
<VolumeGroups volumeGroups={volumeGroups} />
|
||||
</>
|
||||
) : (
|
||||
<ZeroState
|
||||
|
||||
@@ -1,25 +1,16 @@
|
||||
import { isNil, map } from "lodash";
|
||||
import React, { ReactElement, useEffect } from "react";
|
||||
import { useSelector, useDispatch } from "react-redux";
|
||||
import { map } from "lodash";
|
||||
import React, { ReactElement } from "react";
|
||||
import ellipsize from "ellipsize";
|
||||
import { Link } from "react-router-dom";
|
||||
import { fetchVolumeGroups } from "../../actions/fileops.actions";
|
||||
import Masonry from "react-masonry-css";
|
||||
|
||||
export const VolumeGroups = (): ReactElement => {
|
||||
export const VolumeGroups = (props): ReactElement => {
|
||||
const breakpointColumnsObj = {
|
||||
default: 5,
|
||||
1100: 4,
|
||||
700: 2,
|
||||
500: 1,
|
||||
};
|
||||
const dispatch = useDispatch();
|
||||
useEffect(() => {
|
||||
dispatch(fetchVolumeGroups());
|
||||
}, [dispatch]);
|
||||
const volumeGroups = useSelector(
|
||||
(state: RootState) => state.fileOps.comicVolumeGroups,
|
||||
);
|
||||
return (
|
||||
<section className="volumes-container mt-4">
|
||||
<div className="content">
|
||||
@@ -31,32 +22,30 @@ export const VolumeGroups = (): ReactElement => {
|
||||
className="volumes-grid"
|
||||
columnClassName="volumes-grid-column"
|
||||
>
|
||||
{!isNil(volumeGroups) &&
|
||||
volumeGroups &&
|
||||
map(volumeGroups, (group) => {
|
||||
if (!isNil(group._id)) {
|
||||
return (
|
||||
<div className="stack" key={group._id.id}>
|
||||
<img src={group.data[0].image.small_url} />
|
||||
<div className="content">
|
||||
<div className="stack-title is-size-8">
|
||||
<Link to={`/volume/details/${group.comicBookObjectId}`}>
|
||||
{ellipsize(group.data[0].name, 18)}
|
||||
</Link>
|
||||
</div>
|
||||
<div className="control">
|
||||
<span className="tags has-addons">
|
||||
<span className="tag is-primary is-light">Issues</span>
|
||||
<span className="tag">
|
||||
{group.data[0].count_of_issues}
|
||||
</span>
|
||||
{map(props.volumeGroups, (data) => {
|
||||
return map(data.data, (group) => {
|
||||
return (
|
||||
<div className="stack" key={group.id}>
|
||||
<img src={group.volume.image.small_url} />
|
||||
<div className="content">
|
||||
<div className="stack-title is-size-8">
|
||||
<Link to={`/volume/details/${group.id}`}>
|
||||
{ellipsize(group.volume.name, 18)}
|
||||
</Link>
|
||||
</div>
|
||||
<div className="control">
|
||||
<span className="tags has-addons">
|
||||
<span className="tag is-primary is-light">Issues</span>
|
||||
<span className="tag">
|
||||
{group.volume.count_of_issues}
|
||||
</span>
|
||||
</div>
|
||||
</span>
|
||||
</div>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
})}
|
||||
</div>
|
||||
);
|
||||
});
|
||||
})}
|
||||
</Masonry>
|
||||
</section>
|
||||
);
|
||||
|
||||
93
src/client/components/Dashboard/WantedComicsList.tsx
Normal file
93
src/client/components/Dashboard/WantedComicsList.tsx
Normal file
@@ -0,0 +1,93 @@
|
||||
import React, { ReactElement } from "react";
|
||||
import Card from "../Carda";
|
||||
import { Link } from "react-router-dom";
|
||||
import ellipsize from "ellipsize";
|
||||
import { isEmpty, isNil, isUndefined, map } from "lodash";
|
||||
import { detectIssueTypes } from "../../shared/utils/tradepaperback.utils";
|
||||
import Masonry from "react-masonry-css";
|
||||
|
||||
type WantedComicsListProps = {
|
||||
comics: any;
|
||||
};
|
||||
|
||||
export const WantedComicsList = ({
|
||||
comics,
|
||||
}: WantedComicsListProps): ReactElement => {
|
||||
const breakpointColumnsObj = {
|
||||
default: 5,
|
||||
1100: 4,
|
||||
700: 2,
|
||||
600: 2,
|
||||
};
|
||||
|
||||
return (
|
||||
<>
|
||||
<div className="content">
|
||||
<h4 className="title is-4">Wanted Comics</h4>
|
||||
<p className="subtitle is-7">
|
||||
Comics marked as wanted from various sources.
|
||||
</p>
|
||||
</div>
|
||||
<Masonry
|
||||
breakpointCols={breakpointColumnsObj}
|
||||
className="recent-comics-container"
|
||||
columnClassName="recent-comics-column"
|
||||
>
|
||||
{map(comics, ({ _id, rawFileDetails, sourcedMetadata }) => {
|
||||
const isComicBookMetadataAvailable =
|
||||
sourcedMetadata &&
|
||||
!isUndefined(sourcedMetadata.comicvine) &&
|
||||
!isUndefined(sourcedMetadata.comicvine.volumeInformation) &&
|
||||
!isEmpty(sourcedMetadata);
|
||||
let imagePath = "";
|
||||
let comicName = "";
|
||||
if (isComicBookMetadataAvailable) {
|
||||
imagePath = sourcedMetadata.comicvine.image.small_url;
|
||||
comicName = sourcedMetadata.comicvine.name;
|
||||
}
|
||||
const titleElement = (
|
||||
<Link to={"/comic/details/" + _id}>{ellipsize(comicName, 20)}</Link>
|
||||
);
|
||||
return (
|
||||
<Card
|
||||
key={_id}
|
||||
orientation={"vertical"}
|
||||
imageUrl={imagePath}
|
||||
hasDetails
|
||||
title={comicName ? titleElement : <span>No Name</span>}
|
||||
>
|
||||
<div className="content is-flex is-flex-direction-row">
|
||||
{isComicBookMetadataAvailable && (
|
||||
<span className="icon custom-icon is-small">
|
||||
<img src="/img/cvlogo.svg" />
|
||||
</span>
|
||||
)}
|
||||
{/* Raw file presence */}
|
||||
{isEmpty(rawFileDetails.cover) && (
|
||||
<span className="icon custom-icon is-small has-text-danger mr-2">
|
||||
<img src="/img/missing-file.svg" />
|
||||
</span>
|
||||
)}
|
||||
{/* Issue type */}
|
||||
{isComicBookMetadataAvailable &&
|
||||
!isNil(
|
||||
detectIssueTypes(
|
||||
sourcedMetadata.comicvine.volumeInformation.description,
|
||||
),
|
||||
) ? (
|
||||
<span className="tag is-warning">
|
||||
{
|
||||
detectIssueTypes(
|
||||
sourcedMetadata.comicvine.volumeInformation.description,
|
||||
).displayName
|
||||
}
|
||||
</span>
|
||||
) : null}
|
||||
</div>
|
||||
</Card>
|
||||
);
|
||||
})}
|
||||
</Masonry>
|
||||
</>
|
||||
);
|
||||
};
|
||||
Reference in New Issue
Block a user