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/css/app.css b/src/assets/css/app.css index c507b04f38..ae21cf9cb0 100644 --- a/src/assets/css/app.css +++ b/src/assets/css/app.css @@ -5560,7 +5560,7 @@ fieldset:disabled .btn { box-shadow: var(--bs-toast-box-shadow); border-radius: var(--bs-toast-border-radius); } -.toast.showing { +.showing { opacity: 0; } .toast:not(.show) { 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/CheckIn/CheckInModal.test.tsx b/src/components/CheckIn/CheckInModal.test.tsx index 11d95e5885..80fe9dd918 100644 --- a/src/components/CheckIn/CheckInModal.test.tsx +++ b/src/components/CheckIn/CheckInModal.test.tsx @@ -11,6 +11,9 @@ import { ToastContainer } from 'react-toastify'; import { LocalizationProvider } from '@mui/x-date-pickers'; import { AdapterDayjs } from '@mui/x-date-pickers/AdapterDayjs'; import { checkInQueryMock } from './mocks'; +import { StaticMockLink } from 'utils/StaticMockLink'; + +const link = new StaticMockLink(checkInQueryMock, true); describe('Testing Check In Attendees Modal', () => { const props = { @@ -21,7 +24,7 @@ describe('Testing Check In Attendees Modal', () => { test('The modal should be rendered, and all the fetched users should be shown properly and user filtering should work', async () => { const { queryByText, queryByLabelText } = render( - + diff --git a/src/components/CheckIn/CheckInModal.tsx b/src/components/CheckIn/CheckInModal.tsx index a370ebbb7e..3f15824ecd 100644 --- a/src/components/CheckIn/CheckInModal.tsx +++ b/src/components/CheckIn/CheckInModal.tsx @@ -30,6 +30,7 @@ export const CheckInModal = (props: InterfaceModalProp): JSX.Element => { }); useEffect(() => { + checkInRefetch(); if (checkInLoading) setTableData([]); else setTableData( diff --git a/src/components/CheckIn/TableRow.test.tsx b/src/components/CheckIn/TableRow.test.tsx index 789eb4d5f6..b8ab48f397 100644 --- a/src/components/CheckIn/TableRow.test.tsx +++ b/src/components/CheckIn/TableRow.test.tsx @@ -95,9 +95,9 @@ describe('Testing Table Row for CheckIn Table', () => { await waitFor(() => expect(queryByText('Generating pdf...')).toBeInTheDocument() ); - await waitFor(() => - expect(queryByText('PDF generated successfully!')).toBeInTheDocument() - ); + await waitFor(() => { + expect(queryByText('PDF generated successfully!')).toBeInTheDocument(); + }); }); test('Upon failing of check in mutation, the appropiate error message should be shown', async () => { diff --git a/src/components/CheckIn/TableRow.tsx b/src/components/CheckIn/TableRow.tsx index 0c69a26303..90e22deff0 100644 --- a/src/components/CheckIn/TableRow.tsx +++ b/src/components/CheckIn/TableRow.tsx @@ -37,15 +37,17 @@ export const TableRow = ({ }); }; - const generateTag = (): void => { - toast.warning('Generating pdf...'); - const inputs = [{ name: data.name }]; - - generate({ template: tagTemplate, inputs }).then((pdf) => { - const blob = new Blob([pdf.buffer], { type: 'application/pdf' }); - window.open(URL.createObjectURL(blob)); - toast.success('PDF generated successfully!'); + const notify = (): Promise => + toast.promise(generateTag, { + pending: 'Generating pdf...', + success: 'PDF generated successfully!', + error: 'Error generating pdf!', }); + const generateTag = async (): Promise => { + const inputs = [{ name: data.name }]; + const pdf = await generate({ template: tagTemplate, inputs }); + const blob = new Blob([pdf.buffer], { type: 'application/pdf' }); + window.open(URL.createObjectURL(blob)); }; return ( @@ -55,7 +57,7 @@ export const TableRow = ({ - diff --git a/src/components/EventListCard/EventListCard.module.css b/src/components/EventListCard/EventListCard.module.css index 5b128d075d..1648c9d16a 100644 --- a/src/components/EventListCard/EventListCard.module.css +++ b/src/components/EventListCard/EventListCard.module.css @@ -17,18 +17,31 @@ .cards a:hover { color: black; } +.cards { + position: relative; + overflow: hidden; + transition: all 0.3s; +} .dispflex { display: flex; - justify-content: space-between; + height: 50px; + transition: transform 0.3s ease; + cursor: pointer; +} +.cards:hover { + transform: scale(2.5); + z-index: 5; +} +.cards:hover h2 { + font-size: 0.4vmax; + margin-bottom: 0; } .iconContainer { display: flex; justify-content: flex-end; } .icon { - transform: scale(1); - cursor: pointer; - color: #31bb6b; + margin: 1px; } .cards { @@ -86,6 +99,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..820e563957 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,9 +295,50 @@ describe('Testing Event List Card', () => { ); - + userEvent.click(screen.getByTestId('card')); + userEvent.click(screen.getByTestId('deleteEventModalBtn')); const deleteBtn = screen.getByTestId('deleteEventBtn'); fireEvent.click(deleteBtn); }); }); + + test('Should render truncated event details', async () => { + const longEventName = + 'Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. A very long event name that exceeds 150 characters and needs to be truncated'; + const longDescription = + 'Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. A very long description that exceeds 150 characters and needs to be truncated'; + const longEventNameLength = longEventName.length; + const longDescriptionLength = longDescription.length; + const truncatedEventName = longEventName.substring(0, 150) + '...'; + const truncatedDescriptionName = longDescription.substring(0, 150) + '...'; + render( + + + + + + ); + + await wait(); + + expect(longEventNameLength).toBeGreaterThan(100); + expect(longDescriptionLength).toBeGreaterThan(256); + expect(truncatedEventName).toContain('...'); + expect(truncatedDescriptionName).toContain('...'); + await wait(); + }); }); diff --git a/src/components/EventListCard/EventListCard.tsx b/src/components/EventListCard/EventListCard.tsx index 7f817890de..0ec3a62d6f 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, @@ -140,7 +150,17 @@ function eventListCard(props: InterfaceEventListCardProps): JSX.Element { >

- {props.eventName ? <>{props.eventName} : <>Dogs Care}{' '} + {props.eventName ? ( + <> + {props.eventName.length > 150 ? ( + <>{props.eventName.substring(0, 150)}... + ) : ( + <>{props.eventName} + )} + + ) : ( + <>Dogs Care + )}

@@ -162,7 +182,17 @@ function eventListCard(props: InterfaceEventListCardProps): JSX.Element {

{t('eventTitle')}:{' '} - {props.eventName ? <>{props.eventName} : <>Dogs Care}{' '} + {props.eventName ? ( + <> + {props.eventName.length > 100 ? ( + <>{props.eventName.substring(0, 100)}... + ) : ( + <>{props.eventName} + )} + + ) : ( + <>Dogs Care + )}

@@ -177,7 +207,11 @@ function eventListCard(props: InterfaceEventListCardProps): JSX.Element {

{t('description')}:{' '} - {props.eventDescription} + + {props.eventDescription && props.eventDescription.length > 256 + ? props.eventDescription.substring(0, 256) + '...' + : props.eventDescription} +

{t('on')}: {props.regDate} @@ -196,247 +230,234 @@ function eventListCard(props: InterfaceEventListCardProps): JSX.Element {

- + {' '} - - +
{/* delete modal */} - + + + {t('deleteEvent')} + + + {t('deleteEventMsg')} + + + + + {/* Edit Modal */} - @@ -122,6 +130,20 @@ const leftDrawerEvent = ({ eventId={event._id} key={`${event?._id || 'loading'}Stats`} /> + {/* Profile Section & Logout Btn */} 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/components/TaskModals/AddTaskModal.tsx b/src/components/TaskModals/AddTaskModal.tsx index 22bd0f4941..0134077afe 100644 --- a/src/components/TaskModals/AddTaskModal.tsx +++ b/src/components/TaskModals/AddTaskModal.tsx @@ -27,9 +27,15 @@ export const AddTaskModal = ({ const [deadline, setDeadline] = useState(today); const [addMutation] = useMutation(ADD_EVENT_PROJECT_TASK_MUTATION); - - const handleSubmit = (e: React.FormEvent): void => { + const notify = async (e: React.FormEvent): Promise => { e.preventDefault(); + toast.promise(handleSubmit, { + pending: 'Adding the task...', + success: 'Added the task successfully!', + error: 'There was an error in adding the task!', + }); + }; + const handleSubmit = async (): Promise => { let toSubmit = true; if (title.trim().length == 0) { @@ -40,29 +46,19 @@ export const AddTaskModal = ({ toast.error('Description cannot be empty!'); toSubmit = false; } - - if (toSubmit) { - toast.warn('Adding the task...'); - addMutation({ - variables: { - title, - description, - projectId, - deadline, - }, - }) - .then(() => { - toast.success('Added the task successfully!'); - refetchData(); - setTitle(''); - setDescription(''); - handleClose(); - }) - .catch((err) => { - toast.error('There was an error in adding the task!'); - toast.error(err.message); - }); - } + if (!toSubmit) return Promise.reject(); + await addMutation({ + variables: { + title, + description, + projectId, + deadline, + }, + }); + refetchData(); + setTitle(''); + setDescription(''); + handleClose(); }; return ( @@ -71,7 +67,7 @@ export const AddTaskModal = ({ Add an Event Task - + Title diff --git a/src/components/TaskModals/DeleteTaskModal.test.tsx b/src/components/TaskModals/DeleteTaskModal.test.tsx index e9ffea1be0..4eb40e53a8 100644 --- a/src/components/TaskModals/DeleteTaskModal.test.tsx +++ b/src/components/TaskModals/DeleteTaskModal.test.tsx @@ -96,6 +96,5 @@ describe('Testing Delete Event Project Modal', () => { queryByText('There was an error in deleting the task!') ).toBeInTheDocument() ); - await waitFor(() => expect(queryByText('Oops')).toBeInTheDocument()); }); }); diff --git a/src/components/TaskModals/DeleteTaskModal.tsx b/src/components/TaskModals/DeleteTaskModal.tsx index f4b6378c1b..73baff5775 100644 --- a/src/components/TaskModals/DeleteTaskModal.tsx +++ b/src/components/TaskModals/DeleteTaskModal.tsx @@ -13,23 +13,21 @@ type ModalPropType = { export const DeleteTaskModal = (props: ModalPropType): JSX.Element => { const [deleteMutation] = useMutation(DELETE_EVENT_TASK_MUTATION); - - const deleteProject = (): void => { - toast.warn('Deleting the task...'); - deleteMutation({ + const notify = (): Promise => { + return toast.promise(deleteProject, { + pending: 'Deleting the task...', + success: 'Deleted the task successfully!', + error: 'There was an error in deleting the task!', + }); + }; + const deleteProject = async (): Promise => { + await deleteMutation({ variables: { id: props.taskId, }, - }) - .then(() => { - toast.success('Deleted the task successfully!'); - props.refetchData(); - props.handleClose(); - }) - .catch((err) => { - toast.error('There was an error in deleting the task!'); - toast.error(err.message); - }); + }); + props.refetchData(); + props.handleClose(); }; return ( @@ -56,7 +54,7 @@ export const DeleteTaskModal = (props: ModalPropType): JSX.Element => { > Cancel - diff --git a/src/components/TaskModals/ManageVolunteerModal.test.tsx b/src/components/TaskModals/ManageVolunteerModal.test.tsx index 68ac0888d7..e284984969 100644 --- a/src/components/TaskModals/ManageVolunteerModal.test.tsx +++ b/src/components/TaskModals/ManageVolunteerModal.test.tsx @@ -131,7 +131,5 @@ describe('Testing Manage Volunteers Modal', () => { queryByText('There was an error in updating the volunteers!') ).toBeInTheDocument() ); - - await waitFor(() => expect(queryByText('Oops')).toBeInTheDocument()); }); }); diff --git a/src/components/TaskModals/ManageVolunteerModal.tsx b/src/components/TaskModals/ManageVolunteerModal.tsx index 31f9593663..162fda4a02 100644 --- a/src/components/TaskModals/ManageVolunteerModal.tsx +++ b/src/components/TaskModals/ManageVolunteerModal.tsx @@ -32,24 +32,22 @@ export const ManageVolunteerModal = (props: ModalPropType): JSX.Element => { useEffect(() => setVolunteers(props.volunteers), [props.volunteers]); const [setMutation] = useMutation(SET_TASK_VOLUNTEERS_MUTATION); - - const handleSubmit = (): void => { - toast.warn('Updating the volunteers...'); - setMutation({ + const notify = (): Promise => { + return toast.promise(handleSubmit, { + pending: 'Updating the volunteers...', + success: 'Successfully updated the volunteers!', + error: 'There was an error in updating the volunteers!', + }); + }; + const handleSubmit = async (): Promise => { + await setMutation({ variables: { id: props.taskId, volunteers: volunteers.map((volunteer) => volunteer._id), }, - }) - .then(() => { - toast.success('Successfully updated the volunteers!'); - props.refetchData(); - props.handleClose(); - }) - .catch((err) => { - toast.error('There was an error in updating the volunteers!'); - toast.error(err.message); - }); + }); + props.refetchData(); + props.handleClose(); }; return ( @@ -94,7 +92,7 @@ export const ManageVolunteerModal = (props: ModalPropType): JSX.Element => {
- diff --git a/src/components/TaskModals/UpdateTaskModal.test.tsx b/src/components/TaskModals/UpdateTaskModal.test.tsx index 2184c421a7..9541d6d26b 100644 --- a/src/components/TaskModals/UpdateTaskModal.test.tsx +++ b/src/components/TaskModals/UpdateTaskModal.test.tsx @@ -229,8 +229,6 @@ describe('Testing Update Event Task Modal', () => { queryByText('There was an error in updating the task!') ).toBeInTheDocument() ); - - await waitFor(() => expect(queryByText('Oops')).toBeInTheDocument()); }); test('Manage volunteer modal and delete task modal should open and close properly', async () => { diff --git a/src/components/TaskModals/UpdateTaskModal.tsx b/src/components/TaskModals/UpdateTaskModal.tsx index 76d57da797..d79dd19a36 100644 --- a/src/components/TaskModals/UpdateTaskModal.tsx +++ b/src/components/TaskModals/UpdateTaskModal.tsx @@ -57,9 +57,15 @@ export const UpdateTaskModal = (props: ModalPropType): JSX.Element => { }, [props.task]); const [updateMutation] = useMutation(UPDATE_EVENT_PROJECT_TASK_MUTATION); - - const handleSubmit = (e: React.FormEvent): void => { + const notify = (e: React.FormEvent): Promise => { e.preventDefault(); + return toast.promise(handleSubmit, { + pending: 'Updating the task...', + success: 'Updated the task successfully!', + error: 'There was an error in updating the task!', + }); + }; + const handleSubmit = async (): Promise => { let toSubmit = true; if (title.trim().length == 0) { @@ -70,28 +76,19 @@ export const UpdateTaskModal = (props: ModalPropType): JSX.Element => { toast.error('Description cannot be empty!'); toSubmit = false; } + if (!toSubmit) return Promise.reject(); - if (toSubmit) { - toast.warn('Updating the task...'); - updateMutation({ - variables: { - taskId: props.task._id, - title, - description, - deadline, - completed, - }, - }) - .then(() => { - toast.success('Updated the task successfully!'); - props.refetchData(); - props.handleClose(); - }) - .catch((err) => { - toast.error('There was an error in updating the task!'); - toast.error(err.message); - }); - } + await updateMutation({ + variables: { + taskId: props.task._id, + title, + description, + deadline, + completed, + }, + }); + props.refetchData(); + props.handleClose(); }; return ( @@ -107,7 +104,7 @@ export const UpdateTaskModal = (props: ModalPropType): JSX.Element => { Update the Event Task - + Title diff --git a/src/components/UserPortal/SecuredRouteForUser/SecuredRouteForUser.test.tsx b/src/components/UserPortal/SecuredRouteForUser/SecuredRouteForUser.test.tsx new file mode 100644 index 0000000000..72ee402369 --- /dev/null +++ b/src/components/UserPortal/SecuredRouteForUser/SecuredRouteForUser.test.tsx @@ -0,0 +1,54 @@ +import React from 'react'; +import { MemoryRouter, Route } from 'react-router-dom'; +import { render, screen, waitFor } from '@testing-library/react'; +import SecuredRouteForUser from './SecuredRouteForUser'; + +describe('SecuredRouteForUser', () => { + test('renders the route when the user is logged in', () => { + // Set the 'IsLoggedIn' value to 'TRUE' in localStorage to simulate a logged-in user + localStorage.setItem('IsLoggedIn', 'TRUE'); + + render( + + ( + ( +
+ Organizations Component +
+ )} + /> + )} + /> +
+ ); + + expect(screen.getByTestId('organizations-content')).toBeInTheDocument(); + }); + + test('redirects to /user when the user is not logged in', async () => { + // Set the user as not logged in in local storage + localStorage.setItem('IsLoggedIn', 'FALSE'); + + render( + + ( + +
Secured Content
+
+ )} + /> +
+ ); + + await waitFor(() => { + expect(window.location.pathname).toBe('/'); + }); + }); +}); diff --git a/src/components/UsersTableItem/UserTableItemMocks.ts b/src/components/UsersTableItem/UserTableItemMocks.ts index 6fd90d2be4..5f81c8cfe9 100644 --- a/src/components/UsersTableItem/UserTableItemMocks.ts +++ b/src/components/UsersTableItem/UserTableItemMocks.ts @@ -33,7 +33,7 @@ export const MOCKS = [ }, result: { data: { - removeUserFromOrganization: { + removeMember: { _id: '123', }, }, diff --git a/src/screens/EventDashboard/EventDashboard.module.css b/src/screens/EventDashboard/EventDashboard.module.css index 5a484443d8..10ac2ee4ed 100644 --- a/src/screens/EventDashboard/EventDashboard.module.css +++ b/src/screens/EventDashboard/EventDashboard.module.css @@ -41,7 +41,7 @@ font-size: 20px; margin-bottom: 30px; padding-bottom: 5px; - width: 26%; + width: 100%; } .tagdetailsGreen > button { background-color: #31bb6b; diff --git a/src/screens/EventDashboard/EventDashboard.tsx b/src/screens/EventDashboard/EventDashboard.tsx index 810e8335c6..80f1374b71 100644 --- a/src/screens/EventDashboard/EventDashboard.tsx +++ b/src/screens/EventDashboard/EventDashboard.tsx @@ -80,7 +80,7 @@ const EventDashboard = (): JSX.Element => { setShowAddEventProjectModal={setShowAddEventProjectModal} > - +
{/* Side Bar - Static Information about the Event */} @@ -110,7 +110,7 @@ const EventDashboard = (): JSX.Element => {
- + {/* Main Screen Container */}
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..cb221f94ce 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,20 +74,27 @@ 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(); + + const peopleBtn = screen.getByText('Members'); + const adminBtn = screen.getByText('Admins'); + const postBtn = screen.getAllByText('Posts'); + const eventBtn = screen.getAllByText('Events'); + const blockUserBtn = screen.getByText('Blocked Users'); + const requestBtn = screen.getByText('Requests'); + userEvent.click(peopleBtn); + userEvent.click(adminBtn); + userEvent.click(postBtn[0]); + userEvent.click(eventBtn[0]); + userEvent.click(postBtn[1]); + userEvent.click(eventBtn[1]); + userEvent.click(blockUserBtn); + userEvent.click(requestBtn); }); test('Testing buttons and checking empty events, posts and membership requests', async () => { diff --git a/src/screens/OrganizationDashboard/OrganizationDashboard.tsx b/src/screens/OrganizationDashboard/OrganizationDashboard.tsx index 27ab4a4e98..60e31396a5 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'; @@ -34,6 +33,12 @@ function organizationDashboard(): JSX.Element { const { t } = useTranslation('translation', { keyPrefix: 'dashboard' }); document.title = t('title'); const currentUrl = window.location.href.split('=')[1]; + const peopleLink = `/orgpeople/id=${currentUrl}`; + const postsLink = `/orgpost/id=${currentUrl}`; + const eventsLink = `/orgevents/id=${currentUrl}`; + const blockUserLink = `/blockuser/id=${currentUrl}`; + const requestLink = '/requests'; + const history = useHistory(); const [upcomingEvents, setUpcomingEvents] = useState< InterfaceQueryOrganizationEventListItem[] @@ -57,15 +62,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 +71,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 +93,12 @@ function organizationDashboard(): JSX.Element { }); setUpcomingEvents(tempUpcomingEvents); } - }, [eventData?.eventsByOrganization]); + }, [eventData?.eventsByOrganizationConnection]); if (errorOrg || errorPost || errorEvent) { window.location.replace('/orglist'); } + return ( <> @@ -120,42 +116,92 @@ function organizationDashboard(): JSX.Element { ) : ( - + { + history.push(peopleLink); + }} + > } /> - + { + history.push(peopleLink); + }} + > } /> - + { + history.push(postsLink); + }} + > } /> - + { + history.push(eventsLink); + }} + > } /> - + { + history.push(blockUserLink); + }} + > } /> - + { + history.push(requestLink); + }} + > - history.push(`/orgevents/id=${currentUrl}`) - } + onClick={(): void => history.push(eventsLink)} > {t('viewAll')} @@ -192,16 +236,19 @@ function organizationDashboard(): JSX.Element {
{t('noUpcomingEvents')}
) : ( - upcomingEvents.slice(0, 5).map((event) => { - return ( - - ); - }) + upcomingEvents.map( + (event: InterfaceQueryOrganizationEventListItem) => { + return ( + + ); + } + ) )} @@ -214,9 +261,7 @@ function organizationDashboard(): JSX.Element { size="sm" variant="light" data-testid="viewAllPosts" - onClick={(): void => - history.push(`/orgpost/id=${currentUrl}`) - } + onClick={(): void => history.push(postsLink)} > {t('viewAll')} @@ -226,20 +271,27 @@ function organizationDashboard(): JSX.Element { [...Array(4)].map((_, index) => { return ; }) - ) : postData?.postsByOrganization?.length == 0 ? ( + ) : postData?.postsByOrganizationConnection.edges.length == + 0 ? ( + /* eslint-disable */
{t('noPostsPresent')}
) : ( - postData?.postsByOrganization.slice(0, 5).map((post) => { - return ( - - ); - }) + /* eslint-enable */ + postData?.postsByOrganizationConnection.edges + .slice(0, 5) + .map((post: any) => { + return ( + + ); + }) )} diff --git a/src/screens/OrganizationDashboard/OrganizationDashboardMocks.ts b/src/screens/OrganizationDashboard/OrganizationDashboardMocks.ts index f1672c03ca..dc1f158709 100644 --- a/src/screens/OrganizationDashboard/OrganizationDashboardMocks.ts +++ b/src/screens/OrganizationDashboard/OrganizationDashboardMocks.ts @@ -1,7 +1,7 @@ import { ORGANIZATIONS_LIST, - ORGANIZATION_EVENT_LIST, - ORGANIZATION_POST_LIST, + ORGANIZATION_EVENT_CONNECTION_LIST, + ORGANIZATION_POST_CONNECTION_LIST, } from 'GraphQl/Queries/Queries'; import dayjs from 'dayjs'; @@ -26,7 +26,6 @@ export const MOCKS = [ lastName: '', email: '', }, - members: [ { _id: '123', @@ -68,59 +67,114 @@ export const MOCKS = [ }, { request: { - query: ORGANIZATION_POST_LIST, + query: ORGANIZATION_POST_CONNECTION_LIST, }, result: { data: { - postsByOrganization: [ - { - _id: 1, - title: 'Post 1', - text: 'Test Post', - imageUrl: '', - videoUrl: '', - creator: { - _id: '583', - firstName: 'John', - lastName: 'Doe', - email: 'johndoe@gmail.com', + postsByOrganizationConnection: { + edges: [ + { + _id: '6411e53835d7ba2344a78e21', + title: 'Post 15', + text: 'This is the first post that was made', + imageUrl: null, + videoUrl: null, + creator: { + _id: '640d98d9eb6a743d75341067', + firstName: 'Aditya', + lastName: 'Shelke', + email: 'adidacreator1@gmail.com', + }, + createdAt: dayjs(new Date()).add(1, 'day'), + likeCount: 0, + commentCount: 0, + comments: [], + likedBy: [], + pinned: false, }, - }, - ], + { + _id: '6411e54835d7ba2344a78e29', + title: 'Post 2', + text: 'Hey, anyone saw my watch that I left at the office?', + imageUrl: null, + videoUrl: null, + creator: { + _id: '640d98d9eb6a743d75341067', + firstName: 'Aditya', + lastName: 'Shelke', + email: 'adidacreator1@gmail.com', + }, + pinned: false, + createdAt: dayjs(new Date()).add(1, 'day'), + likeCount: 0, + commentCount: 2, + comments: [ + { + _id: '64eb13beca85de60ebe0ed0e', + creator: { + _id: '63d6064458fce20ee25c3bf7', + firstName: 'Noble', + lastName: 'Mittal', + email: 'test@gmail.com', + __typename: 'User', + }, + likeCount: 1, + likedBy: [ + { + _id: 1, + }, + ], + text: 'Yes, that is $50', + __typename: 'Comment', + }, + { + _id: '64eb483aca85de60ebe0ef99', + creator: { + _id: '63d6064458fce20ee25c3bf7', + firstName: 'Noble', + lastName: 'Mittal', + email: 'test@gmail.com', + __typename: 'User', + }, + likeCount: 0, + likedBy: [], + text: 'Great View', + __typename: 'Comment', + }, + ], + likedBy: [ + { + _id: '63d6064458fce20ee25c3bf7', + firstName: 'Comment', + lastName: 'Likkert', + }, + ], + }, + ], + }, }, }, }, { request: { - query: ORGANIZATION_EVENT_LIST, + query: ORGANIZATION_EVENT_CONNECTION_LIST, + variables: { + organization_id: '123', + }, }, result: { data: { - eventsByOrganization: [ - { - _id: 1, - title: 'Event 1', - description: 'Event Test', - startDate: dayjs(new Date()).add(1, 'day'), - endDate: dayjs(new Date()).add(3, 'day'), - location: 'New Delhi', - startTime: '', - endTime: '', - allDay: true, - recurring: false, - isPublic: true, - isRegisterable: true, - }, + eventsByOrganizationConnection: [ { - _id: 2, - title: 'Event 2', - description: 'Event Test', - startDate: dayjs(new Date()), - endDate: dayjs(new Date()).add(1, 'day'), - location: 'Jamaica', - startTime: '', - endTime: '', - allDay: true, + _id: '1', + title: 'Sample Event', + description: 'Sample Description', + startDate: '2023-10-29T00:00:00.000Z', + endDate: '2023-10-29T23:59:59.000Z', + location: 'Sample Location', + startTime: '08:00:00', + endTime: '17:00:00', + allDay: false, recurring: false, isPublic: true, isRegisterable: true, @@ -184,21 +238,23 @@ export const EMPTY_MOCKS = [ }, { request: { - query: ORGANIZATION_POST_LIST, + query: ORGANIZATION_POST_CONNECTION_LIST, }, result: { data: { - postsByOrganization: [], + postsByOrganizationConnection: { + edges: [], + }, }, }, }, { request: { - query: ORGANIZATION_EVENT_LIST, + query: ORGANIZATION_EVENT_CONNECTION_LIST, }, result: { data: { - eventsByOrganization: [], + eventsByOrganizationConnection: [], }, }, }, @@ -213,13 +269,13 @@ export const ERROR_MOCKS = [ }, { request: { - query: ORGANIZATION_POST_LIST, + query: ORGANIZATION_POST_CONNECTION_LIST, }, error: new Error('Mock Graphql ORGANIZATION_POST_LIST Error'), }, { request: { - query: ORGANIZATION_EVENT_LIST, + query: ORGANIZATION_EVENT_CONNECTION_LIST, }, error: new Error('Mock Graphql ORGANIZATION_EVENT_LIST Error'), }, diff --git a/src/screens/OrganizationEvents/OrganizationEvents.test.tsx b/src/screens/OrganizationEvents/OrganizationEvents.test.tsx index 4c08db90d5..9f79991274 100644 --- a/src/screens/OrganizationEvents/OrganizationEvents.test.tsx +++ b/src/screens/OrganizationEvents/OrganizationEvents.test.tsx @@ -13,6 +13,7 @@ import { CREATE_EVENT_MUTATION } from 'GraphQl/Mutations/mutations'; import i18nForTest from 'utils/i18nForTest'; import userEvent from '@testing-library/user-event'; import { StaticMockLink } from 'utils/StaticMockLink'; +import { toast } from 'react-toastify'; const MOCKS = [ { @@ -112,6 +113,14 @@ async function wait(ms = 100): Promise { }); } +jest.mock('react-toastify', () => ({ + toast: { + success: jest.fn(), + warning: jest.fn(), + error: jest.fn(), + }, +})); + describe('Organisation Events Page', () => { const formData = { title: 'Dummy Org', @@ -297,6 +306,91 @@ describe('Organisation Events Page', () => { userEvent.click(screen.getByTestId('createEventBtn')); }, 15000); + test('Testing Create event with invalid inputs', async () => { + const formData = { + title: ' ', + description: ' ', + location: ' ', + startDate: '03/28/2022', + endDate: '04/15/2023', + startTime: '02:00', + endTime: '06:00', + allDay: false, + recurring: false, + isPublic: true, + isRegisterable: true, + }; + render( + + + + + + + + + + ); + + await wait(); + + userEvent.click(screen.getByTestId('createEventModalBtn')); + + userEvent.type(screen.getByPlaceholderText(/Enter Title/i), formData.title); + userEvent.type( + screen.getByPlaceholderText(/Enter Description/i), + formData.description + ); + userEvent.type( + screen.getByPlaceholderText(/Enter Location/i), + formData.location + ); + userEvent.type( + screen.getByPlaceholderText(/Enter Location/i), + formData.location + ); + + const endDateDatePicker = screen.getByPlaceholderText(/End Date/i); + const startDateDatePicker = screen.getByPlaceholderText(/Start Date/i); + + fireEvent.click(endDateDatePicker); + fireEvent.click(startDateDatePicker); + + await act(async () => { + fireEvent.change(endDateDatePicker, { + target: { + value: formData.endDate, + }, + }); + fireEvent.change(startDateDatePicker, { + target: { + value: formData.startDate, + }, + }); + }); + userEvent.click(screen.getByTestId('alldayCheck')); + userEvent.click(screen.getByTestId('recurringCheck')); + userEvent.click(screen.getByTestId('ispublicCheck')); + userEvent.click(screen.getByTestId('registrableCheck')); + + await wait(); + + expect(screen.getByPlaceholderText(/Enter Title/i)).toHaveValue(' '); + expect(screen.getByPlaceholderText(/Enter Description/i)).toHaveValue(' '); + + expect(endDateDatePicker).toHaveValue(formData.endDate); + expect(startDateDatePicker).toHaveValue(formData.startDate); + expect(screen.getByTestId('alldayCheck')).not.toBeChecked(); + expect(screen.getByTestId('recurringCheck')).toBeChecked(); + expect(screen.getByTestId('ispublicCheck')).not.toBeChecked(); + expect(screen.getByTestId('registrableCheck')).toBeChecked(); + + userEvent.click(screen.getByTestId('createEventBtn')); + expect(toast.warning).toBeCalledWith('Title can not be blank!'); + expect(toast.warning).toBeCalledWith('Description can not be blank!'); + expect(toast.warning).toBeCalledWith('Location can not be blank!'); + }, 15000); + test('Testing if the event is not for all day', async () => { render( diff --git a/src/screens/OrganizationEvents/OrganizationEvents.tsx b/src/screens/OrganizationEvents/OrganizationEvents.tsx index fe25bcdb6d..36852389eb 100644 --- a/src/screens/OrganizationEvents/OrganizationEvents.tsx +++ b/src/screens/OrganizationEvents/OrganizationEvents.tsx @@ -83,41 +83,56 @@ function organizationEvents(): JSX.Element { e: ChangeEvent ): Promise => { e.preventDefault(); - try { - const { data: createEventData } = await create({ - variables: { - title: formState.title, - description: formState.eventdescrip, - isPublic: publicchecked, - recurring: recurringchecked, - isRegisterable: registrablechecked, - organizationId: currentUrl, - startDate: dayjs(startDate).format('YYYY-MM-DD'), - endDate: dayjs(endDate).format('YYYY-MM-DD'), - allDay: alldaychecked, - location: formState.location, - startTime: !alldaychecked ? formState.startTime + 'Z' : null, - endTime: !alldaychecked ? formState.endTime + 'Z' : null, - }, - }); - - /* istanbul ignore next */ - if (createEventData) { - toast.success(t('eventCreated')); - refetch(); - hideInviteModal(); - setFormState({ - title: '', - eventdescrip: '', - date: '', - location: '', - startTime: '08:00:00', - endTime: '18:00:00', + if ( + formState.title.trim().length > 0 && + formState.eventdescrip.trim().length > 0 && + formState.location.trim().length > 0 + ) { + try { + const { data: createEventData } = await create({ + variables: { + title: formState.title, + description: formState.eventdescrip, + isPublic: publicchecked, + recurring: recurringchecked, + isRegisterable: registrablechecked, + organizationId: currentUrl, + startDate: dayjs(startDate).format('YYYY-MM-DD'), + endDate: dayjs(endDate).format('YYYY-MM-DD'), + allDay: alldaychecked, + location: formState.location, + startTime: !alldaychecked ? formState.startTime + 'Z' : null, + endTime: !alldaychecked ? formState.endTime + 'Z' : null, + }, }); + + /* istanbul ignore next */ + if (createEventData) { + toast.success(t('eventCreated')); + refetch(); + hideInviteModal(); + setFormState({ + title: '', + eventdescrip: '', + date: '', + location: '', + startTime: '08:00:00', + endTime: '18:00:00', + }); + } + } catch (error: any) { + /* istanbul ignore next */ + errorHandler(t, error); } - } catch (error: any) { - /* istanbul ignore next */ - errorHandler(t, error); + } + if (formState.title.trim().length === 0) { + toast.warning('Title can not be blank!'); + } + if (formState.eventdescrip.trim().length === 0) { + toast.warning('Description can not be blank!'); + } + if (formState.location.trim().length === 0) { + toast.warning('Location can not be blank!'); } }; diff --git a/src/screens/UserPortal/Home/Home.test.tsx b/src/screens/UserPortal/Home/Home.test.tsx index f4ca4b64ba..105714cfc8 100644 --- a/src/screens/UserPortal/Home/Home.test.tsx +++ b/src/screens/UserPortal/Home/Home.test.tsx @@ -14,6 +14,7 @@ import userEvent from '@testing-library/user-event'; import * as getOrganizationId from 'utils/getOrganizationId'; import { CREATE_POST_MUTATION } from 'GraphQl/Mutations/mutations'; import { toast } from 'react-toastify'; +import dayjs from 'dayjs'; jest.mock('react-toastify', () => ({ toast: { @@ -47,12 +48,12 @@ const MOCKS = [ lastName: 'Shelke', email: 'adidacreator1@gmail.com', }, + createdAt: dayjs(new Date()).add(1, 'day'), likeCount: 0, commentCount: 0, comments: [], likedBy: [], pinned: false, - createdAt: '2023-02-18T09:22:27.969Z', }, { _id: '6411e54835d7ba2344a78e29', @@ -66,9 +67,9 @@ const MOCKS = [ lastName: 'Shelke', email: 'adidacreator1@gmail.com', }, + createdAt: dayjs(new Date()).add(1, 'day'), likeCount: 0, commentCount: 2, - createdAt: '2023-02-18T09:22:27.969Z', comments: [ { _id: '64eb13beca85de60ebe0ed0e', diff --git a/src/utils/interfaces.ts b/src/utils/interfaces.ts index 1a41e91dfb..e90711028f 100644 --- a/src/utils/interfaces.ts +++ b/src/utils/interfaces.ts @@ -82,6 +82,7 @@ export interface InterfaceQueryOrganizationPostListItem { text: string; imageUrl: null; videoUrl: null; + createdAt: string; creator: { _id: string; firstName: string;