diff --git a/public/locales/en/translation.json b/public/locales/en/translation.json index 3b7b875821..51df989cff 100644 --- a/public/locales/en/translation.json +++ b/public/locales/en/translation.json @@ -128,6 +128,9 @@ "noOrgErrorTitle": "Organizations Not Found", "noOrgErrorDescription": "Please create an organization through dashboard" }, + "posts": { + "title": "Posts" + }, "users": { "title": "Talawa Roles", "joined_organizations": "Joined Organizations", diff --git a/src/App.tsx b/src/App.tsx index f73055f4c8..b435e0c06d 100644 --- a/src/App.tsx +++ b/src/App.tsx @@ -195,7 +195,7 @@ function app(): JSX.Element { } /> }> } /> - } /> + } /> } /> } /> } /> diff --git a/src/components/UserPortal/OrganizationCard/OrganizationCard.tsx b/src/components/UserPortal/OrganizationCard/OrganizationCard.tsx index b88e17ae95..f90d1a81d4 100644 --- a/src/components/UserPortal/OrganizationCard/OrganizationCard.tsx +++ b/src/components/UserPortal/OrganizationCard/OrganizationCard.tsx @@ -193,7 +193,7 @@ function organizationCard(props: InterfaceOrganizationCardProps): JSX.Element { data-testid="manageBtn" className={styles.joinedBtn} onClick={() => { - navigate(`/user/organization/${props.id}`); + navigate(`/user/posts/${props.id}`); }} > {t('visit')} diff --git a/src/screens/UserPortal/Posts/Posts.tsx b/src/screens/UserPortal/Posts/Posts.tsx index 256bb5f52f..7ba5acf651 100644 --- a/src/screens/UserPortal/Posts/Posts.tsx +++ b/src/screens/UserPortal/Posts/Posts.tsx @@ -52,38 +52,17 @@ type Ad = { endDate: string; // Assuming it's a string in the format 'yyyy-MM-dd' startDate: string; // Assuming it's a string in the format 'yyyy-MM-dd' }; -interface InterfaceAdContent { - _id: string; - name: string; - type: string; - organization: { - _id: string; - }; - mediaUrl: string; - endDate: string; - startDate: string; - - comments: InterfacePostComments; - likes: InterfacePostLikes; -} - -type AdvertisementsConnection = { - edges: { - node: InterfaceAdContent; - }[]; -}; type InterfacePostComments = { + _id: string; creator: { - _id: string; firstName: string; lastName: string; + _id: string; email: string; }; likeCount: number; - likedBy: { - id: string; - }[]; + likedBy: { _id: string }[]; text: string; }[]; @@ -119,6 +98,23 @@ type InterfacePostNode = { likes: InterfacePostLikes; }; +type CommentLike = { + id: string; +}; + +type Comment = { + id: string; + creator: { + firstName: string; + lastName: string; + id: string; + email: string; + }; + likeCount: number; + likedBy: CommentLike[]; + text: string; +}; + /** * `home` component displays the main feed for a user, including posts, promoted content, and options to create a new post. * @@ -226,29 +222,27 @@ export default function home(): JSX.Element { comments, } = node; - const allLikes: any = []; + const allLikes: InterfacePostLikes = []; - likedBy.forEach((value: any) => { - const singleLike = { - firstName: value.firstName, - lastName: value.lastName, - id: value._id, - }; - allLikes.push(singleLike); - }); - - const postComments: any = []; - - comments.forEach((value: any) => { - const commentLikes: any = []; - value.likedBy.forEach((commentLike: any) => { + likedBy.forEach( + (value: { _id: string; firstName: string; lastName: string }) => { const singleLike = { - id: commentLike._id, + firstName: value.firstName, + lastName: value.lastName, + id: value._id, }; - commentLikes.push(singleLike); - }); + allLikes.push(singleLike); + }, + ); + + const postComments: Comment[] = []; - const comment = { + comments.forEach((value) => { + const commentLikes: CommentLike[] = value.likedBy.map((commentLike) => ({ + id: commentLike._id, + })); + + const comment: Comment = { id: value._id, creator: { firstName: value.creator.firstName, @@ -260,6 +254,7 @@ export default function home(): JSX.Element { likedBy: commentLikes, text: value.text, }; + postComments.push(comment); }); @@ -311,7 +306,6 @@ export default function home(): JSX.Element { <>
-

{t('posts')}

{t('startPost')}
diff --git a/src/screens/UserPortal/UserScreen/UserScreen.tsx b/src/screens/UserPortal/UserScreen/UserScreen.tsx index 3bf84022cf..df35cc7b91 100644 --- a/src/screens/UserPortal/UserScreen/UserScreen.tsx +++ b/src/screens/UserPortal/UserScreen/UserScreen.tsx @@ -13,6 +13,7 @@ import { useTranslation } from 'react-i18next'; const map: InterfaceMapType = { organization: 'home', + posts: 'posts', people: 'people', events: 'userEvents', donate: 'donate', diff --git a/src/state/reducers/userRoutesReducer.ts b/src/state/reducers/userRoutesReducer.ts index 44bc91fabb..28962674c8 100644 --- a/src/state/reducers/userRoutesReducer.ts +++ b/src/state/reducers/userRoutesReducer.ts @@ -50,7 +50,7 @@ const components: ComponentType[] = [ }, { name: 'Posts', - comp_id: 'organization', + comp_id: 'posts', component: 'Posts', }, { name: 'People', comp_id: 'people', component: 'People' },