-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathPhotoList.js
More file actions
68 lines (61 loc) · 2.19 KB
/
PhotoList.js
File metadata and controls
68 lines (61 loc) · 2.19 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
import React, { Component } from 'react';
import { connect } from 'react-redux';
import { NavLink } from 'react-router-dom';
import PropTypes from 'prop-types';
import { openUploadWidget } from '../utils/CloudinaryService';
import { photosUploaded } from '../actions';
import Photo from './Photo';
import Introduction from './Introduction';
import {CloudinaryContext} from 'cloudinary-react';
class PhotoList extends Component {
render() {
return (
<div className="photoList">
<Introduction />
<h1> Please see all photos of our state and city and the latitude and longitude for the same to give help</h1>
<div className="actions">
<NavLink className="upload_link" exact to="/photos/new">
Upload Photo of your location
</NavLink>
</div>
<div className="photos">
{this.props.photos.length === 0 && (
<p>No photos were added yet.</p>
)}
{this.props.photos.map(photo => {
return (
<Photo
key={photo.public_id}
publicId={photo.public_id}
context={photo.context}
/>
);
})}
</div>
</div>
);
}
uploadImageWithCloudinary() {
const uploadOptions = { tags: 'myphotoalbum', ...this.context };
openUploadWidget(uploadOptions, (error, photos) => {
if (!error) {
this.props.onPhotosUploaded(photos);
} else {
console.log(error);
}
});
}
static contextType = CloudinaryContext.contextType;
}
PhotoList.propTypes = {
photos: PropTypes.array,
onPhotosUploaded: PropTypes.func,
};
const PhotoListContainer = connect(
state => ({ photos: state.photos }),
{
onPhotosUploaded: photosUploaded,
}
)(PhotoList);
Object.assign(PhotoListContainer.contextTypes, PhotoList.contextTypes);
export default PhotoListContainer;