mirror of
https://github.com/danny-avila/LibreChat.git
synced 2026-01-15 23:15:30 +01:00
30 lines
631 B
JavaScript
30 lines
631 B
JavaScript
import { createSlice } from '@reduxjs/toolkit';
|
|
|
|
const initialState = {
|
|
search: false,
|
|
query: '',
|
|
};
|
|
|
|
const currentSlice = createSlice({
|
|
name: 'search',
|
|
initialState,
|
|
reducers: {
|
|
setSearchState: (state, action) => {
|
|
state.search = 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 { setSearchState, setQuery } = currentSlice.actions;
|
|
|
|
export default currentSlice.reducer;
|