-
Notifications
You must be signed in to change notification settings - Fork 298
Expand file tree
/
Copy pathPollCreationDialogControls.tsx
More file actions
45 lines (42 loc) · 1.33 KB
/
PollCreationDialogControls.tsx
File metadata and controls
45 lines (42 loc) · 1.33 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
import React from 'react';
import { useCanCreatePoll, useMessageComposer } from '../../MessageInput';
import { useMessageInputContext, useTranslationContext } from '../../../context';
export type PollCreationDialogControlsProps = {
close: () => void;
};
export const PollCreationDialogControls = ({
close,
}: PollCreationDialogControlsProps) => {
const { t } = useTranslationContext('PollCreationDialogControls');
const { handleSubmit: handleSubmitMessage } = useMessageInputContext();
const messageComposer = useMessageComposer();
const canCreatePoll = useCanCreatePoll();
return (
<div className='str-chat__dialog__controls'>
<button
className='str-chat__dialog__controls-button str-chat__dialog__controls-button--cancel'
onClick={() => {
messageComposer.pollComposer.initState();
close();
}}
type='button'
>
{t('Cancel')}
</button>
<button
className='str-chat__dialog__controls-button str-chat__dialog__controls-button--submit'
disabled={!canCreatePoll}
onClick={() => {
messageComposer
.createPoll()
.then(() => handleSubmitMessage())
.then(close)
.catch(console.error);
}}
type='submit'
>
{t('Create')}
</button>
</div>
);
};