{"action":"closed","issue":{"url":"https://api.github.com/repos/calblueprint/RMI/issues/121","repository_url":"https://api.github.com/repos/calblueprint/RMI","labels_url":"https://api.github.com/repos/calblueprint/RMI/issues/121/labels{/name}","comments_url":"https://api.github.com/repos/calblueprint/RMI/issues/121/comments","events_url":"https://api.github.com/repos/calblueprint/RMI/issues/121/events","html_url":"https://github.com/calblueprint/RMI/issues/121","id":275219532,"number":121,"title":"Answer create action + reducer","user":{"login":"HacksForHugs","id":14208152,"avatar_url":"https://avatars2.githubusercontent.com/u/14208152?v=4","gravatar_id":"","url":"https://api.github.com/users/HacksForHugs","html_url":"https://github.com/HacksForHugs","followers_url":"https://api.github.com/users/HacksForHugs/followers","following_url":"https://api.github.com/users/HacksForHugs/following{/other_user}","gists_url":"https://api.github.com/users/HacksForHugs/gists{/gist_id}","starred_url":"https://api.github.com/users/HacksForHugs/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/HacksForHugs/subscriptions","organizations_url":"https://api.github.com/users/HacksForHugs/orgs","repos_url":"https://api.github.com/users/HacksForHugs/repos","events_url":"https://api.github.com/users/HacksForHugs/events{/privacy}","received_events_url":"https://api.github.com/users/HacksForHugs/received_events","type":"User","site_admin":false},"labels":[{"id":710013065,"url":"https://api.github.com/repos/calblueprint/RMI/labels/Views","name":"Views","color":"f9d0c4","default":false}],"state":"closed","locked":false,"assignee":{"login":"kevintli","id":6785060,"avatar_url":"https://avatars0.githubusercontent.com/u/6785060?v=4","gravatar_id":"","url":"https://api.github.com/users/kevintli","html_url":"https://github.com/kevintli","followers_url":"https://api.github.com/users/kevintli/followers","following_url":"https://api.github.com/users/kevintli/following{/other_user}","gists_url":"https://api.github.com/users/kevintli/gists{/gist_id}","starred_url":"https://api.github.com/users/kevintli/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/kevintli/subscriptions","organizations_url":"https://api.github.com/users/kevintli/orgs","repos_url":"https://api.github.com/users/kevintli/repos","events_url":"https://api.github.com/users/kevintli/events{/privacy}","received_events_url":"https://api.github.com/users/kevintli/received_events","type":"User","site_admin":false},"assignees":[{"login":"kevintli","id":6785060,"avatar_url":"https://avatars0.githubusercontent.com/u/6785060?v=4","gravatar_id":"","url":"https://api.github.com/users/kevintli","html_url":"https://github.com/kevintli","followers_url":"https://api.github.com/users/kevintli/followers","following_url":"https://api.github.com/users/kevintli/following{/other_user}","gists_url":"https://api.github.com/users/kevintli/gists{/gist_id}","starred_url":"https://api.github.com/users/kevintli/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/kevintli/subscriptions","organizations_url":"https://api.github.com/users/kevintli/orgs","repos_url":"https://api.github.com/users/kevintli/repos","events_url":"https://api.github.com/users/kevintli/events{/privacy}","received_events_url":"https://api.github.com/users/kevintli/received_events","type":"User","site_admin":false}],"milestone":null,"comments":0,"created_at":"2017-11-20T02:26:05Z","updated_at":"2018-03-10T22:43:15Z","closed_at":"2018-03-10T22:43:15Z","author_association":"CONTRIBUTOR","body":"<h1> Redux action for creating an answer </h1>\r\n\r\nResolves #117 \r\n\r\n<h3> Fixes </h3>\r\n\r\n- [x] Fix fetch function to send proper answer data\r\n- [x] Make answer reducers properly update answer in store\r\n- [x] Temporary answers not working? (_View doesn't update until after we get a fetch response_)\r\n- [ ] React-controlled `RangeOption` should still update even if no dependent option was hit\r\n\r\n<h3> Integrate into questionnaire </h3>\r\n\r\n- [x] Make OptionsContainer dispatch an action to update answer in store\r\n- [ ] Retry component to submit answer again when fetch request fails\r\n\r\n<h3> Actions file </h3>\r\n\r\n- [x]  Create Answers actions file\r\n\r\n- [x]  Create `current_fetching` answer action\r\n    - type: `IS_FETCHING` and any other parameters necessary for reducer\r\n\r\n- [x] Create `update_answer` answer action\r\n    - type: `UPDATE_ANSWER` and answer object to set as params\r\n\r\n- [x] Create `done_fetching` answer action\r\n    - inputs dispatch and serialized answer object\r\n    - type: `DONE_FETCHING` and any other parameters necessary for reducer. \r\n\r\n<h3> Reducer file </h3>\r\n\r\n- [x] Create Answers reducer file\r\n\r\n- [x] Contains a case for `UPDATE_ANSWER`\r\n    - The answer object should be added to the redux store state under the correct building object inside the answers object.\r\n\r\n- [x] Contains a case for `IS_FETCHING`\r\n    - when this action is dispatched, redux store state should have a key, value `{ fetching_answer_status: true }`\r\n\r\n- [x] Contains a case for `DONE_FETCHING`\r\n    - redux store state should have key `fetching_answer_status` set to `false`\r\n\r\n<h3> Constants file </h3>\r\n\r\n- [x] Add necessary constants for action type to constants file\r\n\r\n<h3> Action file </h3>\r\n\r\n- [x] edit_answer action (`PATCH` instead of `POST`)\r\n- [x] create_answer action\r\n    - Inputs dispatch and options for any necessary arguments (i.e. answer parameters)\r\n    - pseudo:\r\n\r\n```\r\ncreateAnswer(dispatch, answer_params={}) {\r\n     dispatch currently_fetching(set_fetching: true)\r\n     await fetch( url='/api/answers/create', body=answer_params).then(\r\n          function(response) { \r\n               dispatch update_answer(answer_params)\r\n               dispatch done_fetching(set_fetching: false) \r\n          }\r\n      )\r\n}\r\n```\r\n"}}
{"actor":{"display_login":"ethanlee16"}}