umami/pages/share/[...id].js

25 lines
571 B
JavaScript
Raw Normal View History

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-10-11 11:29:55 +02:00
import useShareToken from 'hooks/useShareToken';
2020-08-15 10:17:15 +02:00
export default function SharePage() {
const router = useRouter();
const { id } = router.query;
const shareId = id?.[0];
2020-10-11 11:29:55 +02:00
const shareToken = useShareToken(shareId);
2020-08-15 10:17:15 +02:00
2020-10-11 11:29:55 +02:00
if (!shareToken) {
return null;
2020-08-15 10:17:15 +02:00
}
2020-10-11 11:29:55 +02:00
const { websiteId } = shareToken;
2020-08-15 10:17:15 +02:00
return (
<Layout>
2020-10-11 11:29:55 +02:00
<WebsiteDetails websiteId={websiteId} />
2020-08-15 10:17:15 +02:00
</Layout>
);
}