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);
|
2023-11-08 08:54:35 -06:00
|
|
|
console.log("AT layout", type, data);
|
2023-10-16 10:59:28 -04:00
|
|
|
if (type === "naddr") {
|
2023-10-16 11:23:37 -04:00
|
|
|
const kind = data.kind;
|
|
|
|
if (kind === 30023) {
|
|
|
|
return (
|
2023-10-27 17:48:49 -04:00
|
|
|
<div className="fixed inset-y-[10px] left-[10px] right-[10px] z-overlay 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))]">
|
2023-10-16 11:23:37 -04:00
|
|
|
{props[30023]}
|
|
|
|
</div>
|
|
|
|
);
|
|
|
|
} else if (kind === 30311) {
|
|
|
|
return (
|
2023-10-27 17:48:49 -04:00
|
|
|
<div className="fixed inset-y-[10px] left-[10px] right-[10px] z-overlay 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))]">
|
2023-10-16 11:23:37 -04:00
|
|
|
{props[30311]}
|
|
|
|
</div>
|
|
|
|
);
|
2023-11-07 11:31:29 -05:00
|
|
|
} else if (kind === 31923 || kind === 31922) {
|
|
|
|
return redirect(`/event/${key}`);
|
|
|
|
} else if (kind === 31924) {
|
|
|
|
return redirect(`/calendar/${key}`);
|
2023-10-16 11:23:37 -04:00
|
|
|
}
|
2023-10-16 10:59:28 -04:00
|
|
|
} else if (type === "note") {
|
|
|
|
return (
|
2023-10-27 17:48:49 -04:00
|
|
|
<div className="fixed inset-y-[10px] left-[10px] right-[10px] z-overlay 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))]">
|
2023-10-16 10:59:28 -04:00
|
|
|
{props[1]}
|
|
|
|
</div>
|
|
|
|
);
|
|
|
|
} else if (type === "nevent") {
|
|
|
|
return (
|
2023-10-27 17:48:49 -04:00
|
|
|
<div className="fixed inset-y-[10px] left-[10px] right-[10px] z-overlay 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))]">
|
2023-10-16 10:59:28 -04:00
|
|
|
{props.event}
|
|
|
|
</div>
|
|
|
|
);
|
|
|
|
} else if (type === "npub") {
|
|
|
|
return redirect(`/${key}`);
|
|
|
|
}
|
2023-10-27 17:48:49 -04:00
|
|
|
return redirect(`/explore`);
|
2023-10-16 10:59:28 -04:00
|
|
|
}
|