Revize 852de08e
Přidáno uživatelem Fantič před téměř 2 roky(ů)
src/stores/reducers/itemSlice.ts | ||
---|---|---|
2 | 2 |
import { getItem, getItemNotes } from "../actions/itemThunks" |
3 | 3 |
import { Certainty, ItemViewState, Item } from "../../types/item"; |
4 | 4 |
|
5 |
|
|
5 |
// TODO set colors |
|
6 | 6 |
export const CertaintyWithColors: Record<Certainty, { certainty: Certainty; color: string }> = { |
7 |
same_as: { certainty: Certainty.SameAs, color: "#000000" },
|
|
8 |
high: { certainty: Certainty.High, color: "#FF0000" },
|
|
9 |
medium: { certainty: Certainty.Medium, color: "#FFFF00" },
|
|
10 |
low: { certainty: Certainty.Low, color: "#00FF00" },
|
|
11 |
unknown : { certainty: Certainty.Unknown, color: "#000000"}
|
|
7 |
same_as: { certainty: Certainty.SameAs, color: "light.300" },
|
|
8 |
high: { certainty: Certainty.High, color: "success.300" },
|
|
9 |
medium: { certainty: Certainty.Medium, color: "warning.300" },
|
|
10 |
low: { certainty: Certainty.Low, color: "danger.300" },
|
|
11 |
unknown : { certainty: Certainty.Unknown, color: "light.300"}
|
|
12 | 12 |
}; |
13 | 13 |
|
14 | 14 |
const initialState: ItemViewState = { |
... | ... | |
16 | 16 |
selectedConcordance: 0, |
17 | 17 |
concordances: [], |
18 | 18 |
notes: [], |
19 |
lastError: "" |
|
19 |
lastError: "", |
|
20 |
itemLoading: true, |
|
21 |
notesLoading: true |
|
20 | 22 |
} |
21 | 23 |
|
22 | 24 |
export const itemSlice = createSlice({ |
... | ... | |
62 | 64 |
state.item.provenance = undefined; |
63 | 65 |
state.item.description = undefined; |
64 | 66 |
} |
67 |
|
|
68 |
state.itemLoading = false; |
|
69 |
}) |
|
70 |
builder.addCase(getItem.pending, (state, action) => { |
|
71 |
state.itemLoading = true; |
|
65 | 72 |
}) |
66 | 73 |
builder.addCase(getItem.rejected, (state, action) => { |
74 |
state.itemLoading = false; |
|
67 | 75 |
state.lastError = action.error.message |
68 | 76 |
}) |
69 | 77 |
|
70 | 78 |
// getItemNotes |
71 | 79 |
builder.addCase(getItemNotes.fulfilled, (state, action) => { |
80 |
state.notesLoading = false; |
|
72 | 81 |
state.notes = action.payload.notes; |
73 | 82 |
}) |
83 |
builder.addCase(getItemNotes.pending, (state, action) => { |
|
84 |
state.notesLoading = true; |
|
85 |
}) |
|
74 | 86 |
builder.addCase(getItemNotes.rejected, (state, action) => { |
87 |
state.notesLoading = false; |
|
75 | 88 |
state.lastError = action.error.message |
76 | 89 |
}) |
77 | 90 |
|
Také k dispozici: Unified diff
re #10454: ItemView: Concordance scroll view, Loading Component