improving rsvp response
This commit is contained in:
parent
9ef6086e76
commit
780771bb99
@ -6,7 +6,7 @@ import { HiOutlineLightningBolt } from "react-icons/hi";
|
||||
import RSVPModal from "@/components/Modals/RSVP";
|
||||
import ConfirmModal from "@/components/Modals/Confirm";
|
||||
|
||||
import { type NDKEvent } from "@nostr-dev-kit/ndk";
|
||||
import { NDKKind, type NDKEvent } from "@nostr-dev-kit/ndk";
|
||||
import { getTagAllValues, getTagValues } from "@/lib/nostr/utils";
|
||||
import { formatDate } from "@/lib/utils/dates";
|
||||
|
||||
@ -17,6 +17,7 @@ import { useNDK } from "@/app/_providers/ndk";
|
||||
import { toast } from "sonner";
|
||||
|
||||
import { sendZap, checkPayment } from "@/lib/actions/zap";
|
||||
import { useEvent } from "@/lib/hooks/useEvents";
|
||||
|
||||
type RSVPButtonProps = {
|
||||
event: NDKEvent;
|
||||
@ -34,6 +35,14 @@ export default function RSVPButton({ event }: RSVPButtonProps) {
|
||||
const [ticketPending, setTicketPending] = useState(false);
|
||||
const [checkingPayment, setCheckingPayment] = useState(false);
|
||||
const [hasValidPayment, setHasValidPayment] = useState(false);
|
||||
const { event: rsvpEvent } = useEvent({
|
||||
filter: {
|
||||
kinds: [31925 as NDKKind],
|
||||
authors: [currentUser?.pubkey as string],
|
||||
["#a"]: [eventReference],
|
||||
},
|
||||
enabled: !!currentUser,
|
||||
});
|
||||
|
||||
async function handleBuyTicket() {
|
||||
setTicketPending(true);
|
||||
@ -75,7 +84,20 @@ export default function RSVPButton({ event }: RSVPButtonProps) {
|
||||
setCheckingPayment(false);
|
||||
}
|
||||
}
|
||||
|
||||
if (!tickets) {
|
||||
if (rsvpEvent) {
|
||||
const rsvpResponse = getTagValues("l", rsvpEvent.tags);
|
||||
return (
|
||||
<Button disabled>
|
||||
{rsvpResponse === "accepted"
|
||||
? "Going"
|
||||
: rsvpResponse === "tentative"
|
||||
? "Tentative"
|
||||
: "Not Going"}
|
||||
</Button>
|
||||
);
|
||||
} else {
|
||||
return (
|
||||
<Button
|
||||
onClick={() =>
|
||||
@ -86,6 +108,7 @@ export default function RSVPButton({ event }: RSVPButtonProps) {
|
||||
</Button>
|
||||
);
|
||||
}
|
||||
}
|
||||
if (price) {
|
||||
return (
|
||||
<Button
|
||||
|
Loading…
x
Reference in New Issue
Block a user