Refactor components and styles.

This commit is contained in:
Mike Cao 2020-08-03 18:12:28 -07:00
parent c5599f1e20
commit a2db27894f
16 changed files with 189 additions and 184 deletions

View file

@ -6,7 +6,7 @@ export default async (req, res) => {
const { id } = req.query;
const website = await getWebsite(id);
const website = await getWebsite({ website_id: +id });
return res.status(200).json(website);
};

View file

@ -1,26 +1,13 @@
import React from 'react';
import Link from 'next/link';
import { parse } from 'cookie';
import Layout from 'components/Layout';
import PageviewsChart from 'components/PageviewsChart';
import { verifySecureToken } from 'lib/crypto';
import { subDays, endOfDay } from 'date-fns';
import WebsiteList from '../components/WebsiteList';
export default function HomePage({ username }) {
return (
<Layout>
<WebsiteList />
<div>
<PageviewsChart
websiteId={3}
startDate={subDays(endOfDay(new Date()), 6)}
endDate={endOfDay(new Date())}
/>
</div>
<Link href="/logout">
<a>Logout 🡒</a>
</Link>
</Layout>
);
}

View file

@ -1,15 +1,19 @@
import React from 'react';
import { useRouter } from 'next/router';
import Layout from 'components/Layout';
import WebsiteDetails from '../components/WebsiteDetails';
import WebsiteDetails from '../../components/WebsiteDetails';
export default function DetailsPage() {
const router = useRouter();
const { id } = router.query;
if (!id) {
return null;
}
return (
<Layout>
<WebsiteDetails websiteId={id} />
<WebsiteDetails websiteId={+id[0]} />
</Layout>
);
}