import { useEffect, useState } from 'react'; import { toast } from 'react-toastify'; import { Panel } from './SettingPanel.style'; import { Divider, IconButton, Stack, Tooltip } from '@mui/material'; import { GroupByObject } from './GroupByObject/GroupByObject'; import { ColorPickerButton } from './ColorPicker/ColorPickerButton'; import { AddLine, FormulaSettingPanel, Minus, Pin, Plus, RemoveLine, Search, } from '../../common/icons/icons'; import CollapsibleTree from '../../common/CollapsibleTree'; import ZoomSlider from './ZoomSlider'; import SearchComponent from '../../common/SearchComponent'; import { ExportDefaultButton } from '../../common/Buttons/ButtonsActions'; import { exportSheet, exportSheetProject } from '../../../utils/exportFile'; const SettingPanel = ({ selectedColumnId, columnPinning, table, columns, onPinColumn, onUnpinColumn, onToggleColumnVisibility, columnVisibility, onChangeSizeMult, onGlobalFilterChange, sizeMult, onChangeShowColumnFilters, onAddRow, onDeleteRow, isLoadingData, formId, sheetName, direction, year, isProject, }) => { const [isPinned, setIsPinned] = useState(false); const [isExporting, setIsExporting] = useState(false); const [selectedColumnIds, setSelectedColumnIds] = useState(); const [showColumnFilters, setShowColumnFilters] = useState(false); // TODO: console.log(!!!) везде посомтреть useEffect(() => { if (!selectedColumnId) { setIsPinned(false); return; } const pinningColumn = columnPinning?.left || table.getState().columnPinning.left || []; const pinned = pinningColumn.includes(selectedColumnId); setIsPinned(pinned); }, [selectedColumnId, columnPinning, table]); useEffect(() => { setSelectedColumnIds( Object.keys(columnVisibility).filter((key) => !columnVisibility[key]), ); }, [columnVisibility]); //TO DO: сделать const { addColorForCells, addFormulaForCells, deleteFormula } = {}; const handleChangeShowColumnFilters = () => { const show = table.getState().showColumnFilters; setShowColumnFilters(!show); onChangeShowColumnFilters(!show); }; const handleClickAddFormula = () => { }; const handleClickDeleteFormula = () => { }; const handleExport = async () => { if (isExporting) return; if (isProject) { if (!formId || !sheetName || !year) return; setIsExporting(true); await exportSheetProject(formId, sheetName, year); setIsExporting(false); return; } if (!formId || !sheetName) return; setIsExporting(true); await exportSheet(formId, sheetName, direction); setIsExporting(false); }; return ( <> {/* */} e.stopPropagation()} onClick={() => { if (!selectedColumnId) { console.warn('[ColumnPin] клик Pin: selectedColumnId пустой'); return; } console.log('[ColumnPin] клик Pin:', { selectedColumnId, isPinned, action: isPinned ? 'unpin' : 'pin', }); isPinned ? onUnpinColumn?.(selectedColumnId) : onPinColumn?.(selectedColumnId); }} > {!isProject ?? <> } {columns ? ( ) : ( '' )} ); }; export default SettingPanel;