back|frontend: update 'tasks' query to filter by status
This commit is contained in:
parent
6479c6c1c9
commit
fb2dbe87c9
7 changed files with 69 additions and 69 deletions
|
@ -3,16 +3,18 @@ module Twenty::GraphQL::Type
|
||||||
field :find_task, Task, null: true do
|
field :find_task, Task, null: true do
|
||||||
argument :task_id, Int
|
argument :task_id, Int
|
||||||
end
|
end
|
||||||
field :tasks, [Task], null: false
|
field :tasks, [Task], null: false do
|
||||||
|
argument :status, TaskStatus
|
||||||
|
end
|
||||||
field :projects, [Project], null: false
|
field :projects, [Project], null: false
|
||||||
|
|
||||||
def find_task(task_id:)
|
def find_task(task_id:)
|
||||||
Twenty::Task.find_by(id: task_id)
|
Twenty::Task.find_by(id: task_id)
|
||||||
end
|
end
|
||||||
|
|
||||||
def tasks
|
def tasks(status:)
|
||||||
Twenty::Task
|
Twenty::Task
|
||||||
.ready
|
.where(status:)
|
||||||
.order(updated_at: :desc)
|
.order(updated_at: :desc)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
@ -44,7 +44,7 @@ type Project {
|
||||||
type Query {
|
type Query {
|
||||||
findTask(taskId: Int!): Task
|
findTask(taskId: Int!): Task
|
||||||
projects: [Project!]!
|
projects: [Project!]!
|
||||||
tasks: [Task!]!
|
tasks(status: TaskStatus!): [Task!]!
|
||||||
}
|
}
|
||||||
|
|
||||||
type Task {
|
type Task {
|
||||||
|
|
|
@ -3,6 +3,6 @@ source "https://rubygems.org"
|
||||||
gemspec
|
gemspec
|
||||||
gem "nanoc", "~> 4.12"
|
gem "nanoc", "~> 4.12"
|
||||||
gem "nanoc-live", "~> 1.0"
|
gem "nanoc-live", "~> 1.0"
|
||||||
gem "nanoc-webpack.rb", "~> 0.4"
|
gem "nanoc-webpack.rb", "~> 0.5"
|
||||||
gem "sass", "~> 3.7"
|
gem "sass", "~> 3.7"
|
||||||
gem "rainpress", "~> 1.0"
|
gem "rainpress", "~> 1.0"
|
||||||
|
|
|
@ -75,7 +75,7 @@ GEM
|
||||||
listen (~> 3.0)
|
listen (~> 3.0)
|
||||||
nanoc-cli (~> 4.11, >= 4.11.14)
|
nanoc-cli (~> 4.11, >= 4.11.14)
|
||||||
nanoc-core (~> 4.11, >= 4.11.14)
|
nanoc-core (~> 4.11, >= 4.11.14)
|
||||||
nanoc-webpack.rb (0.4.5)
|
nanoc-webpack.rb (0.5.5)
|
||||||
ryo.rb (~> 0.4)
|
ryo.rb (~> 0.4)
|
||||||
parallel (1.24.0)
|
parallel (1.24.0)
|
||||||
pastel (0.8.0)
|
pastel (0.8.0)
|
||||||
|
@ -123,7 +123,7 @@ PLATFORMS
|
||||||
DEPENDENCIES
|
DEPENDENCIES
|
||||||
nanoc (~> 4.12)
|
nanoc (~> 4.12)
|
||||||
nanoc-live (~> 1.0)
|
nanoc-live (~> 1.0)
|
||||||
nanoc-webpack.rb (~> 0.4)
|
nanoc-webpack.rb (~> 0.5)
|
||||||
rainpress (~> 1.0)
|
rainpress (~> 1.0)
|
||||||
rake (~> 13.0)
|
rake (~> 13.0)
|
||||||
sass (~> 3.7)
|
sass (~> 3.7)
|
||||||
|
|
|
@ -4,12 +4,12 @@ import { useDestroyTask } from "/hooks/mutations/useDestroyTask";
|
||||||
import { TrashIcon, DoneIcon } from "/components/Icons";
|
import { TrashIcon, DoneIcon } from "/components/Icons";
|
||||||
import { NavBar } from "/components/NavBar";
|
import { NavBar } from "/components/NavBar";
|
||||||
import { DateTime } from "luxon";
|
import { DateTime } from "luxon";
|
||||||
import { Task } from "/types/schema";
|
import { Task, TaskStatus } from "/types/schema";
|
||||||
import classnames from "classnames";
|
import classnames from "classnames";
|
||||||
import { useCompleteTask } from "/hooks/mutations/useCompleteTask";
|
import { useCompleteTask } from "/hooks/mutations/useCompleteTask";
|
||||||
|
|
||||||
export function Tasks() {
|
export function Tasks() {
|
||||||
const { refetch, loading, data } = useTasks();
|
const { refetch, loading, data } = useTasks({variables: {status: TaskStatus.Ready}});
|
||||||
const tasks = data?.tasks;
|
const tasks = data?.tasks;
|
||||||
const [destroyTask] = useDestroyTask();
|
const [destroyTask] = useDestroyTask();
|
||||||
const [completeTask] = useCompleteTask();
|
const [completeTask] = useCompleteTask();
|
||||||
|
|
|
@ -1,8 +1,9 @@
|
||||||
import { useQuery, gql } from "@apollo/client";
|
import { useQuery, gql } from "@apollo/client";
|
||||||
|
import { Task, TaskStatus } from "/types/schema";
|
||||||
|
|
||||||
const GQL = gql`
|
const GQL = gql`
|
||||||
query Query {
|
query Query($status: TaskStatus!) {
|
||||||
tasks {
|
tasks(status: $status) {
|
||||||
id
|
id
|
||||||
title
|
title
|
||||||
status
|
status
|
||||||
|
@ -15,6 +16,6 @@ const GQL = gql`
|
||||||
}
|
}
|
||||||
`;
|
`;
|
||||||
|
|
||||||
export function useTasks() {
|
export function useTasks({...rest}) {
|
||||||
return useQuery(GQL);
|
return useQuery<{tasks: Task[]}>(GQL, rest);
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,123 +1,120 @@
|
||||||
export type Maybe<T> = T | null;
|
export type Maybe<T> = T | null;
|
||||||
export type InputMaybe<T> = Maybe<T>;
|
export type InputMaybe<T> = Maybe<T>;
|
||||||
export type Exact<T extends { [key: string]: unknown }> = {
|
export type Exact<T extends { [key: string]: unknown }> = { [K in keyof T]: T[K] };
|
||||||
[K in keyof T]: T[K];
|
export type MakeOptional<T, K extends keyof T> = Omit<T, K> & { [SubKey in K]?: Maybe<T[SubKey]> };
|
||||||
};
|
export type MakeMaybe<T, K extends keyof T> = Omit<T, K> & { [SubKey in K]: Maybe<T[SubKey]> };
|
||||||
export type MakeOptional<T, K extends keyof T> = Omit<T, K> & {
|
export type MakeEmpty<T extends { [key: string]: unknown }, K extends keyof T> = { [_ in K]?: never };
|
||||||
[SubKey in K]?: Maybe<T[SubKey]>;
|
export type Incremental<T> = T | { [P in keyof T]?: P extends ' $fragmentName' | '__typename' ? T[P] : never };
|
||||||
};
|
|
||||||
export type MakeMaybe<T, K extends keyof T> = Omit<T, K> & {
|
|
||||||
[SubKey in K]: Maybe<T[SubKey]>;
|
|
||||||
};
|
|
||||||
export type MakeEmpty<
|
|
||||||
T extends { [key: string]: unknown },
|
|
||||||
K extends keyof T,
|
|
||||||
> = { [_ in K]?: never };
|
|
||||||
export type Incremental<T> =
|
|
||||||
| T
|
|
||||||
| {
|
|
||||||
[P in keyof T]?: P extends " $fragmentName" | "__typename" ? T[P] : never;
|
|
||||||
};
|
|
||||||
/** All built-in and custom scalars, mapped to their actual values */
|
/** All built-in and custom scalars, mapped to their actual values */
|
||||||
export type Scalars = {
|
export type Scalars = {
|
||||||
ID: { input: string; output: string };
|
ID: { input: string; output: string; }
|
||||||
String: { input: string; output: string };
|
String: { input: string; output: string; }
|
||||||
Boolean: { input: boolean; output: boolean };
|
Boolean: { input: boolean; output: boolean; }
|
||||||
Int: { input: number; output: number };
|
Int: { input: number; output: number; }
|
||||||
Float: { input: number; output: number };
|
Float: { input: number; output: number; }
|
||||||
/** An ISO 8601-encoded datetime */
|
/** An ISO 8601-encoded datetime */
|
||||||
ISO8601DateTime: { input: any; output: any };
|
ISO8601DateTime: { input: any; output: any; }
|
||||||
};
|
};
|
||||||
|
|
||||||
/** Autogenerated return type of CompleteTask. */
|
/** Autogenerated return type of CompleteTask. */
|
||||||
export type CompleteTaskPayload = {
|
export type CompleteTaskPayload = {
|
||||||
__typename?: "CompleteTaskPayload";
|
__typename?: 'CompleteTaskPayload';
|
||||||
errors?: Maybe<Array<Scalars["String"]["output"]>>;
|
errors?: Maybe<Array<Scalars['String']['output']>>;
|
||||||
ok?: Maybe<Scalars["Boolean"]["output"]>;
|
ok?: Maybe<Scalars['Boolean']['output']>;
|
||||||
};
|
};
|
||||||
|
|
||||||
/** Autogenerated return type of CreateTask. */
|
/** Autogenerated return type of CreateTask. */
|
||||||
export type CreateTaskPayload = {
|
export type CreateTaskPayload = {
|
||||||
__typename?: "CreateTaskPayload";
|
__typename?: 'CreateTaskPayload';
|
||||||
errors: Array<Scalars["String"]["output"]>;
|
errors: Array<Scalars['String']['output']>;
|
||||||
};
|
};
|
||||||
|
|
||||||
/** Autogenerated return type of DestroyTask. */
|
/** Autogenerated return type of DestroyTask. */
|
||||||
export type DestroyTaskPayload = {
|
export type DestroyTaskPayload = {
|
||||||
__typename?: "DestroyTaskPayload";
|
__typename?: 'DestroyTaskPayload';
|
||||||
errors?: Maybe<Array<Scalars["String"]["output"]>>;
|
errors?: Maybe<Array<Scalars['String']['output']>>;
|
||||||
ok?: Maybe<Scalars["Boolean"]["output"]>;
|
ok?: Maybe<Scalars['Boolean']['output']>;
|
||||||
};
|
};
|
||||||
|
|
||||||
export type Mutation = {
|
export type Mutation = {
|
||||||
__typename?: "Mutation";
|
__typename?: 'Mutation';
|
||||||
completeTask?: Maybe<CompleteTaskPayload>;
|
completeTask?: Maybe<CompleteTaskPayload>;
|
||||||
createTask?: Maybe<CreateTaskPayload>;
|
createTask?: Maybe<CreateTaskPayload>;
|
||||||
destroyTask?: Maybe<DestroyTaskPayload>;
|
destroyTask?: Maybe<DestroyTaskPayload>;
|
||||||
updateTask?: Maybe<UpdateTaskPayload>;
|
updateTask?: Maybe<UpdateTaskPayload>;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
export type MutationCompleteTaskArgs = {
|
export type MutationCompleteTaskArgs = {
|
||||||
taskId: Scalars["Int"]["input"];
|
taskId: Scalars['Int']['input'];
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
export type MutationCreateTaskArgs = {
|
export type MutationCreateTaskArgs = {
|
||||||
input: TaskInput;
|
input: TaskInput;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
export type MutationDestroyTaskArgs = {
|
export type MutationDestroyTaskArgs = {
|
||||||
taskId: Scalars["Int"]["input"];
|
taskId: Scalars['Int']['input'];
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
export type MutationUpdateTaskArgs = {
|
export type MutationUpdateTaskArgs = {
|
||||||
input: TaskInput;
|
input: TaskInput;
|
||||||
taskId: Scalars["Int"]["input"];
|
taskId: Scalars['Int']['input'];
|
||||||
};
|
};
|
||||||
|
|
||||||
export type Project = {
|
export type Project = {
|
||||||
__typename?: "Project";
|
__typename?: 'Project';
|
||||||
color: Scalars["String"]["output"];
|
color: Scalars['String']['output'];
|
||||||
id: Scalars["Int"]["output"];
|
id: Scalars['Int']['output'];
|
||||||
name: Scalars["String"]["output"];
|
name: Scalars['String']['output'];
|
||||||
path: Scalars["String"]["output"];
|
path: Scalars['String']['output'];
|
||||||
tasks: Array<Task>;
|
tasks: Array<Task>;
|
||||||
};
|
};
|
||||||
|
|
||||||
export type Query = {
|
export type Query = {
|
||||||
__typename?: "Query";
|
__typename?: 'Query';
|
||||||
findTask?: Maybe<Task>;
|
findTask?: Maybe<Task>;
|
||||||
projects: Array<Project>;
|
projects: Array<Project>;
|
||||||
tasks: Array<Task>;
|
tasks: Array<Task>;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
export type QueryFindTaskArgs = {
|
export type QueryFindTaskArgs = {
|
||||||
taskId: Scalars["Int"]["input"];
|
taskId: Scalars['Int']['input'];
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
export type QueryTasksArgs = {
|
||||||
|
status: TaskStatus;
|
||||||
};
|
};
|
||||||
|
|
||||||
export type Task = {
|
export type Task = {
|
||||||
__typename?: "Task";
|
__typename?: 'Task';
|
||||||
content: Scalars["String"]["output"];
|
content: Scalars['String']['output'];
|
||||||
id: Scalars["Int"]["output"];
|
id: Scalars['Int']['output'];
|
||||||
project: Project;
|
project: Project;
|
||||||
status: TaskStatus;
|
status: TaskStatus;
|
||||||
title: Scalars["String"]["output"];
|
title: Scalars['String']['output'];
|
||||||
updatedAt: Scalars["ISO8601DateTime"]["output"];
|
updatedAt: Scalars['ISO8601DateTime']['output'];
|
||||||
};
|
};
|
||||||
|
|
||||||
export type TaskInput = {
|
export type TaskInput = {
|
||||||
content: Scalars["String"]["input"];
|
content: Scalars['String']['input'];
|
||||||
projectId: Scalars["Int"]["input"];
|
projectId: Scalars['Int']['input'];
|
||||||
title: Scalars["String"]["input"];
|
title: Scalars['String']['input'];
|
||||||
};
|
};
|
||||||
|
|
||||||
export enum TaskStatus {
|
export enum TaskStatus {
|
||||||
Complete = "complete",
|
Complete = 'complete',
|
||||||
InProgress = "in_progress",
|
InProgress = 'in_progress',
|
||||||
Ready = "ready",
|
Ready = 'ready'
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Autogenerated return type of UpdateTask. */
|
/** Autogenerated return type of UpdateTask. */
|
||||||
export type UpdateTaskPayload = {
|
export type UpdateTaskPayload = {
|
||||||
__typename?: "UpdateTaskPayload";
|
__typename?: 'UpdateTaskPayload';
|
||||||
errors: Array<Scalars["String"]["output"]>;
|
errors: Array<Scalars['String']['output']>;
|
||||||
};
|
};
|
||||||
|
|
Loading…
Reference in a new issue