Currently, I have successfully built a redux-toolkit api using following code:
const api = createApi({
reducerPath: 'api',
baseQuery: baseQueryWithReauth,
endpoints: (builder) => ({
getClusters: builder.query({
query: ROUTES.CLUSTERS,
}),
}),
})
The data Im receiving from backend looks like this:
[
{
"name": "test 1",
"description": "test 1",
"id": 1
},
{
"name": "test 2",
"description": "test 2",
"id": 2
}
]
The user should be able to select one of these items through the interface, and the selection should be saved at redux. Something like:
{
"data": [
{
"name": "test 1",
"description": "test 1",
"id": 1
},
{
"name": "test 2",
"description": "test 2",
"id": 2
}
],
"selectedItem": 1 // Saved selected item id in redux so I can use it globally!
}
I have tried using createEntityAdapter and adding the selectId adapter, but seems not supported (I dont even know if its the correct approach). Is there any way to do it using redux-toolkit capabilities?