From 4548d9dc626cbe600ce35ca9e3534726cc693a95 Mon Sep 17 00:00:00 2001 From: Pranav Nathe <93403830+pranavnathe@users.noreply.github.com> Date: Sun, 5 Jan 2025 22:24:58 +0530 Subject: [PATCH] #2883 Refactor CSS files in miscellaneous components (#3116) * src/components/UpdateSession/UpdateSession.css * src/components/UserListCard/UserListCard.module.css * Refactor src/components/UserPasswordUpdate/UserPasswordUpdate.module.css * src/components/Venues/VenueModal.module.css * src/components/EventCalendar/YearlyEventCalender.module.css * Refactor src/components/AgendaItems/AgendaItemsContainer.module.css * Refactor src/components/AddOn/core/AddOnStore/AddOnStore.module.css * Refactor src/components/Advertisements/Advertisements.module.css * Refactor src/components/Advertisements/core/AdvertisementRegister/AdvertisementRegister.module.css * Refactor src/components/EventCalendar/EventCalendar.module.css * Refactor src/components/EventListCard/EventListCard.module.css * Refactor CSS OrgPostCard.module.css && fixed eslint destructuring props error * Refactor src/components/OrgSettings/ActionItemCategories/OrgActionItemCategories.module.css * CSS fix * consolidating button styles in greenregbtnUserPasswordUpdate * CSS bugfixes * Replaced hardcoded color values to CSS variables * removed role from .calendar__weekdays and .calendar__days * refactor: extract DeletePostModal from OrgPostCard to fix file-length test * TSDoc added for src/components/OrgPostCard/DeletePostModal.tsx * removed duplicate cursor property --- .../core/AddOnStore/AddOnStore.module.css | 72 - .../AddOn/core/AddOnStore/AddOnStore.tsx | 35 +- .../Advertisements/Advertisements.module.css | 47 - .../Advertisements/Advertisements.tsx | 27 +- .../AdvertisementRegister.module.css | 57 - .../AdvertisementRegister.tsx | 9 +- .../AgendaItemsContainer.module.css | 230 --- .../AgendaItems/AgendaItemsContainer.tsx | 4 +- .../AgendaItems/AgendaItemsCreateModal.tsx | 8 +- .../AgendaItems/AgendaItemsDeleteModal.tsx | 2 +- .../AgendaItems/AgendaItemsPreviewModal.tsx | 4 +- .../AgendaItems/AgendaItemsUpdateModal.tsx | 8 +- .../EventCalendar/EventCalendar.module.css | 572 ------- .../EventCalendar/EventCalendar.tsx | 6 +- src/components/EventCalendar/EventHeader.tsx | 15 +- .../YearlyEventCalender.module.css | 354 ---- .../EventCalendar/YearlyEventCalender.tsx | 16 +- .../EventListCard/EventListCard.module.css | 223 --- .../EventListCard/EventListCard.tsx | 6 +- .../EventListCard/EventListCardModals.tsx | 26 +- .../OrgPostCard/DeletePostModal.spec.tsx | 77 + .../OrgPostCard/DeletePostModal.tsx | 65 + .../OrgPostCard/OrgPostCard.module.css | 278 --- src/components/OrgPostCard/OrgPostCard.tsx | 191 +-- .../ActionItemCategories/CategoryModal.tsx | 2 +- .../OrgActionItemCategories.module.css | 138 -- .../OrgActionItemCategories.tsx | 14 +- .../UpdateSession/UpdateSession.css | 96 -- .../UpdateSession/UpdateSession.tsx | 26 +- .../UserListCard/UserListCard.module.css | 74 - src/components/UserListCard/UserListCard.tsx | 7 +- .../UserPasswordUpdate.module.css | 97 -- .../UserPasswordUpdate/UserPasswordUpdate.tsx | 8 +- src/components/Venues/VenueModal.module.css | 53 - src/components/Venues/VenueModal.tsx | 2 +- src/style/app.module.css | 1521 +++++++++++++++++ 36 files changed, 1862 insertions(+), 2508 deletions(-) delete mode 100644 src/components/AddOn/core/AddOnStore/AddOnStore.module.css delete mode 100644 src/components/Advertisements/Advertisements.module.css delete mode 100644 src/components/Advertisements/core/AdvertisementRegister/AdvertisementRegister.module.css delete mode 100644 src/components/AgendaItems/AgendaItemsContainer.module.css delete mode 100644 src/components/EventCalendar/EventCalendar.module.css delete mode 100644 src/components/EventCalendar/YearlyEventCalender.module.css delete mode 100644 src/components/EventListCard/EventListCard.module.css create mode 100644 src/components/OrgPostCard/DeletePostModal.spec.tsx create mode 100644 src/components/OrgPostCard/DeletePostModal.tsx delete mode 100644 src/components/OrgPostCard/OrgPostCard.module.css delete mode 100644 src/components/OrgSettings/ActionItemCategories/OrgActionItemCategories.module.css delete mode 100644 src/components/UpdateSession/UpdateSession.css delete mode 100644 src/components/UserListCard/UserListCard.module.css delete mode 100644 src/components/UserPasswordUpdate/UserPasswordUpdate.module.css delete mode 100644 src/components/Venues/VenueModal.module.css diff --git a/src/components/AddOn/core/AddOnStore/AddOnStore.module.css b/src/components/AddOn/core/AddOnStore/AddOnStore.module.css deleted file mode 100644 index 9f5bb6c868..0000000000 --- a/src/components/AddOn/core/AddOnStore/AddOnStore.module.css +++ /dev/null @@ -1,72 +0,0 @@ -.container { - display: flex; -} - -.logintitle { - color: #707070; - font-weight: 600; - font-size: 20px; - margin-bottom: 30px; - padding-bottom: 5px; - border-bottom: 3px solid #31bb6b; - width: 15%; -} -.input { - display: flex; - position: relative; - width: 560px; -} -/* .actioninput { - text-decoration: none; - margin-bottom: 50px; - border-color: #e8e5e5; - width: 80%; - border-radius: 7px; - padding-top: 5px; - padding-bottom: 5px; - padding-right: 10px; - padding-left: 10px; - box-shadow: none; -} */ -.actioninput { - margin-top: 10px; - margin-bottom: 10px; - background-color: white; - box-shadow: 0 1px 1px #31bb6b; -} -.inputField > button { - padding-top: 10px; - padding-bottom: 10px; -} - -.actionradio input { - width: fit-content; - margin: inherit; -} -.cardGridItem { - width: 38vw; -} -.justifysp { - display: grid; - width: 100%; - justify-content: space-between; - align-items: baseline; - grid-template-rows: auto; - grid-template-columns: repeat(2, 1fr); - grid-gap: 0.8rem 0.4rem; -} - -@media screen and (max-width: 600px) { - .cardGridItem { - width: 100%; - } - .justifysp { - display: grid; - width: 100%; - justify-content: center; - align-items: start; - grid-template-rows: auto; - grid-template-columns: 1fr; - grid-gap: 0.8rem 0.4rem; - } -} diff --git a/src/components/AddOn/core/AddOnStore/AddOnStore.tsx b/src/components/AddOn/core/AddOnStore/AddOnStore.tsx index 90a32d9bb3..3da19f8a51 100644 --- a/src/components/AddOn/core/AddOnStore/AddOnStore.tsx +++ b/src/components/AddOn/core/AddOnStore/AddOnStore.tsx @@ -1,5 +1,5 @@ import React, { useState } from 'react'; -import styles from './AddOnStore.module.css'; +import styles from '../../../../style/app.module.css'; import AddOnEntry from '../AddOnEntry/AddOnEntry'; import { useQuery } from '@apollo/client'; import { PLUGIN_GET } from 'GraphQl/Queries/Queries'; // PLUGIN_LIST @@ -122,36 +122,19 @@ function addOnStore(): JSX.Element { return ( <> - - -
+ + +
setSearchText(e.target.value)} /> -
@@ -199,7 +182,7 @@ function addOnStore(): JSX.Element { title={t('available')} style={{ backgroundColor: 'white' }} > -
+
{(() => { const filteredPlugins = filterPlugins( data?.getPlugins || [], @@ -211,7 +194,7 @@ function addOnStore(): JSX.Element { } return ( -
+
{filteredPlugins.map((plug, i) => (
-
+
{(() => { const installedPlugins = (data?.getPlugins || []).filter( (plugin) => !plugin.uninstalledOrgs.includes(orgId ?? ''), diff --git a/src/components/Advertisements/Advertisements.module.css b/src/components/Advertisements/Advertisements.module.css deleted file mode 100644 index 6d9eb7f612..0000000000 --- a/src/components/Advertisements/Advertisements.module.css +++ /dev/null @@ -1,47 +0,0 @@ -.container { - display: flex; -} -.listBox { - display: grid; - width: 100%; - grid-template-rows: auto; - grid-template-columns: repeat(6, 1fr); - grid-gap: 0.8rem 0.4rem; -} - -.logintitle { - color: #707070; - font-weight: 600; - font-size: 20px; - margin-bottom: 30px; - padding-bottom: 5px; - border-bottom: 3px solid #31bb6b; - width: 15%; -} -.input { - display: flex; - position: relative; - width: 560px; -} -.justifysp { - display: grid; - width: 100%; - margin-top: 30px; -} -.actioninput { - text-decoration: none; - /* margin-bottom: 50px; */ - border-color: #e8e5e5; - background-color: white; - border-radius: 7px; - padding-top: 10px; - padding-bottom: 10px; - padding-right: 10px; - padding-left: 10px; - box-shadow: none; -} - -.actionradio input { - width: fit-content; - margin: inherit; -} diff --git a/src/components/Advertisements/Advertisements.tsx b/src/components/Advertisements/Advertisements.tsx index 5f0e2b2033..f428b569a0 100644 --- a/src/components/Advertisements/Advertisements.tsx +++ b/src/components/Advertisements/Advertisements.tsx @@ -1,5 +1,5 @@ import React, { useEffect, useState } from 'react'; -import styles from './Advertisements.module.css'; +import styles from '../../style/app.module.css'; import { useQuery } from '@apollo/client'; import { ORGANIZATION_ADVERTISEMENT_LIST } from 'GraphQl/Queries/Queries'; import { Button, Col, Form, Row, Tab, Tabs } from 'react-bootstrap'; @@ -79,29 +79,20 @@ export default function advertisements(): JSX.Element { return ( <> - -
- -
+ +
+ +
setSearchText("search")} /> -
@@ -145,7 +136,7 @@ export default function advertisements(): JSX.Element { orgAdvertisementListData?.organizations[0].advertisements .pageInfo.hasNextPage ?? false } - className={styles.listBox} + className={styles.listBoxAdvertisements} data-testid="organizations-list" endMessage={ advertisements.filter( @@ -221,7 +212,7 @@ export default function advertisements(): JSX.Element { orgAdvertisementListData?.organizations[0].advertisements .pageInfo.hasNextPage ?? false } - className={styles.listBox} + className={styles.listBoxAdvertisements} data-testid="organizations-list" endMessage={ advertisements.filter( diff --git a/src/components/Advertisements/core/AdvertisementRegister/AdvertisementRegister.module.css b/src/components/Advertisements/core/AdvertisementRegister/AdvertisementRegister.module.css deleted file mode 100644 index 9d009cf021..0000000000 --- a/src/components/Advertisements/core/AdvertisementRegister/AdvertisementRegister.module.css +++ /dev/null @@ -1,57 +0,0 @@ -.modalbtn { - margin-top: 1rem; - display: flex !important; - margin-left: auto; - align-items: center; -} - -.modalbtn i, -.button i { - height: min-content; - margin-right: 4px; -} - -.preview { - display: flex; - position: relative; - width: 100%; - margin-top: 10px; - justify-content: center; -} -.preview img { - width: 400px; - height: auto; -} -.preview video { - width: 400px; - height: auto; -} - -.closeButton { - position: absolute; - top: 0px; - right: 0px; - background: transparent; - transform: scale(1.2); - cursor: pointer; - border: none; - color: #707070; - font-weight: 600; - font-size: 16px; - cursor: pointer; -} - -.button { - min-width: 102px; -} - -.editHeader { - background-color: #31bb6b; - color: white; -} - -.link_check { - display: flex; - justify-content: center; - align-items: flex-start; -} diff --git a/src/components/Advertisements/core/AdvertisementRegister/AdvertisementRegister.tsx b/src/components/Advertisements/core/AdvertisementRegister/AdvertisementRegister.tsx index c347ae8959..e329ce6855 100644 --- a/src/components/Advertisements/core/AdvertisementRegister/AdvertisementRegister.tsx +++ b/src/components/Advertisements/core/AdvertisementRegister/AdvertisementRegister.tsx @@ -314,7 +314,10 @@ function advertisementRegister({ }} /> {formState.advertisementMedia && ( -
+
{formState.advertisementMedia.includes('video') ? (
-
+
{renderMonthDays()}
diff --git a/src/components/EventListCard/EventListCard.module.css b/src/components/EventListCard/EventListCard.module.css deleted file mode 100644 index 1e47972a42..0000000000 --- a/src/components/EventListCard/EventListCard.module.css +++ /dev/null @@ -1,223 +0,0 @@ -.cards h2 { - font-size: 15px; - color: #4e4c4c; - font-weight: 500; -} -.cards > h3 { - font-size: 17px; -} -.cards > p { - font-size: 14px; - margin-top: 0px; - margin-bottom: 7px; -} -.cards a { - color: #fff; - font-weight: 600; -} -.cards a:hover { - color: black; -} -.cards { - position: relative; - overflow: hidden; - transition: all 0.3s; - margin-bottom: 5px; -} -.dispflex { - display: flex; - cursor: pointer; - justify-content: space-between; - margin: 10px 5px 5px 0px; -} -.eventtitle { - margin-bottom: 0px; - text-overflow: ellipsis; - overflow: hidden; - white-space: nowrap; -} -.iconContainer { - display: flex; - justify-content: flex-end; -} -.icon { - margin: 2px; -} - -.cards { - width: 100%; - background: #5cacf7 !important; - padding: 2px 3px; - border-radius: 5px; - border: 1px solid #e8e8e8; - box-shadow: 0 3px 2px #e8e8e8; - color: #737373; - box-sizing: border-box; -} -.cards:last-child:nth-last-child(odd) { - grid-column: auto / span 2; -} - -.cards:first-child:nth-last-child(even), -.cards:first-child:nth-last-child(even) ~ .box { - grid-column: auto / span 1; -} - -.sidebarsticky > input { - text-decoration: none; - margin-bottom: 50px; - border-color: #e8e5e5; - width: 80%; - border-radius: 7px; - padding-top: 5px; - padding-bottom: 5px; - padding-right: 10px; - padding-left: 10px; - box-shadow: none; -} -.datediv { - display: flex; - flex-direction: row; - margin-top: 5px; - margin-bottom: 5px; -} -.datebox { - width: 90%; - border-radius: 7px; - border-color: #e8e5e5; - outline: none; - box-shadow: none; - padding-top: 2px; - padding-bottom: 2px; - padding-right: 5px; - padding-left: 5px; -} -.datediv > div > p { - margin-bottom: 0.5rem; -} - -.startDate { - margin-right: 0.25rem; -} -.endDate { - margin-left: 1.5rem; -} - -.checkboxdiv > div label { - margin-right: 50px; -} -.checkboxdiv > label > input { - margin-left: 10px; -} - -.dispflex > input { - width: 20%; - border: none; - box-shadow: none; - margin-top: 5px; -} - -.checkboxContainer { - display: flex; - justify-content: space-between; -} - -.checkboxdiv { - display: flex; - flex-direction: column; -} - -.preview { - display: flex; - flex-direction: row; - font-weight: 700; - font-size: 16px; - color: #000000; - margin: 0; -} -.view { - margin-left: 2%; - font-weight: 600; - font-size: 16px; - color: #707070; -} -.flexdir { - display: flex; - flex-direction: row; - justify-content: space-between; - border: none; -} - -.form_wrapper { - margin-top: 27px; - top: 50%; - left: 50%; - transform: translate(-50%, -50%); - position: absolute; - display: flex; - flex-direction: column; - padding: 20px 30px; - background: #ffffff; - border-color: #e8e5e5; - border-width: 5px; - border-radius: 10px; - width: 40%; -} - -.form_wrapper form { - display: flex; - align-items: left; - justify-content: left; - flex-direction: column; -} -.titlemodal { - color: #000000; - font-weight: 600; - font-size: 24px; - margin-bottom: 20px; - padding-bottom: 5px; - border-bottom: 4px solid #31bb6b; - width: 50%; -} -.cancel > i { - margin-top: 5px; - transform: scale(1.2); - cursor: pointer; - color: #707070; -} -.modalbody { - width: 50px; -} -.list_box { - height: 70vh; - overflow-y: auto; - width: auto; -} -@media only screen and (max-width: 600px) { - .form_wrapper { - width: 90%; - top: 45%; - } - .checkboxContainer { - flex-direction: column; - } - - .datediv { - flex-direction: column; - } - - .datediv > div { - width: 100%; - margin-left: 0; - margin-bottom: 10px; - } - - .datediv > div p { - margin-bottom: 5px; - } -} - -.customButton { - width: 90%; - margin: 0 auto; -} diff --git a/src/components/EventListCard/EventListCard.tsx b/src/components/EventListCard/EventListCard.tsx index ffa508ff7c..dba2ef4541 100644 --- a/src/components/EventListCard/EventListCard.tsx +++ b/src/components/EventListCard/EventListCard.tsx @@ -1,6 +1,6 @@ import React, { useState } from 'react'; import { useTranslation } from 'react-i18next'; -import styles from './EventListCard.module.css'; +import styles from '../../style/app.module.css'; import { Navigate, useParams } from 'react-router-dom'; import EventListCardModals from './EventListCardModals'; import type { InterfaceRecurrenceRule } from 'utils/recurrenceUtils'; @@ -74,14 +74,14 @@ function eventListCard(props: InterfaceEventListCardProps): JSX.Element { return ( <>
-
+

{props.eventName ? <>{props.eventName} : <>Dogs Care}

diff --git a/src/components/EventListCard/EventListCardModals.tsx b/src/components/EventListCard/EventListCardModals.tsx index 7755da2a5a..6f93c709fd 100644 --- a/src/components/EventListCard/EventListCardModals.tsx +++ b/src/components/EventListCard/EventListCardModals.tsx @@ -1,6 +1,6 @@ import React, { useEffect, useState } from 'react'; import { Button, Form, Modal, Popover } from 'react-bootstrap'; -import styles from './EventListCard.module.css'; +import styles from '../../style/app.module.css'; import { DatePicker, TimePicker } from '@mui/x-date-pickers'; import dayjs from 'dayjs'; import type { Dayjs } from 'dayjs'; @@ -401,7 +401,9 @@ function EventListCardModals({
-

{t('eventTitle')}

+

+ {t('eventTitle')} +

-

{tCommon('description')}

+

+ {tCommon('description')} +

-

{tCommon('location')}

+

+ {tCommon('location')} +

)}
-
-
+
+
-
+
-
-
+
+
-
+
{ + it('renders the delete modal with correct text', () => { + const mockOnHide = vi.fn(); + const mockOnDelete = vi.fn(); + + render( + + + , + ); + + expect(screen.getByTestId('delete-post-modal')).toBeInTheDocument(); + expect(screen.getByText(/delete post/i)).toBeInTheDocument(); + expect( + screen.getByText(/do you want to remove this post\?/i), + ).toBeInTheDocument(); + }); + + it('hides the modal when "No" is clicked', () => { + const mockOnHide = vi.fn(); + const mockOnDelete = vi.fn(); + + render( + + + , + ); + + fireEvent.click(screen.getByTestId('deleteModalNoBtn')); + expect(mockOnHide).toHaveBeenCalledTimes(1); + expect(mockOnDelete).not.toHaveBeenCalled(); + }); + + it('calls onDelete and onHide when "Yes" is clicked', () => { + const mockOnHide = vi.fn(); + const mockOnDelete = vi.fn(); + + render( + + + , + ); + + fireEvent.click(screen.getByTestId('deletePostBtn')); + expect(mockOnDelete).toHaveBeenCalledTimes(1); + expect(mockOnHide).toHaveBeenCalledTimes(1); + }); + + it('does not render the modal when show is false', () => { + const { queryByTestId } = render( + + + , + ); + expect(queryByTestId('delete-post-modal')).not.toBeInTheDocument(); + }); +}); diff --git a/src/components/OrgPostCard/DeletePostModal.tsx b/src/components/OrgPostCard/DeletePostModal.tsx new file mode 100644 index 0000000000..67f301ba72 --- /dev/null +++ b/src/components/OrgPostCard/DeletePostModal.tsx @@ -0,0 +1,65 @@ +import React, { type FC } from 'react'; +import { Modal, Button } from 'react-bootstrap'; +import { useTranslation } from 'react-i18next'; + +/** + * A modal component that confirms a post delete operation. + * + * @param show - Whether the modal is visible. + * @param onHide - Callback invoked when the modal is dismissed. + * @param onDelete - Callback invoked to actually delete the post. + * @returns A rendered React Bootstrap Modal for post deletion. + */ + +interface InterfaceDeletePostModalProps { + show: boolean; + onHide: () => void; + onDelete: () => void; +} + +const DeletePostModal: FC = ({ + show, + onHide, + onDelete, +}) => { + const { t } = useTranslation('translation', { + keyPrefix: 'orgPostCard', + }); + const { t: tCommon } = useTranslation('common'); + + const handleConfirmDelete = (): void => { + onDelete(); + onHide(); + }; + + return ( + + +
{t('deletePost')}
+ +
+ {t('deletePostMsg')} + + + + +
+ ); +}; + +export default DeletePostModal; diff --git a/src/components/OrgPostCard/OrgPostCard.module.css b/src/components/OrgPostCard/OrgPostCard.module.css deleted file mode 100644 index c7ff8073d2..0000000000 --- a/src/components/OrgPostCard/OrgPostCard.module.css +++ /dev/null @@ -1,278 +0,0 @@ -.cards h2 { - font-size: 20px; -} -.cards > h3 { - font-size: 17px; -} -.card { - width: 100%; - height: 20rem; - margin-bottom: 2rem; -} -.postimage { - border-radius: 0px; - width: 100%; - height: 12rem; - max-width: 100%; - max-height: 12rem; - object-fit: cover; - position: relative; - color: black; -} -.preview { - display: flex; - position: relative; - width: 100%; - margin-top: 10px; - justify-content: center; -} -.preview img { - width: 400px; - height: auto; -} -.preview video { - width: 400px; - height: auto; -} -.nopostimage { - border-radius: 0px; - width: 100%; - height: 12rem; - max-height: 12rem; - object-fit: cover; - position: relative; -} -.cards:hover { - filter: brightness(0.8); -} -.cards:hover::before { - opacity: 0.5; -} -.knowMoreText { - position: absolute; - top: 50%; - left: 50%; - transform: translate(-50%, -50%); - opacity: 0; - color: white; - padding: 10px; - font-weight: bold; - font-size: 1.5rem; - transition: opacity 0.3s ease-in-out; -} - -.cards:hover .knowMoreText { - opacity: 1; -} -.modal { - position: fixed; - top: 0; - left: 0; - width: 100%; - height: 100%; - display: flex; - align-items: center; - justify-content: center; - background-color: rgba( - 0, - 0, - 0, - 0.9 - ); /* Dark grey modal background with transparency */ - z-index: 9999; -} - -.modalContent { - display: flex; - align-items: center; - justify-content: center; - background-color: #fff; - padding: 20px; - max-width: 800px; - max-height: 600px; - overflow: auto; -} - -.modalImage { - flex: 1; - margin-right: 20px; - width: 25rem; - height: 15rem; -} -.nomodalImage { - flex: 1; - margin-right: 20px; - width: 100%; - height: 15rem; -} - -.modalImage img, -.modalImage video { - border-radius: 0px; - width: 100%; - height: 25rem; - max-width: 25rem; - max-height: 15rem; - object-fit: cover; - position: relative; -} -.modalInfo { - flex: 1; -} -.title { - font-size: 16px; - color: #000; - font-weight: 600; -} -.text { - font-size: 13px; - color: #000; - font-weight: 300; -} -.author { - color: #737373; - font-weight: 100; - font-size: 13px; -} -.closeButton { - position: relative; - bottom: 5rem; - right: 10px; - padding: 4px; - background-color: red; /* Red close button color */ - color: #fff; - border: none; - cursor: pointer; -} -.closeButtonP { - position: absolute; - top: 0px; - right: 0px; - background: transparent; - transform: scale(1.2); - cursor: pointer; - border: none; - color: #707070; - font-weight: 600; - font-size: 16px; - cursor: pointer; -} -.cards:hover::after { - opacity: 1; - mix-blend-mode: normal; -} -.cards > p { - font-size: 14px; - margin-top: 0px; - margin-bottom: 7px; -} -.cards a { - color: #737373; - font-weight: 600; -} -.cards a:hover { - color: black; -} -.infodiv { - margin-bottom: 7px; - width: 15rem; - text-align: justify; - word-wrap: break-word; -} -.infodiv > p { - margin: 0; -} -.dispflex { - display: flex; - justify-content: space-between; -} -.iconContainer { - display: flex; -} -.icon { - transform: scale(0.75); - cursor: pointer; -} -/* .cards { - width: 75%; - background: #fcfcfc; - margin: 10px 40px; - padding: 20px 30px; - border-radius: 5px; - border: 1px solid #e8e8e8; - box-shadow: 0 3px 5px #c9c9c9; - margin-right: 30px; - color: #737373; - box-sizing: border-box; -} */ -.cards:last-child:nth-last-child(odd) { - grid-column: auto / span 2; -} -.cards:first-child:nth-last-child(even), -.cards:first-child:nth-last-child(even) ~ .box { - grid-column: auto / span 1; -} -.toggleClickBtn { - color: #31bb6b; - cursor: pointer; - border: none; - font-size: 12px; - background-color: white; -} -.toggleClickBtnNone { - display: none; -} -/* Menu Modal Styles */ -.menuModal { - position: fixed; - top: 0; - left: 0; - width: 100%; - height: 100%; - display: flex; - align-items: center; - justify-content: center; - background-color: rgba(0, 0, 0, 0.7); /* Dark grey modal background */ - z-index: 9999; -} - -.menuContent { - display: flex; - align-items: center; - justify-content: center; - background-color: #fff; - padding-top: 20px; - max-width: 700px; - max-height: 500px; - overflow: hidden; - position: relative; -} - -.menuOptions { - list-style-type: none; - padding: 0; - margin: 0; -} - -.menuOptions li { - padding: 10px; - border-bottom: 1px solid #ccc; - padding-left: 100px; - padding-right: 100px; - cursor: pointer; -} - -.moreOptionsButton { - position: relative; - bottom: 5rem; - right: 10px; - padding: 2px; - background-color: transparent; - color: #000; - border: none; - cursor: pointer; -} -.list { - color: red; - cursor: pointer; -} diff --git a/src/components/OrgPostCard/OrgPostCard.tsx b/src/components/OrgPostCard/OrgPostCard.tsx index b7cc419d12..5bc9ca1407 100644 --- a/src/components/OrgPostCard/OrgPostCard.tsx +++ b/src/components/OrgPostCard/OrgPostCard.tsx @@ -14,7 +14,8 @@ import { toast } from 'react-toastify'; import convertToBase64 from 'utils/convertToBase64'; import { errorHandler } from 'utils/errorHandler'; import type { InterfacePostForm } from 'utils/interfaces'; -import styles from './OrgPostCard.module.css'; +import styles from '../../style/app.module.css'; +import DeletePostModal from './DeletePostModal'; interface InterfaceOrgPostCardProps { postID: string; id: string; @@ -29,8 +30,14 @@ export default function OrgPostCard( props: InterfaceOrgPostCardProps, ): JSX.Element { const { - postID, // Destructure the key prop from props - // ...rest // Spread the rest of the props + postID, + id, + postTitle, + postInfo, + postAuthor, + postPhoto, + postVideo, + pinned, } = props; const [postformState, setPostFormState] = useState({ posttitle: '', @@ -51,11 +58,7 @@ export default function OrgPostCard( const [toggle] = useMutation(TOGGLE_PINNED_POST); const togglePostPin = async (id: string, pinned: boolean): Promise => { try { - const { data } = await toggle({ - variables: { - id, - }, - }); + const { data } = await toggle({ variables: { id } }); if (data) { setModalVisible(false); setMenuVisible(false); @@ -66,7 +69,6 @@ export default function OrgPostCard( } } catch (error: unknown) { if (error instanceof Error) { - /* istanbul ignore next */ errorHandler(t, error); } } @@ -100,10 +102,7 @@ export default function OrgPostCard( setMenuVisible(true); }; const clearImageInput = (): void => { - setPostFormState({ - ...postformState, - postphoto: '', - }); + setPostFormState({ ...postformState, postphoto: '' }); setPostPhotoUpdated(true); const fileInput = document.getElementById( 'postImageUrl', @@ -150,11 +149,11 @@ export default function OrgPostCard( } useEffect(() => { setPostFormState({ - posttitle: props.postTitle, - postinfo: props.postInfo, - postphoto: props.postPhoto, - postvideo: props.postVideo, - pinned: props.pinned, + posttitle: postTitle, + postinfo: postInfo, + postphoto: postPhoto, + postvideo: postVideo, + pinned: pinned, }); }, []); const { t } = useTranslation('translation', { @@ -166,9 +165,7 @@ export default function OrgPostCard( const deletePost = async (): Promise => { try { const { data } = await deletePostMutation({ - variables: { - id: props.id, - }, + variables: { id }, }); if (data) { toast.success(t('postDeleted') as string); @@ -197,7 +194,7 @@ export default function OrgPostCard( try { const { data } = await updatePostMutation({ variables: { - id: props.id, + id: id, title: postformState.posttitle, text: postformState.postinfo, ...(postPhotoUpdated && { @@ -228,13 +225,13 @@ export default function OrgPostCard( data-testid="post-item" >
- {props.postVideo && ( + {postVideo && ( - + - {props.pinned && ( + {pinned && ( )} - - {props.postTitle} + + {postTitle} - - {props.postInfo} + + {postInfo} - - {props.postAuthor} - + {postAuthor} )} - {props.postPhoto ? ( - + {postPhoto ? ( + - {props.pinned && ( + {pinned && ( )} - - {props.postTitle} + + {postTitle} - {props.postInfo} - {props.postAuthor} + + {postInfo} + + {postAuthor} - ) : !props.postVideo ? ( + ) : !postVideo ? ( - + - {props.pinned && ( + {pinned && ( )} - - {props.postTitle} + + {postTitle} - - {props.postInfo && props.postInfo.length > 20 - ? props.postInfo.substring(0, 20) + '...' - : props.postInfo} + + {postInfo && postInfo.length > 20 + ? postInfo.substring(0, 20) + '...' + : postInfo} {' '} - - {props.postAuthor} - + {postAuthor} @@ -325,21 +326,24 @@ export default function OrgPostCard( )}
{modalVisible && ( -
-
- {props.postPhoto && ( +
+
+ {postPhoto && (
- Post Image + Post Image
)} - {props.postVideo && ( + {postVideo && (
)} - {!props.postPhoto && !props.postVideo && ( + {!postPhoto && !postVideo && (
{' '} Post Image @@ -347,23 +351,23 @@ export default function OrgPostCard( )}

- {t('author')}: {props.postAuthor} + {t('author')}: {postAuthor}

{togglePost === 'Read more' ? (

- {props.postInfo.length > 43 - ? props.postInfo.substring(0, 40) + '...' - : props.postInfo} + {postInfo.length > 43 + ? postInfo.substring(0, 40) + '...' + : postInfo}

) : ( -

{props.postInfo}

+

{postInfo}

)}
- - -
{t('deletePost')}
- -
- {t('deletePostMsg')} - - - - -
+ deletePost()} + /> - {!props.postPhoto && ( + {!postPhoto && ( <> {t('image')} - {props.postPhoto && ( + {postPhoto && ( <> {postformState.postphoto && ( -
+
Post Image Preview )} - {!props.postVideo && ( + {!postVideo && ( <> {t('video')} {postformState.postvideo && ( -
+