-
Notifications
You must be signed in to change notification settings - Fork 77
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add feature to fill, edit and view forms
- Loading branch information
Showing
9 changed files
with
340 additions
and
138 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
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,53 @@ | ||
import axios from 'axios' | ||
import { | ||
urlFormFeedback, | ||
urlSubmissions | ||
} from '../urls' | ||
import { | ||
GET_ANSWERS, | ||
POST_ANSWERS, | ||
ANSWER_ERROR | ||
} from './types' | ||
|
||
export const getAnswers = (form_id) => async dispatch => { | ||
try { | ||
const config = { | ||
headers: { | ||
Authorization: `Bearer ${localStorage.token}`, | ||
} | ||
} | ||
const res = await axios.get(urlSubmissions(undefined, form_id), config); | ||
dispatch({ | ||
type: GET_ANSWERS, | ||
payload: res.data | ||
}); | ||
} | ||
catch (err) { | ||
dispatch({ | ||
type: ANSWER_ERROR, | ||
payload: err.response.data | ||
}) | ||
} | ||
} | ||
|
||
export const postAnswers = (data, callback) => async dispatch => { | ||
try { | ||
const config = { | ||
headers: { | ||
Authorization: `Bearer ${localStorage.token}`, | ||
} | ||
} | ||
const res = await axios.post(urlFormFeedback(),data, config); | ||
dispatch({ | ||
type: POST_ANSWERS, | ||
payload: res.data | ||
}); | ||
callback() | ||
} | ||
catch (err) { | ||
dispatch({ | ||
type: ANSWER_ERROR, | ||
payload: err.response.data | ||
}) | ||
} | ||
} |
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
Oops, something went wrong.