48 lines
1.9 KiB
TypeScript
Raw Normal View History

2023-10-16 10:59:28 -04:00
import { ReactElement, ReactNode } from "react";
import { nip19 } from "nostr-tools";
import { redirect } from "next/navigation";
export default function ModalLayout(props: {
children: ReactElement;
"1": ReactNode;
"30023": ReactNode;
2023-10-16 11:23:37 -04:00
"30311": ReactNode;
2023-10-16 10:59:28 -04:00
event: ReactNode;
params: {
key: string;
};
}) {
const key = props.params.key;
const { data, type } = nip19.decode(key);
if (type === "naddr") {
2023-10-16 11:23:37 -04:00
const kind = data.kind;
if (kind === 30023) {
return (
<div className="z-overlay fixed inset-y-[10px] left-[10px] right-[10px] overflow-hidden overflow-y-auto rounded-lg border bg-background px-4 sm:left-[calc(10px_+_var(--sidebar-closed-width))] xl:left-[calc(10px_+_var(--sidebar-open-width))]">
{props[30023]}
</div>
);
} else if (kind === 30311) {
return (
<div className="z-overlay fixed inset-y-[10px] left-[10px] right-[10px] overflow-hidden overflow-y-auto rounded-lg border bg-background px-4 sm:left-[calc(10px_+_var(--sidebar-closed-width))] xl:left-[calc(10px_+_var(--sidebar-open-width))]">
{props[30311]}
</div>
);
}
2023-10-16 10:59:28 -04:00
} else if (type === "note") {
return (
<div className="z-overlay fixed inset-y-[10px] left-[10px] right-[10px] overflow-hidden overflow-y-auto rounded-lg border bg-background px-4 sm:left-[calc(10px_+_var(--sidebar-closed-width))] xl:left-[calc(10px_+_var(--sidebar-open-width))]">
{props[1]}
</div>
);
} else if (type === "nevent") {
return (
<div className="z-overlay fixed inset-y-[10px] left-[10px] right-[10px] overflow-hidden overflow-y-auto rounded-lg border bg-background px-4 sm:left-[calc(10px_+_var(--sidebar-closed-width))] xl:left-[calc(10px_+_var(--sidebar-open-width))]">
{props.event}
</div>
);
} else if (type === "npub") {
return redirect(`/${key}`);
}
return redirect(`/app`);
}