import React from "react"; import ConfigBox from "@/Components/v1/ConfigBox/index.jsx"; import { Box, Stack, Typography } from "@mui/material"; import Checkbox from "@/Components/v1/Inputs/Checkbox/index.jsx"; import { useTheme } from "@emotion/react"; import { useTranslation } from "react-i18next"; import PropTypes from "prop-types"; const DiskSelection = ({ availableDisks, selectedDisks, onChange }) => { const theme = useTheme(); const { t } = useTranslation(); const handleDiskChange = (event, mountpoint) => { const isChecked = event.target.checked; let newSelectedDisks = []; if (isChecked) { newSelectedDisks = [...selectedDisks, mountpoint]; } else { newSelectedDisks = selectedDisks.filter((disk) => disk !== mountpoint); } onChange(newSelectedDisks); }; return ( {t("v1.infrastructure.disk_selection_title")} {t("v1.infrastructure.disk_selection_description")} {!availableDisks || availableDisks.length === 0 ? ( {t("v1.infrastructure.disk_selection_info")} ) : ( availableDisks.map((disk) => { const identifier = disk.mountpoint || disk.device; return ( handleDiskChange(e, identifier)} /> ); }) )} ); }; DiskSelection.propTypes = { availableDisks: PropTypes.arrayOf( PropTypes.shape({ mountpoint: PropTypes.string.isRequired, }) ), selectedDisks: PropTypes.arrayOf(PropTypes.string).isRequired, onChange: PropTypes.func.isRequired, }; export default DiskSelection;