import React, { useState, useEffect } from 'react'; import api from '../../utils/api'; import Navbar from '../../components/Navbar'; import MemberFooter from '../../components/MemberFooter'; import { Card } from '../../components/ui/card'; import { Button } from '../../components/ui/button'; import { Badge } from '../../components/ui/badge'; import { toast } from 'sonner'; import { Scale, ExternalLink, History, Check } from 'lucide-react'; export default function Bylaws() { const [currentBylaws, setCurrentBylaws] = useState(null); const [history, setHistory] = useState([]); const [showHistory, setShowHistory] = useState(false); const [loading, setLoading] = useState(true); useEffect(() => { fetchCurrentBylaws(); fetchHistory(); }, []); const fetchCurrentBylaws = async () => { try { const response = await api.get('/bylaws/current'); setCurrentBylaws(response.data); } catch (error) { if (error.response?.status !== 404) { toast.error('Failed to load current bylaws'); } } finally { setLoading(false); } }; const fetchHistory = async () => { try { const response = await api.get('/bylaws/history'); setHistory(response.data); } catch (error) { console.error('Failed to load bylaws history'); } }; const formatDate = (dateString) => { return new Date(dateString).toLocaleDateString('en-US', { year: 'numeric', month: 'long', day: 'numeric' }); }; if (loading) { return (

Loading bylaws...

); } return (
{/* Header */}

LOAF Bylaws

Review the official governing bylaws and policies of the LOAF community.

{/* Current Bylaws */} {currentBylaws ? (

{currentBylaws.title}

Current Version
Version: {currentBylaws.version} Effective: {formatDate(currentBylaws.effective_date)}
) : (

No current bylaws document available

)} {/* Version History Toggle */} {history.length > 1 && (
)} {/* Version History */} {showHistory && history.length > 1 && (

Previous Versions

{history.filter(b => !b.is_current).map(bylaws => (

{bylaws.title}

Version {bylaws.version} Effective {formatDate(bylaws.effective_date)}
))}
)} {/* Information Card */}

About LOAF Bylaws

The bylaws serve as the governing document for LOAF, outlining the organization's structure, membership requirements, officer responsibilities, and operational procedures. All members are encouraged to familiarize themselves with these guidelines.

); }