Skip to content

Commit

Permalink
course adding fixed, migrated to s3 from cloudinary
Browse files Browse the repository at this point in the history
  • Loading branch information
abinth11 committed Jul 24, 2023
1 parent faf30af commit 48c27a7
Show file tree
Hide file tree
Showing 6 changed files with 17 additions and 26 deletions.
21 changes: 17 additions & 4 deletions client/src/components/pages/addCourse/AddCourse.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,21 @@ import { addCourse } from "../../../api/endpoints/course/course";
import { toast } from "react-toastify";
import { getAllCategories } from "../../../api/endpoints/category";
import { ApiResponseCategory } from "../../../api/types/apiResponses/apiResponseCategory";
import { CourseInterface } from "../../../types/course";
interface CourseFormValues {
title: string;
duration: string;
category: string;
level: string;
tags: string;
about: string;
description: string;
syllabus: string;
requirements: string;
price: string;
[key: string]: string;
}


const initialValues = {
title: "",
duration: "",
Expand All @@ -28,9 +42,8 @@ const CombinedForm: React.FC = () => {
null
);

const handleFormSubmit = async (values: any, { resetForm }: FormikHelpers<any>) => {
const handleFormSubmit = async (values: CourseFormValues, { resetForm }: FormikHelpers<CourseFormValues>) => {
try {
console.log(values)
const formData = new FormData();
guidelines && formData.append("files", guidelines);
thumbnail && formData.append("files", thumbnail);
Expand All @@ -52,7 +65,7 @@ const CombinedForm: React.FC = () => {
const response = await getAllCategories();
setCategories(response.data);
} catch (error) {
console.log(error);
toast.error("something went wrong")
}
};

Expand Down
2 changes: 0 additions & 2 deletions client/src/components/pages/addCourse/EditCourse.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,6 @@ const EditCourse: React.FC = () => {
try {
setLoading(true);
const response = await getIndividualCourse(courseId);
console.log(response.data.data);
setCourse(response?.data?.data);
setLoading(false);
} catch (error) {
Expand All @@ -50,7 +49,6 @@ const EditCourse: React.FC = () => {
};
useEffect(() => {
if (course) {
console.log(course.title)
initialValues.title = course.title;
initialValues.category=course.category;
initialValues.description=course.description
Expand Down
16 changes: 0 additions & 16 deletions server/src/adapters/controllers/courseController.ts
Original file line number Diff line number Diff line change
Expand Up @@ -69,24 +69,8 @@ const courseController = (
const addCourse = asyncHandler(
async (req: CustomRequest, res: Response, next: NextFunction) => {
const course: AddCourseInfoInterface = req.body;
console.log(course)
const files: Express.Multer.File[] = req.files as Express.Multer.File[];
const instructorId = req.user?.Id;
// if (files) {
// const images = files
// .filter((file) => file.mimetype.startsWith('image/'))
// .map((file) => file.path);
// const videos = files
// .filter((file) => file.mimetype.startsWith('video/'))
// .map((file) => file.path);

// if (images.length > 0) {
// course.thumbnail = images[0];
// }
// if (videos.length > 0) {
// course.introductionVideo = videos[0];
// }
// }
const response = await addCourses(instructorId,course,files,cloudService, dbRepositoryCourse);
res.status(200).json({
status: 'success',
Expand Down
1 change: 0 additions & 1 deletion server/src/app/usecases/course/addCourse.ts
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,6 @@ export const addCourses = async (
courseInfo.requirements = courseInfo.requirements.split(',');
}

console.log(courseInfo);

const courseId = await courseDbRepository.addCourse(courseInfo);

Expand Down
2 changes: 0 additions & 2 deletions server/src/app/usecases/course/listCourse.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@ export const getAllCourseU = async (
courses.map(async (course) => {
if (course.thumbnail) {
course.thumbnailUrl = await cloudService.getFile(course.thumbnail.key)
console.log(course.thumbnailUrl)
}
})
);
Expand Down Expand Up @@ -44,7 +43,6 @@ export const getCourseByIdU = async (
course.guidelinesUrl = guidelines
}
};
console.log(course)
return course;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@ export const courseRepositoryMongodb = () => {
{ _id: new mongoose.Types.ObjectId(courseId) },
{ ...editInfo }
);
console.log(response);
};

const getAllCourse = async () => {
Expand Down

0 comments on commit 48c27a7

Please sign in to comment.