diff --git a/client/components/GroupView/GroupFunctions.js b/client/components/GroupView/GroupFunctions.js
index 7a309602..4ac1f9fc 100644
--- a/client/components/GroupView/GroupFunctions.js
+++ b/client/components/GroupView/GroupFunctions.js
@@ -10,6 +10,7 @@ import { getTestQuestions } from 'Utilities/redux/testReducer'
import { Button } from 'react-bootstrap'
import useWindowDimensions from 'Utilities/windowDimensions'
import GroupLearningSettingsModal from './GroupLearningSettingsModal'
+import ImportStoryModal from './ImportStoryModal'
const GroupFunctions = ({
group,
@@ -29,6 +30,7 @@ const GroupFunctions = ({
} = group
const teacherView = useSelector(({ user }) => user.data.user.is_teacher)
const [learningModalGroupId, setLearningModalGroupId] = useState(null)
+ const [importStoryModalOpen, setImportStoryModalOpen] = useState(false)
const { width } = useWindowDimensions()
const testEnabled = currTestDeadline - Date.now() > 0
const testButtonVariant = testEnabled ? 'danger' : 'primary'
@@ -89,6 +91,9 @@ const GroupFunctions = ({
dispatch(getTestQuestions(language, groupId, true))
}
+
+
+
return (
<>
{width >= 640 ? (
@@ -114,6 +119,9 @@ const GroupFunctions = ({
groupId={learningModalGroupId}
/>
)}
+ {isTeaching && teacherView && (
+
+ )}
{isTeaching && teacherView && (
)}
+ {isTeaching && teacherView && (
+
+
+ )}
) : (
diff --git a/client/components/GroupView/ImportStoryModal.js b/client/components/GroupView/ImportStoryModal.js
new file mode 100644
index 00000000..8a999c7c
--- /dev/null
+++ b/client/components/GroupView/ImportStoryModal.js
@@ -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 (
+ setOpen(false)} onOpen={() => setOpen(true)} open={open}>
+
+ : {group.groupName}
+
+
+
+
+
+
+ setSelectedGroups(value)}
+ style={{ marginTop: '1em' }}
+ />
+
+
+ setMessage(e.target.value)} />
+
+
+
+
+
+
+
+ )
+}
+
+export default ImportStoryModal
\ No newline at end of file
diff --git a/client/util/redux/groupsReducer.js b/client/util/redux/groupsReducer.js
index 501f9a41..0186d88e 100644
--- a/client/util/redux/groupsReducer.js
+++ b/client/util/redux/groupsReducer.js
@@ -123,11 +123,18 @@ export const confirmGroupInvitation = token => {
return callBuilder(route, prefix, 'post', payload)
}
+export const importStoriesFromGroup = (groupId, selectedGroups, message) => {
+ const route = `/groups/${groupId}/import`
+ const prefix = 'IMPORT_STORIES'
+ const payload = { src_group_ids: selectedGroups, message }
+ return callBuilder(route, prefix, 'post', payload)
+}
+
export const emptyLastAddInfo = () => ({
type: 'EMPTY_LAST_ADD_INFO',
})
-export default (state = { groups: [], joinPending: false, deleteSuccessful: false }, action) => {
+export default (state = { groups: [], joinPending: false, deleteSuccessful: false, storyImported: -1 }, action) => {
switch (action.type) {
case 'GET_GROUPS_ATTEMPT':
return {
@@ -408,6 +415,30 @@ export default (state = { groups: [], joinPending: false, deleteSuccessful: fals
...state,
pending: false,
}
+
+ case 'IMPORT_STORIES_ATTEMPT':
+ return {
+ ...state,
+ pending: true,
+ }
+ case 'IMPORT_STORIES_FAILURE':
+ return {
+ ...state,
+ pending: false,
+ }
+ case 'IMPORT_STORIES_SUCCESS':
+ return {
+ ...state,
+ storyImported: action.response.num_story_imported,
+ pending: false,
+ }
+
+ case 'CLEAN_STORY_IMPORT':
+ return {
+ ...state,
+ storyImported: -1,
+ }
+
default:
return state
}