feat(ui+backend): task update ok

This commit is contained in:
2020-09-11 11:55:22 +02:00
parent 7fc1a7f3af
commit aacff1d694
16 changed files with 331 additions and 219 deletions

View File

@ -1,5 +1,21 @@
import { gql } from '@apollo/client';
export const FRAGMENT_FULL_TASK = gql`
fragment FullTask on Task {
id
label
category {
id
label
}
estimations {
optimistic
likely
pessimistic
}
}
`;
export const FRAGMENT_FULL_PROJECT = gql`
fragment FullProject on Project {
id
@ -10,17 +26,7 @@ fragment FullProject on Project {
costPerTimeUnit
}
tasks {
id
label
category {
id
label
}
estimations {
optimistic
likely
pessimistic
}
...FullTask
}
params {
timeUnit {
@ -31,4 +37,5 @@ fragment FullProject on Project {
hideFinancialPreviewOnPrint
}
}
${FRAGMENT_FULL_TASK}
`

View File

@ -1,5 +1,5 @@
import { gql, useMutation, PureQueryOptions } from '@apollo/client';
import { FRAGMENT_FULL_PROJECT } from '../fragments/project';
import { FRAGMENT_FULL_PROJECT, FRAGMENT_FULL_TASK } from '../fragments/project';
import { QUERY_PROJECTS } from '../queries/project';
export const MUTATION_CREATE_PROJECT = gql`
@ -37,9 +37,10 @@ export function useUpdateProjectTitleMutation() {
export const MUTATION_ADD_PROJECT_TASK = gql`
mutation addProjectTask($projectId: ID!, $changes: ProjectTaskChanges!) {
addProjectTask(projectId: $projectId, changes: $changes) {
id
...FullTask
}
}
${FRAGMENT_FULL_TASK}
`;
export function useAddProjectTaskMutation() {
@ -49,9 +50,10 @@ export function useAddProjectTaskMutation() {
export const MUTATION_UPDATE_PROJECT_TASK = gql`
mutation updateProjectTask($projectId: ID!, $taskId: ID!, $changes: ProjectTaskChanges!) {
updateProjectTask(projectId: $projectId, taskId: $taskId, changes: $changes) {
id
...FullTask
}
}
${FRAGMENT_FULL_TASK}
`;
export function useUpdateProjectTaskMutation() {

View File

@ -1,41 +1,15 @@
import { gql, useQuery, QueryHookOptions } from '@apollo/client';
import { User } from '../../types/user';
import { useGraphQLData } from './helper';
import { Project } from '../../types/project';
import { FRAGMENT_FULL_PROJECT } from '../fragments/project';
export const QUERY_PROJECTS = gql`
query projects($filter: ProjectsFilter) {
projects(filter: $filter) {
id
title
taskCategories {
id
label
costPerTimeUnit
}
tasks {
id
label
category {
id
label
}
estimations {
optimistic
likely
pessimistic
}
}
params {
timeUnit {
label
acronym
}
currency
hideFinancialPreviewOnPrint
}
...FullProject
}
}`;
}
${FRAGMENT_FULL_PROJECT}`;
export function useProjectsQuery() {
return useQuery(QUERY_PROJECTS);