adding modal auth guard
This commit is contained in:
parent
3c192feb3b
commit
67779ad5bf
@ -90,7 +90,13 @@ export default function Sidebar() {
|
|||||||
active: false,
|
active: false,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
onClick: () => modal?.show(<ZapPickerModal event={flockstrEvent} />),
|
onClick: () =>
|
||||||
|
modal?.show(
|
||||||
|
<ZapPickerModal
|
||||||
|
title="Help Support Flockstr!"
|
||||||
|
event={flockstrEvent}
|
||||||
|
/>,
|
||||||
|
),
|
||||||
name: "zap",
|
name: "zap",
|
||||||
label: "Zap Flockstr",
|
label: "Zap Flockstr",
|
||||||
icon: HiOutlineLightningBolt,
|
icon: HiOutlineLightningBolt,
|
||||||
|
@ -13,6 +13,7 @@ import { Textarea } from "@/components/ui/textarea";
|
|||||||
import { Label } from "@/components/ui/label";
|
import { Label } from "@/components/ui/label";
|
||||||
import { type NostrEvent } from "@nostr-dev-kit/ndk";
|
import { type NostrEvent } from "@nostr-dev-kit/ndk";
|
||||||
import { sendZap } from "@/lib/actions/zap";
|
import { sendZap } from "@/lib/actions/zap";
|
||||||
|
import useAuthGuard from "./hooks/useAuthGuard";
|
||||||
|
|
||||||
const intervals = [
|
const intervals = [
|
||||||
10, 25, 50, 75, 100, 150, 200, 250, 350, 500, 750, 1000, 1250, 1500, 2_000,
|
10, 25, 50, 75, 100, 150, 200, 250, 350, 500, 750, 1000, 1250, 1500, 2_000,
|
||||||
@ -22,11 +23,11 @@ const intervals = [
|
|||||||
];
|
];
|
||||||
|
|
||||||
type ZapPickerProps = {
|
type ZapPickerProps = {
|
||||||
|
title?: string;
|
||||||
event: NostrEvent;
|
event: NostrEvent;
|
||||||
};
|
};
|
||||||
export default function ZapPicker({ event }: ZapPickerProps) {
|
export default function ZapPicker({ event, title }: ZapPickerProps) {
|
||||||
const { loginWithNip07 } = useNDK();
|
useAuthGuard();
|
||||||
const { loginWithPubkey, currentUser } = useCurrentUser();
|
|
||||||
const [isLoading, setIsLoading] = useState(false);
|
const [isLoading, setIsLoading] = useState(false);
|
||||||
const [note, setNote] = useState("");
|
const [note, setNote] = useState("");
|
||||||
const modal = useModal();
|
const modal = useModal();
|
||||||
@ -59,7 +60,7 @@ export default function ZapPicker({ event }: ZapPickerProps) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<Template title="Send Zap!" className="md:max-w-[400px]">
|
<Template title={title ?? "Send Zap!"} className="md:max-w-[400px]">
|
||||||
<div className="flex flex-col gap-y-5">
|
<div className="flex flex-col gap-y-5">
|
||||||
<div className="pb-2">
|
<div className="pb-2">
|
||||||
<div className="flex items-center justify-center space-x-2">
|
<div className="flex items-center justify-center space-x-2">
|
||||||
|
14
components/Modals/hooks/useAuthGuard.tsx
Normal file
14
components/Modals/hooks/useAuthGuard.tsx
Normal file
@ -0,0 +1,14 @@
|
|||||||
|
import { useEffect } from "react";
|
||||||
|
import useCurrentUser from "@/lib/hooks/useCurrentUser";
|
||||||
|
import { useModal } from "@/app/_providers/modal/provider";
|
||||||
|
import LoginModal from "../Login";
|
||||||
|
import currentUserStore from "@/lib/stores/currentUser";
|
||||||
|
export default function useAuthGuard() {
|
||||||
|
const modal = useModal();
|
||||||
|
const { currentUser } = useCurrentUser();
|
||||||
|
useEffect(() => {
|
||||||
|
if (!currentUser) {
|
||||||
|
modal?.swap(<LoginModal />);
|
||||||
|
}
|
||||||
|
}, [currentUserStore]);
|
||||||
|
}
|
Loading…
x
Reference in New Issue
Block a user