Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[FIX] Events Page Violates The Figma Style Guide #3280

Merged
27 changes: 14 additions & 13 deletions src/components/EventCalendar/EventCalendar.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -198,11 +198,11 @@ const Calendar: React.FC<InterfaceCalendarProps> = ({
}
};

const handleTodayButton = (): void => {
setCurrentYear(today.getFullYear());
setCurrentMonth(today.getMonth());
setCurrentDate(today.getDate());
};
// const handleTodayButton = (): void => {
// setCurrentYear(today.getFullYear());
// setCurrentMonth(today.getMonth());
// setCurrentDate(today.getDate());
// };

const timezoneString = `UTC${
new Date().getTimezoneOffset() > 0 ? '-' : '+'
Expand Down Expand Up @@ -348,7 +348,7 @@ const Calendar: React.FC<InterfaceCalendarProps> = ({
{months[parseInt(holiday.date.slice(0, 2), 10) - 1]}{' '}
{holiday.date.slice(3)}
</span>
<span>{holiday.name}</span>
<span className={styles.holiday_name}>{holiday.name}</span>
</li>
))}
</ul>
Expand All @@ -357,21 +357,21 @@ const Calendar: React.FC<InterfaceCalendarProps> = ({
<div className={styles.events_card} role="region" aria-label="Events">
<h3 className={styles.card_title}>Events</h3>
<div className={styles.legend}>
<div className={styles.list_container}>
<span className={styles.holidayIndicator}></span>
<span className={styles.holidayText}>Holidays</span>
</div>
<div className={styles.eventsLegend}>
<span className={styles.organizationIndicator}></span>
<span className={styles.legendText}>
Events Created by Organization
</span>
</div>
<div className={styles.eventsLegend}>
{/* <div className={styles.eventsLegend}>
<span className={styles.userEvents__color}></span>
<span className={styles.legendText}>
Events Created by User
</span>
</div> */}
hustlernik marked this conversation as resolved.
Show resolved Hide resolved
<div className={styles.list_container_holidays}>
<span className={styles.holidayIndicator}></span>
<span className={styles.holidayText}>Holidays</span>
</div>
</div>
</div>
Expand Down Expand Up @@ -547,15 +547,16 @@ const Calendar: React.FC<InterfaceCalendarProps> = ({
>
<ChevronRight />
</Button>
<div>
{/* <div>
<Button
className={styles.editButton}
onClick={handleTodayButton}
data-testid="today"

>
Today
</Button>
</div>
</div> */}
</div>
)}
<div className={`${styles.calendar__scroll} customScroll`}>
Expand Down
40 changes: 28 additions & 12 deletions src/components/EventCalendar/EventHeader.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import React, { useState } from 'react';
import { Button, Form } from 'react-bootstrap';
import { Search } from '@mui/icons-material';
import SearchOutlinedIcon from '@mui/icons-material/SearchOutlined';
import AddIcon from '@mui/icons-material/Add';
import styles from '../../style/app.module.css';
import { ViewType } from '../../screens/OrganizationEvents/OrganizationEvents';
import { useTranslation } from 'react-i18next';
Expand Down Expand Up @@ -35,7 +36,10 @@ function eventHeader({
});

return (
<div className={styles.calendarEventHeader}>
<div
className={styles.calendarEventHeader}
data-testid="calendarEventHeader"
>
<div className={styles.calendar__header}>
<div className={styles.input}>
<Form.Control
Expand All @@ -57,12 +61,13 @@ function eventHeader({
/>
<Button
className={styles.searchButton}
data-testid="searchButton"
style={{ marginBottom: '10px' }}
>
<Search />
<SearchOutlinedIcon />
</Button>
</div>
<div className={styles.flex_grow}></div>
{/* <div className={styles.flex_grow}></div> */}
<div className={styles.space}>
<SortingButton
title={t('viewType')}
Expand All @@ -88,14 +93,25 @@ function eventHeader({
className={styles.dropdown}
buttonLabel={t('eventType')}
/>
<Button
variant="success"
className={styles.dropdown}
onClick={showInviteModal}
data-testid="createEventModalBtn"
>
Create Event
</Button>
<div className={styles.selectTypeEventHeader}>
<Button
variant="success"
className={styles.dropdown}
onClick={showInviteModal}
data-testid="createEventModalBtn"
>
<div className="">
<AddIcon
sx={{
fontSize: '25px',
marginBottom: '2px',
marginRight: '2px',
}}
/>
<span>Create</span>
</div>
</Button>
</div>
</div>
</div>
</div>
Expand Down
10 changes: 9 additions & 1 deletion src/components/EventCalendar/constants.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,15 @@ export const holidays = [
},
{ name: 'Christmas Day', date: '12-25', month: 'December' }, // December 25th
];
export const weekdays = ['Sun', 'Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat'];
export const weekdays = [
'Sunday',
'Monday',
'Tuesday',
'Wednesday',
'Thursday',
'Friday',
'Saturday',
];
export const months = [
'January',
'February',
Expand Down
12 changes: 0 additions & 12 deletions src/components/HolidayCards/HolidayCard.module.css

This file was deleted.

22 changes: 22 additions & 0 deletions src/components/HolidayCards/HolidayCard.spec.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
import React from 'react';
import { render, screen } from '@testing-library/react';
import { vi, describe, it, expect } from 'vitest';
import HolidayCard from './HolidayCard';

// Mock styles for testing
vi.mock('./../../style/app.module.css', () => ({
default: {},
holidayCard: 'holidayCard',
}));

describe('HolidayCard Component', () => {
it('renders correctly with the given holiday name', () => {
const holidayName = 'Christmas';

render(<HolidayCard holidayName={holidayName} />);

// Assert that the holiday name is displayed
const cardElement = screen.getByText(holidayName);
expect(cardElement).toBeInTheDocument();
});
});
hustlernik marked this conversation as resolved.
Show resolved Hide resolved
5 changes: 2 additions & 3 deletions src/components/HolidayCards/HolidayCard.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import React from 'react';
import styles from './HolidayCard.module.css';
import styles from './../../style/app.module.css';

// Props for the HolidayCard component
interface InterfaceHolidayList {
Expand All @@ -13,8 +13,7 @@
* @returns JSX element representing a card with the holiday name.
*/
const HolidayCard = (props: InterfaceHolidayList): JSX.Element => {
/*istanbul ignore next*/
return <div className={styles.card}>{props?.holidayName}</div>;
return <div className={styles.holidayCard}>{props?.holidayName}</div>;

Check warning on line 16 in src/components/HolidayCards/HolidayCard.tsx

View check run for this annotation

Codecov / codecov/patch

src/components/HolidayCards/HolidayCard.tsx#L16

Added line #L16 was not covered by tests
};

export default HolidayCard;
10 changes: 1 addition & 9 deletions src/screens/UserPortal/Events/Events.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -121,8 +121,6 @@ export default function events(): JSX.Element {
createChat: createChatCheck,
},
});

/* istanbul ignore next */
if (createEventData) {
toast.success(t('eventCreated') as string);
refetch();
Expand All @@ -137,7 +135,6 @@ export default function events(): JSX.Element {
setCreateEventmodalisOpen(false);
} catch (error: unknown) {
console.error('create event error', error);
/* istanbul ignore next */
errorHandler(t, error);
}
};
Expand All @@ -147,7 +144,6 @@ export default function events(): JSX.Element {
*
* @returns Void.
*/
/* istanbul ignore next */
const toggleCreateEventModal = (): void =>
setCreateEventmodalisOpen(!createEventModal);

Expand Down Expand Up @@ -188,7 +184,6 @@ export default function events(): JSX.Element {
};

// Update the list of events when the data from the query changes
/* istanbul ignore next */
React.useEffect(() => {
if (data) {
setEvents(data.eventsByOrganizationConnection);
Expand All @@ -200,7 +195,6 @@ export default function events(): JSX.Element {
*
* @returns Void.
*/
/* istanbul ignore next */
const showInviteModal = (): void => {
setCreateEventmodalisOpen(true);
};
Expand All @@ -211,9 +205,7 @@ export default function events(): JSX.Element {
* @param item - The view type to set, or null to reset.
* @returns Void.
*/
/* istanbul ignore next */
const handleChangeView = (item: string | null): void => {
/*istanbul ignore next*/
if (item) {
setViewType(item as ViewType);
}
Expand All @@ -222,7 +214,7 @@ export default function events(): JSX.Element {
return (
<>
<div className={`d-flex flex-row`}>
<div className={`${styles.mainContainer}`}>
<div className={`${styles.mainContainerEvent}`}>
<EventHeader
viewType={viewType}
showInviteModal={showInviteModal}
Expand Down
Loading
Loading