From b50a827757c4d84111f66d2c6e18d645184f4ce1 Mon Sep 17 00:00:00 2001 From: Philip Cheung Date: Mon, 7 Oct 2024 12:51:05 +0800 Subject: [PATCH] updated --- .../src/components/AboutUs/AddAboutUs.tsx | 54 +++++++++---------- .../src/components/AboutUs/EditAboutUs.tsx | 54 +++++++++---------- .../src/components/Courses/CourseDetails.tsx | 1 - .../src/components/Courses/CourseImages.tsx | 1 - .../components/Courses/CourseInfoImages.tsx | 2 - .../src/components/Courses/EditSechedule.tsx | 4 +- frontend/src/components/Courses/Sechedule.tsx | 5 +- .../routes/_layout/Courses/$id.EditCourse.tsx | 4 +- .../src/routes/_layout/Courses/AddCourse.tsx | 2 - frontend/src/routes/_layout/webSetting.tsx | 15 +++--- frontend/src/routes/login.tsx | 3 -- 11 files changed, 67 insertions(+), 78 deletions(-) diff --git a/frontend/src/components/AboutUs/AddAboutUs.tsx b/frontend/src/components/AboutUs/AddAboutUs.tsx index 1d10985..41ac5e5 100644 --- a/frontend/src/components/AboutUs/AddAboutUs.tsx +++ b/frontend/src/components/AboutUs/AddAboutUs.tsx @@ -41,32 +41,32 @@ type FileUploadProps = { children?: ReactNode } -const FileUpload = (props: FileUploadProps) => { - const { register, accept, multiple, children } = props - const inputRef = useRef(null) - const { ref, ...rest } = register as { ref: (instance: HTMLInputElement | null) => void } +// const FileUpload = (props: FileUploadProps) => { +// const { register, accept, multiple, children } = props +// const inputRef = useRef(null) +// const { ref, ...rest } = register as { ref: (instance: HTMLInputElement | null) => void } - const handleClick = () => inputRef.current?.click() +// const handleClick = () => inputRef.current?.click() - return ( - - { - ref(e) - inputRef.current = e - }} - /> - <> - {children} - - - ) -} +// return ( +// +// { +// ref(e) +// inputRef.current = e +// }} +// /> +// <> +// {children} +// +// +// ) +// } @@ -104,9 +104,9 @@ const AddAboutUs = ({ isOpen, onClose }: AddAboutUsProps) => { } - type FormValues = { - file_: FileList - } + // type FormValues = { + // file_: FileList + // } const mutation = useMutation({ diff --git a/frontend/src/components/AboutUs/EditAboutUs.tsx b/frontend/src/components/AboutUs/EditAboutUs.tsx index 1b8c1a0..a5cbccc 100644 --- a/frontend/src/components/AboutUs/EditAboutUs.tsx +++ b/frontend/src/components/AboutUs/EditAboutUs.tsx @@ -46,32 +46,32 @@ type FileUploadProps = { children?: ReactNode } -const FileUpload = (props: FileUploadProps) => { - const { register, accept, multiple, children } = props - const inputRef = useRef(null) - const { ref, ...rest } = register as { ref: (instance: HTMLInputElement | null) => void } +// const FileUpload = (props: FileUploadProps) => { +// const { register, accept, multiple, children } = props +// const inputRef = useRef(null) +// const { ref, ...rest } = register as { ref: (instance: HTMLInputElement | null) => void } - const handleClick = () => inputRef.current?.click() +// const handleClick = () => inputRef.current?.click() - return ( - - { - ref(e) - inputRef.current = e - }} - /> - <> - {children} - - - ) -} +// return ( +// +// { +// ref(e) +// inputRef.current = e +// }} +// /> +// <> +// {children} +// +// +// ) +// } @@ -118,9 +118,9 @@ const EditAboutUs = ({ aboutUs, isOpen, onClose }: EditAboutUsProps) => { } - type FormValues = { - file_: FileList - } + // type FormValues = { + // file_: FileList + // } const mutation = useMutation({ diff --git a/frontend/src/components/Courses/CourseDetails.tsx b/frontend/src/components/Courses/CourseDetails.tsx index 24daa96..9c54d14 100644 --- a/frontend/src/components/Courses/CourseDetails.tsx +++ b/frontend/src/components/Courses/CourseDetails.tsx @@ -54,7 +54,6 @@ const CourseDetails = () => { reset, getValues, setValue, - unregister, formState: { isSubmitting, errors, isDirty }, } = useForm({ mode: "onBlur", diff --git a/frontend/src/components/Courses/CourseImages.tsx b/frontend/src/components/Courses/CourseImages.tsx index 49ef96d..b3729a8 100644 --- a/frontend/src/components/Courses/CourseImages.tsx +++ b/frontend/src/components/Courses/CourseImages.tsx @@ -44,7 +44,6 @@ const CourseImages = () => { reset, getValues, setValue, - unregister, formState: { isSubmitting, errors, isDirty }, } = useForm({ mode: "onBlur", diff --git a/frontend/src/components/Courses/CourseInfoImages.tsx b/frontend/src/components/Courses/CourseInfoImages.tsx index 92dda93..4a681a3 100644 --- a/frontend/src/components/Courses/CourseInfoImages.tsx +++ b/frontend/src/components/Courses/CourseInfoImages.tsx @@ -39,9 +39,7 @@ const CourseInfoImages = () => { register, handleSubmit, reset, - getValues, setValue, - unregister, formState: { isSubmitting, errors, isDirty }, } = useForm({ mode: "onBlur", diff --git a/frontend/src/components/Courses/EditSechedule.tsx b/frontend/src/components/Courses/EditSechedule.tsx index 841fc60..1435c0a 100644 --- a/frontend/src/components/Courses/EditSechedule.tsx +++ b/frontend/src/components/Courses/EditSechedule.tsx @@ -29,7 +29,7 @@ interface EditItemProps { type: string } -const EditSechedule = ({ sechedule, type, isOpen, onClose }: EditItemProps) => { +const EditSechedule = ({ sechedule, isOpen, onClose }: EditItemProps) => { const queryClient = useQueryClient() const showToast = useCustomToast() const { @@ -38,7 +38,7 @@ const EditSechedule = ({ sechedule, type, isOpen, onClose }: EditItemProps) => { reset, setValue, getValues, - formState: { isSubmitting, errors, isDirty }, + formState: { isSubmitting, errors }, } = useForm({ mode: "onBlur", criteriaMode: "all", diff --git a/frontend/src/components/Courses/Sechedule.tsx b/frontend/src/components/Courses/Sechedule.tsx index 04949ce..7c36ecb 100644 --- a/frontend/src/components/Courses/Sechedule.tsx +++ b/frontend/src/components/Courses/Sechedule.tsx @@ -10,7 +10,6 @@ import { } from "@chakra-ui/react" import moment from 'moment'; import { useQueryClient, } from "@tanstack/react-query" -import useCustomToast from "../../hooks/useCustomToast" import { CourseDetailsPublic } from "../../client" import ActionsMenu from "../../components/Common/ActionsMenu" import 'react-datetime-picker/dist/DateTimePicker.css'; @@ -21,7 +20,7 @@ const Sechedule = () => { const queryClient = useQueryClient(); const courseDetails = queryClient.getQueryData(['course']) as CourseDetailsPublic | undefined; - const showToast = useCustomToast() + // const showToast = useCustomToast() return ( @@ -38,7 +37,7 @@ const Sechedule = () => { - {courseDetails?.schedule?.map((schedule, index) => ( + {courseDetails?.schedule?.map((schedule) => ( {moment(schedule.date).utcOffset("+08:00").format('DD-MM-YYYY HH:mm')} diff --git a/frontend/src/routes/_layout/Courses/$id.EditCourse.tsx b/frontend/src/routes/_layout/Courses/$id.EditCourse.tsx index 34c89f7..ce01131 100644 --- a/frontend/src/routes/_layout/Courses/$id.EditCourse.tsx +++ b/frontend/src/routes/_layout/Courses/$id.EditCourse.tsx @@ -7,9 +7,9 @@ import { TabPanels, Tabs, } from "@chakra-ui/react" -import { useQueryClient, useQuery } from "@tanstack/react-query" +import { useQuery } from "@tanstack/react-query" import { createFileRoute } from "@tanstack/react-router" -import { UserPublic, CoursesService } from "../../../client" +import { CoursesService } from "../../../client" import CourseDetails from "../../../components/Courses/CourseDetails" import CourseImages from "../../../components/Courses/CourseImages" diff --git a/frontend/src/routes/_layout/Courses/AddCourse.tsx b/frontend/src/routes/_layout/Courses/AddCourse.tsx index ace86fc..5bacba3 100644 --- a/frontend/src/routes/_layout/Courses/AddCourse.tsx +++ b/frontend/src/routes/_layout/Courses/AddCourse.tsx @@ -50,8 +50,6 @@ function AddCourseForms() { const { register, handleSubmit, - reset, - getValues, setValue, formState: { isSubmitting, errors, isDirty }, } = useForm({ diff --git a/frontend/src/routes/_layout/webSetting.tsx b/frontend/src/routes/_layout/webSetting.tsx index 1ae93e9..ffc6b79 100644 --- a/frontend/src/routes/_layout/webSetting.tsx +++ b/frontend/src/routes/_layout/webSetting.tsx @@ -21,13 +21,13 @@ export const Route = createFileRoute("/_layout/webSetting")({ -function getWebSettingQuery() { - return { - queryFn: () => - WebSettingsService.readWebSetting(), - queryKey: ["webSetting"], - } -} +// function getWebSettingQuery() { +// return { +// queryFn: () => +// WebSettingsService.readWebSetting(), +// queryKey: ["webSetting"], +// } +// } @@ -54,7 +54,6 @@ function WebSettingForms() { const { register, handleSubmit, - reset, formState: { isSubmitting, errors, isDirty }, } = useForm({ mode: "onBlur", diff --git a/frontend/src/routes/login.tsx b/frontend/src/routes/login.tsx index 4309a1f..32f464b 100644 --- a/frontend/src/routes/login.tsx +++ b/frontend/src/routes/login.tsx @@ -9,12 +9,9 @@ import { Input, InputGroup, InputRightElement, - Link, - Text, useBoolean, } from "@chakra-ui/react" import { - Link as RouterLink, createFileRoute, redirect, } from "@tanstack/react-router"