Advertisement
Guest User

Untitled

a guest
Mar 19th, 2019
50
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. import * as React from 'react';
  2. import {__} from '../../helpers/TranslationService';
  3.  
  4. const wrapperStyle: React.CSSProperties = {
  5. };
  6.  
  7. interface IState {
  8.     cruiseNid: string;
  9. }
  10.  
  11. export class SearchCruise extends React.Component<{}, IState> {
  12.     constructor(props) {
  13.         super(props);
  14.         this.state = {
  15.             cruiseNid: ''
  16.         };
  17.         this.handleChange = this.handleChange.bind(this)
  18.         this.handleSubmit = this.handleSubmit.bind(this);
  19.     }
  20.  
  21.     componentDidMount() {
  22.  
  23.     }
  24.  
  25.     handleSubmit(event) {
  26.         event.preventDefault();
  27.         const data = new FormData(event.target);
  28.         console.log('handleSubmit');
  29.         console.log('this.state.cruiseNid', this.state.cruiseNid);
  30.  
  31.         // const url = `/wp-content/themes/dreamlines/ajax/ajaxhandler.php?action=searchresults_json&searchparams[cruiseNids]=${cruiseNid}`;
  32.         // const urlNotFound = `${window.utilityData.searchPageLink}?cruiseNids=${cruiseNid}`;
  33.  
  34.         // fetch('/api/form-submit-url', {
  35.         //   method: 'POST',
  36.         //   body: data,
  37.         // });
  38.     }
  39.  
  40.     handleChange(e){
  41.         console.log('handleChange', e.target.cruiseNid);
  42.         const re = /^[0-9\b]+$/;
  43.         if (e.target.value === '' || re.test(e.target.value)) {
  44.            this.setState({cruiseNid: e.target.cruiseNid})
  45.         }
  46.     }
  47.  
  48.     render() {
  49.         return (
  50.             <form className='' onSubmit={this.handleSubmit}>
  51.                 <input type="text" value={this.state.cruiseNid} onChange={this.handleChange} className="" placeholder={__('CruiseNid', 'dreamlines')} required />
  52.                 <button>Go!</button>
  53.             </form>
  54.         );
  55.     }
  56. };
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement