Added title in about us and updated apis
This commit is contained in:
		| @@ -134,7 +134,7 @@ const AddAboutUs = ({ isOpen, onClose }: AddAboutUsProps) => { | ||||
|     } | ||||
|     mutation.mutate(data) | ||||
|     console.log(data) | ||||
|      | ||||
|  | ||||
|   } | ||||
|  | ||||
|  | ||||
| @@ -152,6 +152,20 @@ const AddAboutUs = ({ isOpen, onClose }: AddAboutUsProps) => { | ||||
|           <ModalCloseButton /> | ||||
|  | ||||
|           <ModalBody pb={30}> | ||||
|             <FormControl isRequired isInvalid={!!errors.title}> | ||||
|               <FormLabel htmlFor="title">Title</FormLabel> | ||||
|               <Input | ||||
|                 id="title" | ||||
|                 {...register("title", { | ||||
|                   required: "Title is required.", | ||||
|                 })} | ||||
|                 placeholder="Title" | ||||
|                 type="text" | ||||
|               /> | ||||
|               {errors.title && ( | ||||
|                 <FormErrorMessage>{errors.title.message}</FormErrorMessage> | ||||
|               )} | ||||
|             </FormControl> | ||||
|             <FormControl isRequired isInvalid={!!errors.description}> | ||||
|               <Editor | ||||
|                 editorState={editorState} | ||||
| @@ -186,7 +200,7 @@ const AddAboutUs = ({ isOpen, onClose }: AddAboutUsProps) => { | ||||
|                   <NumberDecrementStepper /> | ||||
|                 </NumberInputStepper> | ||||
|               </NumberInput> | ||||
|               | ||||
|  | ||||
|               {errors.index && ( | ||||
|                 <FormErrorMessage>{errors.index.message}</FormErrorMessage> | ||||
|               )} | ||||
| @@ -195,7 +209,7 @@ const AddAboutUs = ({ isOpen, onClose }: AddAboutUsProps) => { | ||||
|             <FormControl isInvalid={!!errors.image} isRequired> | ||||
|               <FormLabel>{'Image Upload'}</FormLabel> | ||||
|  | ||||
|            | ||||
|  | ||||
|               <input type="file" {...register("image", { | ||||
|                 required: "index is required.", | ||||
|               })} /> | ||||
|   | ||||
| @@ -89,6 +89,7 @@ const EditAboutUs = ({ aboutUs, isOpen, onClose }: EditAboutUsProps) => { | ||||
|         criteriaMode: "all", | ||||
|         defaultValues: { | ||||
|             index: aboutUs.index, | ||||
|             title: aboutUs.title, | ||||
|             description: aboutUs.description, | ||||
|             image: undefined, | ||||
|         }, | ||||
| @@ -167,6 +168,20 @@ const EditAboutUs = ({ aboutUs, isOpen, onClose }: EditAboutUsProps) => { | ||||
|                         <Box boxSize='auto'> | ||||
|                             <Image src={url + "/" + aboutUs.image}  /> | ||||
|                         </Box> | ||||
|                         <FormControl isRequired isInvalid={!!errors.title}> | ||||
|                             <FormLabel htmlFor="title">Title</FormLabel> | ||||
|                             <Input | ||||
|                                 id="title" | ||||
|                                 {...register("title", { | ||||
|                                     required: "Title is required.", | ||||
|                                 })} | ||||
|                                 placeholder="Title" | ||||
|                                 type="text" | ||||
|                             /> | ||||
|                             {errors.title && ( | ||||
|                                 <FormErrorMessage>{errors.title.message}</FormErrorMessage> | ||||
|                             )} | ||||
|                         </FormControl> | ||||
|                         <FormControl isRequired isInvalid={!!errors.description}> | ||||
|                             <Editor | ||||
|                                 editorState={editorState} | ||||
|   | ||||
| @@ -36,7 +36,7 @@ import "react-draft-wysiwyg/dist/react-draft-wysiwyg.css"; | ||||
| const CourseDetails = () => { | ||||
|     const queryClient = useQueryClient(); | ||||
|     const courseDetails = queryClient.getQueryData(['course']) as CourseDetailsPublic | undefined; | ||||
|    | ||||
|  | ||||
|     const toolbar = { | ||||
|         options: ['inline', 'blockType', 'fontSize', 'list', 'textAlign', 'history', 'embedded', 'emoji', 'image'], | ||||
|         inline: { inDropdown: true }, | ||||
| @@ -78,9 +78,14 @@ const CourseDetails = () => { | ||||
|     }) | ||||
|  | ||||
|     useEffect(() => { | ||||
|         reset({}, { keepDirty: true }); | ||||
|         if (courseDetails) { | ||||
|             setValue('title', courseDetails.title); | ||||
|             setValue('sort_description', courseDetails.sort_description); | ||||
|             setValue('title', courseDetails.title, { shouldDirty: true }); | ||||
|             setValue('sort_description', courseDetails.sort_description, { shouldDirty: true }); | ||||
|             setValue('long_description', courseDetails.long_description, { shouldDirty: true }); | ||||
|             setValue('remark', courseDetails.remark, { shouldDirty: true }); | ||||
|             setValue('information', courseDetails.information, { shouldDirty: true }); | ||||
|             setValue('contant', courseDetails.contant, { shouldDirty: true }); | ||||
|             // Update other form fields as needed | ||||
|         } | ||||
|         if (courseDetails?.long_description) { | ||||
| @@ -89,7 +94,7 @@ const CourseDetails = () => { | ||||
|                 const contentState = ContentState.createFromBlockArray(contentBlock.contentBlocks); | ||||
|                 const editorState = EditorState.createWithContent(contentState); | ||||
|                 setLongDescriptionEditorState(editorState); | ||||
|                 setValue('long_description', longDescription); | ||||
|                 // setValue('long_description', courseDetails.long_description); | ||||
|             } | ||||
|         } | ||||
|         if (courseDetails?.remark) { | ||||
| @@ -98,7 +103,7 @@ const CourseDetails = () => { | ||||
|                 const contentState = ContentState.createFromBlockArray(contentBlock.contentBlocks); | ||||
|                 const editorState = EditorState.createWithContent(contentState); | ||||
|                 setRemarksEditorState(editorState); | ||||
|                 setValue('remark', remarks); | ||||
|                 //setValue('remark', courseDetails.remark); | ||||
|             } | ||||
|         } | ||||
|         if (courseDetails?.information) { | ||||
| @@ -107,7 +112,7 @@ const CourseDetails = () => { | ||||
|                 const contentState = ContentState.createFromBlockArray(contentBlock.contentBlocks); | ||||
|                 const editorState = EditorState.createWithContent(contentState); | ||||
|                 setInfoEditorState(editorState); | ||||
|                 setValue('information', info); | ||||
|                 //setValue('information', courseDetails.information); | ||||
|             } | ||||
|         } | ||||
|         if (courseDetails?.contant) { | ||||
| @@ -116,11 +121,10 @@ const CourseDetails = () => { | ||||
|                 const contentState = ContentState.createFromBlockArray(contentBlock.contentBlocks); | ||||
|                 const editorState = EditorState.createWithContent(contentState); | ||||
|                 setContentEditorState(editorState); | ||||
|                 setValue('contant', contents); | ||||
|                 //setValue('contant', courseDetails.contant); | ||||
|             } | ||||
|         } | ||||
|     }, [courseDetails]); | ||||
|  | ||||
|     const mutation = useMutation({ | ||||
|         mutationFn: (data: CourseCreate) => | ||||
|             CoursesService.updateCourse({ id: courseDetails?.id ?? '', requestBody: data }), | ||||
|   | ||||
		Reference in New Issue
	
	Block a user