import type { ReactElement } from 'react';
import { useLocalSearchParams } from 'expo-router';
import { ForwardScreen } from '@/features/messaging';

export default function ForwardRoute(): ReactElement | null {
  const params = useLocalSearchParams<{ ids: string; from: string }>();
  const idsParam = typeof params.ids === 'string' ? params.ids : '';
  const from = typeof params.from === 'string' ? params.from : null;
  const messageIds = idsParam.split(',').filter((id) => id.length > 0);
  if (from === null || messageIds.length === 0) {
    return null;
  }
  return <ForwardScreen messageIds={messageIds} fromConversationId={from} />;
}
