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

fix: misplaced layout #2230

Closed
Closed
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
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
3 changes: 3 additions & 0 deletions public/locales/fr/translation.json
Original file line number Diff line number Diff line change
Expand Up @@ -128,6 +128,9 @@
"noOrgErrorTitle": "Organisations introuvables",
"noOrgErrorDescription": "Veuillez créer une organisation via le tableau de bord"
},
"posts": {
"title": "Articles"
},
"users": {
"title": "Rôles Talawa",
"joined_organizations": "Organisations rejointes",
Expand Down
3 changes: 3 additions & 0 deletions public/locales/hi/translation.json
Original file line number Diff line number Diff line change
Expand Up @@ -128,6 +128,9 @@
"noOrgErrorTitle": "संगठन नहीं मिले",
"noOrgErrorDescription": "कृपया डैशबोर्ड के माध्यम से एक संगठन बनाएं"
},
"posts": {
"title": "पोस्ट"
},
"users": {
"title": "तलावा भूमिकाएँ",
"joined_organizations": "संगठनों से जुड़े",
Expand Down
3 changes: 3 additions & 0 deletions public/locales/sp/translation.json
Original file line number Diff line number Diff line change
Expand Up @@ -188,6 +188,9 @@
"noOrgErrorTitle": "Organizaciones no encontradas",
"noOrgErrorDescription": "Por favor, crea una organización a través del panel de control"
},
"posts": {
"title": "Publicaciones"
},
"users": {
"title": "Roles Talawa",
"searchByName": "Buscar por nombre",
Expand Down
3 changes: 3 additions & 0 deletions public/locales/zh/translation.json
Original file line number Diff line number Diff line change
Expand Up @@ -128,6 +128,9 @@
"noOrgErrorTitle": "未找到组织",
"noOrgErrorDescription": "请通过仪表板创建组织"
},
"posts": {
"title": "帖子"
},
"users": {
"title": "塔拉瓦角色",
"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
8 changes: 4 additions & 4 deletions src/state/reducers/userRoutersReducer.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ describe('Testing Routes reducer', () => {
).toEqual({
targets: [
{ name: 'My Organizations', url: 'user/organizations' },
{ name: 'Posts', url: 'user/organization/undefined' },
{ name: 'Posts', url: 'user/posts/undefined' },
{ name: 'People', url: 'user/people/undefined' },
{ name: 'Events', url: 'user/events/undefined' },
{ name: 'Donate', url: 'user/donate/undefined' },
Expand All @@ -26,7 +26,7 @@ describe('Testing Routes reducer', () => {
},
{
name: 'Posts',
comp_id: 'organization',
comp_id: 'posts',
component: 'Posts',
},
{ name: 'People', comp_id: 'people', component: 'People' },
Expand All @@ -51,7 +51,7 @@ describe('Testing Routes reducer', () => {
).toEqual({
targets: [
{ name: 'My Organizations', url: 'user/organizations' },
{ name: 'Posts', url: 'user/organization/orgId' },
{ name: 'Posts', url: 'user/posts/orgId' },
{ name: 'People', url: 'user/people/orgId' },
{ name: 'Events', url: 'user/events/orgId' },
{ name: 'Donate', url: 'user/donate/orgId' },
Expand All @@ -66,7 +66,7 @@ describe('Testing Routes reducer', () => {
},
{
name: 'Posts',
comp_id: 'organization',
comp_id: 'posts',
component: 'Posts',
},
{ name: 'People', comp_id: 'people', component: 'People' },
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
Loading