Skip to content

Commit

Permalink
Merge pull request #320 from calisio/fixes
Browse files Browse the repository at this point in the history
UI Fixes Pt3
  • Loading branch information
PThorpe92 authored Jul 25, 2024
2 parents 552e59c + 5145c32 commit 65ad4be
Show file tree
Hide file tree
Showing 4 changed files with 40 additions and 27 deletions.
5 changes: 3 additions & 2 deletions backend/src/database/users.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,11 +19,12 @@ func (db *DB) GetCurrentUsers(page, itemsPerPage int, facilityId uint, order str
var count int64
var users []models.User
if err := db.Conn.Model(models.User{}).
Where("facility_id = ?", facilityId).
Count(&count).
Offset(offset).
Limit(itemsPerPage).
Order(order).
Find(&users, "facility_id = ?", facilityId).
Count(&count).
Find(&users).
Error; err != nil {
log.Printf("Error fetching users: %v", err)
return 0, nil, err
Expand Down
26 changes: 17 additions & 9 deletions frontend/src/Components/CatalogCourseCard.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import YellowPill from "./pill-labels/YellowPill";
import axios from "axios";
import { ViewType } from "./ToggleView";
import GreyPill from "./pill-labels/GreyPill";
import { MouseEvent } from "react";

export interface CatalogCourseCard {
name: string;
Expand Down Expand Up @@ -39,7 +40,8 @@ export default function CatalogCourseCard({
const coverImage = course.thumbnail_url;
const program_type: PillTagType = course.program_type as PillTagType;

function updateFavorite() {
function updateFavorite(e: MouseEvent) {
e.preventDefault();
axios
.put(`/api/programs/${course.program_id}/save`)
.then((response) => {
Expand Down Expand Up @@ -87,32 +89,38 @@ export default function CatalogCourseCard({
return (
<>
{view == ViewType.List ? (
<div className="card bg-base-teal body-small p-6 flex flex-row items-center">
<a
className="card bg-base-teal body-small p-6 flex flex-row items-center"
href={course.external_url}
target="_blank"
>
<div className="flex flex-col justify-between gap-3">
<div className="flex flex-row gap-3 items-center">
<div onClick={() => updateFavorite()}>{bookmark}</div>
<div onClick={(e) => updateFavorite(e)}>{bookmark}</div>
<h2>{course.program_name}</h2>
<p className="body">|</p>
<a href={course.provider_platform_url} className="body">
{course.provider_name}
</a>
<p className="body">{course.provider_name}</p>
{programPill}
{outcomePills}
</div>
<p className="body-small h-[1rem] line-clamp-2 overflow-hidden">
{course.description}
</p>
</div>
</div>
</a>
) : (
<div className="card card-compact bg-base-teal overflow-hidden relative">
<div
className="absolute top-2 right-2"
onClick={() => updateFavorite()}
onClick={(e) => updateFavorite(e)}
>
{bookmark}
</div>
<a href={course.url} target="_blank" rel="noopener noreferrer">
<a
href={course.external_url}
target="_blank"
rel="noopener noreferrer"
>
<figure className="h-[124px]">
{coverImage !== "" ? (
<img
Expand Down
34 changes: 19 additions & 15 deletions frontend/src/Components/EnrolledCourseCard.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,8 @@ export default function EnrolledCourseCard({
let status: CourseStatus;
if (course.course_progress == 100) status = CourseStatus.Completed;

function updateFavorite() {
function updateFavorite(e) {
e.preventDefault();
axios
.put(`/api/programs/${course.id}/save`)
.then((response) => {
Expand All @@ -45,19 +46,24 @@ export default function EnrolledCourseCard({
return (
<>
{view == ViewType.List ? (
<div className="card bg-inner-background flex flex-row items-center justify-between body-small p-6">
<a
className="card bg-inner-background flex flex-row items-center justify-between body-small p-6"
href={url}
target="_blank"
rel="noopener noreferrer"
>
<div className="flex flex-row gap-3 items-center">
{!recent &&
(course.is_favorited ? (
<StarIcon className="h-5 text-primary-yellow"></StarIcon>
) : (
<StarIconOutline className="h-5 text-header-text"></StarIconOutline>
))}
<div onClick={(e) => updateFavorite(e)}>
{!recent &&
(course.is_favorited ? (
<StarIcon className="h-5 text-primary-yellow"></StarIcon>
) : (
<StarIconOutline className="h-5 text-header-text"></StarIconOutline>
))}
</div>
<h2>{course.program_name}</h2>
<p className="body">|</p>
<a href={course.provider_platform_url} className="body">
{course.provider_platform_name}
</a>
<p className="body">{course.provider_platform_name}</p>
</div>
{status == CourseStatus.Completed ? (
<div className="flex flex-row gap-2 body-small text-teal-3">
Expand All @@ -72,16 +78,14 @@ export default function EnrolledCourseCard({
<ProgressBar percent={Math.floor(course.course_progress)} />
</div>
)}
</div>
</a>
) : (
<div
className={`card card-compact ${recent ? "bg-inner-background" : "bg-base-teal"} overflow-hidden relative`}
>
<div
className="absolute top-2 right-2"
onClick={() => {
updateFavorite();
}}
onClick={(e) => updateFavorite(e)}
>
{!recent &&
(course.is_favorited ? (
Expand Down
2 changes: 1 addition & 1 deletion frontend/src/Components/ResourcesSideBar.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ const KolibriCard = () => {
for all learning levels.
</p>
{/* Temporary-- replace with external link to Kolibri */}
<ExternalLink url="https://learningequality.org/kolibri/">
<ExternalLink url="https://kolibri.v2.unlockedlabs.xyz">
Explore Kolibri's Content
</ExternalLink>
</div>
Expand Down

0 comments on commit 65ad4be

Please sign in to comment.