From 6d72fdb1c33340ffc745db3c262994a841d91fba Mon Sep 17 00:00:00 2001 From: Sergey Yarkov Date: Fri, 5 Nov 2021 21:56:18 +0300 Subject: [PATCH] refactor: user updating --- src/components/FileSelect/FileSelect.tsx | 2 +- src/components/FileSelect/index.ts | 3 + .../create/components/CreateCourseForm.tsx | 19 +-- .../CreateUserForm/CreateUserForm.tsx | 98 ++++++++------- .../components/EditUserForm/EditUserForm.tsx | 116 ++++++++++++------ .../EditUserForm/EditUserForm.validator.ts | 15 ++- .../users/components/UserList/UserList.tsx | 8 +- src/services/UserService.ts | 2 +- 8 files changed, 166 insertions(+), 97 deletions(-) create mode 100644 src/components/FileSelect/index.ts diff --git a/src/components/FileSelect/FileSelect.tsx b/src/components/FileSelect/FileSelect.tsx index a48c03b..5b1a0d0 100644 --- a/src/components/FileSelect/FileSelect.tsx +++ b/src/components/FileSelect/FileSelect.tsx @@ -1,5 +1,6 @@ import React, { useState, useRef } from 'react'; import { Flex, Box, Text } from '@chakra-ui/layout'; +import { Input } from '@chakra-ui/input'; import { Button } from '@chakra-ui/button'; import { MdAttachFile } from 'react-icons/md'; import * as helpres from '@educt/helpers'; @@ -8,7 +9,6 @@ import * as helpres from '@educt/helpers'; * Hooks */ import { useColorModeValue } from '@chakra-ui/color-mode'; -import { Input } from '@chakra-ui/input'; type FileSelectPropsType = { onChange: (file: File) => void; diff --git a/src/components/FileSelect/index.ts b/src/components/FileSelect/index.ts new file mode 100644 index 0000000..ca781f9 --- /dev/null +++ b/src/components/FileSelect/index.ts @@ -0,0 +1,3 @@ +import FileSelect from './FileSelect'; + +export default FileSelect; diff --git a/src/pages/courses/create/components/CreateCourseForm.tsx b/src/pages/courses/create/components/CreateCourseForm.tsx index 021c881..a96a5f2 100644 --- a/src/pages/courses/create/components/CreateCourseForm.tsx +++ b/src/pages/courses/create/components/CreateCourseForm.tsx @@ -13,10 +13,11 @@ import { InputRightElement, Input, } from '@chakra-ui/react'; -import { MdAttachFile, MdCloudUpload } from 'react-icons/md'; +import { MdCloudUpload } from 'react-icons/md'; import { SubmitHandler, useForm, useWatch, Controller } from 'react-hook-form'; import { yupResolver } from '@hookform/resolvers/yup'; import AsyncSelect from '@educt/components/AsyncSelect'; +import FileSelect from '@educt/components/FileSelect'; /** * Types @@ -30,14 +31,12 @@ import { CourseStatusEnum, UserRoleEnum } from '@educt/enums'; import { useHistory } from 'react-router'; import { useRootStore } from '@educt/hooks/useRootStore'; import { useErrorHandler } from 'react-error-boundary'; -import { useColorModeValue } from '@chakra-ui/color-mode'; import useIsMountedRef from '@educt/hooks/useIsMountedRef'; /** * Schema */ import CreateCourseSchema from './CreateCourseForm.validator'; -import FileSelect from '@educt/components/FileSelect/FileSelect'; type CreateCourseInputType = { title: string; @@ -154,7 +153,7 @@ const CreateCourseForm: React.FC = () => {
- + Title @@ -186,7 +185,7 @@ const CreateCourseForm: React.FC = () => { - + Category = () => { {errors.category_id?.message} - + Teacher = () => { {errors.teacher_id?.message} - + Description