blob: 995c14aae13b57a9fe822159de7a5269973ce1c4 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
|
import {createSlice, PayloadAction} from '@reduxjs/toolkit'
import type {RootState} from '@/store'
import {SoftPairBucket} from "@/api";
const initialState: SoftPairBucket[] = []
const bucketSlice = createSlice({
name: 'buckets',
initialState,
reducers: {
setBuckets(state, action: PayloadAction<SoftPairBucket[]>) {
return action.payload;
},
bucketAdded(state, action: PayloadAction<SoftPairBucket>) {
state.push(action.payload);
}
}
})
export const {setBuckets, bucketAdded} = bucketSlice.actions;
export default bucketSlice.reducer
export const selectBucketById = (state: RootState, bucketId: string | null) =>
state.buckets.find(bucket => bucket.id === bucketId)
|