This commit is contained in:
Philip Cheung 2024-10-07 12:55:51 +08:00
parent b50a827757
commit 60ac644fc0
3 changed files with 33 additions and 38 deletions

View File

@ -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>(EditorState.createEmpty());
const [content, setContent] = useState<string>('');
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 = {

View File

@ -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<string>(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 = {

View File

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