diff --git a/apps/web/app/assets/svgs/index.ts b/apps/web/app/assets/svgs/index.ts index 55d89f4de..946e37ed6 100644 --- a/apps/web/app/assets/svgs/index.ts +++ b/apps/web/app/assets/svgs/index.ts @@ -19,6 +19,7 @@ export { default as User } from "./user.svg?react"; export { default as Course } from "./course.svg?react"; export { default as Category } from "./category.svg?react"; export { default as UploadImageIcon } from "./upload-image.svg?react"; +export { default as TrashIcon } from "./trash-icon.svg?react"; export { default as Lesson } from "./lesson.svg?react"; export { default as LessonContent } from "./lesson-content.svg?react"; export { default as Email } from "./email.svg?react"; diff --git a/apps/web/app/assets/svgs/trash-icon.svg b/apps/web/app/assets/svgs/trash-icon.svg new file mode 100644 index 000000000..3712b71c4 --- /dev/null +++ b/apps/web/app/assets/svgs/trash-icon.svg @@ -0,0 +1,3 @@ + + + diff --git a/apps/web/app/components/FileUploadInput/ImageUploadInput.tsx b/apps/web/app/components/FileUploadInput/ImageUploadInput.tsx index 2b09432d1..dd9802d6b 100644 --- a/apps/web/app/components/FileUploadInput/ImageUploadInput.tsx +++ b/apps/web/app/components/FileUploadInput/ImageUploadInput.tsx @@ -12,24 +12,30 @@ interface ImageUploadProps { const ImageUploadInput = ({ field, handleImageUpload, isUploading }: ImageUploadProps) => { return (
-
+
{field.value && ( Uploaded )} +
+ - {!field.value && ( -
- +
+ + {field.value ? "Click to replace" : "Click to upload"} + + or drag and drop
- )} - {!field.value && ( -
- Click to upload - or drag and drop +
+ {field.value ? "SVG, PNG, JPG (max. to 20MB)" : "SVG, PNG, JPG or GIF (max. 800x400px)"}
- )} - +
- {!field.value && ( -
- SVG, PNG, JPG or GIF (max. 20MB) -
- )}
); diff --git a/apps/web/app/modules/Admin/AddCourse/AddCourse.tsx b/apps/web/app/modules/Admin/AddCourse/AddCourse.tsx index 6732eff81..861f29c08 100644 --- a/apps/web/app/modules/Admin/AddCourse/AddCourse.tsx +++ b/apps/web/app/modules/Admin/AddCourse/AddCourse.tsx @@ -8,7 +8,6 @@ import ImageUploadInput from "~/components/FileUploadInput/ImageUploadInput"; import { Icon } from "~/components/Icon"; import Editor from "~/components/RichText/Editor"; import { Button } from "~/components/ui/button"; -import { Card } from "~/components/ui/card"; import { Form, FormControl, FormField, FormItem, FormMessage } from "~/components/ui/form"; import { Input } from "~/components/ui/input"; import { Label } from "~/components/ui/label"; @@ -28,7 +27,7 @@ const AddCourse = () => { const { data: categories } = useCategoriesSuspense(); const [isUploading, setIsUploading] = useState(false); const { mutateAsync: uploadFile } = useUploadFile(); - const { isValid: isFormValid, isDirty } = form.formState; + const { isValid: isFormValid } = form.formState; const watchedImageUrl = form.watch("imageUrl"); const imageUrl = form.getValues("imageUrl"); @@ -49,12 +48,10 @@ const AddCourse = () => { return (
-
- - splashScreenImage - +
+ splashScreenImage
-
+
)} -
- - +
+
+ + +
diff --git a/apps/web/app/modules/Admin/AddCourse/hooks/useAddCourseForm.tsx b/apps/web/app/modules/Admin/AddCourse/hooks/useAddCourseForm.tsx index c899d764f..86f5a55b2 100644 --- a/apps/web/app/modules/Admin/AddCourse/hooks/useAddCourseForm.tsx +++ b/apps/web/app/modules/Admin/AddCourse/hooks/useAddCourseForm.tsx @@ -17,7 +17,6 @@ export const useAddCourseForm = () => { defaultValues: { title: "", description: "", - state: "draft", categoryId: "", imageUrl: "", }, @@ -25,10 +24,10 @@ export const useAddCourseForm = () => { const onSubmit = (values: AddCourseFormValues) => { createCourse({ - data: { ...values }, + data: { ...values, state: "draft" }, }).then(({ data }) => { queryClient.invalidateQueries({ queryKey: ALL_COURSES_QUERY_KEY }); - navigate(`/admin/courses/${data.id}`); + navigate(`/admin/beta-courses/${data.id}`); }); }; diff --git a/apps/web/app/modules/Admin/AddCourse/validators/addCourseFormSchema.ts b/apps/web/app/modules/Admin/AddCourse/validators/addCourseFormSchema.ts index 5535fc7c4..8ded61a77 100644 --- a/apps/web/app/modules/Admin/AddCourse/validators/addCourseFormSchema.ts +++ b/apps/web/app/modules/Admin/AddCourse/validators/addCourseFormSchema.ts @@ -3,7 +3,6 @@ import { z } from "zod"; export const addCourseFormSchema = z.object({ title: z.string().min(2, "Title must be at least 2 characters."), description: z.string().min(2, "Description must be at least 2 characters."), - state: z.enum(["draft", "published"]), categoryId: z.string().min(1, "Category is required"), imageUrl: z.union([z.string().url("Invalid image URL"), z.string().length(0)]).optional(), }); diff --git a/apps/web/app/modules/Admin/EditCourse/CourseSettings/CourseSettings.tsx b/apps/web/app/modules/Admin/EditCourse/CourseSettings/CourseSettings.tsx index b74e2e3bf..c71d2402a 100644 --- a/apps/web/app/modules/Admin/EditCourse/CourseSettings/CourseSettings.tsx +++ b/apps/web/app/modules/Admin/EditCourse/CourseSettings/CourseSettings.tsx @@ -4,6 +4,7 @@ import { useCallback, useMemo, useState } from "react"; import { useUploadFile } from "~/api/mutations/admin/useUploadFile"; import { useCategoriesSuspense } from "~/api/queries/useCategories"; import ImageUploadInput from "~/components/FileUploadInput/ImageUploadInput"; +import { Icon } from "~/components/Icon"; import Editor from "~/components/RichText/Editor"; import { Button } from "~/components/ui/button"; import { Card, CardContent, CardHeader } from "~/components/ui/card"; @@ -68,7 +69,7 @@ const CourseSettings = ({ title, description, categoryId, imageUrl }: CourseSett return (
- +
Basic settings
@@ -82,8 +83,8 @@ const CourseSettings = ({ title, description, categoryId, imageUrl }: CourseSett render={({ field }) => ( @@ -98,7 +99,7 @@ const CourseSettings = ({ title, description, categoryId, imageUrl }: CourseSett render={({ field }) => ( @@ -120,7 +121,7 @@ const CourseSettings = ({ title, description, categoryId, imageUrl }: CourseSett render={({ field }) => (