Skip to content

Commit

Permalink
Ap/no notifications husky page (#265)
Browse files Browse the repository at this point in the history
* Add empty subscriptions logic

* Create EmptyCard component

* Add styling and assets

* Update styling of EmptyCard

* Modified styling, added on hover image change functionality

* edited line-heights

* resolved sass-lint errors

* actually resolved sass-lint errors

* really actually resolved sass-lint errors this time

* Update Empyt Card to include term data.

* Move styles from _Results to new _EmptyCard to declutter.

* Remove empty card styles from _Results

* Revert styles, fix empty card props. subscriptions page requires retrieval of Term name.

* Empty Card Semester Name updates automatically

Properly migrate styles to new _EmptyCard file

* - remove unused leading-trim module

- fix styles in classcard, use function notation

- Redirect Empty card to empty results page.

* remove default from ClassCard export

* Add unsubscribe button functionality

* Notif course fetching refactor

* Remove local config

* Remove yarn install state

* Add pill to subscription class card

* fix lint colors issue

---------

Co-authored-by: Anzhuo-W <[email protected]>
Co-authored-by: cherman27 <[email protected]>
Co-authored-by: mehallhm <[email protected]>
  • Loading branch information
4 people authored Dec 4, 2024
1 parent 445e7f0 commit 0dad192
Show file tree
Hide file tree
Showing 12 changed files with 613 additions and 174 deletions.
1 change: 0 additions & 1 deletion components/ResultsPage/DropdownFilter.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,6 @@ export default function DropdownFilter({
setIsOpen(true);
}
}}

/>
<DropdownArrow
aria-label="Dropdown arrow"
Expand Down
23 changes: 15 additions & 8 deletions components/SubscriptionsPage/ClassCard.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import { DesktopSectionPanel } from '../ResultsPage/Results/SectionPanel';
import { getFormattedSections } from '../ResultsPage/ResultsLoader';
import DropdownArrow from '../icons/DropdownArrow.svg';
import CourseCheckBox from '../panels/CourseCheckBox';
import { SectionPill } from './SectionPill';

type ClassCardWrapperType = {
headerLeft: ReactElement;
Expand All @@ -13,18 +14,17 @@ type ClassCardWrapperType = {
afterBody?: ReactElement;
};

const ClassCardWrapper = ({
export const ClassCardWrapper = ({
headerLeft,
headerRight,
body,
afterBody,
}: ClassCardWrapperType): ReactElement => {
return (
<div className="SearchResult">
<div className="SearchResult__header">
<div className="SearchResult__header--left">{headerLeft}</div>
{headerRight}
</div>
<div>{headerLeft}</div>
{headerRight}

{body}
{afterBody}
</div>
Expand All @@ -39,13 +39,13 @@ type ClassCardType = {
onSignIn: (token: string) => void;
};

export const ClassCard = ({
export function ClassCard({
course,
sections,
userInfo,
fetchUserInfo,
onSignIn,
}: ClassCardType): ReactElement => {
}: ClassCardType): ReactElement {
const sectionsFormatted: Section[] = getFormattedSections(sections);
const [areSectionsHidden, setAreSectionsHidden] = useState(true);

Expand All @@ -66,6 +66,13 @@ export const ClassCard = ({
lastUpdateTime={course.lastUpdateTime}
className="SearchResult__header--sub"
/>
{course.sections.map((section) => (
<SectionPill
key={section.crn}
userInfo={userInfo}
crn={section.crn}
></SectionPill>
))}
</>
}
headerRight={<button>Unsubscribe</button>}
Expand Down Expand Up @@ -146,4 +153,4 @@ export const ClassCard = ({
}
/>
);
};
}
74 changes: 74 additions & 0 deletions components/SubscriptionsPage/EmptyCard.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
import { ReactElement } from 'react';
import React, { useState } from 'react';
import { ClassCardWrapper } from './ClassCard';
import { useRouter } from 'next/router';
import Circular from '../icons/circular.svg';
import CryingHusky from '../icons/crying-husky.svg';
import HappyHusky from '../icons/happy-husky.svg';
import getTermInfosWithError from '../../utils/TermInfoProvider';
import { getTermName } from '../terms';

export const EmptyCard = (): ReactElement => {
const router = useRouter();
const [isHovering, setIsHovering] = useState(false);

const termInfos = getTermInfosWithError().termInfos;
const termId = router.query.termId as string;
const termName = getTermName(termInfos, termId).replace('Semester', '');

return (
<>
<div className="Empty_Container">
<div className="Empty_MainWrapper">
<div className="Empty_Main">
<div className="Empty_Main__EmptyCard">
<div className="Empty_Main_EmptyCard_Header">
<div className="Empty_Main__EmptyCard_Header_Spacer">
<div className="Empty_Main__EmptyCard_Header_Title">
<b>{termName} Notifications</b>
</div>
</div>
{isHovering ? (
<div className="Happy_Husky_SVG">
<HappyHusky />
</div>
) : (
<div className="Crying_Husky_SVG">
<CryingHusky />
</div>
)}
</div>
<ClassCardWrapper
headerLeft={
<div className="Empty_Main__EmptyCard_Text">
<div className="Empty_Main__EmptyCard_Text_Title">
<b>You currently have no notifications. Hoosky sad :(</b>
</div>
<div className="Empty_Main__EmptyCard_Text_Body">
Be the first to know when new classes and sections drop!
</div>
</div>
}
headerRight={
<div
className="Empty_Main__EmptyCard_Divider"
onClick={() => {
router.push(`/NEU/${termId}/search`);
}}
onMouseEnter={() => setIsHovering(true)}
onMouseLeave={() => setIsHovering(false)}
>
<button className="Empty_Main__EmptyCard_Button">
<Circular />
<b>Search for classes</b>
</button>
</div>
}
/>
</div>
</div>
</div>
</div>
</>
);
};
26 changes: 26 additions & 0 deletions components/SubscriptionsPage/SectionPill.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
import { ReactElement } from 'react';
import Keys from '../Keys';
import { UserInfo } from '../types';

type SectionPillProps = {
crn: string;
userInfo: UserInfo;
};

export const SectionPill = ({
crn,
userInfo,
}: SectionPillProps): ReactElement => {
return (
<div className="SectionPill">
<div
className={`SectionPill__subscribed ${
userInfo && userInfo.courseIds.includes(Keys.getClassHash(crn))
? 'SectionPill__subscribed--active'
: ''
}`}
></div>
<div className="SectionPill__text">{crn}</div>
</div>
);
};
12 changes: 12 additions & 0 deletions components/icons/circular.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading

0 comments on commit 0dad192

Please sign in to comment.