Skip to content

Instantly share code, notes, and snippets.

@cristianoliveira
Last active April 5, 2018 06:00
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save cristianoliveira/bfc604f24763cf07aeb27533730ef92e to your computer and use it in GitHub Desktop.
Save cristianoliveira/bfc604f24763cf07aeb27533730ef92e to your computer and use it in GitHub Desktop.
Same same but different - post
// CountryAddressForm.js
const COUNTRY_REGIONS = { IE:[], SP:[], IT:[] };
render() {
return(
<form action="#"
onSubmit={this.handleSubmit.bind(this)}
onChange={this.handleChange.bind(this)}>
<CountrySelector name="country" countries={countries} />
<AddressLineInput name="address_line" value={this.state.address_line} />
{this.state.country === 'BR' && <StreetNumberInput name="street_no" />}
{this.state.country === 'BR' && this.state.address_line && (
<WarningMessage text="address_form.fill_form" />)
}
<AddressLineInput name="address_line2" value={props.address_line2} optional />
<PostCodeInput name="post_code" value={props.post_code} />
<CityInput name="city" value={props.city} />
{COUNTRY_REGIONS[this.state.country] && (
<RegionSelector
name="region"
regions={formatRegions(COUNTRY_REGIONS[this.state.country])} />)
}
<button>Submit</button>
</form>
);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment