diff --git a/backend/app/alembic/versions/94afd163eba3_add_title_in_aboutus.py b/backend/app/alembic/versions/94afd163eba3_add_title_in_aboutus.py new file mode 100644 index 0000000..386abc8 --- /dev/null +++ b/backend/app/alembic/versions/94afd163eba3_add_title_in_aboutus.py @@ -0,0 +1,29 @@ +"""add title in aboutUs + +Revision ID: 94afd163eba3 +Revises: 8e38378fd2f3 +Create Date: 2024-10-05 10:26:21.093141 + +""" +from alembic import op +import sqlalchemy as sa +import sqlmodel.sql.sqltypes + + +# revision identifiers, used by Alembic. +revision = '94afd163eba3' +down_revision = '8e38378fd2f3' +branch_labels = None +depends_on = None + + +def upgrade(): + # ### commands auto generated by Alembic - please adjust! ### + op.add_column('aboutus', sa.Column('title', sqlmodel.sql.sqltypes.AutoString(length=255), nullable=False)) + # ### end Alembic commands ### + + +def downgrade(): + # ### commands auto generated by Alembic - please adjust! ### + op.drop_column('aboutus', 'title') + # ### end Alembic commands ### diff --git a/backend/app/api/routes/aboutUs.py b/backend/app/api/routes/aboutUs.py index c2007f4..f1c8009 100644 --- a/backend/app/api/routes/aboutUs.py +++ b/backend/app/api/routes/aboutUs.py @@ -24,6 +24,7 @@ async def create_aboutUs( session: SessionDep, current_user: CurrentUser, description: str = Form(), + title: str = Form(), image: Annotated[UploadFile, File()], index: int = Form() ) -> Any: @@ -33,7 +34,7 @@ async def create_aboutUs( validate_file_size_type(image) imageUrl = await save_picture(file=image, folderName="tmp") # aboutus_in.image = imageUrl - aboutUs_in = AboutUsCreate(description=description, image=imageUrl, index=index) + aboutUs_in = AboutUsCreate(description=description, image=imageUrl, index=index ,title=title) aboutUs = AboutUs.from_orm(aboutUs_in) session.add(aboutUs) session.commit() @@ -49,6 +50,7 @@ async def edit_aboutUs( id: uuid.UUID, description: str = Form(), image: Annotated[UploadFile, File()] = None, + title: str = Form(), index: int = Form() ) -> Any: aboutUs = session.get(AboutUs, id) @@ -57,9 +59,9 @@ async def edit_aboutUs( validate_file_size_type(image) imageUrl = await save_picture(file=image, folderName="tmp") await del_picture(aboutUs.image) - aboutUs_in = AboutsUpdate(description=description, image=imageUrl, index=index) + aboutUs_in = AboutsUpdate(description=description, image=imageUrl, index=index, title=title) else : - aboutUs_in = AboutsUpdate(description=description, image=aboutUs.image, index=index) + aboutUs_in = AboutsUpdate(description=description, image=aboutUs.image, index=index, title=title) update_dict = aboutUs_in.model_dump(exclude_unset=True) aboutUs.sqlmodel_update(update_dict) diff --git a/backend/app/main.py b/backend/app/main.py index f02650e..f6e7c42 100644 --- a/backend/app/main.py +++ b/backend/app/main.py @@ -26,7 +26,7 @@ if settings.BACKEND_CORS_ORIGINS: CORSMiddleware, allow_origins=[ str(origin).strip("/") for origin in settings.BACKEND_CORS_ORIGINS - ] + ["http://localhost:3000"], + ] + ["http://localhost:3000"]+["http://localhost:5173"]+["http://localhost:5173/aboutUs"], allow_credentials=True, allow_methods=["*"], allow_headers=["*"], diff --git a/backend/app/models.py b/backend/app/models.py index ba514d4..1cb1740 100644 --- a/backend/app/models.py +++ b/backend/app/models.py @@ -166,6 +166,7 @@ class Setting(SettingBase, table=True): class AboutUsBase(SQLModel): description: str = Field(max_length=1024) image:str | None = Field(default=None, max_length=255) + title: str = Field(max_length=255) index: int class AboutUsCreate(AboutUsBase): @@ -209,6 +210,8 @@ class CoursePublic(CourseBase): id: uuid.UUID title: str images: list["Image"] + info_images: list["Info_Image"] + schedule: list["Schedule"] created_at: datetime class CoursesPublic(SQLModel): diff --git a/backend/static/tmp/04102400-8010-4a8b-ad1c-107557592faa.png b/backend/static/tmp/04102400-8010-4a8b-ad1c-107557592faa.png new file mode 100644 index 0000000..3231d04 Binary files /dev/null and b/backend/static/tmp/04102400-8010-4a8b-ad1c-107557592faa.png differ diff --git a/backend/static/tmp/082c52b6-a2f6-4012-9af1-10eb50a055f0.jpeg b/backend/static/tmp/082c52b6-a2f6-4012-9af1-10eb50a055f0.jpeg deleted file mode 100644 index d8fd444..0000000 Binary files a/backend/static/tmp/082c52b6-a2f6-4012-9af1-10eb50a055f0.jpeg and /dev/null differ diff --git a/backend/static/tmp/0a107f7e-9ce6-49a0-8ca8-3c36359fada5.png b/backend/static/tmp/0a107f7e-9ce6-49a0-8ca8-3c36359fada5.png new file mode 100644 index 0000000..3231d04 Binary files /dev/null and b/backend/static/tmp/0a107f7e-9ce6-49a0-8ca8-3c36359fada5.png differ diff --git a/backend/static/tmp/0ccacc20-09da-4ac5-a44e-6be1a98521f3.png b/backend/static/tmp/0ccacc20-09da-4ac5-a44e-6be1a98521f3.png new file mode 100644 index 0000000..3231d04 Binary files /dev/null and b/backend/static/tmp/0ccacc20-09da-4ac5-a44e-6be1a98521f3.png differ diff --git a/backend/static/tmp/10c500e8-7b23-4a29-97ef-c8af67cd02d1.jpeg b/backend/static/tmp/10c500e8-7b23-4a29-97ef-c8af67cd02d1.jpeg deleted file mode 100644 index d8fd444..0000000 Binary files a/backend/static/tmp/10c500e8-7b23-4a29-97ef-c8af67cd02d1.jpeg and /dev/null differ diff --git a/backend/static/tmp/1ee38592-9dc2-4828-a776-5fa8ceb1d5eb.png b/backend/static/tmp/1ee38592-9dc2-4828-a776-5fa8ceb1d5eb.png new file mode 100644 index 0000000..55f86b7 Binary files /dev/null and b/backend/static/tmp/1ee38592-9dc2-4828-a776-5fa8ceb1d5eb.png differ diff --git a/backend/static/tmp/2ac445a8-f1fd-4ca4-8d15-52ce85c9fd44.png b/backend/static/tmp/2ac445a8-f1fd-4ca4-8d15-52ce85c9fd44.png new file mode 100644 index 0000000..3231d04 Binary files /dev/null and b/backend/static/tmp/2ac445a8-f1fd-4ca4-8d15-52ce85c9fd44.png differ diff --git a/backend/static/tmp/3d55b203-7805-46c5-9784-eef53dde8431.png b/backend/static/tmp/3d55b203-7805-46c5-9784-eef53dde8431.png new file mode 100644 index 0000000..3231d04 Binary files /dev/null and b/backend/static/tmp/3d55b203-7805-46c5-9784-eef53dde8431.png differ diff --git a/backend/static/tmp/3e8232cf-9a87-4121-ac28-d523f84d23a0.png b/backend/static/tmp/3e8232cf-9a87-4121-ac28-d523f84d23a0.png new file mode 100644 index 0000000..3231d04 Binary files /dev/null and b/backend/static/tmp/3e8232cf-9a87-4121-ac28-d523f84d23a0.png differ diff --git a/backend/static/tmp/4367756e-16cd-4e2e-875f-39caccc2b203.png b/backend/static/tmp/4367756e-16cd-4e2e-875f-39caccc2b203.png new file mode 100644 index 0000000..3231d04 Binary files /dev/null and b/backend/static/tmp/4367756e-16cd-4e2e-875f-39caccc2b203.png differ diff --git a/backend/static/tmp/49fb8f33-99b6-4f18-89ef-60fe974a4a7a.png b/backend/static/tmp/49fb8f33-99b6-4f18-89ef-60fe974a4a7a.png new file mode 100644 index 0000000..14d7a06 Binary files /dev/null and b/backend/static/tmp/49fb8f33-99b6-4f18-89ef-60fe974a4a7a.png differ diff --git a/backend/static/tmp/6059f71a-b26f-46c3-b8f4-fa7ae9d30553.png b/backend/static/tmp/6059f71a-b26f-46c3-b8f4-fa7ae9d30553.png new file mode 100644 index 0000000..3231d04 Binary files /dev/null and b/backend/static/tmp/6059f71a-b26f-46c3-b8f4-fa7ae9d30553.png differ diff --git a/backend/static/tmp/6ddd5125-2135-4263-90fc-cc1703b1c060.png b/backend/static/tmp/6ddd5125-2135-4263-90fc-cc1703b1c060.png new file mode 100644 index 0000000..3231d04 Binary files /dev/null and b/backend/static/tmp/6ddd5125-2135-4263-90fc-cc1703b1c060.png differ diff --git a/backend/static/tmp/9f9feb3f-02d9-4b63-9d87-c3f8ff1fe54d.png b/backend/static/tmp/9f9feb3f-02d9-4b63-9d87-c3f8ff1fe54d.png new file mode 100644 index 0000000..14d7a06 Binary files /dev/null and b/backend/static/tmp/9f9feb3f-02d9-4b63-9d87-c3f8ff1fe54d.png differ diff --git a/backend/static/tmp/bc47ca53-548c-4736-94cd-855671941e16.jpeg b/backend/static/tmp/bc47ca53-548c-4736-94cd-855671941e16.jpeg deleted file mode 100644 index 4a47eef..0000000 Binary files a/backend/static/tmp/bc47ca53-548c-4736-94cd-855671941e16.jpeg and /dev/null differ diff --git a/backend/static/tmp/d84e450d-5e2a-4f1f-9490-8ee49f91e536.png b/backend/static/tmp/d84e450d-5e2a-4f1f-9490-8ee49f91e536.png new file mode 100644 index 0000000..3231d04 Binary files /dev/null and b/backend/static/tmp/d84e450d-5e2a-4f1f-9490-8ee49f91e536.png differ diff --git a/backend/static/tmp/ddc93b90-6801-4827-b8a9-6dc6a28f4aea.png b/backend/static/tmp/ddc93b90-6801-4827-b8a9-6dc6a28f4aea.png new file mode 100644 index 0000000..3aeca6f Binary files /dev/null and b/backend/static/tmp/ddc93b90-6801-4827-b8a9-6dc6a28f4aea.png differ diff --git a/backend/static/tmp/dde5a9b2-8e69-4231-9f60-1477127dd35c.jpg b/backend/static/tmp/dde5a9b2-8e69-4231-9f60-1477127dd35c.jpg deleted file mode 100644 index 205b345..0000000 Binary files a/backend/static/tmp/dde5a9b2-8e69-4231-9f60-1477127dd35c.jpg and /dev/null differ diff --git a/backend/static/tmp/f3cc985c-e595-43d4-ac1f-a49190fec50c.png b/backend/static/tmp/f3cc985c-e595-43d4-ac1f-a49190fec50c.png new file mode 100644 index 0000000..3231d04 Binary files /dev/null and b/backend/static/tmp/f3cc985c-e595-43d4-ac1f-a49190fec50c.png differ diff --git a/frontend/src/client/models.ts b/frontend/src/client/models.ts index 7730e88..cd77280 100644 --- a/frontend/src/client/models.ts +++ b/frontend/src/client/models.ts @@ -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, } diff --git a/frontend/src/components/AboutUs/AddAboutUs.tsx b/frontend/src/components/AboutUs/AddAboutUs.tsx index d9b9d5c..1e6ba02 100644 --- a/frontend/src/components/AboutUs/AddAboutUs.tsx +++ b/frontend/src/components/AboutUs/AddAboutUs.tsx @@ -134,7 +134,7 @@ const AddAboutUs = ({ isOpen, onClose }: AddAboutUsProps) => { } mutation.mutate(data) console.log(data) - + } @@ -152,6 +152,20 @@ const AddAboutUs = ({ isOpen, onClose }: AddAboutUsProps) => { + + Title + + {errors.title && ( + {errors.title.message} + )} + { - + {errors.index && ( {errors.index.message} )} @@ -195,7 +209,7 @@ const AddAboutUs = ({ isOpen, onClose }: AddAboutUsProps) => { {'Image Upload'} - + diff --git a/frontend/src/components/AboutUs/EditAboutUs.tsx b/frontend/src/components/AboutUs/EditAboutUs.tsx index 2ea462d..0fe8f59 100644 --- a/frontend/src/components/AboutUs/EditAboutUs.tsx +++ b/frontend/src/components/AboutUs/EditAboutUs.tsx @@ -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) => { + + Title + + {errors.title && ( + {errors.title.message} + )} + { 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 }), diff --git a/frontend/src/routes/_layout/Courses/$id.EditCourse.tsx b/frontend/src/routes/_layout/Courses/$id.EditCourse.tsx index 00adb19..34c89f7 100644 --- a/frontend/src/routes/_layout/Courses/$id.EditCourse.tsx +++ b/frontend/src/routes/_layout/Courses/$id.EditCourse.tsx @@ -51,7 +51,7 @@ function EditCourse() { return ( - User Settings + Courses diff --git a/frontend/src/routes/_layout/aboutUs.tsx b/frontend/src/routes/_layout/aboutUs.tsx index 13a880e..c5f4d60 100644 --- a/frontend/src/routes/_layout/aboutUs.tsx +++ b/frontend/src/routes/_layout/aboutUs.tsx @@ -76,6 +76,7 @@ function AboutUsTable() { ID + Title Description Image Index @@ -97,6 +98,12 @@ function AboutUsTable() { {aboutUs?.data.map((aboutUs) => ( {aboutUs.id} + + {parse(aboutUs.title)} +