From 3f41f6994743358a457d4c92625c7412de399658 Mon Sep 17 00:00:00 2001 From: Kamran Ahmed Date: Wed, 29 Aug 2018 12:10:53 +0500 Subject: Save options functionality --- src/components/options-form/index.js | 75 +++++++++++++++++++++++++----------- 1 file changed, 53 insertions(+), 22 deletions(-) (limited to 'src/components/options-form') diff --git a/src/components/options-form/index.js b/src/components/options-form/index.js index 393ab93..f83bfe3 100644 --- a/src/components/options-form/index.js +++ b/src/components/options-form/index.js @@ -1,29 +1,60 @@ import React from 'react'; import { Link } from 'react-router-dom'; +import PropTypes from 'prop-types'; import './styles.css'; -const OptionsForm = () => ( -
-
-

Add the Token

-

Generate a token and add it below to avoid hitting the rate limit.

-
-
    -
  • - Go to the Settings Personal Access Tokens of your github profile -
  • -
  • Click Generate New Token. Enter the description and select the scope called public_repo under repo and click Generate Token.
  • -
  • You will be presented with the generated token. Copy the token and add it below
  • -
- -
- - Go Home -
-); +class OptionsForm extends React.Component { + + state = { + token: this.props.options.token + }; + + saveOptions = () => { + this.props.updateOptions({ + token: this.state.token + }); + }; + + onChange = (e) => { + this.setState({ + [e.target.name]: e.target.value + }); + }; + + render() { + return ( +
+
+

Add the Token

+

Generate a token and add it below to avoid hitting the rate limit.

+
+
    +
  • + Go to the Settings Personal Access Tokens of your github profile +
  • +
  • Click Generate New Token. Enter the description and select the scope called public_repo under repo and click Generate Token.
  • +
  • You will be presented with the generated token. Copy the token and add it below
  • +
+ +
+ + Go Home +
+ ); + } +} + +OptionsForm.propTypes = { + updateOptions: PropTypes.func.isRequired, + options: PropTypes.object.isRequired +}; export default OptionsForm; -- cgit v1.3