Skip to content

Commit

Permalink
Added issue article editing
Browse files Browse the repository at this point in the history
  • Loading branch information
umerfaruk committed Aug 11, 2024
1 parent 272945c commit e3dddd5
Show file tree
Hide file tree
Showing 5 changed files with 48 additions and 17 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ import IssueArticleAssignButton from "./issueArticleAssignButton";
import ArticleStatusButton from "./issueArticleStatusButton";

// ------------------------------------------------------
const AuthorsList = ({ libraryId, authors, t }) => {
const AuthorsList = ({ libraryId, authors, t, showName = true }) => {
if (!authors) return null;
return (
<Avatar.Group maxCount="2" size="large">
Expand All @@ -24,7 +24,7 @@ const AuthorsList = ({ libraryId, authors, t }) => {
key={author.id}
libraryId={libraryId}
author={author}
showName={true}
showName={showName}
t={t} />
))}
</Avatar.Group>
Expand Down Expand Up @@ -122,6 +122,7 @@ const IssueArticleListItem = ({
description={<AuthorsList
libraryId={libraryId}
authors={article?.authors}
showName={false}
t={t}
/>}
avatar={
Expand Down
49 changes: 36 additions & 13 deletions src/domain/bookService.js
Original file line number Diff line number Diff line change
@@ -1,21 +1,44 @@
import { axiosPrivate } from "/src/util/axios.helpers";

const addChapterContent = ({ chapter, language, payload }) => {
return axiosPrivate.post(chapter.links.add_content, payload, {
headers: {
"Content-Type": "application/json",
"Content-Language": language || "en-US",
},
});
return axiosPrivate.post(chapter.links.add_content, payload, {
headers: {
"Content-Type": "application/json",
"Content-Language": language || "en-US",
},
});
};

const updateChapterContent = ({ chapterContent, language, payload }) => {
return axiosPrivate.put(chapterContent.links.update, payload, {
headers: {
"Content-Type": "application/json",
"Content-Language": language || "en-US",
},
});
return axiosPrivate.put(chapterContent.links.update, payload, {
headers: {
"Content-Type": "application/json",
"Content-Language": language || "en-US",
},
});
};

export { addChapterContent, updateChapterContent };
const addIssueArticleContent = ({ article, language, payload }) => {
return axiosPrivate.post(article.links.add_content, payload, {
headers: {
"Content-Type": "application/json",
"Content-Language": language || "en-US",
},
});
};

const updateIssueArticleContent = ({ articleContent, language, payload }) => {
return axiosPrivate.put(articleContent.links.update, payload, {
headers: {
"Content-Type": "application/json",
"Content-Language": language || "en-US",
},
});
};

export {
addChapterContent,
updateChapterContent,
addIssueArticleContent,
updateIssueArticleContent,
};
2 changes: 2 additions & 0 deletions src/pages/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ import IssueEditPage from "./periodicals/issues/edit";
import IssuePage from "./periodicals/issues/index";
import IssuePageEditPage from "./periodicals/issues/pages/edit";
import IssueProcessPage from "./periodicals/issues/process";
import EditIssueArticle from "./periodicals/issues/article/edit";

export {
Home,
Expand Down Expand Up @@ -80,4 +81,5 @@ export {
IssuePage,
IssuePageEditPage,
IssueProcessPage,
EditIssueArticle,
};
5 changes: 5 additions & 0 deletions src/router/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ import {
IssuePage,
IssuePageEditPage,
IssueProcessPage,
EditIssueArticle,
} from "/src/pages";

import LayoutWithHeader from "/src/components/layout/layoutWithHeader";
Expand Down Expand Up @@ -212,6 +213,10 @@ const Router = () => {
path="/libraries/:libraryId/periodicals/:periodicalId/volumes/:volumeNumber/issues/:issueNumber/edit"
element={<IssueEditPage />}
/>
<Route
path="/libraries/:libraryId/periodicals/:periodicalId/volumes/:volumeNumber/issues/:issueNumber/articles/:articleNumber/edit"
element={<EditIssueArticle />}
/>
<Route
path="/libraries/:libraryId/periodicals/:periodicalId/volumes/:volumeNumber/issues/:issueNumber"
element={<IssuePage />}
Expand Down
4 changes: 2 additions & 2 deletions src/store/slices/issuesSlice.js
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ export const issuesApi = createApi({
issueNumber,
articleNumber,
}) => ({
url: `/libraries/${libraryId}/periodicals/${periodicalId}/volumes/${volumeNumber}/issues/${issueNumber}/article/${articleNumber}`,
url: `/libraries/${libraryId}/periodicals/${periodicalId}/volumes/${volumeNumber}/issues/${issueNumber}/articles/${articleNumber}`,
method: "get",
}),
transformResponse: (response) => parseResponse(response),
Expand All @@ -110,7 +110,7 @@ export const issuesApi = createApi({
issueNumber,
articleNumber,
}) => ({
url: `/libraries/${libraryId}/periodicals/${periodicalId}/volumes/${volumeNumber}/issues/${issueNumber}/article/${articleNumber}/contents`,
url: `/libraries/${libraryId}/periodicals/${periodicalId}/volumes/${volumeNumber}/issues/${issueNumber}/articles/${articleNumber}/contents`,
method: "get",
}),
transformResponse: (response) => parseResponse(response),
Expand Down

0 comments on commit e3dddd5

Please sign in to comment.