From 7f46ee396818f9d24bc07c893a17caf100f8f8b0 Mon Sep 17 00:00:00 2001 From: 3syth <120223314+3syth@users.noreply.github.com> Date: Thu, 9 May 2024 17:57:32 +1000 Subject: [PATCH 1/3] fix: added schema (#285) Added Offers and hasCourseInstance schema to the metadata of courses Schema Docs: https://developers.google.com/search/docs/appearance/structured-data/course-info#structured-data-type-definitions --- frontend/src/app/page.tsx | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/frontend/src/app/page.tsx b/frontend/src/app/page.tsx index 0e79f0843..f2966f093 100644 --- a/frontend/src/app/page.tsx +++ b/frontend/src/app/page.tsx @@ -42,7 +42,20 @@ export default async function Home() { ratingValue: course.reviewCount === 0 ? 0 : course.overallRating, bestRating: 5, }, - }, + offers: [{ + "@type": "Offer", + category: "Paid" + }], + hasCourseInstance: course.terms.map((term: number) => ({ + "@type": "CourseInstance", + courseMode: "Blended", + courseSchedule: { + "@type": "Schedule", + repeatCount: term === 0 ? 5 : 10, + repeatFrequency: "Weekly", + } + })) + } })), }; From ca55f1dd45abcdc6a8dccce8e561cb842c08cb81 Mon Sep 17 00:00:00 2001 From: Adrian Balbalosa <87012111+adrianbalbs@users.noreply.github.com> Date: Thu, 9 May 2024 19:03:02 +1000 Subject: [PATCH 2/3] fix: UNI-278 add else branch in getInitialDisplayCourses to reset search bar state (#284) --- frontend/src/components/CoursesList/CoursesList.tsx | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/frontend/src/components/CoursesList/CoursesList.tsx b/frontend/src/components/CoursesList/CoursesList.tsx index b0f4f4aac..2f45ba209 100644 --- a/frontend/src/components/CoursesList/CoursesList.tsx +++ b/frontend/src/components/CoursesList/CoursesList.tsx @@ -32,7 +32,7 @@ export default function CoursesList({ // default courses try { const { courses } = (await get( - `/courses?offset=${index}` + `/courses?offset=${index}`, )) as Courses; fetchedCourses = courses; } catch (err) { @@ -71,7 +71,7 @@ export default function CoursesList({ const getSearchResults = async () => { try { const { courses } = (await get( - `/course/search/${searchTerm}` + `/course/search/${searchTerm}`, )) as Courses; searchCoursesRef.current = courses; } catch (err) { @@ -84,6 +84,9 @@ export default function CoursesList({ const getInitialDisplayCourses = () => { if (searchTerm !== "") { getSearchResults(); + } else { + setDisplayCourses(initialCourses.slice(0, paginationOffset)); + setInitialLoading(false); } }; const loadOnScroll = () => { @@ -119,7 +122,7 @@ export default function CoursesList({ terms={c.terms} /> - ) + ), )} {!initialLoading ? (
No more courses
From 4f9eaa2863a0164e16b332c140d655eb753e38fd Mon Sep 17 00:00:00 2001 From: Maximilian Falco Widjaya <97402501+maximilianfalco@users.noreply.github.com> Date: Mon, 13 May 2024 18:07:36 +1000 Subject: [PATCH 3/3] chore/uni-270-desc-and-tnc-fix (#279) * feat: update devsoc branding references (#260) * chore(landing): update landing meta description * Update README.md * fixed truncated descriptions * deleted some useless code * Fixed some eedge cases and added comments * reverted some old changes regarding fetching reviews * Merge Develop To Main (#289) * fix: added schema (#285) Added Offers and hasCourseInstance schema to the metadata of courses Schema Docs: https://developers.google.com/search/docs/appearance/structured-data/course-info#structured-data-type-definitions * fix: UNI-278 add else branch in getInitialDisplayCourses to reset search bar state (#284) --------- Co-authored-by: 3syth <120223314+3syth@users.noreply.github.com> Co-authored-by: Adrian Balbalosa <87012111+adrianbalbs@users.noreply.github.com> * Fixed bug of review card showing another review's description * removed inline from review desc --------- Co-authored-by: Bob Chen <83627389+3bobchen@users.noreply.github.com> Co-authored-by: Jared L <48422312+lhjt@users.noreply.github.com> Co-authored-by: Dylan W <119717655+dylanwz@users.noreply.github.com> Co-authored-by: eaglethrostdiff --git a/frontend/src/components/TruncatedDescription/TruncatedDescription.tsx b/frontend/src/components/TruncatedDescription/TruncatedDescription.tsx index 0e2ea920d..e08fa3074 100644 --- a/frontend/src/components/TruncatedDescription/TruncatedDescription.tsx +++ b/frontend/src/components/TruncatedDescription/TruncatedDescription.tsx @@ -1,6 +1,6 @@ "use client"; -import { useState } from "react"; +import { useEffect, useState } from "react"; export default function TruncatedDescription({ content, @@ -9,26 +9,63 @@ export default function TruncatedDescription({ content: string; maxCharacters: number; }) { + const [showFullContent, setShowFullContent] = useState(false); + const [exceed, setExceed] = useState(false); + const [shortenedContent, setShortenedContent] = useState(" "); - const shortenedContent = - content.length < maxCharacters - ? content - : `${content.slice(0, maxCharacters)}...`; + /** + * If the content exceeds the maxCharacters, find the next whitespace + * and make the cutoff point there so the break does not happen mid-word + * + * If the new cutoff point is the end of the entire content, make it so + * the See More/Less button does not appear + */ + useEffect(() => { + if (content.length > maxCharacters) { + // Description exceeds max characters + setShowFullContent(false); + let newMax = maxCharacters; + let index = newMax - 1; + while (true) { + if (content[index] === ' ' || index === content.length) { + newMax = index; + break; + } + newMax++; + index++; + } + if (index === content.length) { + setShortenedContent(content); + } else { + setExceed(true); + setShortenedContent(content.slice(0, newMax) + '...'); + } + } else { + // Description length is less than maxCharacters + setShowFullContent(true); + setExceed(false); + setShortenedContent(content); + } + }, [content]) return (
- {showFullContent ? content : shortenedContent}{" "} +
+ {showFullContent ? content : shortenedContent}
- {content.length > maxCharacters && ( - - )} +