Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Section archive added #44

Open
wants to merge 1 commit into
base: dev
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
47 changes: 47 additions & 0 deletions src/NDC/Forum.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ const tabs = {
SHOW_ARTICLE: { id: 1 },
ARTICLE_WORKSHOP: { id: 2 },
SHOW_ARTICLES_LIST_BY_AUTHORS: { id: 3 },
SHOW_ARCHIVE_LIST: { id: 4 },
};

function getInitialTabId() {
Expand All @@ -65,6 +66,7 @@ function getInitialTabId() {
const [categories] = useState(getCategories())
const [category, setCategory] = useState(getCategories()[0].value)
const [articles, setArticles] = useState([]);
const [archives, setArchives] = useState([]);
const [article, setArticle] = useState({});
const [loggedUserHaveSbt, setLoggedUserHaveSbt] = useState(false)
const [showShareModal, setShowShareModal] = useState(false);
Expand All @@ -91,6 +93,20 @@ function loadArticles(category) {
})
}

function loadArchivedArticles(category) {
const userFilters = { category: category };
setLoadingArticles(true);

getArticles(getConfig(isTest, lookForArchives), userFilters).then((newArticles) => {
setArchives(newArticles)
setLoadingArticles(false)
})
}

if(archives.length === 0 && displayedTabId === tabs.SHOW_ARCHIVE_LIST.id) {
loadArchivedArticles(category)
}

useEffect(() => {
setLoadingArticles(true)
loadArticles(category);
Expand Down Expand Up @@ -125,6 +141,7 @@ if (filterBy.parameterName == "author") {
const navigationPills = [
{ id: tabs.SHOW_ARTICLES_LIST.id, title: "Articles" },
{ id: tabs.SHOW_ARTICLES_LIST_BY_AUTHORS.id, title: "Authors" },
{ id: tabs.SHOW_ARCHIVE_LIST.id, title: "Archive" },
// { id: tabs.SHOW_KANBAN_VIEW.id, title: "Kanban" },
];

Expand Down Expand Up @@ -557,6 +574,9 @@ function handleOnCommitArticle(articleId) {
})
}, 5000);
}

console.log("archives: ", archives)

//===============================================END FUNCTIONS======================================================
return (
<AppContainer>
Expand Down Expand Up @@ -619,6 +639,33 @@ return (
}}
/>
)}
{displayedTabId == tabs.SHOW_ARCHIVE_LIST.id && (
loadingArticles ?
<Widget
src={widgets.views.standardWidgets.newStyledComponents.Feedback.Spinner}
/>
:
<Widget
src={widgets.views.editableWidgets.showArticlesList}
props={{
isTest,
articles: archives,
widgets,
handleOpenArticle,
handleFilterArticles,
authorForWidget,
editArticleData,
handleEditArticle,
loggedUserHaveSbt,
handleShareButton,
handleShareSearch,
filterBy,
handleOnCommitArticle,
sharedSearchInputValue: sharedData.sharedSearch,
category
}}
/>
)}
{article.value.articleData.title &&
displayedTabId == tabs.SHOW_ARTICLE.id && (
<Widget
Expand Down
10 changes: 5 additions & 5 deletions src/config/CommunityVoice.jsx
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
function getConfig(isTest,networkId) {
function getConfig(isTest,networkId, lookForArchives) {
const componentsOwner = "communityvoice.ndctools.near";
const authorForWidget = "communityvoice.ndctools.near";
const configWidget = "home";
return {
isTest,
networkId,
baseActions: {
article: "communityVoiceArticle",
upVote: "communityVoiceUpVote",
reaction: "communityVoiceReaction",
comment: "communityVoiceComment",
article: lookForArchives ? "archive/communityVoiceArticle" : "communityVoiceArticle",
upVote: lookForArchives ? "archive/communityVoiceUpVote" : "communityVoiceUpVote",
reaction: lookForArchives ? "archive/communityVoiceReaction" : "communityVoiceReaction",
comment: lookForArchives ? "archive/communityVoiceComment" : "communityVoiceComment",
},
componentsOwner,
authorForWidget,
Expand Down