-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: add messages query to component
- Loading branch information
Showing
1 changed file
with
40 additions
and
35 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,40 +1,45 @@ | ||
import { Button, Col, Form } from 'react-bootstrap'; | ||
import { ArrowRightSquare } from 'react-bootstrap-icons'; | ||
import { useGetMessagesQuery } from '../api/messagesApi'; | ||
|
||
const Messages = () => ( | ||
<Col className="p-0 h-100"> | ||
<div className="d-flex flex-column h-100"> | ||
<div className="bg-light mb-4 p-3 shadow-sm small"> | ||
<p className="m-0"> | ||
<b>#general</b> | ||
</p> | ||
<span className="text-muted">0 сообщений</span> | ||
</div> | ||
<div id="messages-box" className="chat-messages overflow-auto px-5 "> | ||
Сообщения | ||
</div> | ||
<div className="mt-auto px-5 py-3"> | ||
<Form | ||
noValidate | ||
className="py-1 border rounded-2" | ||
> | ||
<Form.Group className="input-group"> | ||
<Form.Control | ||
name="messageBody" | ||
autoComplete="off" | ||
aria-label="Новое сообщение" | ||
placeholder="Введите сообщение..." | ||
className="border-0 p-0 ps-2" | ||
/> | ||
<Button type="submit" variant="light" className="border-0"> | ||
<span className="visually-hidden">Отправить</span> | ||
<ArrowRightSquare /> | ||
</Button> | ||
</Form.Group> | ||
</Form> | ||
</div> | ||
</div> | ||
</Col> | ||
); | ||
const Messages = () => { | ||
const { data: messages = [] } = useGetMessagesQuery(); | ||
console.log(messages); | ||
|
||
return ( | ||
<Col className="p-0 h-100"> | ||
<div className="d-flex flex-column h-100"> | ||
<div className="bg-light mb-4 p-3 shadow-sm small"> | ||
<p className="m-0"> | ||
<b>#general</b> | ||
</p> | ||
<span className="text-muted">0 сообщений</span> | ||
</div> | ||
<div id="messages-box" className="chat-messages overflow-auto px-5 "> | ||
Сообщения | ||
</div> | ||
<div className="mt-auto px-5 py-3"> | ||
<Form | ||
noValidate | ||
className="py-1 border rounded-2" | ||
> | ||
<Form.Group className="input-group"> | ||
<Form.Control | ||
name="messageBody" | ||
autoComplete="off" | ||
aria-label="Новое сообщение" | ||
placeholder="Введите сообщение..." | ||
className="border-0 p-0 ps-2" | ||
/> | ||
<Button type="submit" variant="light" className="border-0"> | ||
<span className="visually-hidden">Отправить</span> | ||
<ArrowRightSquare /> | ||
</Button> | ||
</Form.Group> | ||
</Form> | ||
</div> | ||
</div> | ||
</Col> | ||
); | ||
}; | ||
export default Messages; |