diff --git a/client/components/creator-network/DevConnectLinkModal.tsx b/client/components/creator-network/DevConnectLinkModal.tsx new file mode 100644 index 00000000..70d0f60c --- /dev/null +++ b/client/components/creator-network/DevConnectLinkModal.tsx @@ -0,0 +1,101 @@ +import { useState } from "react"; +import { + AlertDialog, + AlertDialogAction, + AlertDialogCancel, + AlertDialogContent, + AlertDialogDescription, + AlertDialogHeader, + AlertDialogTitle, +} from "@/components/ui/alert-dialog"; +import { Button } from "@/components/ui/button"; +import { Input } from "@/components/ui/input"; +import { Loader2 } from "lucide-react"; +import { linkDevConnectAccount } from "@/api/devconnect-links"; +import { useAethexToast } from "@/hooks/use-aethex-toast"; + +export interface DevConnectLinkModalProps { + open: boolean; + onOpenChange: (open: boolean) => void; + onSuccess?: () => void; +} + +export function DevConnectLinkModal({ + open, + onOpenChange, + onSuccess, +}: DevConnectLinkModalProps) { + const [username, setUsername] = useState(""); + const [isLoading, setIsLoading] = useState(false); + const { toast } = useAethexToast(); + + const handleLink = async () => { + if (!username.trim()) { + toast("Please enter your DevConnect username", "error"); + return; + } + + setIsLoading(true); + try { + await linkDevConnectAccount({ + devconnect_username: username.trim(), + devconnect_profile_url: `https://devconnect.sbs/${username.trim()}`, + }); + toast("DevConnect account linked successfully!", "success"); + setUsername(""); + onOpenChange(false); + onSuccess?.(); + } catch (error) { + toast( + error instanceof Error ? error.message : "Failed to link DevConnect account", + "error" + ); + } finally { + setIsLoading(false); + } + }; + + return ( + + + + Link Your DevConnect Account + + Enter your DevConnect username to link your profile. This allows you to showcase your presence on both platforms. + + + +
+
+ +
+ devconnect.sbs/ + setUsername(e.target.value)} + disabled={isLoading} + className="flex-1" + /> +
+

+ Your username will be used to create a link to your DevConnect profile +

+
+
+ +
+ Cancel + +
+
+
+ ); +}