import React from 'react' import Layout from '../components/layout' import { callAPI } from '../utils/api' import { withAuthSync } from '../utils/auth' import Chart from '../components/chart' import Purchase from '../components/purchase' const deletePurchase = id => callAPI(null, { url: `/api/purchases/${id}`, method: 'delete', }).then(() => location.reload()).catch(() => alert('There was a problem deleting the purchase')) const Home = ({ purchases, stats, me }) => { return

summa



diarium

{purchases.map((purchase, i) => )}
} Home.getInitialProps = async ctx => ({ stats: await callAPI(ctx, { url: '/api/purchases/stats' }), purchases: await callAPI(ctx, { url: `/api/purchases/` }), me: await callAPI(ctx, { url: '/api/users/me' }), }) export default withAuthSync(Home)