diff --git a/components/Modals/CreateCalendarEvent.tsx b/components/Modals/CreateCalendarEvent.tsx index e83abd4..ddc4e75 100644 --- a/components/Modals/CreateCalendarEvent.tsx +++ b/components/Modals/CreateCalendarEvent.tsx @@ -1,6 +1,7 @@ "use client"; import { useState, useRef, useEffect } from "react"; +import Image from "next/image"; import { HiX } from "react-icons/hi"; import { toast } from "sonner"; import { cn } from "@/lib/utils"; @@ -18,20 +19,27 @@ import { Label } from "@/components/ui/label"; import SmallCalendarIcon from "@/components/EventIcons/DateIcon"; import LocationIcon from "@/components/EventIcons/LocationIcon"; import LocationSearchInput from "@/components/LocationSearch"; +import Spinner from "../spinner"; import useAutosizeTextArea from "@/lib/hooks/useAutoSizeTextArea"; import { useModal } from "@/app/_providers/modal/provider"; import { useRouter } from "next/navigation"; import { createEvent } from "@/lib/actions/create"; import { useNDK } from "@/app/_providers/ndk"; -import { type NostrEvent } from "@nostr-dev-kit/ndk"; import useCurrentUser from "@/lib/hooks/useCurrentUser"; +import useImageUpload from "@/lib/hooks/useImageUpload"; export default function CreateCalendarEventModal() { const modal = useModal(); const now = new Date(new Date().setHours(12, 0, 0, 0)); const [isLoading, setIsLoading] = useState(false); - + const { + ImageUploadButton, + clear, + imagePreview, + imageUrl, + status: imageStatus, + } = useImageUpload("event"); const [error, setError] = useState(""); const [title, setTitle] = useState(""); const [description, setDescription] = useState(""); @@ -100,6 +108,9 @@ export default function CreateCalendarEventModal() { location.address, ]); } + if (imageUrl) { + tags.push(["image", imageUrl]); + } console.log("Adding ", tags); const preEvent = { content: description, @@ -265,7 +276,7 @@ export default function CreateCalendarEventModal() {
-
+
@@ -287,10 +298,57 @@ export default function CreateCalendarEventModal() { placeholder="Some into about this event..." />
+
+ {imagePreview ? ( +
+
+ Image +
+ {imageStatus === "uploading" && ( + + )} + {imageStatus === "success" && ( + + )} +
+ ) : ( + + + + )} +
+