From 0af7ec693ff8929b66bf7a9721166cc8ef993106 Mon Sep 17 00:00:00 2001 From: Arturo Buono Date: Fri, 2 Feb 2024 10:26:52 +0100 Subject: [PATCH 1/3] feat(fix-drupal-e-cr): updates 20240202 --- .../CardCommunity/cardCommunity.tsx | 2 +- .../src/components/Comments/comment.tsx | 18 +++++----- .../components/Comments/commentSection.tsx | 2 +- .../DocumentDetail/sectionDetail.tsx | 20 +++++------ .../src/components/ReportCard/ReportCard.tsx | 2 +- .../Entities/modals/manageComment.tsx | 4 +-- .../Entities/modals/manageReport.tsx | 2 +- .../Entities/modals/manageTopic.tsx | 8 ++--- .../src/pages/common/Community/community.tsx | 3 +- .../common/Community/communityDetails.tsx | 18 +++++----- .../CommunityWidget/communityWidget.tsx | 4 +-- .../Home/components/HeroHome/HeroHome.tsx | 3 +- .../src/redux/features/forum/forumThunk.ts | 33 +++++++++---------- fe-piattaforma/src/routes/index.tsx | 4 +-- fe-piattaforma/src/utils/common.ts | 2 +- fe-piattaforma/src/utils/mockHelper.ts | 4 +-- 16 files changed, 62 insertions(+), 67 deletions(-) diff --git a/fe-piattaforma/src/components/CardCommunity/cardCommunity.tsx b/fe-piattaforma/src/components/CardCommunity/cardCommunity.tsx index a185d29fc..dd1a972c8 100644 --- a/fe-piattaforma/src/components/CardCommunity/cardCommunity.tsx +++ b/fe-piattaforma/src/components/CardCommunity/cardCommunity.tsx @@ -23,7 +23,7 @@ const CardCommunity: React.FC = (props) => { const navigate = useNavigate(); const navigateTo = () => { - navigate(`/community/${id}`); + navigate(`/forum/${id}`); }; return ( diff --git a/fe-piattaforma/src/components/Comments/comment.tsx b/fe-piattaforma/src/components/Comments/comment.tsx index 79c42b20f..3677c4804 100644 --- a/fe-piattaforma/src/components/Comments/comment.tsx +++ b/fe-piattaforma/src/components/Comments/comment.tsx @@ -44,7 +44,7 @@ export interface CommentI { isAnswer?: boolean; thread?: boolean; noBorder?: boolean; - section: 'board' | 'community' | 'documents'; + section: 'board' | 'forum' | 'documents'; onDeleteComment?: () => void; onEditComment?: () => void; reported: 0 | 1; @@ -134,7 +134,7 @@ const Comment: React.FC = (props) => { hasUserPermission([ section === 'board' ? 'del.news' - : section === 'community' + : section === 'forum' ? 'del.topic' : section === 'documents' ? 'del.doc' @@ -148,7 +148,7 @@ const Comment: React.FC = (props) => { hasUserPermission([ section === 'board' ? 'upd.news' - : section === 'community' + : section === 'forum' ? 'upd.topic' : section === 'documents' ? 'upd.doc' @@ -162,7 +162,7 @@ const Comment: React.FC = (props) => { hasUserPermission([ section === 'board' ? 'rprt.news' - : section === 'community' + : section === 'forum' ? 'rprt.topic' : section === 'documents' ? 'rprt.doc' @@ -327,20 +327,20 @@ const Comment: React.FC = (props) => { replies={ // eslint-disable-next-line @typescript-eslint/ban-ts-comment // @ts-ignore - section === 'community' && replies !== '[]' + section === 'forum' && replies !== '[]' ? replies?.length : undefined } - views={section === 'community' ? views : undefined} + views={section === 'forum' ? views : undefined} onShowReplies={ // eslint-disable-next-line @typescript-eslint/ban-ts-comment // @ts-ignore - section === 'community' && replies !== '[]' && replies?.length + section === 'forum' && replies !== '[]' && replies?.length ? () => setShowReplies((prev) => !prev) : undefined } isReply={isReply} - showReplies={section === 'community' ? showReplies : undefined} + showReplies={section === 'forum' ? showReplies : undefined} likes={likes} user_like={user_like} onLike={async () => { @@ -355,7 +355,7 @@ const Comment: React.FC = (props) => { } }} onComment={ - section === 'community' + section === 'forum' ? () => dispatch( openModal({ diff --git a/fe-piattaforma/src/components/Comments/commentSection.tsx b/fe-piattaforma/src/components/Comments/commentSection.tsx index 814b21739..2ec288e15 100644 --- a/fe-piattaforma/src/components/Comments/commentSection.tsx +++ b/fe-piattaforma/src/components/Comments/commentSection.tsx @@ -8,7 +8,7 @@ import SectionTitle from '../SectionTitle/sectionTitle'; import Comment from './comment'; interface commentSectionI { - section: 'board' | 'community' | 'documents'; + section: 'board' | 'forum' | 'documents'; } const CommentSection: React.FC = ({ section }) => { diff --git a/fe-piattaforma/src/components/DocumentDetail/sectionDetail.tsx b/fe-piattaforma/src/components/DocumentDetail/sectionDetail.tsx index 25b9d367e..51610ca3b 100644 --- a/fe-piattaforma/src/components/DocumentDetail/sectionDetail.tsx +++ b/fe-piattaforma/src/components/DocumentDetail/sectionDetail.tsx @@ -48,7 +48,7 @@ export interface CardDocumentDetailI { user_like?: boolean; likes?: number; views?: number; - section?: 'community' | 'documents'; + section?: 'forum' | 'documents'; isDocument?: boolean | undefined; onDeleteClick?: () => void; onEditClick?: () => void; @@ -138,7 +138,7 @@ const SectionDetail: React.FC = (props) => { hasUserPermission([ section === 'documents' || isDocument ? 'del.doc' - : section === 'community' + : section === 'forum' ? 'del.topic' : 'hidden', ]) || @@ -146,7 +146,7 @@ const SectionDetail: React.FC = (props) => { hasUserPermission([ section === 'documents' || isDocument ? 'new.doc' - : section === 'community' + : section === 'forum' ? 'new.topic' : 'hidden', ])) @@ -157,7 +157,7 @@ const SectionDetail: React.FC = (props) => { hasUserPermission([ section === 'documents' || isDocument ? 'upd.doc' - : section === 'community' + : section === 'forum' ? 'upd.topic' : 'hidden', ]) || @@ -165,7 +165,7 @@ const SectionDetail: React.FC = (props) => { hasUserPermission([ section === 'documents' || isDocument ? 'new.doc' - : section === 'community' + : section === 'forum' ? 'new.topic' : 'hidden', ])) @@ -176,7 +176,7 @@ const SectionDetail: React.FC = (props) => { hasUserPermission([ section === 'documents' || isDocument ? 'rprt.doc' - : section === 'community' + : section === 'forum' ? 'rprt.topic' : 'hidden', ]) @@ -392,7 +392,7 @@ const SectionDetail: React.FC = (props) => { ) : null} = (props) => { downloads={downloads} user_like={user_like} onLike={ - section === 'community' + section === 'forum' ? async () => { if (id) { if (user_like as boolean) { @@ -422,7 +422,7 @@ const SectionDetail: React.FC = (props) => { }) ); } - userId && dispatch(GetItemDetail(id, userId, 'community')); + userId && dispatch(GetItemDetail(id, userId, 'forum')); } } : undefined @@ -434,7 +434,7 @@ const SectionDetail: React.FC = (props) => { payload: { title: 'Aggiungi commento', action: 'comment', - entity: section === 'community' ? 'community' : 'document', + entity: section === 'forum' ? 'forum' : 'document', category: category_label || category, textLabel: 'Digita qui sotto il testo', }, diff --git a/fe-piattaforma/src/components/ReportCard/ReportCard.tsx b/fe-piattaforma/src/components/ReportCard/ReportCard.tsx index 71506169f..1e17da5fb 100644 --- a/fe-piattaforma/src/components/ReportCard/ReportCard.tsx +++ b/fe-piattaforma/src/components/ReportCard/ReportCard.tsx @@ -265,7 +265,7 @@ const ReportCard: React.FC = ({ navigate(`/bacheca/${item_id}`); break; case 'community_item': - navigate(`/community/${item_id}`); + navigate(`/forum/${item_id}`); break; case 'document_item': navigate(`/documenti/${item_id}`); diff --git a/fe-piattaforma/src/pages/administrator/AdministrativeArea/Entities/modals/manageComment.tsx b/fe-piattaforma/src/pages/administrator/AdministrativeArea/Entities/modals/manageComment.tsx index 66342c950..3e89bafa1 100644 --- a/fe-piattaforma/src/pages/administrator/AdministrativeArea/Entities/modals/manageComment.tsx +++ b/fe-piattaforma/src/pages/administrator/AdministrativeArea/Entities/modals/manageComment.tsx @@ -60,7 +60,7 @@ const ManageComment: React.FC = ({ // @ts-ignore if (res) { userId && - dispatch(GetItemDetail(id, userId, payload.entity || 'community')); + dispatch(GetItemDetail(id, userId, payload.entity || 'forum')); dispatch( ActionTracker({ target: 'tnd', @@ -68,7 +68,7 @@ const ManageComment: React.FC = ({ event_type: payload.entity === 'board' ? 'NEWS' - : payload.entity === 'community' + : payload.entity === 'forum' ? 'TOPIC' : 'DOCUMENTI', category: payload.category_label || payload.category, diff --git a/fe-piattaforma/src/pages/administrator/AdministrativeArea/Entities/modals/manageReport.tsx b/fe-piattaforma/src/pages/administrator/AdministrativeArea/Entities/modals/manageReport.tsx index 35f21f62e..0e081a1c1 100644 --- a/fe-piattaforma/src/pages/administrator/AdministrativeArea/Entities/modals/manageReport.tsx +++ b/fe-piattaforma/src/pages/administrator/AdministrativeArea/Entities/modals/manageReport.tsx @@ -43,7 +43,7 @@ const ManageReport: React.FC = ({ if (newReport.trim() !== '' && payload) { switch (payload.entity) { case 'board': - case 'community': + case 'forum': case 'document': if (id && userId) { await dispatch(CreateItemReport(id, newReport)); diff --git a/fe-piattaforma/src/pages/administrator/AdministrativeArea/Entities/modals/manageTopic.tsx b/fe-piattaforma/src/pages/administrator/AdministrativeArea/Entities/modals/manageTopic.tsx index 30a0f6b60..f9e0af2ab 100644 --- a/fe-piattaforma/src/pages/administrator/AdministrativeArea/Entities/modals/manageTopic.tsx +++ b/fe-piattaforma/src/pages/administrator/AdministrativeArea/Entities/modals/manageTopic.tsx @@ -95,13 +95,13 @@ const ManageTopic: React.FC = ({ // @ts-ignore !newFormValues?.attachment?.data, }, - 'community' + 'forum' ) ); // eslint-disable-next-line @typescript-eslint/ban-ts-comment // @ts-ignore if (res) { - userId && dispatch(GetItemDetail(id, userId, 'community')); + userId && dispatch(GetItemDetail(id, userId, 'forum')); setNewFormValues({}); setStep('confirm'); } @@ -120,7 +120,7 @@ const ManageTopic: React.FC = ({ ? 'Ente gestore di programma' : '-', }, - 'community' + 'forum' ) ); // eslint-disable-next-line @typescript-eslint/ban-ts-comment @@ -170,7 +170,7 @@ const ManageTopic: React.FC = ({ onClick: () => { resetModal(); dispatch(closeModal()); - newNodeId && navigate(`/community/${newNodeId}`); + newNodeId && navigate(`/forum/${newNodeId}`); }, }, secondaryCTA: null, diff --git a/fe-piattaforma/src/pages/common/Community/community.tsx b/fe-piattaforma/src/pages/common/Community/community.tsx index 75be1cde4..ab71999cb 100644 --- a/fe-piattaforma/src/pages/common/Community/community.tsx +++ b/fe-piattaforma/src/pages/common/Community/community.tsx @@ -155,8 +155,7 @@ const Community = () => {
{ const getItemDetails = async () => { if (id && userId) { - const res = await dispatch(GetItemDetail(id, userId, 'community')); + const res = await dispatch(GetItemDetail(id, userId, 'forum')); // eslint-disable-next-line @typescript-eslint/ban-ts-comment // @ts-ignore if (res) { @@ -62,7 +62,7 @@ const CommunityDetails = () => { }) ); } else { - navigate('/community', { replace: true }); + navigate('/forum', { replace: true }); } } }; @@ -86,7 +86,7 @@ const CommunityDetails = () => { const backButton = (