blob: a1db7f00bd77eab3764e8c85b6bf5a0633de605d (
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
|
import {createSlice, PayloadAction} from "@reduxjs/toolkit";
import {MarketProfileKnowledge} from "@/api";
const marketplaceInitialState: MarketProfileKnowledge[] = []
const marketplaceAnswerSlice = createSlice({
name: 'marketplaceAnswers',
marketplaceInitialState,
reducers: {
setMarketplaceAnswers(state, action: PayloadAction<MarketProfileKnowledge[]>) {
// TODO: Does this need question_id + source uniqueness?
const existingIds = new Set(state.map(q => q.question_id));
const newQuestions = action.payload.filter(q => !existingIds.has(q.question_id));
state.push(...newQuestions);
}
}
})
export const {
setMarketplaceAnswers,
} = marketplaceAnswerSlice.actions;
export default marketplaceAnswerSlice.reducer;
|