import { ReactNode } from 'react';

interface WorkspaceSurfaceHeaderConfig {
  title: ReactNode;
  subtitle?: ReactNode;
  leading?: ReactNode;
  actions?: ReactNode;
  breadcrumbs?: ReactNode;
  selectionLabel?: ReactNode;
  floatingActions?: ReactNode;
}

interface WorkspaceSurfaceConfig {
  key: string;
  variant: string;
  header: WorkspaceSurfaceHeaderConfig;
  content?: ReactNode;
  detail?: ReactNode;
}

interface CreateWorkspaceSurfaceConfigArgs {
  title: ReactNode;
  subtitle?: ReactNode;
  sidebarToggle?: ReactNode;
  actions?: ReactNode;
  breadcrumbs?: ReactNode;
  selectionLabel?: ReactNode;
  floatingActions?: ReactNode;
  content?: ReactNode;
  detail?: ReactNode;
  variant?: string;
  key?: string;
}

export const createWorkspaceSurfaceConfig = ({
  title,
  subtitle = null,
  sidebarToggle = null,
  actions = null,
  breadcrumbs = null,
  selectionLabel = null,
  floatingActions = null,
  content = null,
  detail = null,
  variant = 'documents',
  key = 'documents',
}: CreateWorkspaceSurfaceConfigArgs): WorkspaceSurfaceConfig => {
  const leading = sidebarToggle ? <>{sidebarToggle}</> : null;

  return {
    key,
    variant,
    header: {
      title,
      subtitle,
      leading,
      actions,
      breadcrumbs,
      selectionLabel,
      floatingActions,
    },
    content,
    detail,
  };
};

export default createWorkspaceSurfaceConfig;
