import { createAppSlice } from '../../app/createAppSlice';
import booksData from './booksData';

export const booksSlice = createAppSlice({
  name: 'books',
  initialState: booksData,
  reducers: {},
  selectors: {
    selectAllBooks: (state) => state,
    selectBookById: (state) => (id: number) => state.find((b) => b.id === id),
  },
});

export const { selectAllBooks, selectBookById } = booksSlice.selectors;
