'use client';

import { useEffect, useState } from 'react';

export default function AppFooter() {
    const [version, setVersion] = useState<string>('');

    useEffect(() => {
        fetch('/api/version')
            .then(res => res.json())
            .then(data => setVersion(data.version))
            .catch(() => setVersion(''));
    }, []);

    return (
        <footer className="app-footer">
            <p>
                Vibe coded with ☕ and 🍺 by{' '}
                <a href="https://digitalcourage.social/@elpatron" target="_blank" rel="noopener noreferrer">
                    @elpatron@digitalcourage.social
                </a>
                {' '}- prototype for personal use among friends only!
                {version && (
                    <>
                        {' '}·{' '}
                        <span style={{ fontSize: '0.85em', opacity: 0.7 }}>
                            {version}
                        </span>
                    </>
                )}
            </p>
        </footer>
    );
}
