import React, { Component, Fragment } from 'react';
import { connect } from 'react-redux';
import { personsFetchData } from '../Actions/persons';
// import { User, Headline, Paragraph, UserImage } from '../Website/Users/UsersStyles';
class PersonsData extends Component {
componentDidMount() {
this.props.fetchData('https://frontend-test-assignment-api.abz.agency/api/v1/users');
}
render() {
const { users } = this.props.persons;
return(
<Fragment>
{ users ? users.map(user => <div>{ user.name }</div>) : null }
</Fragment>
);
}
}
const mapStateToProps = state => ({
persons: state.persons.payload,
});
const mapDispatchToProps = dispatch => ({
fetchData: url => dispatch(personsFetchData(url)),
});
export default connect(mapStateToProps, mapDispatchToProps)(PersonsData);
import React, { Component, Fragment } from 'react';
import { connect } from 'react-redux';
import { personsFetchData } from '../Actions/persons';
// import { User, Headline, Paragraph, UserImage } from '../Website/Users/UsersStyles';
class PersonsData extends Component {
componentDidMount() {
this.props.fetchData('https://frontend-test-assignment-api.abz.agency/api/v1/users');
}
render() {
const { users } = this.props.persons;
return(
<Fragment>
{ users.map(user => <div>{ user.name }</div>) ?? null }
</Fragment>
);
}
}
const mapStateToProps = state => ({
persons: state.persons.payload,
});
const mapDispatchToProps = dispatch => ({
fetchData: url => dispatch(personsFetchData(url)),
});
export default connect(mapStateToProps, mapDispatchToProps)(PersonsData);
const { persons } = this.props.persons.users;
наconst { persons } = this.props.persons;
console.log(persons);
import React, { Component, Fragment } from 'react';
import { connect } from 'react-redux';
import { personsFetchData } from '../Actions/persons';
// import { User, Headline, Paragraph, UserImage } from '../Website/Users/UsersStyles';
class PersonsData extends Component {
componentDidMount() {
this.props.fetchData('https://frontend-test-assignment-api.abz.agency/api/v1/users');
}
render() {
const { persons } = this.props.persons.users;
return(
<Fragment>
{ persons.map(person => <div>{ person.name }</div>) ?? null }
</Fragment>
);
}
}
const mapStateToProps = state => ({
persons: state.persons.payload,
});
const mapDispatchToProps = dispatch => ({
fetchData: url => dispatch(personsFetchData(url)),
});
export default connect(mapStateToProps, mapDispatchToProps)(PersonsData);
import React, { Component, Fragment } from 'react';
import { connect } from 'react-redux';
import { personsFetchData } from '../Actions/persons';
// import { User, Headline, Paragraph, UserImage } from '../Website/Users/UsersStyles';
class PersonsData extends Component {
componentDidMount() {
this.props.fetchData('https://frontend-test-assignment-api.abz.agency/api/v1/users');
}
render() {
const { persons } = this.props.persons.users;
return(
<Fragment>
{ persons.map(person => <div>{ person.name }</div>) }
</Fragment>
);
}
}
const mapStateToProps = state => ({
persons: state.persons.payload,
});
const mapDispatchToProps = dispatch => ({
fetchData: url => dispatch(personsFetchData(url)),
});
export default connect(mapStateToProps, mapDispatchToProps)(PersonsData);
$('.action__button.primary').on('click', function() {
var fd = new FormData;
var avatar = $('input[name=avatar]');
fd.append('avatar', avatar.prop('files')[0]);
fd.append('csrfmiddlewaretoken', '{{ csrf_token }}');
$.ajax({
type: 'POST',
url: '{% url "Home:Edit" %}',
data: fd,
processData: false,
contentType: false,
success: function() {
window.location.href = '{% url "Profile:Profile" username=user.username %}'
}
})
})
Или: https://developer.mozilla.org/en-US/docs/Web/API/G... (если хотите без карт)