[tasks] add empty state and new task button (#1072)

* [tasks] add empty state

* add refetch + use spacing for padding

* create task auto assigned with dueAt as today

* add unscheduled tasks section

* remove unnecessary assigneeId fetching

* remove unnecessary refetchQueries

* add refetch for delete task

* rename createCommentMutation to deleteActivityMutation in activityActionBar
This commit is contained in:
Weiko
2023-08-04 20:04:06 +02:00
committed by GitHub
parent c6bec40c90
commit 0d16053c31
9 changed files with 140 additions and 74 deletions

View File

@ -11,7 +11,11 @@ import { RightDrawerPages } from '@/ui/right-drawer/types/RightDrawerPages';
import { useSetHotkeyScope } from '@/ui/utilities/hotkey/hooks/useSetHotkeyScope';
import { ActivityType, useCreateActivityMutation } from '~/generated/graphql';
import { GET_ACTIVITIES_BY_TARGETS, GET_ACTIVITY } from '../queries';
import {
GET_ACTIVITIES,
GET_ACTIVITIES_BY_TARGETS,
GET_ACTIVITY,
} from '../queries';
import { commentableEntityArrayState } from '../states/commentableEntityArrayState';
import { viewableActivityIdState } from '../states/viewableActivityIdState';
import { CommentableEntity } from '../types/CommentableEntity';
@ -28,34 +32,48 @@ export function useOpenCreateActivityDrawer() {
const [, setViewableActivityId] = useRecoilState(viewableActivityIdState);
return function openCreateActivityDrawer(
entity: CommentableEntity,
type: ActivityType,
entity?: CommentableEntity,
) {
createActivityMutation({
const now = new Date().toISOString();
return createActivityMutation({
variables: {
authorId: currentUser?.id ?? '',
activityId: v4(),
createdAt: new Date().toISOString(),
type: type,
activityTargetArray: [
{
commentableId: entity.id,
commentableType: entity.type,
id: v4(),
createdAt: new Date().toISOString(),
data: {
id: v4(),
createdAt: now,
updatedAt: now,
author: { connect: { id: currentUser?.id ?? '' } },
assignee: { connect: { id: currentUser?.id ?? '' } },
type: type,
activityTargets: {
createMany: {
data: entity
? [
{
commentableId: entity.id,
commentableType: entity.type,
id: v4(),
createdAt: now,
},
]
: [],
skipDuplicates: true,
},
},
],
},
},
refetchQueries: [
getOperationName(GET_COMPANIES) ?? '',
getOperationName(GET_PEOPLE) ?? '',
getOperationName(GET_ACTIVITY) ?? '',
getOperationName(GET_ACTIVITIES_BY_TARGETS) ?? '',
getOperationName(GET_ACTIVITIES) ?? '',
],
onCompleted(data) {
setHotkeyScope(RightDrawerHotkeyScope.RightDrawer, { goto: false });
setViewableActivityId(data.createOneActivity.id);
setCommentableEntityArray([entity]);
setCommentableEntityArray(entity ? [entity] : []);
openRightDrawer(RightDrawerPages.CreateActivity);
},
});