From 0429d59bd5eaa0829556ea4a2e032fbd068b42f9 Mon Sep 17 00:00:00 2001
From: Kanhaiya yadav <93936630+kanhaiya04@users.noreply.github.com>
Date: Sat, 11 Nov 2023 06:19:35 +0530
Subject: [PATCH 1/3] update and delete buttons of event modal are now working
(#1051)
* update and delete buttons of event modal are now working
* fixed the naming conventions and style of the modal
---
.../EventListCard/EventListCard.module.css | 6 +-
.../EventListCard/EventListCard.test.tsx | 41 +-
.../EventListCard/EventListCard.tsx | 431 +++++++++---------
3 files changed, 254 insertions(+), 224 deletions(-)
diff --git a/src/components/EventListCard/EventListCard.module.css b/src/components/EventListCard/EventListCard.module.css
index 5b128d075d..c2a8e9eb0e 100644
--- a/src/components/EventListCard/EventListCard.module.css
+++ b/src/components/EventListCard/EventListCard.module.css
@@ -26,9 +26,7 @@
justify-content: flex-end;
}
.icon {
- transform: scale(1);
- cursor: pointer;
- color: #31bb6b;
+ margin: 1px;
}
.cards {
@@ -86,6 +84,8 @@
}
.dispflex {
display: flex;
+ margin-bottom: 5px;
+ margin-right: 5px;
}
.dispflex > input {
width: 20%;
diff --git a/src/components/EventListCard/EventListCard.test.tsx b/src/components/EventListCard/EventListCard.test.tsx
index ee48e2f871..17edaf5050 100644
--- a/src/components/EventListCard/EventListCard.test.tsx
+++ b/src/components/EventListCard/EventListCard.test.tsx
@@ -149,6 +149,30 @@ describe('Testing Event List Card', () => {
expect(screen.queryByText(props.eventName)).not.toBeInTheDocument();
});
+ test('Testing for update modal', async () => {
+ render(
+
+
+
+
+
+
+
+
+
+ );
+
+ await wait();
+
+ userEvent.click(screen.getByTestId('card'));
+ userEvent.click(screen.getByTestId('editEventModalBtn'));
+
+ userEvent.click(screen.getByTestId('EventUpdateModalCloseBtn'));
+ userEvent.click(screen.getByTestId('createEventModalCloseBtn'));
+
+ await wait();
+ });
+
test('Testing event update functionality', async () => {
render(
@@ -159,7 +183,8 @@ describe('Testing Event List Card', () => {
);
await wait();
-
+ userEvent.click(screen.getByTestId('card'));
+ userEvent.click(screen.getByTestId('editEventModalBtn'));
userEvent.type(screen.getByTestId('updateTitle'), props.eventName);
userEvent.type(
screen.getByTestId('updateDescription'),
@@ -199,7 +224,8 @@ describe('Testing Event List Card', () => {
);
await wait();
-
+ userEvent.click(screen.getByTestId('card'));
+ userEvent.click(screen.getByTestId('editEventModalBtn'));
userEvent.type(screen.getByTestId('updateTitle'), props.eventName);
userEvent.type(
screen.getByTestId('updateDescription'),
@@ -232,6 +258,11 @@ describe('Testing Event List Card', () => {
);
+ userEvent.click(screen.getByTestId('card'));
+ userEvent.click(screen.getByTestId('deleteEventModalBtn'));
+
+ userEvent.click(screen.getByTestId('EventDeleteModalCloseBtn'));
+ userEvent.click(screen.getByTestId('createEventModalCloseBtn'));
});
it('should call the delete event mutation when the "Yes" button is clicked', async () => {
@@ -240,7 +271,8 @@ describe('Testing Event List Card', () => {
);
-
+ userEvent.click(screen.getByTestId('card'));
+ userEvent.click(screen.getByTestId('deleteEventModalBtn'));
const deleteBtn = screen.getByTestId('deleteEventBtn');
fireEvent.click(deleteBtn);
});
@@ -263,7 +295,8 @@ describe('Testing Event List Card', () => {
);
-
+ userEvent.click(screen.getByTestId('card'));
+ userEvent.click(screen.getByTestId('deleteEventModalBtn'));
const deleteBtn = screen.getByTestId('deleteEventBtn');
fireEvent.click(deleteBtn);
});
diff --git a/src/components/EventListCard/EventListCard.tsx b/src/components/EventListCard/EventListCard.tsx
index 7f817890de..f41c0e9c91 100644
--- a/src/components/EventListCard/EventListCard.tsx
+++ b/src/components/EventListCard/EventListCard.tsx
@@ -38,6 +38,8 @@ function eventListCard(props: InterfaceEventListCardProps): JSX.Element {
const [recurringchecked, setRecurringChecked] = useState(false);
const [publicchecked, setPublicChecked] = useState(true);
const [registrablechecked, setRegistrableChecked] = React.useState(false);
+ const [eventDeleteModalIsOpen, setEventDeleteModalIsOpen] = useState(false);
+ const [eventUpdateModalIsOpen, setEventUpdateModalIsOpen] = useState(false);
const history = useHistory();
const [formState, setFormState] = useState({
title: '',
@@ -53,6 +55,14 @@ function eventListCard(props: InterfaceEventListCardProps): JSX.Element {
setEventModalIsOpen(false);
};
+ const toggleDeleteModal = (): void => {
+ setEventDeleteModalIsOpen(!eventDeleteModalIsOpen);
+ };
+
+ const toggleUpdateModel = (): void => {
+ setEventUpdateModalIsOpen(!eventUpdateModalIsOpen);
+ };
+
useEffect(() => {
setFormState({
title: props.eventName,
@@ -196,247 +206,234 @@ function eventListCard(props: InterfaceEventListCardProps): JSX.Element {
-
-
-
-
- {t('editEvent')}
-
-
-
-
+
+
+
+
+
+
+
>
);
}
From 5e4730ac45c493ec16e50a1581763547c372157d Mon Sep 17 00:00:00 2001
From: Jamari McFarlane <71823011+JamarTG@users.noreply.github.com>
Date: Fri, 10 Nov 2023 19:50:43 -0500
Subject: [PATCH 2/3] Dynamic dashboard Enhancements (#979)
* Dynamic Organization Dashboard
* Dynamic Organization Dashboard
* refined organization dashboard
* Update src/utils/handleLatestFeed.ts
Co-authored-by: Noble Mittal <62551163+beingnoble03@users.noreply.github.com>
* fixed inconsistent casing
* fixed org dashboard test
* fixed org dashboard test
* revert previous commit
* final changes
* final changes
---------
Co-authored-by: Noble Mittal <62551163+beingnoble03@users.noreply.github.com>
---
src/GraphQl/Queries/Queries.ts | 4 +-
src/assets/svgs/date.svg | 1 +
src/assets/svgs/location.svg | 1 +
src/assets/svgs/user.svg | 1 +
.../OrganizationDashCards/CardItem.module.css | 13 ++
.../OrganizationDashCards/CardItem.test.tsx | 9 +-
.../OrganizationDashCards/CardItem.tsx | 56 ++++++-
src/screens/OrgPost/OrgPost.test.tsx | 6 +-
.../OrganizationDashboard.test.tsx | 11 +-
.../OrganizationDashboard.tsx | 90 +++++-----
.../OrganizationDashboardMocks.ts | 154 ++++++++++++------
src/screens/UserPortal/Home/Home.test.tsx | 5 +-
src/utils/interfaces.ts | 1 +
13 files changed, 232 insertions(+), 120 deletions(-)
create mode 100644 src/assets/svgs/date.svg
create mode 100644 src/assets/svgs/location.svg
create mode 100644 src/assets/svgs/user.svg
diff --git a/src/GraphQl/Queries/Queries.ts b/src/GraphQl/Queries/Queries.ts
index fccad7d88e..14b2cf4249 100644
--- a/src/GraphQl/Queries/Queries.ts
+++ b/src/GraphQl/Queries/Queries.ts
@@ -567,6 +567,7 @@ export const ORGANIZATION_POST_LIST = gql`
lastName
email
}
+ createdAt
}
}
`;
@@ -594,7 +595,7 @@ export const ORGANIZATION_POST_CONNECTION_LIST = gql`
lastName
email
}
- pinned
+ createdAt
likeCount
commentCount
comments {
@@ -611,7 +612,6 @@ export const ORGANIZATION_POST_CONNECTION_LIST = gql`
}
text
}
- createdAt
likedBy {
_id
firstName
diff --git a/src/assets/svgs/date.svg b/src/assets/svgs/date.svg
new file mode 100644
index 0000000000..9baf0768c4
--- /dev/null
+++ b/src/assets/svgs/date.svg
@@ -0,0 +1 @@
+
\ No newline at end of file
diff --git a/src/assets/svgs/location.svg b/src/assets/svgs/location.svg
new file mode 100644
index 0000000000..b75f616dd6
--- /dev/null
+++ b/src/assets/svgs/location.svg
@@ -0,0 +1 @@
+
\ No newline at end of file
diff --git a/src/assets/svgs/user.svg b/src/assets/svgs/user.svg
new file mode 100644
index 0000000000..b23b34481e
--- /dev/null
+++ b/src/assets/svgs/user.svg
@@ -0,0 +1 @@
+
\ No newline at end of file
diff --git a/src/components/OrganizationDashCards/CardItem.module.css b/src/components/OrganizationDashCards/CardItem.module.css
index e90a6d3655..0330411b0c 100644
--- a/src/components/OrganizationDashCards/CardItem.module.css
+++ b/src/components/OrganizationDashCards/CardItem.module.css
@@ -45,3 +45,16 @@
font-size: 0.9rem;
color: var(--bs-secondary);
}
+
+.cardItem .creator {
+ font-size: 1rem;
+ color: rgb(33, 208, 21);
+}
+
+.rightCard {
+ display: flex;
+ gap: 5px;
+ min-width: 170px;
+ justify-content: center;
+ flex-direction: column;
+}
diff --git a/src/components/OrganizationDashCards/CardItem.test.tsx b/src/components/OrganizationDashCards/CardItem.test.tsx
index 6841fe9659..2102e86f94 100644
--- a/src/components/OrganizationDashCards/CardItem.test.tsx
+++ b/src/components/OrganizationDashCards/CardItem.test.tsx
@@ -2,6 +2,7 @@ import React from 'react';
import { render, screen } from '@testing-library/react';
import CardItem from './CardItem';
import type { InterfaceCardItem } from './CardItem';
+import dayjs from 'dayjs';
describe('Testing the Organization Card', () => {
test('should render props and text elements For event card', () => {
@@ -14,7 +15,9 @@ describe('Testing the Organization Card', () => {
render(
);
expect(screen.getByText(/Event Title/i)).toBeInTheDocument();
- expect(screen.getByText(/03-09-2023/i)).toBeInTheDocument();
+ expect(
+ screen.getByText(dayjs(props.time).format('MMM D, YYYY'))
+ ).toBeInTheDocument();
});
test('Should render props and text elements for Post card', () => {
@@ -27,7 +30,9 @@ describe('Testing the Organization Card', () => {
render(
);
expect(screen.getByText(/Post Title/i)).toBeInTheDocument();
- expect(screen.getByText(/03-09-2023/i)).toBeInTheDocument();
+ expect(
+ screen.getByText(dayjs(props.time).format('MMM D, YYYY'))
+ ).toBeInTheDocument();
});
test('Should render props and text elements for Membership Request card', () => {
diff --git a/src/components/OrganizationDashCards/CardItem.tsx b/src/components/OrganizationDashCards/CardItem.tsx
index 4843d421c5..bcaaea68c5 100644
--- a/src/components/OrganizationDashCards/CardItem.tsx
+++ b/src/components/OrganizationDashCards/CardItem.tsx
@@ -1,6 +1,9 @@
import React from 'react';
import { ReactComponent as EventsIcon } from 'assets/svgs/events.svg';
import { ReactComponent as PostsIcon } from 'assets/svgs/post.svg';
+import { ReactComponent as MarkerIcon } from 'assets/svgs/location.svg';
+import { ReactComponent as DateIcon } from 'assets/svgs/date.svg';
+import { ReactComponent as UserIcon } from 'assets/svgs/user.svg';
import dayjs from 'dayjs';
import styles from './CardItem.module.css';
import { PersonAddAlt1Rounded } from '@mui/icons-material';
@@ -9,10 +12,12 @@ export interface InterfaceCardItem {
type: 'Event' | 'Post' | 'MembershipRequest';
title: string;
time?: string;
+ creator?: any;
+ location?: string;
}
const cardItem = (props: InterfaceCardItem): JSX.Element => {
- const { type, title, time } = props;
+ const { creator, type, title, time, location } = props;
return (
<>
@@ -33,13 +38,48 @@ const cardItem = (props: InterfaceCardItem): JSX.Element => {
)}
{`${title}`}
- {time ? (
-
- {dayjs(time).format('DD-MM-YYYY')}
-
- ) : (
- ''
- )}
+
+
+ {creator && (
+
+ {' '}
+ {' '}
+
+ {creator.firstName} {creator.lastName}
+
+
+ )}
+
+ {location && (
+
+ {' '}
+ {location}
+
+ )}
+ {time && (
+
+ {type === 'Event' && (
+
+ )}{' '}
+ {dayjs(time).format('MMM D, YYYY')}
+
+ )}
+
>
);
diff --git a/src/screens/OrgPost/OrgPost.test.tsx b/src/screens/OrgPost/OrgPost.test.tsx
index 93f603d446..85dfc03edc 100644
--- a/src/screens/OrgPost/OrgPost.test.tsx
+++ b/src/screens/OrgPost/OrgPost.test.tsx
@@ -33,7 +33,7 @@ const MOCKS = [
{
_id: '6411e53835d7ba2344a78e21',
title: 'postone',
- text: 'THis is the frist post',
+ text: 'This is the first post',
imageUrl: null,
videoUrl: null,
createdAt: '2023-08-24T09:26:56.524+00:00',
@@ -52,7 +52,7 @@ const MOCKS = [
{
_id: '6411e54835d7ba2344a78e29',
title: 'posttwo',
- text: 'THis is the post two',
+ text: 'Tis is the post two',
imageUrl: null,
videoUrl: null,
createdAt: '2023-08-24T09:26:56.524+00:00',
@@ -133,7 +133,7 @@ describe('Organisation Post Page', () => {
expect(dataQuery1).toEqual({
_id: '6411e53835d7ba2344a78e21',
title: 'postone',
- text: 'THis is the frist post',
+ text: 'This is the first post',
imageUrl: null,
videoUrl: null,
createdAt: '2023-08-24T09:26:56.524+00:00',
diff --git a/src/screens/OrganizationDashboard/OrganizationDashboard.test.tsx b/src/screens/OrganizationDashboard/OrganizationDashboard.test.tsx
index f1560ee4f0..a54a5fd421 100644
--- a/src/screens/OrganizationDashboard/OrganizationDashboard.test.tsx
+++ b/src/screens/OrganizationDashboard/OrganizationDashboard.test.tsx
@@ -11,7 +11,6 @@ import { StaticMockLink } from 'utils/StaticMockLink';
import OrganizationDashboard from './OrganizationDashboard';
import { EMPTY_MOCKS, ERROR_MOCKS, MOCKS } from './OrganizationDashboardMocks';
import i18nForTest from 'utils/i18nForTest';
-import dayjs from 'dayjs';
import { toast } from 'react-toastify';
import userEvent from '@testing-library/user-event';
@@ -75,17 +74,9 @@ describe('Organisation Dashboard Page', () => {
expect(screen.getByText('Upcoming Events')).toBeInTheDocument();
expect(screen.getByText('Latest Posts')).toBeInTheDocument();
expect(screen.getByText('Membership requests')).toBeInTheDocument();
- expect(screen.getAllByText('View All')).toHaveLength(3);
- // Checking if events are rendered
- expect(screen.getByText('Event 1')).toBeInTheDocument();
- expect(
- screen.getByText(
- `${dayjs(new Date()).add(1, 'day').format('DD-MM-YYYY')}`
- )
- ).toBeInTheDocument();
// Checking if posts are rendered
- expect(screen.getByText('Post 1')).toBeInTheDocument();
+ expect(screen.getByText('Post 15')).toBeInTheDocument();
// Checking if membership requests are rendered
expect(screen.getByText('Jane Doe')).toBeInTheDocument();
diff --git a/src/screens/OrganizationDashboard/OrganizationDashboard.tsx b/src/screens/OrganizationDashboard/OrganizationDashboard.tsx
index 27ab4a4e98..a6551fd84b 100644
--- a/src/screens/OrganizationDashboard/OrganizationDashboard.tsx
+++ b/src/screens/OrganizationDashboard/OrganizationDashboard.tsx
@@ -7,8 +7,8 @@ import { useTranslation } from 'react-i18next';
import {
ORGANIZATIONS_LIST,
- ORGANIZATION_EVENT_LIST,
- ORGANIZATION_POST_LIST,
+ ORGANIZATION_POST_CONNECTION_LIST,
+ ORGANIZATION_EVENT_CONNECTION_LIST,
} from 'GraphQl/Queries/Queries';
import { ReactComponent as AdminsIcon } from 'assets/svgs/admin.svg';
import { ReactComponent as BlockedUsersIcon } from 'assets/svgs/blockedUser.svg';
@@ -22,7 +22,6 @@ import CardItem from 'components/OrganizationDashCards/CardItem';
import type { ApolloError } from '@apollo/client';
import type {
InterfaceQueryOrganizationEventListItem,
- InterfaceQueryOrganizationPostListItem,
InterfaceQueryOrganizationsListObject,
} from 'utils/interfaces';
import { toast } from 'react-toastify';
@@ -57,15 +56,7 @@ function organizationDashboard(): JSX.Element {
data: postData,
loading: loadingPost,
error: errorPost,
- }: {
- data:
- | {
- postsByOrganization: InterfaceQueryOrganizationPostListItem[];
- }
- | undefined;
- loading: boolean;
- error?: ApolloError;
- } = useQuery(ORGANIZATION_POST_LIST, {
+ } = useQuery(ORGANIZATION_POST_CONNECTION_LIST, {
variables: { id: currentUrl },
});
@@ -74,22 +65,20 @@ function organizationDashboard(): JSX.Element {
loading: loadingEvent,
error: errorEvent,
}: {
- data:
- | {
- eventsByOrganization: InterfaceQueryOrganizationEventListItem[];
- }
- | undefined;
+ data: any;
loading: boolean;
error?: ApolloError;
- } = useQuery(ORGANIZATION_EVENT_LIST, {
- variables: { id: currentUrl },
+ } = useQuery(ORGANIZATION_EVENT_CONNECTION_LIST, {
+ variables: {
+ organization_id: currentUrl,
+ },
});
// UseEffect to update upcomingEvents array
useEffect(() => {
- if (eventData && eventData?.eventsByOrganization.length > 0) {
+ if (eventData && eventData?.eventsByOrganizationConnection.length > 0) {
const tempUpcomingEvents: InterfaceQueryOrganizationEventListItem[] = [];
- eventData?.eventsByOrganization.map((event) => {
+ eventData?.eventsByOrganizationConnection.map((event: any) => {
const startDate = new Date(event.startDate);
const now = new Date();
if (startDate > now) {
@@ -98,11 +87,12 @@ function organizationDashboard(): JSX.Element {
});
setUpcomingEvents(tempUpcomingEvents);
}
- }, [eventData?.eventsByOrganization]);
+ }, [eventData?.eventsByOrganizationConnection]);
if (errorOrg || errorPost || errorEvent) {
window.location.replace('/orglist');
}
+
return (
<>
@@ -136,14 +126,16 @@ function organizationDashboard(): JSX.Element {
}
/>
}
/>
@@ -192,16 +184,19 @@ function organizationDashboard(): JSX.Element {
{t('noUpcomingEvents')}
) : (
- upcomingEvents.slice(0, 5).map((event) => {
- return (
-