Revize c03fd43c
Přidáno uživatelem Fantič před téměř 2 roky(ů)
src/stores/reducers/itemSlice.ts | ||
---|---|---|
1 | 1 |
import { PayloadAction, createSlice } from "@reduxjs/toolkit" |
2 |
import { getItem, getItemNotes, getNextConcordance, getPreviousConcordance } from "../actions/itemThunks"
|
|
2 |
import { getItem, getItemNotes } from "../actions/itemThunks" |
|
3 | 3 |
import { Certainty, ItemViewState, Item } from "../../types/item"; |
4 | 4 |
|
5 | 5 |
|
... | ... | |
22 | 22 |
name: "item", |
23 | 23 |
initialState: initialState, |
24 | 24 |
reducers: { |
25 |
setSelectedConcordance: (state, action) => { |
|
26 |
state.selectedConcordance = action.payload.selectedConcordance; |
|
27 |
}, |
|
28 |
setConcordances: (state, action) => { |
|
29 |
state.concordances = action.payload.concordances; |
|
30 |
} |
|
25 | 31 |
}, |
26 | 32 |
extraReducers: (builder) => { |
27 | 33 |
// getItem |
28 | 34 |
builder.addCase(getItem.fulfilled, (state, action) => { |
29 | 35 |
|
30 |
state.item.id= action.payload.id; |
|
31 |
state.item.authorDisplayName= action.payload.authorDisplayName; |
|
32 |
state.item.workName= action.payload.workName; |
|
33 |
state.item.concordances= action.payload.concordances; |
|
34 |
state.item.searchSubjects= action.payload.searchSubjects; |
|
35 |
state.item.inventoryItem= action.payload.inventoryItem; |
|
36 |
state.item.fullView= action.payload.fullView; |
|
37 |
|
|
36 |
state.item.id = action.payload.id;
|
|
37 |
state.item.authorDisplayName = action.payload.authorDisplayName;
|
|
38 |
state.item.workName = action.payload.workName;
|
|
39 |
state.item.concordances = action.payload.concordances;
|
|
40 |
state.item.searchSubjects = action.payload.searchSubjects;
|
|
41 |
state.item.inventoryItem = action.payload.inventoryItem;
|
|
42 |
state.item.fullView = action.payload.fullView;
|
|
43 |
|
|
38 | 44 |
if (action.payload.fullView) { |
39 | 45 |
state.item.institution = action.payload.institution; |
40 | 46 |
state.item.authorName = action.payload.authorName; |
... | ... | |
44 | 50 |
state.item.provenance = action.payload.provenance; |
45 | 51 |
state.item.description = action.payload.description; |
46 | 52 |
} |
47 |
else{ |
|
53 |
else {
|
|
48 | 54 |
state.item.institution = undefined; |
49 | 55 |
state.item.authorName = undefined; |
50 | 56 |
state.item.imageUrl = undefined; |
... | ... | |
53 | 59 |
state.item.provenance = undefined; |
54 | 60 |
state.item.description = undefined; |
55 | 61 |
} |
56 |
|
|
57 |
// set concordances from item, if selected concordance is 0 |
|
58 |
if (state.selectedConcordance === 0) { |
|
59 |
console.log("Tohle se vola!"); |
|
60 |
state.concordances = action.payload.concordances; |
|
61 |
} |
|
62 | 62 |
|
63 |
// // set concordances from item, if selected concordance is 0 |
|
64 |
// if (state.selectedConcordance === 0) { |
|
65 |
// state.concordances = action.payload.concordances; |
|
66 |
// } |
|
63 | 67 |
}) |
64 | 68 |
builder.addCase(getItem.rejected, (state, action) => { |
65 | 69 |
state.lastError = action.error.message |
66 | 70 |
}) |
67 | 71 |
|
68 |
// getNextConcordance |
|
69 |
builder.addCase(getNextConcordance.fulfilled, (state, action) => { |
|
70 |
state.selectedConcordance = action.payload; |
|
71 |
}); |
|
72 |
|
|
73 |
builder.addCase(getNextConcordance.rejected, (state, action) => { |
|
74 |
state.lastError = action.error.message; |
|
75 |
}); |
|
76 |
|
|
77 |
// getPreviousConcordance |
|
78 |
builder.addCase(getPreviousConcordance.fulfilled, (state, action) => { |
|
79 |
state.selectedConcordance = action.payload; |
|
80 |
}); |
|
81 |
|
|
82 |
builder.addCase(getPreviousConcordance.rejected, (state, action) => { |
|
83 |
state.lastError = action.error.message; |
|
84 |
}); |
|
85 |
|
|
86 | 72 |
} |
87 | 73 |
}) |
88 | 74 |
|
Také k dispozici: Unified diff
re #10454: ItemView concordances switching