mirror of
https://github.com/arc53/DocsGPT.git
synced 2025-11-30 17:13:15 +00:00
added modal to select source documentation
This commit is contained in:
@@ -1,12 +1,15 @@
|
||||
import { createSlice } from '@reduxjs/toolkit';
|
||||
import { Doc } from '../models/misc';
|
||||
import store from '../store';
|
||||
|
||||
interface Preference {
|
||||
apiKey: string;
|
||||
selectedDocs: Doc | null;
|
||||
}
|
||||
|
||||
const initialState: Preference = {
|
||||
apiKey: '',
|
||||
selectedDocs: null,
|
||||
};
|
||||
|
||||
export const prefSlice = createSlice({
|
||||
@@ -16,10 +19,13 @@ export const prefSlice = createSlice({
|
||||
setApiKey: (state, action) => {
|
||||
state.apiKey = action.payload;
|
||||
},
|
||||
setSelectedDocs: (state, action) => {
|
||||
state.selectedDocs = action.payload;
|
||||
},
|
||||
},
|
||||
});
|
||||
|
||||
export const { setApiKey } = prefSlice.actions;
|
||||
export const { setApiKey, setSelectedDocs } = prefSlice.actions;
|
||||
export default prefSlice.reducer;
|
||||
|
||||
type RootState = ReturnType<typeof store.getState>;
|
||||
@@ -27,3 +33,7 @@ type RootState = ReturnType<typeof store.getState>;
|
||||
export const selectApiKey = (state: RootState) => state.preference.apiKey;
|
||||
export const selectApiKeyStatus = (state: RootState) =>
|
||||
!!state.preference.apiKey;
|
||||
export const selectSelectedDocs = (state: RootState) =>
|
||||
state.preference.selectedDocs;
|
||||
export const selectSelectedDocsStatus = (state: RootState) =>
|
||||
!!state.preference.selectedDocs;
|
||||
|
||||
Reference in New Issue
Block a user