Added title in about us and updated apis
This commit is contained in:
@@ -150,6 +150,7 @@ export type AboutUssPublic = {
|
||||
export type AboutUsPublic = {
|
||||
index: number,
|
||||
description: string,
|
||||
title: string,
|
||||
image: string,
|
||||
id: string
|
||||
}
|
||||
@@ -157,12 +158,14 @@ export type AboutUsPublic = {
|
||||
export type AboutUsCreate = {
|
||||
index: number,
|
||||
description: string,
|
||||
title: string,
|
||||
image: File,
|
||||
}
|
||||
|
||||
export type AboutUsUpdate = {
|
||||
index: number,
|
||||
description: string,
|
||||
title: string,
|
||||
image?: File | undefined | null,
|
||||
}
|
||||
|
||||
|
@@ -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 }),
|
||||
|
@@ -51,7 +51,7 @@ function EditCourse() {
|
||||
return (
|
||||
<Container maxW="full">
|
||||
<Heading size="lg" textAlign={{ base: "center", md: "left" }} py={12}>
|
||||
User Settings
|
||||
Courses
|
||||
</Heading>
|
||||
<Tabs variant="enclosed">
|
||||
<TabList>
|
||||
|
@@ -76,6 +76,7 @@ function AboutUsTable() {
|
||||
<Thead>
|
||||
<Tr>
|
||||
<Th>ID</Th>
|
||||
<Th>Title</Th>
|
||||
<Th>Description</Th>
|
||||
<Th>Image</Th>
|
||||
<Th>Index</Th>
|
||||
@@ -97,6 +98,12 @@ function AboutUsTable() {
|
||||
{aboutUs?.data.map((aboutUs) => (
|
||||
<Tr key={aboutUs.id} opacity={isPlaceholderData ? 0.5 : 1}>
|
||||
<Td isTruncated maxWidth="50">{aboutUs.id}</Td>
|
||||
<Td
|
||||
whiteSpace="pre-line"
|
||||
maxWidth="350px"
|
||||
>
|
||||
{parse(aboutUs.title)}
|
||||
</Td>
|
||||
|
||||
<Td
|
||||
whiteSpace="pre-line"
|
||||
|
Reference in New Issue
Block a user