added title in add aboutus

This commit is contained in:
Philip Cheung 2024-10-07 20:07:54 +08:00
parent be06a0783f
commit dadc2cec38
1 changed files with 20 additions and 4 deletions

View File

@ -1,4 +1,4 @@
import { useState } from 'react'; import { useState } from 'react';
import { import {
Button, Button,
FormControl, FormControl,
@ -16,6 +16,7 @@ import {
NumberInputStepper, NumberInputStepper,
NumberIncrementStepper, NumberIncrementStepper,
NumberDecrementStepper, NumberDecrementStepper,
Input,
} from "@chakra-ui/react" } from "@chakra-ui/react"
import { useMutation, useQueryClient } from "@tanstack/react-query" import { useMutation, useQueryClient } from "@tanstack/react-query"
@ -82,6 +83,7 @@ const AddAboutUs = ({ isOpen, onClose }: AddAboutUsProps) => {
criteriaMode: "all", criteriaMode: "all",
defaultValues: { defaultValues: {
index: 0, index: 0,
title: "",
description: "", description: "",
image: undefined, image: undefined,
}, },
@ -131,7 +133,7 @@ const AddAboutUs = ({ isOpen, onClose }: AddAboutUsProps) => {
} }
mutation.mutate(data) mutation.mutate(data)
console.log(data) console.log(data)
} }
@ -149,6 +151,20 @@ const AddAboutUs = ({ isOpen, onClose }: AddAboutUsProps) => {
<ModalCloseButton /> <ModalCloseButton />
<ModalBody pb={30}> <ModalBody pb={30}>
<FormControl isRequired isInvalid={!!errors.title}>
<FormLabel htmlFor="title">Title</FormLabel>
<Input
id="title"
{...register("title", {
required: "Title is required.",
})}
placeholder="Title"
type="text"
/>
{errors.title && (
<FormErrorMessage>{errors.title.message}</FormErrorMessage>
)}
</FormControl>
<FormControl isRequired isInvalid={!!errors.description}> <FormControl isRequired isInvalid={!!errors.description}>
<Editor <Editor
editorState={editorState} editorState={editorState}
@ -183,7 +199,7 @@ const AddAboutUs = ({ isOpen, onClose }: AddAboutUsProps) => {
<NumberDecrementStepper /> <NumberDecrementStepper />
</NumberInputStepper> </NumberInputStepper>
</NumberInput> </NumberInput>
{errors.index && ( {errors.index && (
<FormErrorMessage>{errors.index.message}</FormErrorMessage> <FormErrorMessage>{errors.index.message}</FormErrorMessage>
)} )}
@ -192,7 +208,7 @@ const AddAboutUs = ({ isOpen, onClose }: AddAboutUsProps) => {
<FormControl isInvalid={!!errors.image} isRequired> <FormControl isInvalid={!!errors.image} isRequired>
<FormLabel>{'Image Upload'}</FormLabel> <FormLabel>{'Image Upload'}</FormLabel>
<input type="file" {...register("image", { <input type="file" {...register("image", {
required: "index is required.", required: "index is required.",
})} /> })} />