熊谷洸介(Kousuke Kumagai) hace 5 años
padre
commit
338cbd2b0e
Se han modificado 1 ficheros con 54 adiciones y 8 borrados
  1. 54 8
      src/client/js/components/ShareLinkForm.jsx

+ 54 - 8
src/client/js/components/ShareLinkForm.jsx

@@ -17,24 +17,37 @@ class ShareLinkForm extends React.Component {
   constructor(props) {
   constructor(props) {
     super(props);
     super(props);
     this.state = {
     this.state = {
-      value: ' '
+      isGoing: true,
+      numberOfGuests: '',
+      value: ' ',
     };
     };
 
 
+    this.handleInputChange = this.handleInputChange.bind(this);
     this.handleChange = this.handleChange.bind(this);
     this.handleChange = this.handleChange.bind(this);
     this.handleSubmit = this.handleSubmit.bind(this);
     this.handleSubmit = this.handleSubmit.bind(this);
   }
   }
 
 
+  handleInputChange(event) {
+    const target = event.target;
+    const value = target.name === 'isGoing' ? target.checked : target.value;
+    const name = target.name;
+
+    this.setState({
+      [name]: value
+    });
+
+  }
+
   handleChange(event) {
   handleChange(event) {
     this.setState({ value: event.target.value });
     this.setState({ value: event.target.value });
-    console.log( event.target.value) ;
+    console.log(event.target.value);
   }
   }
 
 
   handleSubmit(event) {
   handleSubmit(event) {
     event.preventDefault();
     event.preventDefault();
-    console.log( '発行する!' );
+    console.log('発行する!');
   }
   }
 
 
-
   render() {
   render() {
     return (
     return (
       <div className="share-link-form border">
       <div className="share-link-form border">
@@ -42,22 +55,54 @@ class ShareLinkForm extends React.Component {
         <form onSubmit={this.handleSubmit}>
         <form onSubmit={this.handleSubmit}>
           <div className="form-group">
           <div className="form-group">
             <div className="custom-control custom-radio offset-4 mb-2">
             <div className="custom-control custom-radio offset-4 mb-2">
-              <input id="customRadio1" name="customRadio" type="radio" className="custom-control-input"></input>
+              <input
+                type="radio"
+                className="custom-control-input"
+                id="customRadio1"
+                name="isGoing"
+                value="customRadio1"
+                checked={this.state.isGoing}
+                onChange={this.handleInputChange}
+              />
               <label className="custom-control-label" htmlFor="customRadio1">Unlimited</label>
               <label className="custom-control-label" htmlFor="customRadio1">Unlimited</label>
             </div>
             </div>
 
 
             <div className="custom-control custom-radio offset-4 mb-2">
             <div className="custom-control custom-radio offset-4 mb-2">
-              <input id="customRadio2" name="customRadio" type="radio" className="custom-control-input"></input>
+              <input
+                type="radio"
+                className="custom-control-input"
+                id="customRadio2"
+                value="customRadio2"
+                onChange={this.handleInputChange}
+                name="isGoing"
+              />
               <label className="custom-control-label" htmlFor="customRadio2">
               <label className="custom-control-label" htmlFor="customRadio2">
+
                 <div className="row align-items-center m-0">
                 <div className="row align-items-center m-0">
-                  <input className="form-control col-2" type="number" min="1" max="7" value="7"></input>
+                  <input
+                    type="number"
+                    min="1"
+                    max="7"
+                    className="form-control col-5"
+                    name="numberOfGuests"
+                    value={this.state.numberOfGuests}
+                    onChange={this.handleInputChange}
+                  />
                   <span className="col-auto">Days</span>
                   <span className="col-auto">Days</span>
                 </div>
                 </div>
               </label>
               </label>
             </div>
             </div>
 
 
             <div className="custom-control custom-radio offset-4 mb-2">
             <div className="custom-control custom-radio offset-4 mb-2">
-              <input id="customRadio3" name="customRadio" type="radio" className="custom-control-input"></input>
+              <input
+                type="radio"
+                className="custom-control-input"
+                id="customRadio3"
+                name="isGoing"
+                value="customRadio3"
+                checked={this.state.isGoing}
+                onChange={this.handleInputChange}
+              />
               <label className="custom-control-label" htmlFor="customRadio3">
               <label className="custom-control-label" htmlFor="customRadio3">
                 Custom
                 Custom
               <div className="date-picker">Date Picker</div>
               <div className="date-picker">Date Picker</div>
@@ -81,6 +126,7 @@ class ShareLinkForm extends React.Component {
           </div>
           </div>
         </form>
         </form>
       </div>
       </div>
+
     );
     );
   };
   };
 }
 }