added details drawer
This commit is contained in:
@@ -0,0 +1,41 @@
|
||||
import LinkDetails from "@/components/LinkDetails";
|
||||
import { useGetLink } from "@/hooks/store/links";
|
||||
import { useRouter } from "next/router";
|
||||
import { useEffect, useState } from "react";
|
||||
import getServerSideProps from "@/lib/client/getServerSideProps";
|
||||
|
||||
const Index = () => {
|
||||
const router = useRouter();
|
||||
const { id } = router.query;
|
||||
|
||||
useState;
|
||||
|
||||
const getLink = useGetLink();
|
||||
|
||||
useEffect(() => {
|
||||
getLink.mutate({ id: Number(id) });
|
||||
}, []);
|
||||
|
||||
return (
|
||||
<div className="flex h-screen">
|
||||
{getLink.data ? (
|
||||
<LinkDetails
|
||||
link={getLink.data}
|
||||
className="mx-auto max-w-2xl p-5 m-auto w-full"
|
||||
/>
|
||||
) : (
|
||||
<div className="mx-auto max-w-2xl p-5 m-auto w-full flex flex-col items-center gap-5">
|
||||
<div className="w-20 h-20 skeleton rounded-xl"></div>
|
||||
<div className="w-full h-10 skeleton rounded-xl"></div>
|
||||
<div className="w-full h-10 skeleton rounded-xl"></div>
|
||||
<div className="w-full h-10 skeleton rounded-xl"></div>
|
||||
<div className="w-full h-10 skeleton rounded-xl"></div>
|
||||
</div>
|
||||
)}
|
||||
</div>
|
||||
);
|
||||
};
|
||||
|
||||
export default Index;
|
||||
|
||||
export { getServerSideProps };
|
||||
@@ -6,10 +6,9 @@ import {
|
||||
} from "@/types/global";
|
||||
import ReadableView from "@/components/ReadableView";
|
||||
import getServerSideProps from "@/lib/client/getServerSideProps";
|
||||
import { useGetLink, useLinks } from "@/hooks/store/links";
|
||||
import { useGetLink } from "@/hooks/store/links";
|
||||
|
||||
export default function Index() {
|
||||
const { links } = useLinks();
|
||||
const getLink = useGetLink();
|
||||
|
||||
const [link, setLink] = useState<LinkIncludingShortenedCollectionAndTags>();
|
||||
@@ -19,18 +18,14 @@ export default function Index() {
|
||||
useEffect(() => {
|
||||
const fetchLink = async () => {
|
||||
if (router.query.id) {
|
||||
await getLink.mutateAsync(Number(router.query.id));
|
||||
const get = await getLink.mutateAsync({ id: Number(router.query.id) });
|
||||
setLink(get);
|
||||
}
|
||||
};
|
||||
|
||||
fetchLink();
|
||||
}, []);
|
||||
|
||||
useEffect(() => {
|
||||
if (links && links[0])
|
||||
setLink(links.find((e) => e.id === Number(router.query.id)));
|
||||
}, [links]);
|
||||
|
||||
return (
|
||||
<div className="relative">
|
||||
{/* <div className="fixed left-1/2 transform -translate-x-1/2 w-fit py-1 px-3 bg-base-200 border border-neutral-content rounded-md">
|
||||
@@ -39,6 +34,12 @@ export default function Index() {
|
||||
{link && Number(router.query.format) === ArchivedFormat.readability && (
|
||||
<ReadableView link={link} />
|
||||
)}
|
||||
{link && Number(router.query.format) === ArchivedFormat.monolith && (
|
||||
<iframe
|
||||
src={`/api/v1/archives/${link.id}?format=${ArchivedFormat.monolith}`}
|
||||
className="w-full h-screen border-none"
|
||||
></iframe>
|
||||
)}
|
||||
{link && Number(router.query.format) === ArchivedFormat.pdf && (
|
||||
<iframe
|
||||
src={`/api/v1/archives/${link.id}?format=${ArchivedFormat.pdf}`}
|
||||
|
||||
Reference in New Issue
Block a user