-
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
971 additions
and
866 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,47 +1,41 @@ | ||
import React, { Component } from 'react'; | ||
import { Route, Switch, Redirect } from 'react-router-dom'; | ||
import Login from './components/Login'; | ||
import Register from './components/Register'; | ||
import Activate from './components/Activate'; | ||
import Dashboard from './components/Dashboard'; | ||
import Forms from './components/Forms'; | ||
import ErrorPage from './components/ErrorPage'; | ||
import Submission from './components/Submission'; | ||
import Questions from './components/Questions'; | ||
import { | ||
login, | ||
register, | ||
activate, | ||
dashboard, | ||
forms, | ||
upload, | ||
submission, | ||
urlBaseFrontend, | ||
} from './urls'; | ||
import Upload from './components/Upload'; | ||
import { PrivateRoute } from './PrivateRoute'; | ||
import { AuthRoute } from './AuthRoute'; | ||
import React, { Component } from 'react' | ||
import { Route, Switch, Redirect } from 'react-router-dom' | ||
import Login from './components/Login' | ||
import Register from './components/Register' | ||
import Dashboard from './components/Dashboard' | ||
import Forms from './components/Forms' | ||
import ErrorPage from './components/ErrorPage' | ||
import Submission from './components/Submission' | ||
import Questions from './components/Questions' | ||
import { | ||
login, | ||
register, | ||
dashboard, | ||
forms, | ||
submission, | ||
urlBaseFrontend | ||
} from './urls' | ||
import {PrivateRoute} from './PrivateRoute' | ||
import { AuthRoute } from './AuthRoute' | ||
|
||
export default class Routes extends Component { | ||
render() { | ||
return ( | ||
<> | ||
<Switch> | ||
<PrivateRoute exact path={dashboard()} component={Dashboard} /> | ||
<PrivateRoute exact path={forms()} component={Forms} /> | ||
<PrivateRoute exact path={submission()} component={Submission} /> | ||
<PrivateRoute | ||
exact | ||
path={`${urlBaseFrontend()}form/:id`} | ||
component={Questions} | ||
/> | ||
<AuthRoute path={login()} component={Login} /> | ||
<AuthRoute path={register()} component={Register} /> | ||
<AuthRoute path={activate()} component={Activate} /> | ||
<Route path={upload()} component={Upload} /> | ||
<AuthRoute component={ErrorPage} /> | ||
</Switch> | ||
</> | ||
); | ||
} | ||
render() { | ||
return ( | ||
<> | ||
<Switch> | ||
<PrivateRoute exact path={dashboard()} component={Dashboard} /> | ||
<PrivateRoute exact path={forms()} component={Forms} /> | ||
<PrivateRoute exact path={submission()} component={Submission} /> | ||
<PrivateRoute | ||
exact | ||
path={`${urlBaseFrontend()}form/:id`} | ||
component={Questions} | ||
/> | ||
<AuthRoute path={login()} component={Login} /> | ||
<AuthRoute path={register()} component={Register} /> | ||
<AuthRoute component={ErrorPage} /> | ||
</Switch> | ||
</> | ||
) | ||
} | ||
} |
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.