-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
9331fd3
commit 1a41647
Showing
1 changed file
with
55 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
import { createSlice } from "@reduxjs/toolkit"; | ||
|
||
export interface BookState { | ||
status?: string; | ||
title: string; | ||
id: string; | ||
subtitle: string; | ||
description?: string; | ||
authors: string; | ||
publisher?: string; | ||
pages?: string; | ||
year?: string; | ||
image: string; | ||
url: string; | ||
download?: string; | ||
} | ||
|
||
interface Bookslibrary { | ||
allBooks: BookState[]; | ||
bookById?: BookState; | ||
} | ||
const books: Bookslibrary = { | ||
allBooks: [ | ||
{ | ||
status: "ok", | ||
id: "1503212300", | ||
title: "Invent Your Own Computer Games with Python", | ||
subtitle: "A beginner's guide to computer programming in Python", | ||
description: | ||
"Invent Your Own Computer Games with Python teaches you how to program in the Python language...", | ||
authors: "Al Sweigart", | ||
publisher: "CreateSpace", | ||
pages: "367", | ||
year: "2015", | ||
image: "https://www.dbooks.org/img/books/1503212300s.jpg", | ||
url: "https://www.dbooks.org/invent-your-own-computer-games-with-python-1503212300/", | ||
download: | ||
"https://www.dbooks.org/d/1503212300-1635507922-39943ccf97e71c6e/", | ||
}, | ||
], | ||
}; | ||
export const bookSlice = createSlice({ | ||
name: "books", | ||
initialState: books, | ||
reducers: { | ||
addBooks: (state, action) => { | ||
return { ...state, ...action.payload }; | ||
}, | ||
}, | ||
}); | ||
|
||
// Action creators are generated for each case reducer function | ||
export const { addBooks } = bookSlice.actions; | ||
|
||
export default bookSlice.reducer; |