-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
c137134
commit 8340f9f
Showing
15 changed files
with
324 additions
and
50 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
import React from 'react'; | ||
import { Grid , Row, Col } from 'react-bootstrap'; | ||
import Navigation from './neighborhoods/Navigation.js'; | ||
import BankAccountForm from './neighborhoods/blocks/houses/Bank Account Form.js'; | ||
import Footer from './neighborhoods/Footer.js'; | ||
import GotoTop from './neighborhoods/blocks/houses/Goto Top.js'; | ||
import Copyright from './neighborhoods/blocks/houses/Copyright.js'; | ||
|
||
|
||
export default class BankAccount extends React.Component { | ||
render() { | ||
return ( | ||
<section className="edit-profile"> | ||
<Navigation logged_in={true} profile_id= {this.props.match.params.profile_id}/> | ||
<Grid> | ||
<br /><Row> | ||
<Col lg={6} lgOffset={3} md={6} mdOffset={3} sm={12} xs={12}> | ||
<BankAccountForm profile_id= {this.props.match.params.profile_id}/> | ||
</Col> | ||
</Row><br /><br /> | ||
</Grid> | ||
<GotoTop/> | ||
<Footer/> | ||
<Copyright/> | ||
</section> | ||
) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
168 changes: 168 additions & 0 deletions
168
src/components/village/neighborhoods/blocks/houses/Bank Account Form.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,168 @@ | ||
import React from 'react'; | ||
import { Redirect } from 'react-router-dom' | ||
import { Button,FormGroup, FormControl, HelpBlock } from 'react-bootstrap'; | ||
import Heading from './Heading' | ||
import Spinner from 'react-activity/lib/Spinner'; | ||
import 'react-activity/lib/Spinner/Spinner.css'; | ||
|
||
|
||
export default class BankAccountForm extends React.Component { | ||
|
||
state = { | ||
isLoading: false, | ||
message : [], | ||
banklist: [] | ||
} | ||
|
||
async componentWillMount(){ | ||
this.setState({ isLoading: true}) | ||
|
||
const auth = localStorage.getItem('auth_code') | ||
|
||
|
||
try { | ||
const res = await fetch('https://www.iwansell.com/api/bank_account/', { | ||
headers : { | ||
'Authorization' : 'Token ' + auth | ||
} | ||
|
||
}) | ||
const banklist = await res.json(); | ||
this.setState({ | ||
banklist | ||
}); | ||
|
||
} catch (e) { | ||
console.log(e); | ||
} | ||
|
||
|
||
this.setState({ isLoading: false}) | ||
} | ||
|
||
|
||
|
||
async update(){ | ||
|
||
this.setState({ isLoading: true}) | ||
const auth = localStorage.getItem('auth_code') | ||
|
||
var account_number = document.getElementById("account_number").value | ||
|
||
var formData = new FormData() | ||
formData.append('account_number', account_number) | ||
|
||
try { | ||
const res = await fetch('https://www.iwansell.com/api/bank_account/', { | ||
|
||
|
||
body : formData, | ||
method: 'POST', | ||
headers : { | ||
'Authorization' : 'Token ' + auth | ||
} | ||
|
||
}) | ||
const banklist = await res.json(); | ||
this.setState({ | ||
banklist | ||
}); | ||
|
||
} catch (e) { | ||
console.log(e); | ||
} | ||
|
||
false | ||
|
||
} | ||
|
||
|
||
emptyResult(){ | ||
|
||
var empty_set = false | ||
|
||
if(this.state.banklist.length <= 0 ){ | ||
empty_set = true | ||
} | ||
|
||
return empty_set | ||
|
||
|
||
} | ||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
render(){ | ||
|
||
const formInstance = ( | ||
<section className="edit-profile-form"> | ||
<Heading title="Add Bank Account"/> | ||
|
||
{this.state.isLoading ? ( | ||
<Spinner color="#ff0000" size={32}/> | ||
) : ( | ||
<div> | ||
{this.emptyResult() ? ( | ||
<p>Its empty here, add bank account</p> | ||
) : ( | ||
|
||
<div> | ||
{this.state.banklist.map(item => | ||
<div> | ||
<p>{item.account_number}</p> | ||
<p>{item.account_name}</p> | ||
</div> | ||
)} | ||
</div> | ||
|
||
)} | ||
</div> | ||
)} | ||
|
||
|
||
|
||
|
||
|
||
<form> | ||
<FormGroup> | ||
<FormControl | ||
id="account_number" | ||
type="text" | ||
label="Account Number" | ||
name="account_number" | ||
placeholder="eg 0838320302" | ||
|
||
/> | ||
<HelpBlock>Add Account Number here for faster electronic transaction</HelpBlock> | ||
</FormGroup> | ||
|
||
{this.state.message.error_message ? ( | ||
<p className="err-msg">{this.state.message.error_message}</p> | ||
) : ( | ||
<span></span> | ||
)} | ||
|
||
{this.state.message.code ? ( | ||
<p className="success-msg">Success!</p> | ||
) : ( | ||
<span></span> | ||
)} | ||
|
||
{this.state.isLoading ? ( | ||
<Spinner color="#ff0000" size={32}/> | ||
) : ( | ||
<div/> | ||
)} | ||
|
||
<Button onClick={this.update.bind(this)}>add new</Button> | ||
</form> | ||
</section> | ||
); | ||
|
||
return (formInstance); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.