fix: some refactor

This commit is contained in:
Sergey Yarkov 2022-01-05 19:08:41 +03:00
parent ce46c7a739
commit fab649ee18
2 changed files with 12 additions and 5 deletions

View File

@ -1,9 +1,17 @@
import { yupResolver } from '@hookform/resolvers/yup';
import React from 'react'; import React from 'react';
import { yupResolver } from '@hookform/resolvers/yup';
import { SubmitHandler, useForm } from 'react-hook-form'; import { SubmitHandler, useForm } from 'react-hook-form';
import { LessonForm } from '.';
import type { InputFields } from './LessonForm'; import type { InputFields } from './LessonForm';
import { LessonForm } from '.';
/**
* Validator
*/
import LessonFormSchema from './LessonForm.validator'; import LessonFormSchema from './LessonForm.validator';
/**
* Hooks
*/
import { useCreateLesson } from '@educt/hooks/queries'; import { useCreateLesson } from '@educt/hooks/queries';
import { useHistory, useParams } from 'react-router-dom'; import { useHistory, useParams } from 'react-router-dom';
@ -14,7 +22,7 @@ const CreateLessonForm: React.FC = () => {
const history = useHistory(); const history = useHistory();
const onSubmit: SubmitHandler<InputFields> = async data => { const onSubmit: SubmitHandler<InputFields> = async data => {
const lesson = await createLesson({ await createLesson({
title: data.title, title: data.title,
description: data.description, description: data.description,
duration: data.duration, duration: data.duration,
@ -22,7 +30,6 @@ const CreateLessonForm: React.FC = () => {
materials: Array.from(data.materials || []), materials: Array.from(data.materials || []),
course_id, course_id,
}); });
console.log(`created: ${lesson}`);
history.push(`/courses/edit/${course_id}`); history.push(`/courses/edit/${course_id}`);
}; };

View File

@ -71,7 +71,7 @@ class LessonService {
* @param ids Ordered ids of lessons * @param ids Ordered ids of lessons
* @returns Empty data * @returns Empty data
*/ */
public async saveOrder(ids: string[]): Promise<IApiRespose<any>> { public async saveOrder(ids: string[]): Promise<IApiRespose<Record<string, unknown>>> {
const result = await this.api.post('/v1/lessons/save-order', { const result = await this.api.post('/v1/lessons/save-order', {
ids, ids,
}); });