import { redirect } from 'next/navigation';
import { getMe } from '@/features/auth/api.server';
import { DataIntegrationView } from '@/features/data-integration/ui/DataIntegrationView';

export const metadata = {
  title: 'Data integration',
};

/**
 * Data Management > Data integration: imports and syncs. Admins, and anyone with import rights
 * (Contacts' and Companies' "Add › Import" open it, as the hosted design; the user's call, 12 Nov.
 * Deals' and custom objects' lists too, the user's call, 25 Nov 2026).
 */
export default async function DataIntegrationPage() {
  const me = await getMe();
  const { app } = me.permissionSet.rules;
  if (!app.manage_settings && !app.import) {
    redirect('/home');
  }
  return <DataIntegrationView />;
}
