import { MainLayout } from '@/components/layout/MainLayout.tsx'; import PageHeader from '@/components/layout/PageHeader.tsx'; import ResourceFlowList from '@/components/resource-flow/ResourceFlowList.tsx'; import ResourceFlowWizard from '@/components/resource-flow/ResourceFlowWizard.tsx'; import { FormField } from '@/components/ui'; import Button from '@/components/ui/Button.tsx'; import { Card, CardContent, CardHeader, CardTitle } from '@/components/ui/Card.tsx'; import { SelectDropdown } from '@/components/ui/DropdownMenu.tsx'; import { Container, Flex, Stack } from '@/components/ui/layout'; import { useTranslation } from '@/hooks/useI18n.tsx'; import { useNavigation } from '@/hooks/useNavigation.tsx'; import { useOrganizations } from '@/hooks/useOrganizations.ts'; import type { ResourceDirection } from '@/schemas/backend/resource-flow'; import { useMemo, useState } from 'react'; import { useNavigate } from 'react-router-dom'; const ResourceFlowsPage = () => { const { t } = useTranslation(); const navigate = useNavigate(); const { handleBackNavigation, handleFooterNavigate } = useNavigation(); const { organizations, isLoading: isLoadingOrgs } = useOrganizations(); const [selectedOrganizationId, setSelectedOrganizationId] = useState(''); const [isWizardOpen, setIsWizardOpen] = useState(false); const [wizardDirection, setWizardDirection] = useState('input'); // Get selected organization details const selectedOrganization = useMemo(() => { return organizations?.find((org) => org.ID === selectedOrganizationId) || null; }, [organizations, selectedOrganizationId]); const handleAddResourceFlow = (direction: ResourceDirection) => { if (!selectedOrganizationId) { // If no organization selected, show organization selector or redirect return; } setWizardDirection(direction); setIsWizardOpen(true); }; const handleViewMatches = (resourceId: string) => { navigate(`/resource-flow/${resourceId}/matches`); }; const handleWizardClose = () => { setIsWizardOpen(false); }; const handleWizardSuccess = () => { setIsWizardOpen(false); // Optionally refresh data or show success message }; const organizationOptions = useMemo(() => { return ( organizations?.map((org) => ({ value: org.ID, label: org.Name, })) || [] ); }, [organizations]); return ( {/* Organization Selector */} {t('resourceFlows.selectOrganization')}
{selectedOrganization && ( )}
{/* Resource Flows List */} {selectedOrganizationId ? ( ) : (

{t('resourceFlows.selectOrganizationToView')}

)}
{/* Resource Flow Creation Wizard */} {selectedOrganization && ( )}
); }; export default ResourceFlowsPage;