From 70bde246d4b477379bca7c638768aeb3f74fa8df Mon Sep 17 00:00:00 2001 From: Nick Taylor Date: Thu, 17 Oct 2024 16:46:28 -0400 Subject: [PATCH] feat: removed developer pack form from user settings page --- .../UserSettingsPage/developer-pack-form.tsx | 67 --------------- .../UserSettingsPage/user-settings-page.tsx | 82 +++++++------------ 2 files changed, 30 insertions(+), 119 deletions(-) delete mode 100644 components/organisms/UserSettingsPage/developer-pack-form.tsx diff --git a/components/organisms/UserSettingsPage/developer-pack-form.tsx b/components/organisms/UserSettingsPage/developer-pack-form.tsx deleted file mode 100644 index ef16d7849c..0000000000 --- a/components/organisms/UserSettingsPage/developer-pack-form.tsx +++ /dev/null @@ -1,67 +0,0 @@ -import { useState } from "react"; - -import Button from "components/shared/Button/button"; -import { useToast } from "lib/hooks/useToast"; -import { supabase } from "lib/utils/supabase"; - -interface DeveloperPackFormProps { - providerToken?: string | null; - refreshUser: () => void; -} - -const DeveloperPackForm = ({ refreshUser, providerToken }: DeveloperPackFormProps) => { - const [updating, setUpdating] = useState(false); - const { toast } = useToast(); - - const handeVerification = async () => { - if (!providerToken) { - toast({ description: "Unable to connect to GitHub! Try logging out and re-connecting.", variant: "warning" }); - return; - } - - const sessionResponse = await supabase.auth.getSession(); - const sessionToken = sessionResponse?.data.session?.access_token; - setUpdating(true); - - const response = await fetch(`${process.env.NEXT_PUBLIC_API_URL}/auth/profile/developer-pack`, { - headers: { - Accept: "application/json", - "Content-Type": "application/json", - Authorization: `Bearer ${sessionToken}`, - }, - method: "PATCH", - body: JSON.stringify({ - token: providerToken, - }), - }); - - if (response.ok) { - const data = (await response.json()) as { eligible: boolean }; - if (data.eligible) { - toast({ description: "Developer pack eligibility verified!", variant: "success" }); - refreshUser?.(); - } else { - toast({ description: "Your account is not currently eligible for the developer pack", variant: "warning" }); - } - } else { - toast({ description: "Could not verify developer pack!", variant: "danger" }); - } - - setUpdating(false); - }; - - return ( -
- -
- ); -}; - -export default DeveloperPackForm; diff --git a/components/organisms/UserSettingsPage/user-settings-page.tsx b/components/organisms/UserSettingsPage/user-settings-page.tsx index a9421e2d16..b348c99bb2 100644 --- a/components/organisms/UserSettingsPage/user-settings-page.tsx +++ b/components/organisms/UserSettingsPage/user-settings-page.tsx @@ -24,7 +24,6 @@ import { validateTwitterUsername } from "lib/utils/validate-twitter-username"; import { Dialog, DialogContent, DialogHeader, DialogTitle } from "components/molecules/Dialog/dialog"; import { LanguageSwitch } from "components/shared/LanguageSwitch/language-switch"; import useSupabaseAuth from "lib/hooks/useSupabaseAuth"; -import DeveloperPackForm from "./developer-pack-form"; interface UserSettingsPageProps { user: User | null; @@ -435,59 +434,38 @@ const UserSettingsPage = ({ user }: UserSettingsPageProps) => { {userInfo && ( - <> -
- {!coupon ? ( -
-
- -
- Verify your developer pack eligibilty to get an upgrade! -
-
- { - mutate(); - setCoupon("verified"); - }} - /> -
- ) : null} +
{ + setIsModalOpen(true); + e.preventDefault(); + }} + > +
+ +
+ + Please note that account deletion is irreversible. Proceed only if you are certain about this + action. + +
- { - setIsModalOpen(true); - e.preventDefault(); + + { + setIsModalOpen(false); + deleteFormRef.current?.submit(); }} - > -
- -
- - Please note that account deletion is irreversible. Proceed only if you are certain about this - action. - -
-
- - { - setIsModalOpen(false); - deleteFormRef.current?.submit(); - }} - /> - - + /> + )}