fix manage sync

This commit is contained in:
fadingNA
2024-11-10 15:33:33 -05:00
parent 32c67c2a02
commit 6974db5fd8
2 changed files with 16 additions and 2 deletions

View File

@@ -58,6 +58,7 @@ const Documents: React.FC<DocumentsProps> = ({
);
// State for documents
const currentDocuments = filteredDocuments ?? [];
console.log('currentDocuments', currentDocuments);
const syncOptions = [
{ label: 'Never', value: 'never' },
{ label: 'Daily', value: 'daily' },
@@ -101,12 +102,25 @@ const Documents: React.FC<DocumentsProps> = ({
userService
.manageSync({ source_id: doc.id, sync_frequency })
.then(() => {
// First, fetch the updated source docs
return getDocs();
})
.then((data) => {
dispatch(setSourceDocs(data));
return getDocsWithPagination(
sortField,
sortOrder,
currentPage,
rowsPerPage,
);
})
.catch((error) => console.error(error))
.then((paginatedData) => {
dispatch(
setPaginatedDocuments(paginatedData ? paginatedData.docs : []),
);
setTotalPages(paginatedData ? paginatedData.totalPages : 0);
})
.catch((error) => console.error('Error in handleManageSync:', error))
.finally(() => {
setLoading(false);
});