- Progress Commit

Signed-off-by: Dave Richer <dave@imexsystems.ca>
This commit is contained in:
Dave Richer
2024-03-21 13:42:08 -04:00
parent ab2323e5c1
commit 9012e4deec
4 changed files with 24 additions and 12 deletions

View File

@@ -476,7 +476,7 @@ function Header({
key: 'tasks', key: 'tasks',
id: 'tasks', id: 'tasks',
icon: <FaTasks />, icon: <FaTasks />,
label: t('menus.header.tasks'), label: t('menus.header.my_tasks'),
children: [ children: [
{ {
key: 'createTask', key: 'createTask',

View File

@@ -4,7 +4,7 @@ import React, {useEffect} from "react";
import {useTranslation} from "react-i18next"; import {useTranslation} from "react-i18next";
import {connect} from "react-redux"; import {connect} from "react-redux";
import {createStructuredSelector} from "reselect"; import {createStructuredSelector} from "reselect";
import {INSERT_NEW_TASK, UPDATE_TASK} from "../../graphql/tasks.queries"; import {MUTATION_INSERT_NEW_TASK, MUTATION_UPDATE_TASK} from "../../graphql/tasks.queries";
import {toggleModalVisible} from "../../redux/modals/modals.actions"; import {toggleModalVisible} from "../../redux/modals/modals.actions";
import {selectTaskUpsert} from "../../redux/modals/modals.selectors"; import {selectTaskUpsert} from "../../redux/modals/modals.selectors";
import {selectBodyshop, selectCurrentUser} from "../../redux/user/user.selectors"; import {selectBodyshop, selectCurrentUser} from "../../redux/user/user.selectors";
@@ -26,13 +26,12 @@ export function TaskUpsertModalContainer({
toggleModalVisible, toggleModalVisible,
}) { }) {
const {t} = useTranslation(); const {t} = useTranslation();
const [insertTask] = useMutation(INSERT_NEW_TASK); const [insertTask] = useMutation(MUTATION_INSERT_NEW_TASK);
const [updateTask] = useMutation(UPDATE_TASK); const [updateTask] = useMutation(MUTATION_UPDATE_TASK);
const {open, context, actions} = taskUpsert; const {open, context, actions} = taskUpsert;
const {jobId, existingTask} = context; const {jobId, existingTask} = context;
const {refetch} = actions; const {refetch} = actions;
const [form] = Form.useForm(); const [form] = Form.useForm();
useEffect(() => { useEffect(() => {
@@ -53,7 +52,6 @@ export function TaskUpsertModalContainer({
task: values, task: values,
}, },
}).then((r) => { }).then((r) => {
window.dispatchEvent(new CustomEvent('taskUpdated'));
notification["success"]({ notification["success"]({
message: t("tasks.successes.updated"), message: t("tasks.successes.updated"),
}); });
@@ -67,12 +65,26 @@ export function TaskUpsertModalContainer({
{...values, jobid: jobId, created_by: currentUser.email, bodyshopid: bodyshop.id}, {...values, jobid: jobId, created_by: currentUser.email, bodyshopid: bodyshop.id},
], ],
}, },
update(cache) {
cache.modify({
fields: {
tasks(existingTasks) {
return [{
...values,
jobid: jobId,
created_by: currentUser.email,
bodyshopid: bodyshop.id
}, ...existingTasks]
},
},
});
},
}); });
if (refetch) refetch(); if (refetch) refetch();
form.resetFields(); form.resetFields();
toggleModalVisible(); toggleModalVisible();
window.dispatchEvent(new CustomEvent('taskUpdated'));
notification["success"]({ notification["success"]({
message: t("tasks.successes.create"), message: t("tasks.successes.create"),
}); });

View File

@@ -134,8 +134,8 @@ export const MUTATION_TOGGLE_TASK_DELETED = gql`
* Insert new task mutation * Insert new task mutation
* @type {DocumentNode} * @type {DocumentNode}
*/ */
export const INSERT_NEW_TASK = gql` export const MUTATION_INSERT_NEW_TASK = gql`
mutation INSERT_NEW_TASK($taskInput: [tasks_insert_input!]!) { mutation MUTATION_INSERT_NEW_TASK($taskInput: [tasks_insert_input!]!) {
insert_tasks(objects: $taskInput) { insert_tasks(objects: $taskInput) {
returning { returning {
id id
@@ -165,8 +165,8 @@ export const INSERT_NEW_TASK = gql`
* Update task mutation * Update task mutation
* @type {DocumentNode} * @type {DocumentNode}
*/ */
export const UPDATE_TASK = gql` export const MUTATION_UPDATE_TASK = gql`
mutation UPDATE_TASK($taskId: uuid!, $task: tasks_set_input!) { mutation MUTATION_UPDATE_TASK($taskId: uuid!, $task: tasks_set_input!) {
update_tasks(where: { id: { _eq: $taskId } }, _set: $task) { update_tasks(where: { id: { _eq: $taskId } }, _set: $task) {
returning { returning {
id id

View File

@@ -13,7 +13,7 @@ const INITIAL_STATE = {
billEnter: {...baseModal}, billEnter: {...baseModal},
courtesyCarReturn: {...baseModal}, courtesyCarReturn: {...baseModal},
noteUpsert: {...baseModal}, noteUpsert: {...baseModal},
taskUpsert: {...baseModal}, taskUpsert: {...baseModal, },
schedule: {...baseModal}, schedule: {...baseModal},
partsOrder: {...baseModal}, partsOrder: {...baseModal},
timeTicket: {...baseModal}, timeTicket: {...baseModal},