From 4fb0eaa4dd58de032f8c9b16bed9eee86cb66b7f Mon Sep 17 00:00:00 2001 From: Avior Date: Wed, 29 Apr 2020 16:01:21 +0200 Subject: [PATCH] #7 done (c'est moche mais TG) Signed-off-by: Avior --- components/CoinItem.jsx | 59 +++++++++++++++++++++++++++++++++++++++++ pages/coins.jsx | 32 ++++++++++++++++++++++ 2 files changed, 91 insertions(+) create mode 100644 components/CoinItem.jsx create mode 100644 pages/coins.jsx diff --git a/components/CoinItem.jsx b/components/CoinItem.jsx new file mode 100644 index 0000000..b6c3ab5 --- /dev/null +++ b/components/CoinItem.jsx @@ -0,0 +1,59 @@ +import React from 'react' +import Link from 'next/link' + +export default class CoinItem extends React.Component { + + + render() { + console.log(this.props.photos) + return ( +
+

Coin {this.props.item.name}

+ + +
+ ) + } +} diff --git a/pages/coins.jsx b/pages/coins.jsx new file mode 100644 index 0000000..c891022 --- /dev/null +++ b/pages/coins.jsx @@ -0,0 +1,32 @@ +import React from 'react' +import CoinItem from '../components/CoinItem' +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() + const locations = await (await fetch(`${hostname}/api/coins`)).json() + return {data, locations} + } + + render() { + return ( +
+ {this.props.locations.map((el, index) => { + // console.log(el, this.props.data.filter((item) => item.coinId == el.id)) + return ( + item.coinId == el.id)} /> + ) + })} +
+ ) + } +}