|
@@ -1,15 +1,14 @@
|
|
import { useEffect, useState } from 'react';
|
|
import { useEffect, useState } from 'react';
|
|
import { useAppDispatch, useAppSelector } from '../../stores/store';
|
|
import { useAppDispatch, useAppSelector } from '../../stores/store';
|
|
import { boardActions } from '../../stores/reducers/board/slice';
|
|
import { boardActions } from '../../stores/reducers/board/slice';
|
|
-import { IDatabase, IDatabaseRow, ISelectOption } from '../../stores/reducers/database/slice';
|
|
|
|
|
|
+import { ISelectOption, ISelectOptionType } from '../../stores/reducers/database/slice';
|
|
|
|
|
|
export const useBoard = () => {
|
|
export const useBoard = () => {
|
|
const dispatch = useAppDispatch();
|
|
const dispatch = useAppDispatch();
|
|
const groupingFieldId = useAppSelector((state) => state.board);
|
|
const groupingFieldId = useAppSelector((state) => state.board);
|
|
const database = useAppSelector((state) => state.database);
|
|
const database = useAppSelector((state) => state.database);
|
|
const [title, setTitle] = useState('');
|
|
const [title, setTitle] = useState('');
|
|
- const [boardColumns, setBoardColumns] =
|
|
|
|
- useState<(ISelectOption & { rows: (IDatabaseRow & { isGhost: boolean })[] })[]>();
|
|
|
|
|
|
+ const [boardColumns, setBoardColumns] = useState<ISelectOption[]>([]);
|
|
const [movingRowId, setMovingRowId] = useState<string | undefined>(undefined);
|
|
const [movingRowId, setMovingRowId] = useState<string | undefined>(undefined);
|
|
const [ghostLocation, setGhostLocation] = useState<{ column: number; row: number }>({ column: 0, row: 0 });
|
|
const [ghostLocation, setGhostLocation] = useState<{ column: number; row: number }>({ column: 0, row: 0 });
|
|
|
|
|
|
@@ -17,18 +16,7 @@ export const useBoard = () => {
|
|
setTitle(database.title);
|
|
setTitle(database.title);
|
|
if (database.fields[groupingFieldId]) {
|
|
if (database.fields[groupingFieldId]) {
|
|
setBoardColumns(
|
|
setBoardColumns(
|
|
- database.fields[groupingFieldId].fieldOptions.selectOptions?.map((groupFieldItem) => {
|
|
|
|
- /* const rows = database.rows
|
|
|
|
- .filter((row) => row.cells[groupingFieldId].data?.some((so) => so === groupFieldItem.selectOptionId))
|
|
|
|
- .map((row) => ({
|
|
|
|
- ...row,
|
|
|
|
- isGhost: false,
|
|
|
|
- }));*/
|
|
|
|
- return {
|
|
|
|
- ...groupFieldItem,
|
|
|
|
- rows: [],
|
|
|
|
- };
|
|
|
|
- }) || []
|
|
|
|
|
|
+ (database.fields[groupingFieldId].fieldOptions as ISelectOptionType | undefined)?.selectOptions || []
|
|
);
|
|
);
|
|
}
|
|
}
|
|
}, [database, groupingFieldId]);
|
|
}, [database, groupingFieldId]);
|