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 { Input } from '../../components/ui/input'; import { toast } from 'sonner'; import { Scale, ExternalLink, History, Check, Search, Calendar } from 'lucide-react'; export default function Bylaws() { const [currentBylaws, setCurrentBylaws] = useState(null); const [history, setHistory] = useState([]); const [years, setYears] = useState([]); const [selectedYear, setSelectedYear] = useState(null); const [searchTerm, setSearchTerm] = useState(''); const [showHistory, setShowHistory] = useState(false); const [loading, setLoading] = useState(true); useEffect(() => { fetchCurrentBylaws(); fetchYears(); fetchHistory(); }, []); const fetchYears = async () => { try { const response = await api.get('/bylaws/years'); setYears(response.data); } catch (error) { console.error('Failed to load years'); } }; 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 (year = null) => { try { const url = year ? `/bylaws/history?year=${year}` : '/bylaws/history'; const response = await api.get(url); setHistory(response.data); } catch (error) { console.error('Failed to load bylaws history'); } }; const handleYearFilter = (year) => { setSelectedYear(year); fetchHistory(year); }; const clearFilter = () => { setSelectedYear(null); fetchHistory(); }; const filteredHistory = history.filter(bylaws => bylaws.title.toLowerCase().includes(searchTerm.toLowerCase()) || (bylaws.version && bylaws.version.toLowerCase().includes(searchTerm.toLowerCase())) ); const groupByYear = (items) => { const grouped = {}; items.forEach(item => { const year = new Date(item.effective_date).getFullYear(); if (!grouped[year]) { grouped[year] = []; } grouped[year].push(item); }); return grouped; }; const groupedHistory = groupByYear(filteredHistory.filter(b => !b.is_current)); const sortedYears = Object.keys(groupedHistory).sort((a, b) => b - a); const formatDate = (dateString) => { return new Date(dateString).toLocaleDateString('en-US', { year: 'numeric', month: 'long', day: 'numeric' }); }; if (loading) { return (
Loading bylaws...
Review the official governing bylaws and policies of the LOAF community.
{/* Filters */}No current bylaws document available
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.