import { selectBranchState } from '../branch.selectors';
import { createSelector } from '@ngrx/store';
import { taskFilesAdapter } from './task-files.state';
import { FileDTO } from './defs';

export const selectTaskFilesState = createSelector(selectBranchState, (s) => s.taskFiles);

const { selectAll } = taskFilesAdapter.getSelectors(selectTaskFilesState);

export const selectFilesByTaskId = createSelector(selectAll, (s: FileDTO[], taskId: number) => s.filter((file) => file.taskId === taskId));
