Skip to content

Commit

Permalink
fix: misplaced layout
Browse files Browse the repository at this point in the history
  • Loading branch information
anuragnegi000 committed Aug 28, 2024
1 parent 6e51fc0 commit c988096
Show file tree
Hide file tree
Showing 6 changed files with 45 additions and 47 deletions.
3 changes: 3 additions & 0 deletions public/locales/en/translation.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
2 changes: 1 addition & 1 deletion src/App.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -195,7 +195,7 @@ function app(): JSX.Element {
<Route path="/user/chat" element={<Chat />} />
<Route element={<UserScreen />}>
<Route path="/user/organizations" element={<Organizations />} />
<Route path="/user/organization/:orgId" element={<Posts />} />
<Route path="/user/posts/:orgId" element={<Posts />} />
<Route path="/user/people/:orgId" element={<People />} />
<Route path="/user/donate/:orgId" element={<Donate />} />
<Route path="/user/events/:orgId" element={<Events />} />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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')}
Expand Down
82 changes: 38 additions & 44 deletions src/screens/UserPortal/Posts/Posts.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}[];

Expand Down Expand Up @@ -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.
*
Expand Down Expand Up @@ -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,
Expand All @@ -260,6 +254,7 @@ export default function home(): JSX.Element {
likedBy: commentLikes,
text: value.text,
};

postComments.push(comment);
});

Expand Down Expand Up @@ -311,7 +306,6 @@ export default function home(): JSX.Element {
<>
<div className={`d-flex flex-row ${styles.containerHeight}`}>
<div className={`${styles.colorLight} ${styles.mainContainer}`}>
<h1>{t('posts')}</h1>
<div className={`${styles.postContainer}`}>
<div className={`${styles.heading}`}>{t('startPost')}</div>
<div className={styles.postInputContainer}>
Expand Down
1 change: 1 addition & 0 deletions src/screens/UserPortal/UserScreen/UserScreen.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ import { useTranslation } from 'react-i18next';

const map: InterfaceMapType = {
organization: 'home',
posts: 'posts',
people: 'people',
events: 'userEvents',
donate: 'donate',
Expand Down
2 changes: 1 addition & 1 deletion src/state/reducers/userRoutesReducer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ const components: ComponentType[] = [
},
{
name: 'Posts',
comp_id: 'organization',
comp_id: 'posts',
component: 'Posts',
},
{ name: 'People', comp_id: 'people', component: 'People' },
Expand Down

0 comments on commit c988096

Please sign in to comment.