github.com/quickfeed/quickfeed@v0.0.0-20240507093252-ed8ca812a09c/public/src/components/CourseFavoriteButton.tsx (about)

     1  import React from "react"
     2  import { Enrollment } from "../../proto/qf/types_pb"
     3  import { isVisible } from "../Helpers"
     4  import { useActions } from "../overmind"
     5  
     6  
     7  // CourseFavoriteButton is a component that displays a button to toggle the favorite status of a course.
     8  const CourseFavoriteButton = ({ enrollment, style }: { enrollment: Enrollment, style: React.CSSProperties }) => {
     9      const actions = useActions()
    10  
    11      return (
    12          // TODO: Consider creating a tooltip component.
    13          <span style={style} title="Favorite or unfavorite this course. Favorite courses will appear on your dashboard.">
    14              <i className={isVisible(enrollment) ? 'fa fa-star' : "fa fa-star-o"}
    15                  onClick={() => actions.setEnrollmentState(enrollment)} />
    16          </span>
    17      )
    18  }
    19  
    20  export default CourseFavoriteButton