import React, { useState } from 'react';
import PropTypes from 'prop-types';
import { Box, Tabs, Tab, Typography } from '@mui/material';
import SystemLoginDetails from './SystemLoginDetails.js';
import SystemSleepDetails from './SystemSleepDetails.js';

function CustomTabPanel(props) {
  const { children, value, index, ...other } = props;
  return (
    <div
      role="tabpanel"
      hidden={value !== index}
      id={`system-activity-tabpanel-${index}`}
      aria-labelledby={`system-activity-tab-${index}`}
      {...other}
    >
      {value === index && (
        <Box sx={{ p: 2 }}>
          {children}
        </Box>
      )}
    </div>
  );
}

CustomTabPanel.propTypes = {
  children: PropTypes.node,
  index: PropTypes.number.isRequired,
  value: PropTypes.number.isRequired,
};

function a11yProps(index) {
  return {
    id: `system-activity-tab-${index}`,
    'aria-controls': `system-activity-tabpanel-${index}`,
  };
}

function SystemActivityScreen(props) {
  const [value, setValue] = useState(0);

  const handleChange = (event, newValue) => {
    setValue(newValue);
  };

  return (
    <Box className="system-activity-container">
      <Box sx={{ borderBottom: 1, borderColor: 'divider' }}>
        <Tabs 
          value={value} 
          onChange={handleChange}
          aria-label="system activity tabs"
        >
          <Tab label="Login Details" {...a11yProps(0)} />
          <Tab label="System Sleep Details" {...a11yProps(1)} />
        </Tabs>
      </Box>
      
      <CustomTabPanel value={value} index={0}>
        <SystemLoginDetails
          summaryFilter={props.summaryFilter}
          title={props.title}
          employeeId={props.employeeId}
        />
      </CustomTabPanel>
      
      <CustomTabPanel value={value} index={1}>
        <SystemSleepDetails
          summaryFilter={props.summaryFilter}
          title={props.title}
          employeeId={props.employeeId}
        />
      </CustomTabPanel>
    </Box>
  );
}

SystemActivityScreen.propTypes = {
  summaryFilter: PropTypes.object,
  title: PropTypes.string,
  employeeId: PropTypes.string,
};

export default SystemActivityScreen;
