mirror of
https://github.com/danny-avila/LibreChat.git
synced 2026-03-02 22:30:18 +01:00
31 lines
601 B
JavaScript
31 lines
601 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 || q === '') {
|
||
|
|
state.search = false;
|
||
|
|
} else {
|
||
|
|
state.search = true;
|
||
|
|
}
|
||
|
|
},
|
||
|
|
}
|
||
|
|
});
|
||
|
|
|
||
|
|
export const { setSearchState, setQuery } = currentSlice.actions;
|
||
|
|
|
||
|
|
export default currentSlice.reducer;
|