From 7aeff18a274d7c86acd47d2d78c96d06cbd7bef4 Mon Sep 17 00:00:00 2001 From: Ren Amamiya <123083837+reyamir@users.noreply.github.com> Date: Wed, 24 May 2023 21:09:52 +0700 Subject: [PATCH] add create block --- src/app/space/components/create.tsx | 116 +++++++++++++++++++++++++++- src/stores/constants.tsx | 3 - src/utils/storage.tsx | 14 ++++ 3 files changed, 126 insertions(+), 7 deletions(-) diff --git a/src/app/space/components/create.tsx b/src/app/space/components/create.tsx index 89efa4f2..3b727e3e 100644 --- a/src/app/space/components/create.tsx +++ b/src/app/space/components/create.tsx @@ -1,12 +1,25 @@ import { Dialog, Transition } from "@headlessui/react"; import CancelIcon from "@icons/cancel"; import PlusIcon from "@icons/plus"; +import { useActiveAccount } from "@utils/hooks/useActiveAccount"; +import { createBlock } from "@utils/storage"; import { Fragment, useState } from "react"; +import { useForm } from "react-hook-form"; export function CreateBlockModal() { + const { + register, + handleSubmit, + reset, + setValue, + formState: { isDirty, isValid }, + } = useForm(); + const [isOpen, setIsOpen] = useState(false); const [loading, setLoading] = useState(false); + const { account } = useActiveAccount(); + const closeModal = () => { setIsOpen(false); }; @@ -15,12 +28,25 @@ export function CreateBlockModal() { setIsOpen(true); }; + const onSubmit = (data: any) => { + setLoading(true); + + createBlock(account.id, data.kind, data.title, data.content).then(() => { + // reset form + reset(); + // close modal + setIsOpen(false); + // stop loading + setLoading(false); + }); + }; + return ( <> - Channels are freedom square, everyone can speech freely, - no one can stop you or deceive what to speech + Personalize your space by adding a new block. -
+
+
+
+ +
+ +
+
+
+ +
+ +
+
+
+ +
+