From 60ac644fc00cb32f1ca7d2de7e05e859accc322b Mon Sep 17 00:00:00 2001 From: Philip Cheung Date: Mon, 7 Oct 2024 12:55:51 +0800 Subject: [PATCH] updated --- .../src/components/AboutUs/AddAboutUs.tsx | 33 +++++++++-------- .../src/components/AboutUs/EditAboutUs.tsx | 35 +++++++++---------- .../src/components/Courses/CourseImages.tsx | 3 -- 3 files changed, 33 insertions(+), 38 deletions(-) diff --git a/frontend/src/components/AboutUs/AddAboutUs.tsx b/frontend/src/components/AboutUs/AddAboutUs.tsx index 41ac5e5..590c7d6 100644 --- a/frontend/src/components/AboutUs/AddAboutUs.tsx +++ b/frontend/src/components/AboutUs/AddAboutUs.tsx @@ -1,4 +1,4 @@ -import { useRef, ReactNode, useState } from 'react'; +import { useState } from 'react'; import { Button, FormControl, @@ -11,7 +11,6 @@ import { ModalFooter, ModalHeader, ModalOverlay, - InputGroup, NumberInput, NumberInputField, NumberInputStepper, @@ -34,12 +33,12 @@ interface AddAboutUsProps { onClose: () => void } -type FileUploadProps = { - register: UseFormRegisterReturn - accept?: string - multiple?: boolean - children?: ReactNode -} +// type FileUploadProps = { +// register: UseFormRegisterReturn +// accept?: string +// multiple?: boolean +// children?: ReactNode +// } // const FileUpload = (props: FileUploadProps) => { // const { register, accept, multiple, children } = props @@ -90,18 +89,18 @@ const AddAboutUs = ({ isOpen, onClose }: AddAboutUsProps) => { const [editorState, setEditorState] = useState(EditorState.createEmpty()); const [content, setContent] = useState(''); - const validateFiles = (value: File) => { - if (typeof value === 'string') return true; + // const validateFiles = (value: File) => { + // if (typeof value === 'string') return true; - const fsMb = value.size / (1024 * 1024) - const MAX_FILE_SIZE = 10 - if (fsMb > MAX_FILE_SIZE) { - return 'Max file size 10mb' - } + // const fsMb = value.size / (1024 * 1024) + // const MAX_FILE_SIZE = 10 + // if (fsMb > MAX_FILE_SIZE) { + // return 'Max file size 10mb' + // } - return true - } + // return true + // } // type FormValues = { diff --git a/frontend/src/components/AboutUs/EditAboutUs.tsx b/frontend/src/components/AboutUs/EditAboutUs.tsx index a5cbccc..3f4b872 100644 --- a/frontend/src/components/AboutUs/EditAboutUs.tsx +++ b/frontend/src/components/AboutUs/EditAboutUs.tsx @@ -1,4 +1,4 @@ -import { useRef, ReactNode, useState } from 'react'; +import {useState } from 'react'; import { Button, FormControl, @@ -12,7 +12,6 @@ import { ModalFooter, ModalHeader, ModalOverlay, - InputGroup, NumberInput, NumberInputField, NumberInputStepper, @@ -23,7 +22,7 @@ import { } from "@chakra-ui/react" import { useMutation, useQueryClient } from "@tanstack/react-query" -import { type SubmitHandler, useForm, UseFormRegisterReturn } from "react-hook-form" +import { type SubmitHandler, useForm } from "react-hook-form" import { type ApiError, AboutUsService, AboutUsUpdate, AboutUsPublic } from "../../client" import useCustomToast from "../../hooks/useCustomToast" import { handleError } from "../../utils" @@ -39,12 +38,12 @@ interface EditAboutUsProps { aboutUs: AboutUsPublic } -type FileUploadProps = { - register: UseFormRegisterReturn - accept?: string - multiple?: boolean - children?: ReactNode -} +// type FileUploadProps = { +// register: UseFormRegisterReturn +// accept?: string +// multiple?: boolean +// children?: ReactNode +// } // const FileUpload = (props: FileUploadProps) => { // const { register, accept, multiple, children } = props @@ -104,18 +103,18 @@ const EditAboutUs = ({ aboutUs, isOpen, onClose }: EditAboutUsProps) => { }); const [content, setContent] = useState(aboutUs.description); - const validateFiles = (value: File) => { - if (typeof value === 'string') return true; + // const validateFiles = (value: File) => { + // if (typeof value === 'string') return true; - const fsMb = value.size / (1024 * 1024) - const MAX_FILE_SIZE = 10 - if (fsMb > MAX_FILE_SIZE) { - return 'Max file size 10mb' - } + // const fsMb = value.size / (1024 * 1024) + // const MAX_FILE_SIZE = 10 + // if (fsMb > MAX_FILE_SIZE) { + // return 'Max file size 10mb' + // } - return true - } + // return true + // } // type FormValues = { diff --git a/frontend/src/components/Courses/CourseImages.tsx b/frontend/src/components/Courses/CourseImages.tsx index b3729a8..6e14374 100644 --- a/frontend/src/components/Courses/CourseImages.tsx +++ b/frontend/src/components/Courses/CourseImages.tsx @@ -12,12 +12,9 @@ import { NumberIncrementStepper, NumberDecrementStepper, Image, - Flex, HStack, VStack, Text, - Td, - Icon, Grid } from "@chakra-ui/react" import { useQueryClient, useMutation } from "@tanstack/react-query"