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

Removing live course access concept #1191

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
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
31 changes: 3 additions & 28 deletions components/cards/CourseCard.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
import Circle from '@mui/icons-material/Circle';
import Event from '@mui/icons-material/Event';
import KeyboardArrowDown from '@mui/icons-material/KeyboardArrowDown';
import PendingOutlined from '@mui/icons-material/PendingOutlined';
import {
Expand All @@ -19,7 +17,6 @@ import { useRouter } from 'next/router';
import { useState } from 'react';
import { PROGRESS_STATUS } from '../../constants/enums';
import { iconTextRowStyle, rowStyle } from '../../styles/common';
import { courseIsLiveNow, courseIsLiveSoon } from '../../utils/courseLiveStatus';
import { formatDateToString } from '../../utils/dateTime';
import Link from '../common/Link';
import ProgressStatus from '../common/ProgressStatus';
Expand Down Expand Up @@ -71,20 +68,17 @@ const statusRowStyle = {
interface CourseCardProps {
course: ISbStoryData;
courseProgress: PROGRESS_STATUS | null;
liveCourseAccess: boolean;
clickable?: boolean;
}

const CourseCard = (props: CourseCardProps) => {
const { course, courseProgress, liveCourseAccess, clickable = true } = props;
const { course, courseProgress, clickable = true } = props;
const [expanded, setExpanded] = useState<boolean>(false);
const t = useTranslations('Courses');
const router = useRouter();
const locale = router.locale || 'en';

const courseComingSoon: boolean = course.content.coming_soon;
const courseLiveSoon: boolean = courseIsLiveSoon(course.content);
const courseLiveNow: boolean = courseIsLiveNow(course.content);

const handleExpandClick = () => {
setExpanded(!expanded);
Expand Down Expand Up @@ -145,32 +139,13 @@ const CourseCard = (props: CourseCardProps) => {
</CardContent>
)}
<CardActions sx={cardActionsStyle}>
{courseComingSoon && (!courseLiveSoon || !liveCourseAccess) && (
{courseComingSoon && !courseLiveSoon && (
<Box sx={statusRowStyle}>
<PendingOutlined color="error" />
<Typography>{t('comingSoon')}</Typography>
</Box>
)}
{courseLiveSoon && liveCourseAccess && (
<Box sx={statusRowStyle}>
<Event color="error" />
<Typography>
{t.rich('liveFrom', {
date: formatDateToString(course.content.live_start_date, locale),
})}
</Typography>
</Box>
)}
{courseLiveNow && liveCourseAccess && (
<Box sx={statusRowStyle}>
<Circle color="error" />
<Typography>
{t.rich('liveUntil', {
date: formatDateToString(course.content.live_end_date, locale),
})}
</Typography>
</Box>
)}


<IconButton
sx={{ marginLeft: 'auto' }}
Expand Down
3 changes: 0 additions & 3 deletions pages/courses/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,6 @@ const CourseList: NextPage<Props> = ({ stories }) => {
const courses = useTypedSelector((state) => state.courses);

const eventUserData = getEventUserData(userCreatedAt, partnerAccesses, partnerAdmin);
const liveCourseAccess = !!userId; // soon to be retired in issue 1176
const t = useTranslations('Courses');

const headerProps = {
Expand Down Expand Up @@ -163,7 +162,6 @@ const CourseList: NextPage<Props> = ({ stories }) => {
key={course.id}
course={course}
courseProgress={courseProgress}
liveCourseAccess={liveCourseAccess}
/>
);
})}
Expand All @@ -177,7 +175,6 @@ const CourseList: NextPage<Props> = ({ stories }) => {
key={course.id}
course={course}
courseProgress={courseProgress}
liveCourseAccess={liveCourseAccess}
/>
);
})}
Expand Down
Loading