File size: 879 Bytes
c7fbc2e
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
"use client";

import { signIn } from "next-auth/react";
import { Instagram } from "lucide-react";
import { useState } from "react";

export default function ConnectButton() {
    const [isLoading, setIsLoading] = useState(false);

    const handleConnect = async () => {
        setIsLoading(true);
        // Redirect to our custom API route that initiates the Facebook OAuth flow for connecting connections
        window.location.href = "/api/connect/instagram";
    };

    return (
        <button
            onClick={handleConnect}
            disabled={isLoading}
            className="flex items-center gap-2 px-3 py-1.5 bg-primary-green hover:bg-emerald-600 text-white text-sm font-medium rounded transition-colors disabled:opacity-50"
        >
            <Instagram size={16} />
            {isLoading ? "Connecting..." : "Add Account"}
        </button>
    );
}