- Fix an issue with not having an upper context to store intermediate values. Thus allowing me to fix the top level 'Add Task'

Signed-off-by: Dave Richer <dave@imexsystems.ca>
This commit is contained in:
Dave Richer
2024-04-11 21:01:38 -04:00
parent 4d1480bb61
commit d7f946ec2a
5 changed files with 448 additions and 418 deletions

View File

@@ -4,7 +4,7 @@ import { useMutation, useQuery } from "@apollo/client";
import { MUTATION_TOGGLE_TASK_COMPLETED, MUTATION_TOGGLE_TASK_DELETED } from "../../graphql/tasks.queries.js";
import { pageLimit } from "../../utils/config.js";
import AlertComponent from "../alert/alert.component.jsx";
import React from "react";
import React, { useContext, useEffect } from "react";
import TaskListComponent from "./task-list.component.jsx";
import { notification } from "antd";
import { useTranslation } from "react-i18next";
@@ -14,6 +14,7 @@ import AuditTrailMapping from "../../utils/AuditTrailMappings.js";
import { createStructuredSelector } from "reselect";
import { selectBodyshop, selectCurrentUser } from "../../redux/user/user.selectors.js";
import dayjs from "../../utils/day";
import { SharedModalContext } from "../../providers/shared-modal.provider.jsx";
const mapStateToProps = createStructuredSelector({
bodyshop: selectBodyshop,
@@ -40,6 +41,8 @@ export function TaskListContainer({
const searchParams = queryString.parse(useLocation().search);
const { page, sortcolumn, sortorder, deleted, completed, mine } = searchParams;
const dispatch = useDispatch();
const { updateTaskQuery } = useContext(SharedModalContext); // Use the context
const { loading, error, data, refetch } = useQuery(query[Object.keys(query)[0]], {
fetchPolicy: "network-only",
nextFetchPolicy: "network-only",
@@ -163,6 +166,11 @@ export function TaskListContainer({
}
};
// Update the Last Task Paginated Query
useEffect(() => {
updateTaskQuery(Object.keys(query)[0]);
}, [query]);
if (error) return <AlertComponent message={error.message} type="error" />;
return (