diff --git a/react-debug/src/App.js b/react-debug/src/App.js index c5274af..d891b59 100644 --- a/react-debug/src/App.js +++ b/react-debug/src/App.js @@ -1,6 +1,50 @@ import React from 'react'; -class App extends React.Component { +class Album extends React.Component { + constructor(props) { + super(props); + this.state = { + error: null, + album: null, + }; + } + componentDidMount() { + let {album} = this.props; + fetch(process.env.PUBLIC_URL + `/photosync/${album}/album.json`) + .then(res => res.json()) + .then( + (result) => this.setState({album: result}), + (error) => this.setState({error}), + ); + } + render() { + let {error, album} = this.state; + console.log(this.state); + if (error !== null) { + return

Error: {JSON.stringify(error)}

; + } else if (album !== null) { + console.log(album); + return album.map((a) => { + let img = unset; + if (a.coverPhotoBaseUrl !== undefined) { + img = {; + } + + let figure =
+ {img} +
{ a.title || "No title" } - { a.mediaItemsCount || 0 } photos
+
; + return + { figure } + + }); + } else { + return

Loading...

; + } + } +} + +class AlbumIndex extends React.Component { constructor(props) { super(props); this.state = { @@ -18,29 +62,45 @@ class App extends React.Component { } render() { let {error, albums} = this.state; - console.log(this.state); - let content; if (error !== null) { - content =

Error: {JSON.stringify(error)}

; + return

Error: {JSON.stringify(error)}

; } else if (albums !== null) { console.log(albums); - content = albums.map((a) => { - let thumb = ; + return albums.map((a) => { + let img = unset; if (a.coverPhotoBaseUrl !== undefined) { - thumb = {; + img = {; } - return
- - {thumb} + + let figure =
+ {img} +
{ a.title || "No title" } - { a.mediaItemsCount || 0 } photos
+
; + return
+ { figure } -
-
{ a.title }
- { a.mediaItemsCount } photos -
-
}); } else { - content =

Loading...

; + return

Loading...

; + } + } +} + +class App extends React.Component { + constructor(props) { + super(props); + this.state = { + curAlbum: window.location.hash, + }; + } + render() { + let {curAlbum} = this.state; + console.log(this.state); + let content; + if (curAlbum) { + content = + } else { + content = ; } return (