Skip to content

Commit

Permalink
update: error message
Browse files Browse the repository at this point in the history
  • Loading branch information
liangfung committed Oct 30, 2024
1 parent b273002 commit 3e79e23
Showing 1 changed file with 3 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -521,7 +521,7 @@ function MessageContentForm({
onSubmit: (newMessage: ConversationMessage) => Promise<string | void>
}) {
const formSchema = z.object({
content: z.string()
content: z.string().trim()
})
const form = useForm<z.infer<typeof formSchema>>({
resolver: zodResolver(formSchema),
Expand All @@ -532,11 +532,8 @@ function MessageContentForm({
const isEmptyContent = !content || isEmpty(content.trim())
const [draftMessage] = useState<ConversationMessage>(message)
const { formRef, onKeyDown } = useEnterSubmit()
const handleSubmit = async (values: z.infer<typeof formSchema>) => {
if (!values.content || isEmpty(values.content.trim())) {
return
}

const handleSubmit = async (values: z.infer<typeof formSchema>) => {
const errorMessage = await onSubmit({
...draftMessage,
content: values.content
Expand Down Expand Up @@ -564,6 +561,7 @@ function MessageContentForm({
{...field}
/>
</FormControl>
<FormMessage />
</FormItem>
)}
/>
Expand Down

0 comments on commit 3e79e23

Please sign in to comment.