'use client'; import { RFAList } from '@/components/rfas/list'; import { Button } from '@/components/ui/button'; import { Input } from '@/components/ui/input'; import { Select, SelectContent, SelectItem, SelectTrigger, SelectValue, } from '@/components/ui/select'; import Link from 'next/link'; import { Plus, Loader2, Search } from 'lucide-react'; import { useRFAs } from '@/hooks/use-rfa'; import { useSearchParams, useRouter, usePathname } from 'next/navigation'; import { Pagination } from '@/components/common/pagination'; import { Suspense, useCallback } from 'react'; const RFA_STATUS_OPTIONS = [ { value: 'ALL', label: 'All Statuses' }, { value: 'DFT', label: 'Draft' }, { value: 'FAP', label: 'For Approve' }, { value: 'FRE', label: 'For Review' }, { value: 'FCO', label: 'For Comment Only' }, { value: 'CC', label: 'Cancelled' }, ]; function RFAsContent() { const searchParams = useSearchParams(); const router = useRouter(); const pathname = usePathname(); const page = Number(searchParams.get('page') || '1'); const statusCode = searchParams.get('statusCode') || undefined; const search = searchParams.get('search') || undefined; const projectId = searchParams.get('projectId') || undefined; const revisionStatus = (searchParams.get('revisionStatus') as 'CURRENT' | 'ALL' | 'OLD') || 'CURRENT'; const { data, isLoading, isError } = useRFAs({ page, statusCode, search, projectId, revisionStatus }); const updateParam = useCallback( (key: string, value: string) => { const params = new URLSearchParams(searchParams.toString()); if (value && value !== 'ALL') { params.set(key, value); } else { params.delete(key); } params.set('page', '1'); router.push(`${pathname}?${params.toString()}`); }, [searchParams, router, pathname] ); return ( <>
Manage approval requests and submissions