-
Notifications
You must be signed in to change notification settings - Fork 14
Ht3 #14
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
veresku
wants to merge
7
commits into
romabelka:master
Choose a base branch
from
veresku:HT3
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Ht3 #14
Changes from all commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
d8b4d50
done
veresku 81b44c6
Merge branch 'master' of https://github.com/romabelka/advreact_04_12
veresku 8c9f77f
Merge branch 'master' of https://github.com/romabelka/advreact_04_12
veresku cb4f683
Merge branch 'master' of https://github.com/romabelka/advreact_04_12
veresku 5d192bd
merge after new lesson
veresku 8196e6d
##HT3.1 Добавлять людей в firebase
veresku 31816aa
##HT3.2
veresku File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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 hidden or 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 hidden or 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,72 @@ | ||
| import React, {Component} from 'react' | ||
| import firebase from 'firebase/index' | ||
|
|
||
| class EventList extends Component { | ||
| static propTypes = { | ||
|
|
||
| }; | ||
|
|
||
| state = { | ||
| events: null | ||
| } | ||
|
|
||
| componentDidMount = () => { | ||
| const eventsRef = firebase.database().ref('events/'); | ||
|
|
||
| eventsRef.on('value', (snapshot) => { | ||
| let events = [] | ||
|
|
||
| snapshot.forEach((childSnapshot) => { | ||
| events.push({ | ||
| id: childSnapshot.key, | ||
| ...childSnapshot.val() | ||
| }) | ||
| }); | ||
|
|
||
| this.setState({events: events}); | ||
| }); | ||
| } | ||
|
|
||
| getEventList = (events) => { | ||
| return ( | ||
| <table> | ||
| <thead> | ||
| <tr> | ||
| <th>Month</th> | ||
| <th>Deadline</th> | ||
| <th>Title</th> | ||
| <th>URL</th> | ||
| <th>When</th> | ||
| <th>Where</th> | ||
| </tr> | ||
| </thead> | ||
| <tbody> | ||
| { | ||
| events.map(event => | ||
| <tr key={event.id}> | ||
| <td>{event.month}</td> | ||
| <td>{event.submissionDeadline}</td> | ||
| <td>{event.title}</td> | ||
| <td>{event.url}</td> | ||
| <td>{event.when}</td> | ||
| <td>{event.where}</td> | ||
| </tr> | ||
| ) | ||
| } | ||
| </tbody> | ||
| </table> | ||
| ) | ||
| } | ||
|
|
||
| render() { | ||
| const {events} = this.state | ||
|
|
||
| return ( | ||
| <div> | ||
| {!events ? <p>List is empty</p> : this.getEventList(events)} | ||
| </div> | ||
| ) | ||
| } | ||
| } | ||
|
|
||
| export default EventList | ||
78 changes: 78 additions & 0 deletions
78
admin-panel/src/components/events/EventsInfiniteLoaderVirtualized.js
This file contains hidden or 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,78 @@ | ||
| import React, {Component} from 'react' | ||
| import {connect} from 'react-redux' | ||
| import { | ||
| fetchLimitEvents, | ||
| selectEvent, | ||
| fetchAllEvents, | ||
| eventLimitListSelector, | ||
| eventListSelector | ||
| } from '../../ducks/events' | ||
| import {InfiniteLoader, List} from 'react-virtualized' | ||
| import 'react-virtualized/styles.css' | ||
|
|
||
| export class EventsInfiniteLoaderVirtualized extends Component { | ||
| static propTypes = {}; | ||
|
|
||
| componentDidMount() { | ||
| this.props.fetchAllEvents() | ||
| this.loadMoreRows({startIndex: 0, stopIndex: 10}) | ||
| } | ||
|
|
||
| loadMoreRows = ({startIndex, stopIndex}) => { | ||
| this.props.fetchLimitEvents(startIndex, stopIndex) | ||
| } | ||
|
|
||
| isRowLoaded = ({index}) => { | ||
| return !!this.props.events[index]; | ||
| } | ||
|
|
||
| rowRenderer = ({key, index, style}) => { | ||
| const {events} = this.props | ||
|
|
||
| return ( | ||
| <div | ||
| key={key} | ||
| style={style} | ||
| > | ||
| {events[index] && this.getRow(events[index])} | ||
| </div> | ||
| ) | ||
| } | ||
|
|
||
| getRow = (event) => ( | ||
| <div key={event.uid} className="test__event_div_row"> | ||
| <span>{event.title}</span> | ||
| <span>{event.when}</span> | ||
| <span>{event.where}</span> | ||
| </div> | ||
| ) | ||
|
|
||
| render() { | ||
| const {eventsTotal, loading} = this.props | ||
|
|
||
| return ( | ||
| <InfiniteLoader | ||
| isRowLoaded={this.isRowLoaded} | ||
| loadMoreRows={this.loadMoreRows} | ||
| rowCount={eventsTotal} | ||
| > | ||
| {({onRowsRendered, registerChild}) => ( | ||
| <List | ||
| height={200} | ||
| onRowsRendered={onRowsRendered} | ||
| ref={registerChild} | ||
| rowCount={eventsTotal} | ||
| rowHeight={20} | ||
| rowRenderer={this.rowRenderer} | ||
| width={600} | ||
| /> | ||
| )} | ||
| </InfiniteLoader> | ||
| ) | ||
| } | ||
| } | ||
|
|
||
| export default connect((state) => ({ | ||
| events: eventLimitListSelector(state), | ||
| eventsTotal: eventListSelector(state).length, | ||
|
Owner
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. откуда у тебя total? там ведьпросто загруженные на данный момент |
||
| }), {fetchLimitEvents, selectEvent, fetchAllEvents})(EventsInfiniteLoaderVirtualized) | ||
This file contains hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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,50 @@ | ||
| import React, { Component } from 'react'; | ||
| import PropTypes from 'prop-types'; | ||
| import {reduxForm, Field} from 'redux-form'; | ||
| import validator from 'email-validator'; | ||
|
|
||
| import ErrorField from '../common/ErrorField'; | ||
|
|
||
| class NewUserForm extends Component { | ||
| static propTypes = { | ||
| handleSubmit: PropTypes.func.isRequired | ||
| }; | ||
|
|
||
| render() { | ||
| return ( | ||
| <div> | ||
| <h3>Add user</h3> | ||
| <form onSubmit={this.props.handleSubmit}> | ||
| <div> | ||
| First name: <Field name='firstName' component={ErrorField} /> | ||
| </div> | ||
| <div> | ||
| Last name: <Field name='lastName' component={ErrorField} /> | ||
| </div> | ||
| <div> | ||
| Email: <Field name='email' component={ErrorField} type='email' /> | ||
| </div> | ||
| <input type='submit' /> | ||
| </form> | ||
|
|
||
| </div> | ||
| ) | ||
| } | ||
| } | ||
|
|
||
| const validate = ({ firstName, lastName, email }) => { | ||
| const errors = {}; | ||
|
|
||
| if (!email) errors.email = 'Email is a required field'; | ||
| if (email && !validator.validate(email)) errors.email = 'Incorrect email format'; | ||
|
|
||
| if (!firstName) errors.firstName = 'First name is a required field'; | ||
| if (!lastName) errors.lastName = 'Last name is a required field'; | ||
|
|
||
| return errors; | ||
| } | ||
|
|
||
| export default reduxForm({ | ||
| form: 'new-user', | ||
| validate | ||
| })(NewUserForm) |
This file contains hidden or 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 |
|---|---|---|
| @@ -1,14 +1,14 @@ | ||
| import firebase from 'firebase' | ||
| import firebase from 'firebase'; | ||
|
|
||
| export const appName = 'advreact-04-12' | ||
| export const appName = 'adv-react-8c4fb'; | ||
|
|
||
| const config = { | ||
| apiKey: "AIzaSyCmDWlgYIhtEr1pWjgKYds3iXKWBl9wbjE", | ||
| apiKey: "AIzaSyCPlodrXJgpCXqDWklsFc_V5vHGiD6G2Uc", | ||
| authDomain: `${appName}.firebaseapp.com`, | ||
| databaseURL: `https://${appName}.firebaseio.com`, | ||
| projectId: appName, | ||
| storageBucket: "", | ||
| messagingSenderId: "95255462276" | ||
| } | ||
| projectId: {appName}, | ||
| storageBucket: "adv-react-8c4fb.appspot.com", | ||
| messagingSenderId: "47356959167" | ||
| }; | ||
|
|
||
| firebase.initializeApp(config) | ||
| firebase.initializeApp(config); |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ну делать запросы прямо из компонента - так себе идея. У нас для этого саги есть