MCPcopy Create free account
hub / github.com/CodeGraphContext/CodeGraphContext / Footer

Function Footer

website/src/components/Footer.tsx:17–323  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

15const supabase = supabaseUrl && supabaseAnonKey ? getSupabaseClient() : null;
16
17const Footer = () => {
18 const [email, setEmail] = useState("");
19 const [isLoading, setIsLoading] = useState(false);
20 const [version, setVersion] = useState("");
21
22 useEffect(() => {
23 async function fetchVersion() {
24 try {
25 const res = await fetch(
26 "https://raw.githubusercontent.com/CodeGraphContext/CodeGraphContext/main/README.md",
27 );
28 if (!res.ok) throw new Error("Failed to fetch README");
29 const text = await res.text();
30 const match = text.match(
31 /\*\*Version:\*\*\s*([0-9]+\.[0-9]+\.[0-9]+)/i,
32 );
33 setVersion(match ? match[1] : "N/A");
34 } catch (err) {
35 console.error(err);
36 setVersion("N/A");
37 }
38 }
39 fetchVersion();
40 }, []);
41
42 const handleNewsletterSubmit = async (e: React.FormEvent) => {
43 e.preventDefault();
44 if (!email) {
45 toast.error("Please enter your email address");
46 return;
47 }
48 if (!/\S+@\S+\.\S+/.test(email)) {
49 toast.error("Please enter a valid email address");
50 return;
51 }
52 if (!supabase) {
53 toast.error(
54 "Newsletter subscription is currently unavailable. Please try again later.",
55 );
56 return;
57 }
58 setIsLoading(true);
59 try {
60 const { data, error } = await supabase
61 .from("subscribers")
62 .insert([{ email }]);
63 if (error) {
64 if (error.code === "23505") {
65 toast("You are already subscribed!");
66 } else {
67 toast.error(error.message);
68 }
69 } else {
70 toast.success("Thank you for subscribing to our newsletter!");
71 setEmail("");
72 }
73 } catch (err) {
74 console.error(err);

Callers

nothing calls this directly

Calls 1

fetchVersionFunction · 0.70

Tested by

no test coverage detected