@@ -476,7 +476,7 @@ function Header({
|
||||
key: 'tasks',
|
||||
id: 'tasks',
|
||||
icon: <FaTasks />,
|
||||
label: t('menus.header.tasks'),
|
||||
label: t('menus.header.my_tasks'),
|
||||
children: [
|
||||
{
|
||||
key: 'createTask',
|
||||
|
||||
@@ -4,7 +4,7 @@ import React, {useEffect} from "react";
|
||||
import {useTranslation} from "react-i18next";
|
||||
import {connect} from "react-redux";
|
||||
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 {selectTaskUpsert} from "../../redux/modals/modals.selectors";
|
||||
import {selectBodyshop, selectCurrentUser} from "../../redux/user/user.selectors";
|
||||
@@ -26,13 +26,12 @@ export function TaskUpsertModalContainer({
|
||||
toggleModalVisible,
|
||||
}) {
|
||||
const {t} = useTranslation();
|
||||
const [insertTask] = useMutation(INSERT_NEW_TASK);
|
||||
const [updateTask] = useMutation(UPDATE_TASK);
|
||||
const [insertTask] = useMutation(MUTATION_INSERT_NEW_TASK);
|
||||
const [updateTask] = useMutation(MUTATION_UPDATE_TASK);
|
||||
|
||||
const {open, context, actions} = taskUpsert;
|
||||
const {jobId, existingTask} = context;
|
||||
const {refetch} = actions;
|
||||
|
||||
const [form] = Form.useForm();
|
||||
|
||||
useEffect(() => {
|
||||
@@ -53,7 +52,6 @@ export function TaskUpsertModalContainer({
|
||||
task: values,
|
||||
},
|
||||
}).then((r) => {
|
||||
window.dispatchEvent(new CustomEvent('taskUpdated'));
|
||||
notification["success"]({
|
||||
message: t("tasks.successes.updated"),
|
||||
});
|
||||
@@ -67,12 +65,26 @@ export function TaskUpsertModalContainer({
|
||||
{...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();
|
||||
form.resetFields();
|
||||
toggleModalVisible();
|
||||
window.dispatchEvent(new CustomEvent('taskUpdated'));
|
||||
notification["success"]({
|
||||
message: t("tasks.successes.create"),
|
||||
});
|
||||
|
||||
@@ -134,8 +134,8 @@ export const MUTATION_TOGGLE_TASK_DELETED = gql`
|
||||
* Insert new task mutation
|
||||
* @type {DocumentNode}
|
||||
*/
|
||||
export const INSERT_NEW_TASK = gql`
|
||||
mutation INSERT_NEW_TASK($taskInput: [tasks_insert_input!]!) {
|
||||
export const MUTATION_INSERT_NEW_TASK = gql`
|
||||
mutation MUTATION_INSERT_NEW_TASK($taskInput: [tasks_insert_input!]!) {
|
||||
insert_tasks(objects: $taskInput) {
|
||||
returning {
|
||||
id
|
||||
@@ -165,8 +165,8 @@ export const INSERT_NEW_TASK = gql`
|
||||
* Update task mutation
|
||||
* @type {DocumentNode}
|
||||
*/
|
||||
export const UPDATE_TASK = gql`
|
||||
mutation UPDATE_TASK($taskId: uuid!, $task: tasks_set_input!) {
|
||||
export const MUTATION_UPDATE_TASK = gql`
|
||||
mutation MUTATION_UPDATE_TASK($taskId: uuid!, $task: tasks_set_input!) {
|
||||
update_tasks(where: { id: { _eq: $taskId } }, _set: $task) {
|
||||
returning {
|
||||
id
|
||||
|
||||
@@ -13,7 +13,7 @@ const INITIAL_STATE = {
|
||||
billEnter: {...baseModal},
|
||||
courtesyCarReturn: {...baseModal},
|
||||
noteUpsert: {...baseModal},
|
||||
taskUpsert: {...baseModal},
|
||||
taskUpsert: {...baseModal, },
|
||||
schedule: {...baseModal},
|
||||
partsOrder: {...baseModal},
|
||||
timeTicket: {...baseModal},
|
||||
|
||||
Reference in New Issue
Block a user