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

Add a dock clear button #648

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 23 additions & 0 deletions frontend/degree-plan/components/Dock/Dock.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ import AccountIndicator from "pcx-shared-components/src/accounts/AccountIndicato
import _ from 'lodash';
import CoursePlanned from '../FourYearPlan/CourseInPlan';
import CourseInDock from './CourseInDock';
import { CourseXButton } from "../Course/Course";

const DockWrapper = styled.div`
z-index: 1;
Expand Down Expand Up @@ -74,6 +75,17 @@ const DockedCourses = styled.div`
overflow: auto;
`

const CloseIcon = styled.div`
cursor: pointer;
opacity: 0.5;
display: flex;
align-items: center;
justify-content: flex-end;
&:hover {
opacity: 1;
}
`;

const CenteringCourseDock = styled.div`
color: var(--primary-color-extra-dark);
margin-left: auto;
Expand Down Expand Up @@ -140,6 +152,11 @@ const Dock = ({ user, login, logout, activeDegreeplanId }: DockProps) => {
// }
// }, [isMount, dockedCourses]);

const { remove } = useSWRCrud<DockedCourse>(`/api/degree/docked`, { idKey: 'full_code' });
const handleRemoveCourse = (full_code: string) => {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

convention: fullCode

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Screenshot 2024-04-09 at 3 59 35 PM 👀

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yeah we've been using full_code. That might not be a good pattern (mb if so), but tbh I think this OK for now.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Will defer to @esinx here, but if we want to clean this up, we should probably do so at the entire project level and likely after we solve the user facing issues

remove(full_code);
}

return (
<DockWrapper ref={drop} >
<DockContainer $isDroppable={canDrop} $isOver={isOver}>
Expand Down Expand Up @@ -183,6 +200,12 @@ const Dock = ({ user, login, logout, activeDegreeplanId }: DockProps) => {
{dockedCourses.map((course) =>
<AnimatedDockedCourseItem course={course} isDisabled={false} />
)}
<CloseIcon>
<CourseXButton onClick={(e) => {
temps.forEach((course) => handleRemoveCourse(course.full_code));
JHawk0224 marked this conversation as resolved.
Show resolved Hide resolved
e.stopPropagation();
}} hidden={false}/>
</CloseIcon>
</DockedCourses>}
</DockedCoursesWrapper>
<Logo src='pdp-logo.svg' width='30' height='45'/>
Expand Down