From 3799f150a8d0be6f8519103d480f7fba8c2c3cbd Mon Sep 17 00:00:00 2001 From: Sergey Yarkov Date: Mon, 25 Oct 2021 22:19:27 +0300 Subject: [PATCH] feat: create course page layout --- src/interfaces/index.ts | 6 +- .../components/CourseList/CourseItem.tsx | 4 +- .../create/components/CreateCourseForm.tsx | 62 +++++++++++++++++++ src/pages/courses/create/components/index.ts | 3 + src/pages/courses/create/create.tsx | 15 ++--- .../users/components/UserList/UserItem.tsx | 4 +- src/stores/UserStore.ts | 4 +- src/types/index.d.ts | 10 +-- vite.config.ts | 4 ++ 9 files changed, 91 insertions(+), 21 deletions(-) create mode 100644 src/pages/courses/create/components/CreateCourseForm.tsx create mode 100644 src/pages/courses/create/components/index.ts diff --git a/src/interfaces/index.ts b/src/interfaces/index.ts index b5e460b..4757bd3 100644 --- a/src/interfaces/index.ts +++ b/src/interfaces/index.ts @@ -1,5 +1,5 @@ import type { RouteComponentProps } from 'react-router-dom'; -import { CourseImage, LinkType } from '@educt/types'; +import { AttachmentFileType, LinkType } from '@educt/types'; import { CourseStatusEnum, UserRoleEnum } from '../enums'; export interface IAppConfig { @@ -18,10 +18,10 @@ export interface IToken { export interface ICourse { id: string; + image: AttachmentFileType | null; title: string; description: string; status: CourseStatusEnum; - image: null | CourseImage; teacher: Pick; category: ICategory; lessons: ILesson[]; @@ -81,6 +81,7 @@ export interface IUser { id: string; first_name: string; last_name: string; + fullname: string; email: string; roles: IUserRole[]; contacts: IUserContacts | null; @@ -90,7 +91,6 @@ export interface IUser { * Current authenticated user data */ export interface IMe extends IUser { - fullname: string; /** * The field can be undefined if the user * does not have the STUDENT role diff --git a/src/pages/courses/components/CourseList/CourseItem.tsx b/src/pages/courses/components/CourseList/CourseItem.tsx index 44d6c1c..5ea2248 100644 --- a/src/pages/courses/components/CourseList/CourseItem.tsx +++ b/src/pages/courses/components/CourseList/CourseItem.tsx @@ -111,7 +111,7 @@ const CourseItem: React.FC = ({ course, onDelete, onSetStat borderTopRightRadius='lg' p='10px' > - {course.image && ( + {course.image && course.image.url && ( = ({ course, onDelete, onSetStat w='100%' borderTopLeftRadius='lg' borderTopRightRadius='lg' - src={`/api/assets/images/courses/${course.image.name}`} + src={course.image.url} /> )} diff --git a/src/pages/courses/create/components/CreateCourseForm.tsx b/src/pages/courses/create/components/CreateCourseForm.tsx new file mode 100644 index 0000000..debec8f --- /dev/null +++ b/src/pages/courses/create/components/CreateCourseForm.tsx @@ -0,0 +1,62 @@ +import React from 'react'; +import { Box, Grid } from '@chakra-ui/react'; +import { Input } from '@chakra-ui/react'; +import { Select, Flex, Button, Textarea } from '@chakra-ui/react'; +import { FormControl, FormLabel, InputGroup, InputRightElement } from '@chakra-ui/react'; + +/** + * Types + */ +import { MdCloudUpload } from 'react-icons/md'; + +type CreateCourseFormProps = {}; + +const CreateCourseForm: React.FC = () => { + return ( + +
+ + + Title + + + + + + + + Image + + + + + Category + + + + + Teacher + + + + + Description +