"use client";
import React, { useState } from 'react';
import { motion, AnimatePresence } from 'framer-motion';
import { HelpCircle, X, Search, ChevronDown, ChevronUp } from 'lucide-react';
import { useTenantConfig } from '@/contexts/TenantConfigContext';
import { FAQS } from '@/lib/helpContent';
const FAQItem = ({ question, answer }: { question: string, answer: string }) => {
const [isOpen, setIsOpen] = useState(false);
return (
{isOpen && (
{answer}
)}
);
};
export function HelpCenterFAB() {
const [isOpen, setIsOpen] = useState(false);
const [searchQuery, setSearchQuery] = useState("");
const { tenantConfig } = useTenantConfig();
const brandName = tenantConfig?.brandName || "System";
const footerCopyright = tenantConfig?.footerCopyright || `${brandName} © 2026`;
const filteredFaqs = FAQS.filter(
faq =>
faq.question.toLowerCase().includes(searchQuery.toLowerCase()) ||
faq.answer.toLowerCase().includes(searchQuery.toLowerCase())
);
return (
<>
{/* Floating Action Button */}
setIsOpen(true)}
whileHover={{ scale: 1.05 }}
whileTap={{ scale: 0.95 }}
className="fixed bottom-24 lg:bottom-6 right-6 z-40 flex h-14 w-14 items-center justify-center rounded-full bg-blue-600 text-white shadow-[0_0_20px_rgba(37,99,235,0.4)] hover:bg-blue-500 transition-colors"
aria-label="Help and Resources"
>
{/* Pulse effect */}
{/* Drawer Overlay */}
{isOpen && (
<>
setIsOpen(false)}
className="fixed inset-0 z-50 bg-background/40 backdrop-blur-sm"
/>
{/* Drawer Panel */}
{/* Header */}
Help & Resources
{brandName} Guide & Documentation
{/* Scrollable Content */}
{/* Search Bar */}
setSearchQuery(e.target.value)}
className="w-full rounded-xl border border-border bg-secondary/50 py-2.5 pl-10 pr-4 text-sm text-foreground placeholder:text-muted-foreground focus:border-blue-500 focus:outline-none focus:ring-1 focus:ring-blue-500 transition-all"
/>
{/* FAQs */}
Frequently Asked Questions
{filteredFaqs.length === 0 ? (
No matching FAQs found
) : (
filteredFaqs.map((faq, index) => (
))
)}
{/* Footer */}
>
)}
>
);
}