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 RSVPModal from "@/components/Modals/RSVP";
|
||||||
import ConfirmModal from "@/components/Modals/Confirm";
|
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 { getTagAllValues, getTagValues } from "@/lib/nostr/utils";
|
||||||
import { formatDate } from "@/lib/utils/dates";
|
import { formatDate } from "@/lib/utils/dates";
|
||||||
|
|
||||||
@ -17,6 +17,7 @@ import { useNDK } from "@/app/_providers/ndk";
|
|||||||
import { toast } from "sonner";
|
import { toast } from "sonner";
|
||||||
|
|
||||||
import { sendZap, checkPayment } from "@/lib/actions/zap";
|
import { sendZap, checkPayment } from "@/lib/actions/zap";
|
||||||
|
import { useEvent } from "@/lib/hooks/useEvents";
|
||||||
|
|
||||||
type RSVPButtonProps = {
|
type RSVPButtonProps = {
|
||||||
event: NDKEvent;
|
event: NDKEvent;
|
||||||
@ -34,6 +35,14 @@ export default function RSVPButton({ event }: RSVPButtonProps) {
|
|||||||
const [ticketPending, setTicketPending] = useState(false);
|
const [ticketPending, setTicketPending] = useState(false);
|
||||||
const [checkingPayment, setCheckingPayment] = useState(false);
|
const [checkingPayment, setCheckingPayment] = useState(false);
|
||||||
const [hasValidPayment, setHasValidPayment] = 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() {
|
async function handleBuyTicket() {
|
||||||
setTicketPending(true);
|
setTicketPending(true);
|
||||||
@ -75,16 +84,30 @@ export default function RSVPButton({ event }: RSVPButtonProps) {
|
|||||||
setCheckingPayment(false);
|
setCheckingPayment(false);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!tickets) {
|
if (!tickets) {
|
||||||
return (
|
if (rsvpEvent) {
|
||||||
<Button
|
const rsvpResponse = getTagValues("l", rsvpEvent.tags);
|
||||||
onClick={() =>
|
return (
|
||||||
modal?.show(<RSVPModal eventReference={eventReference} />)
|
<Button disabled>
|
||||||
}
|
{rsvpResponse === "accepted"
|
||||||
>
|
? "Going"
|
||||||
RSVP
|
: rsvpResponse === "tentative"
|
||||||
</Button>
|
? "Tentative"
|
||||||
);
|
: "Not Going"}
|
||||||
|
</Button>
|
||||||
|
);
|
||||||
|
} else {
|
||||||
|
return (
|
||||||
|
<Button
|
||||||
|
onClick={() =>
|
||||||
|
modal?.show(<RSVPModal eventReference={eventReference} />)
|
||||||
|
}
|
||||||
|
>
|
||||||
|
RSVP
|
||||||
|
</Button>
|
||||||
|
);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
if (price) {
|
if (price) {
|
||||||
return (
|
return (
|
||||||
|
Loading…
x
Reference in New Issue
Block a user