mirror of
https://github.com/danny-avila/LibreChat.git
synced 2026-03-08 00:52:37 +01:00
feat: search bar working, still in progress
This commit is contained in:
parent
610cba4a60
commit
0f54ffd8b4
10 changed files with 147 additions and 24 deletions
30
client/src/store/searchSlice.js
Normal file
30
client/src/store/searchSlice.js
Normal file
|
|
@ -0,0 +1,30 @@
|
|||
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;
|
||||
Loading…
Add table
Add a link
Reference in a new issue