presque finis #6 vreste plus qu'a avoir un design propres
Signed-off-by: Avior <florian.bouillon@delta-wings.net>
This commit is contained in:
@ -42,7 +42,7 @@ export default async (req, res) => {
|
||||
builder.pseudo = pseudo
|
||||
}
|
||||
if (location) {
|
||||
builder.location = parseInt(location)
|
||||
builder.coinId = parseInt(location)
|
||||
|
||||
}
|
||||
res.end(JSON.stringify(await Photo.findAll(Object.keys(builder).length > 0 ? {where: builder} : undefined)))
|
||||
|
@ -5,20 +5,23 @@ import fetch from 'isomorphic-unfetch'
|
||||
export default class Flux extends React.Component {
|
||||
|
||||
static async getInitialProps(ctx) {
|
||||
const coindId = ctx.query.location
|
||||
const pseudo = ctx.query.pseudo
|
||||
let hostname = ''
|
||||
if (ctx.req) {
|
||||
hostname = `http://${ctx.req.headers.host}`
|
||||
|
||||
}
|
||||
const data = await (await fetch(`${hostname}/api/photos`)).json()
|
||||
return {data}
|
||||
const data = await (await fetch(`${hostname}/api/photos${pseudo ? `?pseudo=${pseudo}${coindId && `&location=${coindId}` || ''}` : `${coindId && `?location=${coindId}` || ''}`}`)).json()
|
||||
const locations = await (await fetch(`${hostname}/api/coins`)).json()
|
||||
return {data, locations}
|
||||
}
|
||||
|
||||
render() {
|
||||
return (
|
||||
<div>
|
||||
{this.props.data.map((el, index) => (
|
||||
<FluxItem key={index} item={el} />
|
||||
<FluxItem key={index} item={el} locations={this.props.locations} />
|
||||
))}
|
||||
</div>
|
||||
)
|
||||
|
Reference in New Issue
Block a user