This commit is contained in:
Philip Cheung 2024-10-07 12:51:05 +08:00
parent daf301ee73
commit b50a827757
11 changed files with 67 additions and 78 deletions

View File

@ -41,32 +41,32 @@ type FileUploadProps = {
children?: ReactNode
}
const FileUpload = (props: FileUploadProps) => {
const { register, accept, multiple, children } = props
const inputRef = useRef<HTMLInputElement | null>(null)
const { ref, ...rest } = register as { ref: (instance: HTMLInputElement | null) => void }
// const FileUpload = (props: FileUploadProps) => {
// const { register, accept, multiple, children } = props
// const inputRef = useRef<HTMLInputElement | null>(null)
// const { ref, ...rest } = register as { ref: (instance: HTMLInputElement | null) => void }
const handleClick = () => inputRef.current?.click()
// const handleClick = () => inputRef.current?.click()
return (
<InputGroup onClick={handleClick}>
<input
type={'file'}
multiple={multiple || false}
hidden
accept={accept}
{...rest}
ref={(e) => {
ref(e)
inputRef.current = e
}}
/>
<>
{children}
</>
</InputGroup>
)
}
// return (
// <InputGroup onClick={handleClick}>
// <input
// type={'file'}
// multiple={multiple || false}
// hidden
// accept={accept}
// {...rest}
// ref={(e) => {
// ref(e)
// inputRef.current = e
// }}
// />
// <>
// {children}
// </>
// </InputGroup>
// )
// }
@ -104,9 +104,9 @@ const AddAboutUs = ({ isOpen, onClose }: AddAboutUsProps) => {
}
type FormValues = {
file_: FileList
}
// type FormValues = {
// file_: FileList
// }
const mutation = useMutation({

View File

@ -46,32 +46,32 @@ type FileUploadProps = {
children?: ReactNode
}
const FileUpload = (props: FileUploadProps) => {
const { register, accept, multiple, children } = props
const inputRef = useRef<HTMLInputElement | null>(null)
const { ref, ...rest } = register as { ref: (instance: HTMLInputElement | null) => void }
// const FileUpload = (props: FileUploadProps) => {
// const { register, accept, multiple, children } = props
// const inputRef = useRef<HTMLInputElement | null>(null)
// const { ref, ...rest } = register as { ref: (instance: HTMLInputElement | null) => void }
const handleClick = () => inputRef.current?.click()
// const handleClick = () => inputRef.current?.click()
return (
<InputGroup onClick={handleClick}>
<input
type={'file'}
multiple={multiple || false}
hidden
accept={accept}
{...rest}
ref={(e) => {
ref(e)
inputRef.current = e
}}
/>
<>
{children}
</>
</InputGroup>
)
}
// return (
// <InputGroup onClick={handleClick}>
// <input
// type={'file'}
// multiple={multiple || false}
// hidden
// accept={accept}
// {...rest}
// ref={(e) => {
// ref(e)
// inputRef.current = e
// }}
// />
// <>
// {children}
// </>
// </InputGroup>
// )
// }
@ -118,9 +118,9 @@ const EditAboutUs = ({ aboutUs, isOpen, onClose }: EditAboutUsProps) => {
}
type FormValues = {
file_: FileList
}
// type FormValues = {
// file_: FileList
// }
const mutation = useMutation({

View File

@ -54,7 +54,6 @@ const CourseDetails = () => {
reset,
getValues,
setValue,
unregister,
formState: { isSubmitting, errors, isDirty },
} = useForm<CourseCreate>({
mode: "onBlur",

View File

@ -44,7 +44,6 @@ const CourseImages = () => {
reset,
getValues,
setValue,
unregister,
formState: { isSubmitting, errors, isDirty },
} = useForm<ImageCreate>({
mode: "onBlur",

View File

@ -39,9 +39,7 @@ const CourseInfoImages = () => {
register,
handleSubmit,
reset,
getValues,
setValue,
unregister,
formState: { isSubmitting, errors, isDirty },
} = useForm<ImageCreate>({
mode: "onBlur",

View File

@ -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<ScheduleUpdate>({
mode: "onBlur",
criteriaMode: "all",

View File

@ -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 (
<Container maxW="full">
@ -38,7 +37,7 @@ const Sechedule = () => {
</Tr>
</Thead>
<Tbody>
{courseDetails?.schedule?.map((schedule, index) => (
{courseDetails?.schedule?.map((schedule) => (
<Tr key={schedule.id}>
<Td maxWidth="20px">
{moment(schedule.date).utcOffset("+08:00").format('DD-MM-YYYY HH:mm')}

View File

@ -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"

View File

@ -50,8 +50,6 @@ function AddCourseForms() {
const {
register,
handleSubmit,
reset,
getValues,
setValue,
formState: { isSubmitting, errors, isDirty },
} = useForm<CourseCreate>({

View File

@ -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<WebSettingUpdate>({
mode: "onBlur",

View File

@ -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"