Skip to content

Commit

Permalink
Drip indicators in the course viewer (#404)
Browse files Browse the repository at this point in the history
* Drip indicators in the courseviewer

* Edge cases fixes

* Typo fixes

---------

Co-authored-by: Rajat Saxena <[email protected]>
  • Loading branch information
rajat1saxena and Rajat Saxena authored Jul 8, 2024
1 parent 5f045a1 commit 92ca07a
Show file tree
Hide file tree
Showing 14 changed files with 566 additions and 544 deletions.
2 changes: 1 addition & 1 deletion apps/web/components/admin/products/editor/section.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ function SectionEditor({
);
setEmailSubject(
group.drip?.email?.subject ||
`A new section is now avaiable in ${course.title}`,
`A new section is now available in ${course.title}`,
);
setStatus(
typeof group.drip?.status === "boolean"
Expand Down
48 changes: 10 additions & 38 deletions apps/web/components/public/article.tsx
Original file line number Diff line number Diff line change
@@ -1,42 +1,42 @@
import React from "react";
import { formattedLocaleDate, isEnrolled } from "../../ui-lib/utils";
import { formattedLocaleDate } from "../../ui-lib/utils";
import { connect } from "react-redux";
import {
PriceTag,
Image,
Link,
TextRenderer,
TextEditorEmptyDoc,
Button2,
} from "@courselit/components-library";
import { ENROLL_BUTTON_TEXT, FREE_COST } from "../../ui-config/strings";
import { AppState } from "@courselit/state-management";
import { Course, Profile, SiteInfo } from "@courselit/common-models";
import { UIConstants as constants } from "@courselit/common-models";
import { checkPermission } from "@courselit/utils";

const { permissions } = constants;

interface ArticleProps {
course: Course;
options: ArticleOptionsProps;
options?: ArticleOptionsProps;
profile: Profile;
siteInfo: SiteInfo;
}

interface ArticleOptionsProps {
showAttribution?: boolean;
showEnrollmentArea?: boolean;
hideTitle?: boolean;
}

const Article = (props: ArticleProps) => {
const { course, options, profile } = props;
const { course, options = { hideTitle: false } } = props;

return (
<div className="flex flex-col">
<header>
<h1 className="text-4xl font-semibold mb-8">{course.title}</h1>
{options.showAttribution && (
{!options?.hideTitle && (
<h1 className="text-4xl font-semibold mb-8">
{course.title}
</h1>
)}
{options?.showAttribution && (
<div className="flex flex-col mb-8">
<Link href={`/profile/${course.creatorId}`}>
<p className="font-medium">{course.creatorName}</p>
Expand All @@ -59,34 +59,6 @@ const Article = (props: ArticleProps) => {
</div>
</div>
)}
{options.showEnrollmentArea &&
(profile.fetched
? !isEnrolled(course.courseId, profile) &&
checkPermission(profile.permissions, [
permissions.enrollInCourse,
])
: true) && (
<div>
<p>{profile.fetched}</p>
<div className="flex justify-between items-center">
<PriceTag
cost={course.cost}
freeCostCaption={FREE_COST}
currencyISOCode={
props.siteInfo.currencyISOCode as string
}
/>
<Link
href={`/checkout/${course.courseId}`}
sxProps={{
textDecoration: "none",
}}
>
<Button2>{ENROLL_BUTTON_TEXT}</Button2>
</Link>
</div>
</div>
)}
<div className="overflow-hidden">
<TextRenderer
json={
Expand Down
Loading

0 comments on commit 92ca07a

Please sign in to comment.