remove log on api, add paginatedDoc on redux

This commit is contained in:
fadingNA
2024-11-10 14:39:20 -05:00
parent b19e9cae23
commit 839f0a3b95
2 changed files with 8 additions and 7 deletions

View File

@@ -9,7 +9,6 @@ export async function getDocs(): Promise<Doc[] | null> {
const data = await response.json();
const docs: Doc[] = [];
console.log(data);
data.forEach((doc: object) => {
docs.push(doc as Doc);
});
@@ -31,17 +30,11 @@ export async function getDocsWithPagination(
const query = `sort=${sort}&order=${order}&page=${pageNumber}&rows=${rowsPerPage}`;
const response = await userService.getDocsWithPagination(query);
const data = await response.json();
const docs: Doc[] = [];
console.log(`data: ${data}`);
Array.isArray(data.paginated) &&
data.paginated.forEach((doc: Doc) => {
docs.push(doc as Doc);
});
console.log(`total: ${data.total}`);
console.log(`totalPages: ${data.totalPages}`);
console.log(`cursor: ${data.nextCursor}`);
console.log(`currentPage: ${data.currentPage}`);
return {
docs: docs,
totalDocuments: data.total,

View File

@@ -20,6 +20,7 @@ export interface Preference {
loading: boolean;
};
modalState: ActiveState;
paginatedDocuments: Doc[] | null;
}
const initialState: Preference = {
@@ -42,6 +43,7 @@ const initialState: Preference = {
loading: false,
},
modalState: 'INACTIVE',
paginatedDocuments: null,
};
export const prefSlice = createSlice({
@@ -57,6 +59,9 @@ export const prefSlice = createSlice({
setSourceDocs: (state, action) => {
state.sourceDocs = action.payload;
},
setPaginatedDocuments: (state, action) => {
state.paginatedDocuments = action.payload;
},
setConversations: (state, action) => {
state.conversations = action.payload;
},
@@ -84,6 +89,7 @@ export const {
setChunks,
setTokenLimit,
setModalStateDeleteConv,
setPaginatedDocuments,
} = prefSlice.actions;
export default prefSlice.reducer;
@@ -155,3 +161,5 @@ export const selectPrompt = (state: RootState) => state.preference.prompt;
export const selectChunks = (state: RootState) => state.preference.chunks;
export const selectTokenLimit = (state: RootState) =>
state.preference.token_limit;
export const selectPaginatedDocuments = (state: RootState) =>
state.preference.paginatedDocuments;