2020-08-31 00:29:31 +02:00
|
|
|
import React from 'react';
|
2020-08-15 10:17:15 +02:00
|
|
|
import { useRouter } from 'next/router';
|
|
|
|
import Layout from 'components/layout/Layout';
|
2020-09-27 09:51:29 +02:00
|
|
|
import WebsiteDetails from 'components/pages/WebsiteDetails';
|
2020-08-31 00:29:31 +02:00
|
|
|
import useFetch from 'hooks/useFetch';
|
2020-08-15 10:17:15 +02:00
|
|
|
|
|
|
|
export default function SharePage() {
|
|
|
|
const router = useRouter();
|
|
|
|
const { id } = router.query;
|
2020-08-31 00:29:31 +02:00
|
|
|
const shareId = id?.[0];
|
|
|
|
const { data } = useFetch(shareId ? `/api/share/${shareId}` : null);
|
2020-08-15 10:17:15 +02:00
|
|
|
|
2020-08-31 00:29:31 +02:00
|
|
|
if (!data) {
|
|
|
|
return null;
|
2020-08-15 10:17:15 +02:00
|
|
|
}
|
|
|
|
|
2020-09-18 07:52:20 +02:00
|
|
|
const { websiteId, token } = data;
|
|
|
|
|
2020-08-15 10:17:15 +02:00
|
|
|
return (
|
|
|
|
<Layout>
|
2020-09-18 07:52:20 +02:00
|
|
|
<WebsiteDetails websiteId={websiteId} token={token} />
|
2020-08-15 10:17:15 +02:00
|
|
|
</Layout>
|
|
|
|
);
|
|
|
|
}
|