import { supabase } from '../supabaseClient'; import React, { useState } from 'react'; import { motion } from 'framer-motion'; // Import motion for the button // You might need this icon if it's not globally available const SpinnerIcon = () => ; export default function AdminSettings() { const [newAdminEmail, setNewAdminEmail] = useState(''); const [password, setPassword] = useState(''); const [loading, setLoading] = useState(false); const handleTransferRequest = async (e) => { e.preventDefault(); setLoading(true); try { const { data: { user } } = await supabase.auth.getUser(); if (!user) throw new Error("You must be logged in."); const { error: signInError } = await supabase.auth.signInWithPassword({ email: user.email, password: password, }); if (signInError) { throw new Error("Incorrect password. Please try again."); } const { error: invokeError } = await supabase.functions.invoke('initiate-admin-transfer', { body: { newAdminEmail: newAdminEmail }, }); if (invokeError) throw invokeError; alert(`An invitation to become the new admin has been sent to ${newAdminEmail}.`); setNewAdminEmail(''); setPassword(''); } catch (error) { alert(`Error: ${error.message}`); } finally { setLoading(false); } }; return (

Transfer Admin Ownership

setNewAdminEmail(e.target.value)} required placeholder="david@company.com" // --- STYLE UPDATES FOR INPUT --- style={{ width: '100%', padding: '0.75rem', borderRadius: '0.5rem', border: '1px solid rgba(239, 68, 68, 0.3)', backgroundColor: 'rgba(255,255,255,0.05)', color: 'white', boxSizing: 'border-box' // Important for consistent sizing }} />
setPassword(e.target.value)} required placeholder="••••••••" // --- STYLE UPDATES FOR INPUT --- style={{ width: '100%', padding: '0.75rem', borderRadius: '0.5rem', border: '1px solid rgba(239, 68, 68, 0.3)', backgroundColor: 'rgba(255,255,255,0.05)', color: 'white', boxSizing: 'border-box' }} />
{/* --- STYLE UPDATES FOR BUTTON --- */} {loading && } {loading ? 'Sending Invitation...' : 'Send Transfer Invitation'}
); }