Skip to content
This repository has been archived by the owner on Jan 17, 2023. It is now read-only.

Commit

Permalink
fix: chatbot input
Browse files Browse the repository at this point in the history
  • Loading branch information
aprets committed Apr 16, 2022
1 parent 82a0236 commit a84cdab
Showing 1 changed file with 45 additions and 0 deletions.
45 changes: 45 additions & 0 deletions next/components/Chatbot/Input.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
import React, {useState} from 'react'
import {TextInput, Box, Group, Button, Grid} from '@mantine/core'

import {IoMdSend} from 'react-icons/io'

export default function Input({onSend}) {
const [text, setText] = useState('')

const handleInputChange = (e) => {
setText(e.target.value)
}

const handleSend = (e) => {
e.preventDefault()
onSend(text)
setText('')
}

return (
<Box
className='input'
style={{
position: 'relative',
}}
>
<form onSubmit={handleSend}>
<Grid>
<Grid.Col span={10}>
<TextInput
radius='xl'
type='text'
onChange={handleInputChange}
value={text}
placeholder='Enter your message here'
/>
</Grid.Col>
<Grid.Col span={2}>
<Button radius='xl' type='submit'> <IoMdSend /> </Button>
</Grid.Col>
</Grid>

</form>
</Box>
)
}

0 comments on commit a84cdab

Please sign in to comment.