diff options
| author | Max Nanis | 2025-05-28 04:41:37 +0100 |
|---|---|---|
| committer | Max Nanis | 2025-05-28 04:41:37 +0100 |
| commit | 8caa77413ea372e5cbd2980a9922d701af359c04 (patch) | |
| tree | 9341e2f70fab6b2678fdff53c002954ef69c7b3e /src/models/bucketSlice.ts | |
| download | panel-ui-8caa77413ea372e5cbd2980a9922d701af359c04.tar.gz panel-ui-8caa77413ea372e5cbd2980a9922d701af359c04.zip | |
initial commit
Diffstat (limited to 'src/models/bucketSlice.ts')
| -rw-r--r-- | src/models/bucketSlice.ts | 34 |
1 files changed, 34 insertions, 0 deletions
diff --git a/src/models/bucketSlice.ts b/src/models/bucketSlice.ts new file mode 100644 index 0000000..9c6aee8 --- /dev/null +++ b/src/models/bucketSlice.ts @@ -0,0 +1,34 @@ +import {createSlice, PayloadAction} from '@reduxjs/toolkit' +import {SoftPairBucketClass} from "@/models/bucket.ts" +// import {ProfilingQuestion} from "@/models/question.ts"; +import type {RootState} from '@/store' +import {SoftPairBucket} from "@/api/models/soft-pair-bucket.ts" + +// Create an initial state value for the reducer, with that type +const initialState: SoftPairBucket[] = [] + +// Create the slice and pass in the initial state +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 the generated reducer function +export const {setBuckets, bucketAdded} = bucketSlice.actions; +export default bucketSlice.reducer + +export const selectBucketsStatus = (state: RootState) => state.buckets.status +export const selectBucketsError = (state: RootState) => state.buckets.error + +export const selectAllBuckets = (state: RootState) => state.buckets + +export const selectBucketById = (state: RootState, bucketId: string | null) => + state.buckets.find(bucket => bucket.id === bucketId)
\ No newline at end of file |
