diff --git a/src/interfaces/index.ts b/src/interfaces/index.ts index 1094eec..96881c3 100644 --- a/src/interfaces/index.ts +++ b/src/interfaces/index.ts @@ -1,5 +1,5 @@ import type { RouteComponentProps } from 'react-router-dom'; -import { AttachmentFileType, LinkType } from '@educt/types'; +import { AttachmentFileType, ColorType, LinkType } from '@educt/types'; import { CourseStatusEnum, UserRoleEnum } from '../enums'; export interface IAppConfig { @@ -39,6 +39,8 @@ export interface ILesson { course_id: string; title: string; description: string; + duration: string; + color?: ColorType | undefined | null; created_at: string; updated_at: string; } diff --git a/src/pages/courses/components/CourseList/CourseItem.tsx b/src/pages/courses/components/CourseList/CourseItem.tsx index f56cbe3..e0ccb65 100644 --- a/src/pages/courses/components/CourseList/CourseItem.tsx +++ b/src/pages/courses/components/CourseList/CourseItem.tsx @@ -4,8 +4,9 @@ import { Link as ReactRouterLink } from 'react-router-dom'; import { Badge, Image, Link, IconButton, Icon } from '@chakra-ui/react'; import { Flex, Box, Heading, Text } from '@chakra-ui/layout'; import { Menu, MenuButton, MenuItem, MenuList } from '@chakra-ui/menu'; -import { MdNote, MdMoreHoriz, MdGroup, MdThumbUp, MdVideoLibrary } from 'react-icons/md'; -import { CheckIcon, DeleteIcon, EditIcon } from '@chakra-ui/icons'; +import { MdMoreHoriz, MdGroup, MdThumbUp, MdVideoLibrary } from 'react-icons/md'; +import { AiOutlineEye, AiOutlineEyeInvisible } from 'react-icons/ai'; +import { DeleteIcon, EditIcon } from '@chakra-ui/icons'; /** * Types @@ -65,14 +66,17 @@ const CourseItem: React.FC = ({ course, onDelete, onSetStat return ( onSetStatus(course.id, CourseStatusEnum.PUBLISHED)} - icon={} + icon={} > Publish ); case CourseStatusEnum.PUBLISHED: return ( - onSetStatus(course.id, CourseStatusEnum.DRAFT)} icon={}> + onSetStatus(course.id, CourseStatusEnum.DRAFT)} + icon={} + > Mark as Draft ); diff --git a/src/pages/courses/edit/components/LessonList/LessonItem.tsx b/src/pages/courses/edit/components/LessonList/LessonItem.tsx index 0b0fe12..5719e57 100644 --- a/src/pages/courses/edit/components/LessonList/LessonItem.tsx +++ b/src/pages/courses/edit/components/LessonList/LessonItem.tsx @@ -1,8 +1,8 @@ import React from 'react'; import moment from 'moment'; -import { Flex, Box, Text, Icon, Button } from '@chakra-ui/react'; -import { EditIcon, TimeIcon } from '@chakra-ui/icons'; -import { MdLibraryBooks, MdPlayCircleOutline } from 'react-icons/md'; +import { Flex, Box, Text, Icon, Button, IconButton } from '@chakra-ui/react'; +import { DeleteIcon } from '@chakra-ui/icons'; +import { MdTimer, MdAttachment } from 'react-icons/md'; /** * Types @@ -22,59 +22,66 @@ export type LessonItemPropsType = { const LessonItem: React.FC = ({ lesson }) => { const history = useHistory(); + const handleEditLesson = (): void => history.push(`/lessons/edit/${lesson.id}`); + const handleDeleteLesson = (): void => undefined; + return ( - - - - - - {/* TODO: need to make lesson order */} - Lesson {lesson.id} - -
- {lesson.title} -
+ + + + + + - Created {moment(lesson.created_at).format('ll')}{' '} + + + 1. + + {lesson.title} + + + Sergey Yarkov + - {lesson.description} - - - - - - - 1:30:00 - - - 4 materials - - - - + + + + } + /> + + + + + + + + ~{moment(lesson.duration, 'HH:mm:ss').minutes()}min + + + + + + + + 4 attachments + + + +
diff --git a/src/pages/courses/edit/components/LessonList/LessonList.tsx b/src/pages/courses/edit/components/LessonList/LessonList.tsx index 3d4721f..28df04c 100644 --- a/src/pages/courses/edit/components/LessonList/LessonList.tsx +++ b/src/pages/courses/edit/components/LessonList/LessonList.tsx @@ -1,5 +1,5 @@ import React from 'react'; -import { Box, Stack, Text, Button } from '@chakra-ui/react'; +import { Box, Stack, Text, Button, StackDivider } from '@chakra-ui/react'; /** * Types @@ -17,29 +17,36 @@ type LessonListPropsType = { course: Omit; }; -const LessonList: React.FC = ({ render: Item, course }) => { +const CreateLessonButton: React.FC<{ id: string }> = ({ id }) => { const history = useHistory(); + const handleCreateLesson = (): void => history.push(`${id}/create-lesson`); + + return ( + + + + ); +}; + +const LessonList: React.FC = ({ render: Item, course }) => { return ( {course.lessons.length !== 0 ? ( - - {course.lessons.map(lesson => ( - - ))} - + + + {course.lessons.map(lesson => ( + + ))} + + + ) : ( - + No lessons have been added to this course yet - + )} diff --git a/src/types/index.d.ts b/src/types/index.d.ts index a8b3f04..26c52fa 100644 --- a/src/types/index.d.ts +++ b/src/types/index.d.ts @@ -28,6 +28,12 @@ export type OptionType = { label: string; }; +export type ColorType = { + id: number; + name: string; + hex: string; +}; + export type ConfirmEmailContainerDataType = { newEmail: string; expired_seconds: number;