From ef2229b9eca52914f75b6515c0fc112cd8d96791 Mon Sep 17 00:00:00 2001 From: George Weiler Date: Tue, 29 Nov 2022 20:30:16 -0700 Subject: [PATCH 1/5] Build the initial MVP for submitting the feature suggestion form --- src/hooks/useGCloudStorage.ts | 21 +++++++ src/pages/Feedback/Suggestions/index.tsx | 72 +++++++++++++++++++++++- src/types/posthog.ts | 1 + 3 files changed, 91 insertions(+), 3 deletions(-) create mode 100644 src/hooks/useGCloudStorage.ts diff --git a/src/hooks/useGCloudStorage.ts b/src/hooks/useGCloudStorage.ts new file mode 100644 index 000000000..04e63481d --- /dev/null +++ b/src/hooks/useGCloudStorage.ts @@ -0,0 +1,21 @@ +import { useCallback } from "react" + +const bucket = "threshold_dapp_feedback" + +const useGCloudStorage: () => (file: File) => Promise = () => { + return useCallback(async (file) => { + const formData = new FormData() + + formData.append("file", file) + formData.append("key", file.name) + + return fetch(`https://storage.googleapis.com/${bucket}`, { + method: "POST", + body: formData, + }).then((resp) => { + return `https://storage.cloud.google.com/${bucket}/${file.name}` + }) + }, []) +} + +export default useGCloudStorage diff --git a/src/pages/Feedback/Suggestions/index.tsx b/src/pages/Feedback/Suggestions/index.tsx index 2c7bcfba6..a2abd5272 100644 --- a/src/pages/Feedback/Suggestions/index.tsx +++ b/src/pages/Feedback/Suggestions/index.tsx @@ -1,9 +1,75 @@ -import React from "react" -import { Box } from "@threshold-network/components" +import React, { useState } from "react" +import { + BodyLg, + Button, + Card, + Divider, + FileUploader, + H5, + Select, + Textarea, +} from "@threshold-network/components" import { PageComponent } from "../../../types" +import useGCloudStorage from "../../../hooks/useGCloudStorage" +import Link from "../../../components/Link" +import { ExternalHref } from "../../../enums" +import { useCapture } from "../../../hooks/posthog" +import { PosthogEvent } from "../../../types/posthog" + +const featureCategoryOptions = ["Upgrade", "Staking"] const Suggestions: PageComponent = () => { - return suggestions page + const captureSuggestionSubmit = useCapture(PosthogEvent.SuggestionSubmit) + + const [file, setFile] = useState(null) + const uploadToGCP = useGCloudStorage() + const [featureCategory, setFeatureCategory] = useState("") + const [suggestionText, setSuggestionText] = useState("") + + const handleSubmit = async () => { + let fileLink = "" + if (file) { + fileLink = await uploadToGCP(file) + } + + captureSuggestionSubmit({ + file: fileLink, + category: featureCategory, + suggestion: suggestionText, + }) + } + + return ( + +
What suggestions do you have?
+ + + Submit your suggestions for product improvements by using this form. To + discuss ideas with other Threshold users and DAO members, consider + posting it in the{" "} + + Discord + + + +