From c98809657e243bb8d2bb806d27f1d270ac0c4e2f Mon Sep 17 00:00:00 2001 From: anuragnegi000 Date: Wed, 28 Aug 2024 19:57:22 +0530 Subject: [PATCH 1/5] fix: misplaced layout --- public/locales/en/translation.json | 3 + src/App.tsx | 2 +- .../OrganizationCard/OrganizationCard.tsx | 2 +- src/screens/UserPortal/Posts/Posts.tsx | 82 +++++++++---------- .../UserPortal/UserScreen/UserScreen.tsx | 1 + src/state/reducers/userRoutesReducer.ts | 2 +- 6 files changed, 45 insertions(+), 47 deletions(-) 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' }, From efbf0d0774237f6e0a1eadf8de7c7c7733a0d67c Mon Sep 17 00:00:00 2001 From: anuragnegi000 Date: Wed, 28 Aug 2024 20:20:13 +0530 Subject: [PATCH 2/5] added translation for posts --- public/locales/fr/translation.json | 3 +++ public/locales/hi/translation.json | 3 +++ public/locales/sp/translation.json | 3 +++ public/locales/zh/translation.json | 3 +++ src/screens/LoginPage/LoginPage.tsx | 2 +- 5 files changed, 13 insertions(+), 1 deletion(-) diff --git a/public/locales/fr/translation.json b/public/locales/fr/translation.json index ac72be3def..3f47f34799 100644 --- a/public/locales/fr/translation.json +++ b/public/locales/fr/translation.json @@ -128,6 +128,9 @@ "noOrgErrorTitle": "Organisations introuvables", "noOrgErrorDescription": "Veuillez créer une organisation via le tableau de bord" }, + "posts": { + "title": "Messages" + }, "users": { "title": "Rôles Talawa", "joined_organizations": "Organisations rejointes", diff --git a/public/locales/hi/translation.json b/public/locales/hi/translation.json index 0f74a5978e..c52f50f010 100644 --- a/public/locales/hi/translation.json +++ b/public/locales/hi/translation.json @@ -128,6 +128,9 @@ "noOrgErrorTitle": "संगठन नहीं मिले", "noOrgErrorDescription": "कृपया डैशबोर्ड के माध्यम से एक संगठन बनाएं" }, + "posts": { + "title": "पोस्ट्स" + }, "users": { "title": "तलावा भूमिकाएँ", "joined_organizations": "संगठनों से जुड़े", diff --git a/public/locales/sp/translation.json b/public/locales/sp/translation.json index 5d32d79368..330a034af9 100644 --- a/public/locales/sp/translation.json +++ b/public/locales/sp/translation.json @@ -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", diff --git a/public/locales/zh/translation.json b/public/locales/zh/translation.json index 56d93b13da..3f33fa008c 100644 --- a/public/locales/zh/translation.json +++ b/public/locales/zh/translation.json @@ -128,6 +128,9 @@ "noOrgErrorTitle": "未找到组织", "noOrgErrorDescription": "请通过仪表板创建组织" }, + "posts": { + "title": "帖子" + }, "users": { "title": "塔拉瓦角色", "joined_organizations": "加入组织", diff --git a/src/screens/LoginPage/LoginPage.tsx b/src/screens/LoginPage/LoginPage.tsx index d69f4f88d5..756753cfee 100644 --- a/src/screens/LoginPage/LoginPage.tsx +++ b/src/screens/LoginPage/LoginPage.tsx @@ -61,7 +61,7 @@ const loginPage = (): JSX.Element => { const [recaptchaToken, setRecaptchaToken] = useState(null); const [showTab, setShowTab] = useState<'LOGIN' | 'REGISTER'>('LOGIN'); - const [role, setRole] = useState<'admin' | 'user'>('admin'); + const [role, setRole] = useState<'admin' | 'user'>(); const [isInputFocused, setIsInputFocused] = useState(false); const [signformState, setSignFormState] = useState({ signfirstName: '', From 455c7864e9f1c591d9791a39ecabe809f42a1ea8 Mon Sep 17 00:00:00 2001 From: anuragnegi000 Date: Tue, 3 Sep 2024 20:58:38 +0530 Subject: [PATCH 3/5] fixes in test cases --- src/screens/LoginPage/LoginPage.tsx | 2 +- src/state/reducers/userRoutersReducer.test.ts | 8 ++++---- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/src/screens/LoginPage/LoginPage.tsx b/src/screens/LoginPage/LoginPage.tsx index 756753cfee..d69f4f88d5 100644 --- a/src/screens/LoginPage/LoginPage.tsx +++ b/src/screens/LoginPage/LoginPage.tsx @@ -61,7 +61,7 @@ const loginPage = (): JSX.Element => { const [recaptchaToken, setRecaptchaToken] = useState(null); const [showTab, setShowTab] = useState<'LOGIN' | 'REGISTER'>('LOGIN'); - const [role, setRole] = useState<'admin' | 'user'>(); + const [role, setRole] = useState<'admin' | 'user'>('admin'); const [isInputFocused, setIsInputFocused] = useState(false); const [signformState, setSignFormState] = useState({ signfirstName: '', diff --git a/src/state/reducers/userRoutersReducer.test.ts b/src/state/reducers/userRoutersReducer.test.ts index 98c4a78464..8ce105bd75 100644 --- a/src/state/reducers/userRoutersReducer.test.ts +++ b/src/state/reducers/userRoutersReducer.test.ts @@ -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' }, @@ -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' }, @@ -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' }, @@ -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' }, From a042ea9c0532f02ba5e38b9b1b96a7d7bc65039c Mon Sep 17 00:00:00 2001 From: anuragnegi000 Date: Tue, 3 Sep 2024 21:54:52 +0530 Subject: [PATCH 4/5] fixes in test --- public/locales/fr/translation.json | 3 --- public/locales/hi/translation.json | 3 --- public/locales/sp/translation.json | 3 --- public/locales/zh/translation.json | 3 --- 4 files changed, 12 deletions(-) diff --git a/public/locales/fr/translation.json b/public/locales/fr/translation.json index 3f47f34799..ac72be3def 100644 --- a/public/locales/fr/translation.json +++ b/public/locales/fr/translation.json @@ -128,9 +128,6 @@ "noOrgErrorTitle": "Organisations introuvables", "noOrgErrorDescription": "Veuillez créer une organisation via le tableau de bord" }, - "posts": { - "title": "Messages" - }, "users": { "title": "Rôles Talawa", "joined_organizations": "Organisations rejointes", diff --git a/public/locales/hi/translation.json b/public/locales/hi/translation.json index c52f50f010..0f74a5978e 100644 --- a/public/locales/hi/translation.json +++ b/public/locales/hi/translation.json @@ -128,9 +128,6 @@ "noOrgErrorTitle": "संगठन नहीं मिले", "noOrgErrorDescription": "कृपया डैशबोर्ड के माध्यम से एक संगठन बनाएं" }, - "posts": { - "title": "पोस्ट्स" - }, "users": { "title": "तलावा भूमिकाएँ", "joined_organizations": "संगठनों से जुड़े", diff --git a/public/locales/sp/translation.json b/public/locales/sp/translation.json index 330a034af9..5d32d79368 100644 --- a/public/locales/sp/translation.json +++ b/public/locales/sp/translation.json @@ -188,9 +188,6 @@ "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", diff --git a/public/locales/zh/translation.json b/public/locales/zh/translation.json index 3f33fa008c..56d93b13da 100644 --- a/public/locales/zh/translation.json +++ b/public/locales/zh/translation.json @@ -128,9 +128,6 @@ "noOrgErrorTitle": "未找到组织", "noOrgErrorDescription": "请通过仪表板创建组织" }, - "posts": { - "title": "帖子" - }, "users": { "title": "塔拉瓦角色", "joined_organizations": "加入组织", From 7df776e3d45a59d2edf02000cdab77b93fdf0d5a Mon Sep 17 00:00:00 2001 From: anuragnegi000 Date: Tue, 3 Sep 2024 22:10:36 +0530 Subject: [PATCH 5/5] added translation --- public/locales/fr/translation.json | 3 +++ public/locales/hi/translation.json | 3 +++ public/locales/sp/translation.json | 3 +++ public/locales/zh/translation.json | 3 +++ 4 files changed, 12 insertions(+) diff --git a/public/locales/fr/translation.json b/public/locales/fr/translation.json index ac72be3def..5f4d5ee171 100644 --- a/public/locales/fr/translation.json +++ b/public/locales/fr/translation.json @@ -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", diff --git a/public/locales/hi/translation.json b/public/locales/hi/translation.json index 0f74a5978e..61f8f100b0 100644 --- a/public/locales/hi/translation.json +++ b/public/locales/hi/translation.json @@ -128,6 +128,9 @@ "noOrgErrorTitle": "संगठन नहीं मिले", "noOrgErrorDescription": "कृपया डैशबोर्ड के माध्यम से एक संगठन बनाएं" }, + "posts": { + "title": "पोस्ट" + }, "users": { "title": "तलावा भूमिकाएँ", "joined_organizations": "संगठनों से जुड़े", diff --git a/public/locales/sp/translation.json b/public/locales/sp/translation.json index 5d32d79368..330a034af9 100644 --- a/public/locales/sp/translation.json +++ b/public/locales/sp/translation.json @@ -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", diff --git a/public/locales/zh/translation.json b/public/locales/zh/translation.json index 56d93b13da..3f33fa008c 100644 --- a/public/locales/zh/translation.json +++ b/public/locales/zh/translation.json @@ -128,6 +128,9 @@ "noOrgErrorTitle": "未找到组织", "noOrgErrorDescription": "请通过仪表板创建组织" }, + "posts": { + "title": "帖子" + }, "users": { "title": "塔拉瓦角色", "joined_organizations": "加入组织",