mirror of
https://github.com/danny-avila/LibreChat.git
synced 2025-12-28 22:28:51 +01:00
35 lines
783 B
JavaScript
35 lines
783 B
JavaScript
import { createSlice } from '@reduxjs/toolkit';
|
|
|
|
const initialState = {
|
|
searchEnabled: false,
|
|
search: false,
|
|
query: '',
|
|
inputValue: '',
|
|
};
|
|
|
|
const currentSlice = createSlice({
|
|
name: 'search',
|
|
initialState,
|
|
reducers: {
|
|
setInputValue: (state, action) => {
|
|
state.inputValue = action.payload;
|
|
},
|
|
setSearchState: (state, action) => {
|
|
state.searchEnabled = action.payload;
|
|
},
|
|
setQuery: (state, action) => {
|
|
const q = action.payload;
|
|
state.query = q;
|
|
|
|
if (q === '') {
|
|
state.search = false;
|
|
} else if (q?.length > 0 && !state.search) {
|
|
state.search = true;
|
|
}
|
|
},
|
|
}
|
|
});
|
|
|
|
export const { setInputValue, setSearchState, setQuery } = currentSlice.actions;
|
|
|
|
export default currentSlice.reducer;
|