📝 Adding elements to Comic Detail page
This commit is contained in:
@@ -22,7 +22,7 @@ class App extends React.Component<Record<string, unknown>, undefined> {
|
|||||||
<Import path={"./comics"} />
|
<Import path={"./comics"} />
|
||||||
</Route>
|
</Route>
|
||||||
<Route
|
<Route
|
||||||
path={"/comic/details/:mongoObjId"}
|
path={"/comic/details/:comicObjectId"}
|
||||||
component={ComicDetail}
|
component={ComicDetail}
|
||||||
/>
|
/>
|
||||||
</Switch>
|
</Switch>
|
||||||
|
|||||||
@@ -1,5 +1,6 @@
|
|||||||
import * as React from "react";
|
import * as React from "react";
|
||||||
import { IExtractedComicBookCoverFile } from "../../server/interfaces/folder.interface";
|
import { IExtractedComicBookCoverFile } from "../../server/interfaces/folder.interface";
|
||||||
|
import { removeLeadingPeriod } from "../shared/utils/formatting.utils";
|
||||||
import { isUndefined, isEmpty } from "lodash";
|
import { isUndefined, isEmpty } from "lodash";
|
||||||
import { Link } from "react-router-dom";
|
import { Link } from "react-router-dom";
|
||||||
|
|
||||||
@@ -14,14 +15,7 @@ class Card extends React.Component<IProps, IState> {
|
|||||||
super(props);
|
super(props);
|
||||||
console.log(props);
|
console.log(props);
|
||||||
}
|
}
|
||||||
private removeLeadingPeriod = (input: string): string => {
|
|
||||||
if (!isUndefined(this.props.comicBookCoversMetadata)) {
|
|
||||||
if (input.charAt(0) == ".") {
|
|
||||||
input = input.substr(1);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return input;
|
|
||||||
};
|
|
||||||
public drawCoverCard = (
|
public drawCoverCard = (
|
||||||
metadata: IExtractedComicBookCoverFile,
|
metadata: IExtractedComicBookCoverFile,
|
||||||
): JSX.Element => {
|
): JSX.Element => {
|
||||||
@@ -34,7 +28,7 @@ class Card extends React.Component<IProps, IState> {
|
|||||||
<img
|
<img
|
||||||
src={
|
src={
|
||||||
"http://localhost:3000" +
|
"http://localhost:3000" +
|
||||||
this.removeLeadingPeriod(metadata.path) +
|
removeLeadingPeriod(metadata.path) +
|
||||||
"/" +
|
"/" +
|
||||||
metadata.name
|
metadata.name
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,5 +1,40 @@
|
|||||||
import React from "react";
|
import React, { useState, useEffect } from "react";
|
||||||
|
import { useParams } from "react-router-dom";
|
||||||
|
import axios from "axios";
|
||||||
|
import Card from "./Card";
|
||||||
|
import { isEmpty, isUndefined } from "lodash";
|
||||||
type ComicDetailProps = {};
|
type ComicDetailProps = {};
|
||||||
|
|
||||||
export const ComicDetail = ({}: ComicDetailProps) => <section>1,2,3</section>;
|
export const ComicDetail = ({}: ComicDetailProps) => {
|
||||||
|
const [page, setPage] = useState(1);
|
||||||
|
const [comicDetail, setComicDetail] = useState([]);
|
||||||
|
const { comicObjectId } = useParams();
|
||||||
|
|
||||||
|
useEffect(() => {
|
||||||
|
axios
|
||||||
|
.request({
|
||||||
|
url: `http://localhost:3000/api/import/getComicBookById`,
|
||||||
|
|
||||||
|
method: "POST",
|
||||||
|
data: {
|
||||||
|
id: comicObjectId,
|
||||||
|
},
|
||||||
|
})
|
||||||
|
.then((response) => {
|
||||||
|
console.log("fetched", response);
|
||||||
|
setComicDetail(response.data);
|
||||||
|
})
|
||||||
|
.catch((error) => console.log(error));
|
||||||
|
}, [page]);
|
||||||
|
|
||||||
|
return (
|
||||||
|
<section className="container">
|
||||||
|
{!isEmpty(comicDetail) && !isUndefined(comicDetail) && (
|
||||||
|
<>
|
||||||
|
<h1 className="title">{comicDetail.rawFileDetails.name}</h1>
|
||||||
|
<Card comicBookCoversMetadata={comicDetail.rawFileDetails} />
|
||||||
|
</>
|
||||||
|
)}
|
||||||
|
</section>
|
||||||
|
);
|
||||||
|
};
|
||||||
|
|||||||
6
src/client/shared/utils/formatting.utils.ts
Normal file
6
src/client/shared/utils/formatting.utils.ts
Normal file
@@ -0,0 +1,6 @@
|
|||||||
|
export const removeLeadingPeriod = (input: string): string => {
|
||||||
|
if (input.charAt(0) == ".") {
|
||||||
|
input = input.substr(1);
|
||||||
|
}
|
||||||
|
return input;
|
||||||
|
};
|
||||||
Reference in New Issue
Block a user