-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge commit 'cdfd18cc6c5b878e0a5f30062f50cf7261fd4d27'
- Loading branch information
Showing
3 changed files
with
120 additions
and
1 deletion.
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
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 |
---|---|---|
@@ -0,0 +1,74 @@ | ||
import React, { useState } from 'react' | ||
import { useSelector, useDispatch } from 'react-redux' | ||
import { Modal, Dropdown, Input } from 'semantic-ui-react' | ||
import { FormattedMessage, FormattedHTMLMessage, useIntl } from 'react-intl' | ||
import { Button } from 'react-bootstrap' | ||
import { importStoriesFromGroup } from 'Utilities/redux/groupsReducer' | ||
import { getAllStories } from 'Utilities/redux/storiesReducer' | ||
|
||
const ImportStoryModal = ({ open, setOpen, groupId }) => { | ||
const dispatch = useDispatch() | ||
const intl = useIntl() | ||
const { groups, pending, storyImported } = useSelector(({ groups }) => groups) | ||
const [selectedGroups, setSelectedGroups] = useState([]) | ||
const [message, setMessage] = useState('') | ||
const group = groups.find(group => group.group_id === groupId) | ||
|
||
const options = groups.filter(group => group.group_id !== groupId).map( | ||
group => ({key: group.group_id, text: group.groupName, value: group.group_id})) | ||
const submitGroupImport = async () => { | ||
// console.log(selectedGroups) | ||
// console.log(message) | ||
await dispatch(importStoriesFromGroup(groupId, selectedGroups, message)) | ||
dispatch( | ||
getAllStories(group.language, { | ||
sort_by: 'date', | ||
order: -1, | ||
}) | ||
) | ||
setOpen(false) | ||
setSelectedGroups([]) | ||
setMessage('') | ||
} | ||
|
||
return ( | ||
<Modal onClose={() => setOpen(false)} onOpen={() => setOpen(true)} open={open}> | ||
<Modal.Header> | ||
<FormattedMessage id="import-story" /> : {group.groupName} | ||
</Modal.Header> | ||
<Modal.Content style={{ display: 'flex', flexDirection: 'column', height: '260px' }}> | ||
<h2 style={{ fontSize: '17px', fontWeight: '550' }}> | ||
<FormattedMessage id="import-story-label" /> | ||
</h2> | ||
<FormattedHTMLMessage id="import-story-description" /> | ||
<Dropdown | ||
placeholder={intl.formatMessage({id: 'import-from'})} | ||
fluid multiple selection | ||
options={options} | ||
onChange={(e, { value }) => setSelectedGroups(value)} | ||
style={{ marginTop: '1em' }} | ||
/> | ||
<span style={{marginTop: '1em'}}> | ||
<label style={{marginRight: '2em', fontWeight: 'bold'}}><FormattedMessage id="import-story-message" /></label> | ||
<Input type="text" onChange={(e)=> setMessage(e.target.value)} /> | ||
</span> | ||
</Modal.Content> | ||
<Modal.Actions> | ||
<Button onClick={submitGroupImport} disabled={selectedGroups.length === 0}> | ||
<FormattedMessage id="import" /> | ||
</Button> | ||
<Button | ||
style={{ marginLeft: '1em' }} | ||
onClick={() => { | ||
setOpen(false) | ||
}} | ||
variant="secondary" | ||
> | ||
<FormattedMessage id="cancel" /> | ||
</Button> | ||
</Modal.Actions> | ||
</Modal> | ||
) | ||
} | ||
|
||
export default ImportStoryModal |
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