Moving queries into dedicated files (#1210)
* Moving queries into dedicated files * fix ci
This commit is contained in:
File diff suppressed because it is too large
Load Diff
@ -13,7 +13,7 @@ import {
|
|||||||
useUpdateActivityMutation,
|
useUpdateActivityMutation,
|
||||||
} from '~/generated/graphql';
|
} from '~/generated/graphql';
|
||||||
|
|
||||||
import { ACTIVITY_UPDATE_FRAGMENT } from '../queries/update';
|
import { ACTIVITY_UPDATE_FRAGMENT } from '../graphql/fragments/activityUpdateFragment';
|
||||||
|
|
||||||
export type OwnProps = {
|
export type OwnProps = {
|
||||||
activity: Pick<Activity, 'id'> & {
|
activity: Pick<Activity, 'id'> & {
|
||||||
|
|||||||
@ -8,7 +8,7 @@ import debounce from 'lodash.debounce';
|
|||||||
import { BlockEditor } from '@/ui/editor/components/BlockEditor';
|
import { BlockEditor } from '@/ui/editor/components/BlockEditor';
|
||||||
import { Activity, useUpdateActivityMutation } from '~/generated/graphql';
|
import { Activity, useUpdateActivityMutation } from '~/generated/graphql';
|
||||||
|
|
||||||
import { ACTIVITY_UPDATE_FRAGMENT } from '../queries/update';
|
import { ACTIVITY_UPDATE_FRAGMENT } from '../graphql/fragments/activityUpdateFragment';
|
||||||
|
|
||||||
const BlockNoteStyledContainer = styled.div`
|
const BlockNoteStyledContainer = styled.div`
|
||||||
width: 100%;
|
width: 100%;
|
||||||
|
|||||||
@ -13,7 +13,7 @@ import { Activity, useCreateCommentMutation } from '~/generated/graphql';
|
|||||||
import { isNonEmptyString } from '~/utils/isNonEmptyString';
|
import { isNonEmptyString } from '~/utils/isNonEmptyString';
|
||||||
|
|
||||||
import { Comment } from '../comment/Comment';
|
import { Comment } from '../comment/Comment';
|
||||||
import { GET_ACTIVITY } from '../queries';
|
import { GET_ACTIVITY } from '../graphql/queries/getActivity';
|
||||||
import { CommentForDrawer } from '../types/CommentForDrawer';
|
import { CommentForDrawer } from '../types/CommentForDrawer';
|
||||||
|
|
||||||
type OwnProps = {
|
type OwnProps = {
|
||||||
|
|||||||
@ -6,7 +6,7 @@ import styled from '@emotion/styled';
|
|||||||
import { ActivityBodyEditor } from '@/activities/components/ActivityBodyEditor';
|
import { ActivityBodyEditor } from '@/activities/components/ActivityBodyEditor';
|
||||||
import { ActivityComments } from '@/activities/components/ActivityComments';
|
import { ActivityComments } from '@/activities/components/ActivityComments';
|
||||||
import { ActivityTypeDropdown } from '@/activities/components/ActivityTypeDropdown';
|
import { ActivityTypeDropdown } from '@/activities/components/ActivityTypeDropdown';
|
||||||
import { GET_ACTIVITIES } from '@/activities/queries';
|
import { GET_ACTIVITIES } from '@/activities/graphql/queries/getActivities';
|
||||||
import { PropertyBox } from '@/ui/editable-field/property-box/components/PropertyBox';
|
import { PropertyBox } from '@/ui/editable-field/property-box/components/PropertyBox';
|
||||||
import { DateEditableField } from '@/ui/editable-field/variants/components/DateEditableField';
|
import { DateEditableField } from '@/ui/editable-field/variants/components/DateEditableField';
|
||||||
import { IconCalendar } from '@/ui/icon/index';
|
import { IconCalendar } from '@/ui/icon/index';
|
||||||
@ -22,7 +22,7 @@ import { debounce } from '~/utils/debounce';
|
|||||||
|
|
||||||
import { ActivityAssigneeEditableField } from '../editable-fields/components/ActivityAssigneeEditableField';
|
import { ActivityAssigneeEditableField } from '../editable-fields/components/ActivityAssigneeEditableField';
|
||||||
import { ActivityRelationEditableField } from '../editable-fields/components/ActivityRelationEditableField';
|
import { ActivityRelationEditableField } from '../editable-fields/components/ActivityRelationEditableField';
|
||||||
import { ACTIVITY_UPDATE_FRAGMENT } from '../queries/update';
|
import { ACTIVITY_UPDATE_FRAGMENT } from '../graphql/fragments/activityUpdateFragment';
|
||||||
import { CommentForDrawer } from '../types/CommentForDrawer';
|
import { CommentForDrawer } from '../types/CommentForDrawer';
|
||||||
|
|
||||||
import { ActivityTitle } from './ActivityTitle';
|
import { ActivityTitle } from './ActivityTitle';
|
||||||
|
|||||||
@ -2,7 +2,7 @@ import { getOperationName } from '@apollo/client/utilities';
|
|||||||
import type { Meta, StoryObj } from '@storybook/react';
|
import type { Meta, StoryObj } from '@storybook/react';
|
||||||
import { graphql } from 'msw';
|
import { graphql } from 'msw';
|
||||||
|
|
||||||
import { GET_ACTIVITIES } from '@/activities/queries';
|
import { GET_ACTIVITIES } from '@/activities/graphql/queries/getActivities';
|
||||||
import { TasksRecoilScopeContext } from '@/activities/states/recoil-scope-contexts/TasksRecoilScopeContext';
|
import { TasksRecoilScopeContext } from '@/activities/states/recoil-scope-contexts/TasksRecoilScopeContext';
|
||||||
import { ComponentWithRecoilScopeDecorator } from '~/testing/decorators/ComponentWithRecoilScopeDecorator';
|
import { ComponentWithRecoilScopeDecorator } from '~/testing/decorators/ComponentWithRecoilScopeDecorator';
|
||||||
import { ComponentWithRouterDecorator } from '~/testing/decorators/ComponentWithRouterDecorator';
|
import { ComponentWithRouterDecorator } from '~/testing/decorators/ComponentWithRouterDecorator';
|
||||||
|
|||||||
@ -3,8 +3,8 @@ import styled from '@emotion/styled';
|
|||||||
|
|
||||||
import { useHandleCheckableActivityTargetChange } from '@/activities/hooks/useHandleCheckableActivityTargetChange';
|
import { useHandleCheckableActivityTargetChange } from '@/activities/hooks/useHandleCheckableActivityTargetChange';
|
||||||
import { flatMapAndSortEntityForSelectArrayOfArrayByName } from '@/activities/utils/flatMapAndSortEntityForSelectArrayByName';
|
import { flatMapAndSortEntityForSelectArrayOfArrayByName } from '@/activities/utils/flatMapAndSortEntityForSelectArrayByName';
|
||||||
import { useFilteredSearchCompanyQuery } from '@/companies/queries';
|
import { useFilteredSearchCompanyQuery } from '@/companies/hooks/useFilteredSearchCompanyQuery';
|
||||||
import { useFilteredSearchPeopleQuery } from '@/people/queries';
|
import { useFilteredSearchPeopleQuery } from '@/people/hooks/useFilteredSearchPeopleQuery';
|
||||||
import { useEditableField } from '@/ui/editable-field/hooks/useEditableField';
|
import { useEditableField } from '@/ui/editable-field/hooks/useEditableField';
|
||||||
import { MultipleEntitySelect } from '@/ui/input/relation-picker/components/MultipleEntitySelect';
|
import { MultipleEntitySelect } from '@/ui/input/relation-picker/components/MultipleEntitySelect';
|
||||||
import { Activity, ActivityTarget } from '~/generated/graphql';
|
import { Activity, ActivityTarget } from '~/generated/graphql';
|
||||||
|
|||||||
@ -0,0 +1,54 @@
|
|||||||
|
import { gql } from '@apollo/client';
|
||||||
|
|
||||||
|
export const ACTIVITY_QUERY_FRAGMENT = gql`
|
||||||
|
fragment ActivityQueryFragment on Activity {
|
||||||
|
id
|
||||||
|
createdAt
|
||||||
|
title
|
||||||
|
body
|
||||||
|
type
|
||||||
|
completedAt
|
||||||
|
dueAt
|
||||||
|
assignee {
|
||||||
|
id
|
||||||
|
firstName
|
||||||
|
lastName
|
||||||
|
displayName
|
||||||
|
avatarUrl
|
||||||
|
}
|
||||||
|
author {
|
||||||
|
id
|
||||||
|
firstName
|
||||||
|
lastName
|
||||||
|
displayName
|
||||||
|
}
|
||||||
|
comments {
|
||||||
|
id
|
||||||
|
body
|
||||||
|
createdAt
|
||||||
|
updatedAt
|
||||||
|
author {
|
||||||
|
id
|
||||||
|
displayName
|
||||||
|
firstName
|
||||||
|
lastName
|
||||||
|
avatarUrl
|
||||||
|
}
|
||||||
|
}
|
||||||
|
activityTargets {
|
||||||
|
id
|
||||||
|
companyId
|
||||||
|
personId
|
||||||
|
company {
|
||||||
|
id
|
||||||
|
name
|
||||||
|
domainName
|
||||||
|
}
|
||||||
|
person {
|
||||||
|
id
|
||||||
|
displayName
|
||||||
|
avatarUrl
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
`;
|
||||||
@ -0,0 +1,18 @@
|
|||||||
|
import { gql } from '@apollo/client';
|
||||||
|
|
||||||
|
export const ACTIVITY_UPDATE_FRAGMENT = gql`
|
||||||
|
fragment ActivityUpdateParts on Activity {
|
||||||
|
id
|
||||||
|
body
|
||||||
|
title
|
||||||
|
type
|
||||||
|
completedAt
|
||||||
|
dueAt
|
||||||
|
assignee {
|
||||||
|
id
|
||||||
|
firstName
|
||||||
|
lastName
|
||||||
|
displayName
|
||||||
|
}
|
||||||
|
}
|
||||||
|
`;
|
||||||
@ -0,0 +1,24 @@
|
|||||||
|
import { gql } from '@apollo/client';
|
||||||
|
|
||||||
|
export const ADD_ACTIVITY_TARGETS = gql`
|
||||||
|
mutation AddActivityTargetsOnActivity(
|
||||||
|
$activityId: String!
|
||||||
|
$activityTargetInputs: [ActivityTargetCreateManyActivityInput!]!
|
||||||
|
) {
|
||||||
|
updateOneActivity(
|
||||||
|
where: { id: $activityId }
|
||||||
|
data: { activityTargets: { createMany: { data: $activityTargetInputs } } }
|
||||||
|
) {
|
||||||
|
id
|
||||||
|
createdAt
|
||||||
|
updatedAt
|
||||||
|
activityTargets {
|
||||||
|
id
|
||||||
|
createdAt
|
||||||
|
updatedAt
|
||||||
|
companyId
|
||||||
|
personId
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
`;
|
||||||
@ -0,0 +1,30 @@
|
|||||||
|
import { gql } from '@apollo/client';
|
||||||
|
|
||||||
|
export const CREATE_ACTIVITY_WITH_COMMENT = gql`
|
||||||
|
mutation CreateActivity($data: ActivityCreateInput!) {
|
||||||
|
createOneActivity(data: $data) {
|
||||||
|
id
|
||||||
|
createdAt
|
||||||
|
updatedAt
|
||||||
|
authorId
|
||||||
|
type
|
||||||
|
activityTargets {
|
||||||
|
id
|
||||||
|
createdAt
|
||||||
|
updatedAt
|
||||||
|
activityId
|
||||||
|
companyId
|
||||||
|
personId
|
||||||
|
}
|
||||||
|
comments {
|
||||||
|
id
|
||||||
|
createdAt
|
||||||
|
updatedAt
|
||||||
|
body
|
||||||
|
author {
|
||||||
|
id
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
`;
|
||||||
@ -31,32 +31,3 @@ export const CREATE_COMMENT = gql`
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
`;
|
`;
|
||||||
|
|
||||||
export const CREATE_ACTIVITY_WITH_COMMENT = gql`
|
|
||||||
mutation CreateActivity($data: ActivityCreateInput!) {
|
|
||||||
createOneActivity(data: $data) {
|
|
||||||
id
|
|
||||||
createdAt
|
|
||||||
updatedAt
|
|
||||||
authorId
|
|
||||||
type
|
|
||||||
activityTargets {
|
|
||||||
id
|
|
||||||
createdAt
|
|
||||||
updatedAt
|
|
||||||
activityId
|
|
||||||
companyId
|
|
||||||
personId
|
|
||||||
}
|
|
||||||
comments {
|
|
||||||
id
|
|
||||||
createdAt
|
|
||||||
updatedAt
|
|
||||||
body
|
|
||||||
author {
|
|
||||||
id
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
`;
|
|
||||||
@ -0,0 +1,9 @@
|
|||||||
|
import { gql } from '@apollo/client';
|
||||||
|
|
||||||
|
export const DELETE_ACTIVITY = gql`
|
||||||
|
mutation DeleteActivity($activityId: String!) {
|
||||||
|
deleteManyActivities(where: { id: { equals: $activityId } }) {
|
||||||
|
count
|
||||||
|
}
|
||||||
|
}
|
||||||
|
`;
|
||||||
@ -0,0 +1,27 @@
|
|||||||
|
import { gql } from '@apollo/client';
|
||||||
|
|
||||||
|
export const REMOVE_ACTIVITY_TARGETS = gql`
|
||||||
|
mutation RemoveActivityTargetsOnActivity(
|
||||||
|
$activityId: String!
|
||||||
|
$activityTargetIds: [String!]!
|
||||||
|
) {
|
||||||
|
updateOneActivity(
|
||||||
|
where: { id: $activityId }
|
||||||
|
data: {
|
||||||
|
activityTargets: { deleteMany: { id: { in: $activityTargetIds } } }
|
||||||
|
}
|
||||||
|
) {
|
||||||
|
id
|
||||||
|
createdAt
|
||||||
|
updatedAt
|
||||||
|
activityTargets {
|
||||||
|
id
|
||||||
|
createdAt
|
||||||
|
updatedAt
|
||||||
|
companyId
|
||||||
|
personId
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
`;
|
||||||
|
//
|
||||||
@ -0,0 +1,12 @@
|
|||||||
|
import { gql } from '@apollo/client';
|
||||||
|
|
||||||
|
export const UPDATE_ACTIVITY = gql`
|
||||||
|
mutation UpdateActivity(
|
||||||
|
$where: ActivityWhereUniqueInput!
|
||||||
|
$data: ActivityUpdateInput!
|
||||||
|
) {
|
||||||
|
updateOneActivity(where: $where, data: $data) {
|
||||||
|
...ActivityUpdateParts
|
||||||
|
}
|
||||||
|
}
|
||||||
|
`;
|
||||||
@ -0,0 +1,7 @@
|
|||||||
|
import { gql } from '@apollo/client';
|
||||||
|
|
||||||
|
export const UPLOAD_ATTACHMENT = gql`
|
||||||
|
mutation UploadAttachment($file: Upload!, $activityId: String!) {
|
||||||
|
uploadAttachment(file: $file, activityId: $activityId)
|
||||||
|
}
|
||||||
|
`;
|
||||||
@ -0,0 +1,12 @@
|
|||||||
|
import { gql } from '@apollo/client';
|
||||||
|
|
||||||
|
export const GET_ACTIVITIES = gql`
|
||||||
|
query GetActivities(
|
||||||
|
$where: ActivityWhereInput!
|
||||||
|
$orderBy: [ActivityOrderByWithRelationInput!]
|
||||||
|
) {
|
||||||
|
findManyActivities(orderBy: $orderBy, where: $where) {
|
||||||
|
...ActivityQueryFragment
|
||||||
|
}
|
||||||
|
}
|
||||||
|
`;
|
||||||
@ -0,0 +1,24 @@
|
|||||||
|
import { gql } from '@apollo/client';
|
||||||
|
|
||||||
|
export const GET_ACTIVITIES_BY_TARGETS = gql`
|
||||||
|
query GetActivitiesByTargets(
|
||||||
|
$activityTargetIds: [String!]!
|
||||||
|
$orderBy: [ActivityOrderByWithRelationInput!]
|
||||||
|
) {
|
||||||
|
findManyActivities(
|
||||||
|
orderBy: $orderBy
|
||||||
|
where: {
|
||||||
|
activityTargets: {
|
||||||
|
some: {
|
||||||
|
OR: [
|
||||||
|
{ personId: { in: $activityTargetIds } }
|
||||||
|
{ companyId: { in: $activityTargetIds } }
|
||||||
|
]
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
) {
|
||||||
|
...ActivityQueryFragment
|
||||||
|
}
|
||||||
|
}
|
||||||
|
`;
|
||||||
@ -0,0 +1,9 @@
|
|||||||
|
import { gql } from '@apollo/client';
|
||||||
|
|
||||||
|
export const GET_ACTIVITY = gql`
|
||||||
|
query GetActivity($activityId: String!) {
|
||||||
|
findManyActivities(where: { id: { equals: $activityId } }) {
|
||||||
|
...ActivityQueryFragment
|
||||||
|
}
|
||||||
|
}
|
||||||
|
`;
|
||||||
@ -3,7 +3,7 @@ import { useApolloClient } from '@apollo/client';
|
|||||||
|
|
||||||
import { Activity, useUpdateActivityMutation } from '~/generated/graphql';
|
import { Activity, useUpdateActivityMutation } from '~/generated/graphql';
|
||||||
|
|
||||||
import { ACTIVITY_UPDATE_FRAGMENT } from '../queries/update';
|
import { ACTIVITY_UPDATE_FRAGMENT } from '../graphql/fragments/activityUpdateFragment';
|
||||||
|
|
||||||
type Task = Pick<Activity, 'id'>;
|
type Task = Pick<Activity, 'id'>;
|
||||||
|
|
||||||
|
|||||||
@ -1,8 +1,8 @@
|
|||||||
import { getOperationName } from '@apollo/client/utilities';
|
import { getOperationName } from '@apollo/client/utilities';
|
||||||
import { v4 } from 'uuid';
|
import { v4 } from 'uuid';
|
||||||
|
|
||||||
import { GET_COMPANIES } from '@/companies/queries';
|
import { GET_COMPANIES } from '@/companies/graphql/queries/getCompanies';
|
||||||
import { GET_PEOPLE } from '@/people/queries';
|
import { GET_PEOPLE } from '@/people/graphql/queries/getPeople';
|
||||||
import {
|
import {
|
||||||
Activity,
|
Activity,
|
||||||
ActivityTarget,
|
ActivityTarget,
|
||||||
@ -10,7 +10,7 @@ import {
|
|||||||
useRemoveActivityTargetsOnActivityMutation,
|
useRemoveActivityTargetsOnActivityMutation,
|
||||||
} from '~/generated/graphql';
|
} from '~/generated/graphql';
|
||||||
|
|
||||||
import { GET_ACTIVITY } from '../queries';
|
import { GET_ACTIVITY } from '../graphql/queries/getActivity';
|
||||||
import { ActivityTargetableEntityType } from '../types/ActivityTargetableEntity';
|
import { ActivityTargetableEntityType } from '../types/ActivityTargetableEntity';
|
||||||
import { ActivityTargetableEntityForSelect } from '../types/ActivityTargetableEntityForSelect';
|
import { ActivityTargetableEntityForSelect } from '../types/ActivityTargetableEntityForSelect';
|
||||||
|
|
||||||
|
|||||||
@ -3,19 +3,17 @@ import { useRecoilState, useRecoilValue } from 'recoil';
|
|||||||
import { v4 } from 'uuid';
|
import { v4 } from 'uuid';
|
||||||
|
|
||||||
import { currentUserState } from '@/auth/states/currentUserState';
|
import { currentUserState } from '@/auth/states/currentUserState';
|
||||||
import { GET_COMPANIES } from '@/companies/queries';
|
import { GET_COMPANIES } from '@/companies/graphql/queries/getCompanies';
|
||||||
import { GET_PEOPLE } from '@/people/queries';
|
import { GET_PEOPLE } from '@/people/graphql/queries/getPeople';
|
||||||
import { useRightDrawer } from '@/ui/right-drawer/hooks/useRightDrawer';
|
import { useRightDrawer } from '@/ui/right-drawer/hooks/useRightDrawer';
|
||||||
import { RightDrawerHotkeyScope } from '@/ui/right-drawer/types/RightDrawerHotkeyScope';
|
import { RightDrawerHotkeyScope } from '@/ui/right-drawer/types/RightDrawerHotkeyScope';
|
||||||
import { RightDrawerPages } from '@/ui/right-drawer/types/RightDrawerPages';
|
import { RightDrawerPages } from '@/ui/right-drawer/types/RightDrawerPages';
|
||||||
import { useSetHotkeyScope } from '@/ui/utilities/hotkey/hooks/useSetHotkeyScope';
|
import { useSetHotkeyScope } from '@/ui/utilities/hotkey/hooks/useSetHotkeyScope';
|
||||||
import { ActivityType, useCreateActivityMutation } from '~/generated/graphql';
|
import { ActivityType, useCreateActivityMutation } from '~/generated/graphql';
|
||||||
|
|
||||||
import {
|
import { GET_ACTIVITIES } from '../graphql/queries/getActivities';
|
||||||
GET_ACTIVITIES,
|
import { GET_ACTIVITIES_BY_TARGETS } from '../graphql/queries/getActivitiesByTarget';
|
||||||
GET_ACTIVITIES_BY_TARGETS,
|
import { GET_ACTIVITY } from '../graphql/queries/getActivity';
|
||||||
GET_ACTIVITY,
|
|
||||||
} from '../queries';
|
|
||||||
import { activityTargetableEntityArrayState } from '../states/activityTargetableEntityArrayState';
|
import { activityTargetableEntityArrayState } from '../states/activityTargetableEntityArrayState';
|
||||||
import { viewableActivityIdState } from '../states/viewableActivityIdState';
|
import { viewableActivityIdState } from '../states/viewableActivityIdState';
|
||||||
import {
|
import {
|
||||||
|
|||||||
@ -1 +0,0 @@
|
|||||||
export * from './select';
|
|
||||||
@ -1,96 +0,0 @@
|
|||||||
import { gql } from '@apollo/client';
|
|
||||||
|
|
||||||
export const ACTIVITY_QUERY_FRAGMENT = gql`
|
|
||||||
fragment ActivityQueryFragment on Activity {
|
|
||||||
id
|
|
||||||
createdAt
|
|
||||||
title
|
|
||||||
body
|
|
||||||
type
|
|
||||||
completedAt
|
|
||||||
dueAt
|
|
||||||
assignee {
|
|
||||||
id
|
|
||||||
firstName
|
|
||||||
lastName
|
|
||||||
displayName
|
|
||||||
avatarUrl
|
|
||||||
}
|
|
||||||
author {
|
|
||||||
id
|
|
||||||
firstName
|
|
||||||
lastName
|
|
||||||
displayName
|
|
||||||
}
|
|
||||||
comments {
|
|
||||||
id
|
|
||||||
body
|
|
||||||
createdAt
|
|
||||||
updatedAt
|
|
||||||
author {
|
|
||||||
id
|
|
||||||
displayName
|
|
||||||
firstName
|
|
||||||
lastName
|
|
||||||
avatarUrl
|
|
||||||
}
|
|
||||||
}
|
|
||||||
activityTargets {
|
|
||||||
id
|
|
||||||
companyId
|
|
||||||
personId
|
|
||||||
company {
|
|
||||||
id
|
|
||||||
name
|
|
||||||
domainName
|
|
||||||
}
|
|
||||||
person {
|
|
||||||
id
|
|
||||||
displayName
|
|
||||||
avatarUrl
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
`;
|
|
||||||
|
|
||||||
export const GET_ACTIVITIES_BY_TARGETS = gql`
|
|
||||||
query GetActivitiesByTargets(
|
|
||||||
$activityTargetIds: [String!]!
|
|
||||||
$orderBy: [ActivityOrderByWithRelationInput!]
|
|
||||||
) {
|
|
||||||
findManyActivities(
|
|
||||||
orderBy: $orderBy
|
|
||||||
where: {
|
|
||||||
activityTargets: {
|
|
||||||
some: {
|
|
||||||
OR: [
|
|
||||||
{ personId: { in: $activityTargetIds } }
|
|
||||||
{ companyId: { in: $activityTargetIds } }
|
|
||||||
]
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
) {
|
|
||||||
...ActivityQueryFragment
|
|
||||||
}
|
|
||||||
}
|
|
||||||
`;
|
|
||||||
|
|
||||||
export const GET_ACTIVITIES = gql`
|
|
||||||
query GetActivities(
|
|
||||||
$where: ActivityWhereInput!
|
|
||||||
$orderBy: [ActivityOrderByWithRelationInput!]
|
|
||||||
) {
|
|
||||||
findManyActivities(orderBy: $orderBy, where: $where) {
|
|
||||||
...ActivityQueryFragment
|
|
||||||
}
|
|
||||||
}
|
|
||||||
`;
|
|
||||||
|
|
||||||
export const GET_ACTIVITY = gql`
|
|
||||||
query GetActivity($activityId: String!) {
|
|
||||||
findManyActivities(where: { id: { equals: $activityId } }) {
|
|
||||||
...ActivityQueryFragment
|
|
||||||
}
|
|
||||||
}
|
|
||||||
`;
|
|
||||||
@ -1,91 +0,0 @@
|
|||||||
import { gql } from '@apollo/client';
|
|
||||||
|
|
||||||
export const ADD_ACTIVITY_TARGETS = gql`
|
|
||||||
mutation AddActivityTargetsOnActivity(
|
|
||||||
$activityId: String!
|
|
||||||
$activityTargetInputs: [ActivityTargetCreateManyActivityInput!]!
|
|
||||||
) {
|
|
||||||
updateOneActivity(
|
|
||||||
where: { id: $activityId }
|
|
||||||
data: { activityTargets: { createMany: { data: $activityTargetInputs } } }
|
|
||||||
) {
|
|
||||||
id
|
|
||||||
createdAt
|
|
||||||
updatedAt
|
|
||||||
activityTargets {
|
|
||||||
id
|
|
||||||
createdAt
|
|
||||||
updatedAt
|
|
||||||
companyId
|
|
||||||
personId
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
`;
|
|
||||||
|
|
||||||
export const REMOVE_ACTIVITY_TARGETS = gql`
|
|
||||||
mutation RemoveActivityTargetsOnActivity(
|
|
||||||
$activityId: String!
|
|
||||||
$activityTargetIds: [String!]!
|
|
||||||
) {
|
|
||||||
updateOneActivity(
|
|
||||||
where: { id: $activityId }
|
|
||||||
data: {
|
|
||||||
activityTargets: { deleteMany: { id: { in: $activityTargetIds } } }
|
|
||||||
}
|
|
||||||
) {
|
|
||||||
id
|
|
||||||
createdAt
|
|
||||||
updatedAt
|
|
||||||
activityTargets {
|
|
||||||
id
|
|
||||||
createdAt
|
|
||||||
updatedAt
|
|
||||||
companyId
|
|
||||||
personId
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
`;
|
|
||||||
|
|
||||||
export const DELETE_ACTIVITY = gql`
|
|
||||||
mutation DeleteActivity($activityId: String!) {
|
|
||||||
deleteManyActivities(where: { id: { equals: $activityId } }) {
|
|
||||||
count
|
|
||||||
}
|
|
||||||
}
|
|
||||||
`;
|
|
||||||
|
|
||||||
export const ACTIVITY_UPDATE_FRAGMENT = gql`
|
|
||||||
fragment ActivityUpdateParts on Activity {
|
|
||||||
id
|
|
||||||
body
|
|
||||||
title
|
|
||||||
type
|
|
||||||
completedAt
|
|
||||||
dueAt
|
|
||||||
assignee {
|
|
||||||
id
|
|
||||||
firstName
|
|
||||||
lastName
|
|
||||||
displayName
|
|
||||||
}
|
|
||||||
}
|
|
||||||
`;
|
|
||||||
|
|
||||||
export const UPDATE_ACTIVITY = gql`
|
|
||||||
mutation UpdateActivity(
|
|
||||||
$where: ActivityWhereUniqueInput!
|
|
||||||
$data: ActivityUpdateInput!
|
|
||||||
) {
|
|
||||||
updateOneActivity(where: $where, data: $data) {
|
|
||||||
...ActivityUpdateParts
|
|
||||||
}
|
|
||||||
}
|
|
||||||
`;
|
|
||||||
|
|
||||||
export const UPLOAD_ATTACHMENT = gql`
|
|
||||||
mutation UploadAttachment($file: Upload!, $activityId: String!) {
|
|
||||||
uploadAttachment(file: $file, activityId: $activityId)
|
|
||||||
}
|
|
||||||
`;
|
|
||||||
@ -3,12 +3,10 @@ import { useTheme } from '@emotion/react';
|
|||||||
import styled from '@emotion/styled';
|
import styled from '@emotion/styled';
|
||||||
import { useRecoilState } from 'recoil';
|
import { useRecoilState } from 'recoil';
|
||||||
|
|
||||||
import {
|
import { GET_ACTIVITIES } from '@/activities/graphql/queries/getActivities';
|
||||||
GET_ACTIVITIES,
|
import { GET_ACTIVITIES_BY_TARGETS } from '@/activities/graphql/queries/getActivitiesByTarget';
|
||||||
GET_ACTIVITIES_BY_TARGETS,
|
import { GET_COMPANIES } from '@/companies/graphql/queries/getCompanies';
|
||||||
} from '@/activities/queries';
|
import { GET_PEOPLE } from '@/people/graphql/queries/getPeople';
|
||||||
import { GET_COMPANIES } from '@/companies/queries';
|
|
||||||
import { GET_PEOPLE } from '@/people/queries';
|
|
||||||
import { IconButton } from '@/ui/button/components/IconButton';
|
import { IconButton } from '@/ui/button/components/IconButton';
|
||||||
import { IconTrash } from '@/ui/icon';
|
import { IconTrash } from '@/ui/icon';
|
||||||
import { isRightDrawerOpenState } from '@/ui/right-drawer/states/isRightDrawerOpenState';
|
import { isRightDrawerOpenState } from '@/ui/right-drawer/states/isRightDrawerOpenState';
|
||||||
|
|||||||
@ -0,0 +1,29 @@
|
|||||||
|
import { gql } from '@apollo/client';
|
||||||
|
|
||||||
|
export const USER_QUERY_FRAGMENT = gql`
|
||||||
|
fragment UserQueryFragment on User {
|
||||||
|
id
|
||||||
|
email
|
||||||
|
displayName
|
||||||
|
firstName
|
||||||
|
lastName
|
||||||
|
canImpersonate
|
||||||
|
supportUserHash
|
||||||
|
workspaceMember {
|
||||||
|
id
|
||||||
|
allowImpersonation
|
||||||
|
workspace {
|
||||||
|
id
|
||||||
|
domainName
|
||||||
|
displayName
|
||||||
|
logo
|
||||||
|
inviteHash
|
||||||
|
}
|
||||||
|
}
|
||||||
|
settings {
|
||||||
|
id
|
||||||
|
colorScheme
|
||||||
|
locale
|
||||||
|
}
|
||||||
|
}
|
||||||
|
`;
|
||||||
12
front/src/modules/auth/graphql/mutations/challenge.ts
Normal file
12
front/src/modules/auth/graphql/mutations/challenge.ts
Normal file
@ -0,0 +1,12 @@
|
|||||||
|
import { gql } from '@apollo/client';
|
||||||
|
|
||||||
|
export const CHALLENGE = gql`
|
||||||
|
mutation Challenge($email: String!, $password: String!) {
|
||||||
|
challenge(email: $email, password: $password) {
|
||||||
|
loginToken {
|
||||||
|
expiresAt
|
||||||
|
token
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
`;
|
||||||
22
front/src/modules/auth/graphql/mutations/impersonate.ts
Normal file
22
front/src/modules/auth/graphql/mutations/impersonate.ts
Normal file
@ -0,0 +1,22 @@
|
|||||||
|
import { gql } from '@apollo/client';
|
||||||
|
|
||||||
|
// TODO: Fragments should be used instead of duplicating the user fields !
|
||||||
|
export const IMPERSONATE = gql`
|
||||||
|
mutation Impersonate($userId: String!) {
|
||||||
|
impersonate(userId: $userId) {
|
||||||
|
user {
|
||||||
|
...UserQueryFragment
|
||||||
|
}
|
||||||
|
tokens {
|
||||||
|
accessToken {
|
||||||
|
token
|
||||||
|
expiresAt
|
||||||
|
}
|
||||||
|
refreshToken {
|
||||||
|
token
|
||||||
|
expiresAt
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
`;
|
||||||
18
front/src/modules/auth/graphql/mutations/renewToken.ts
Normal file
18
front/src/modules/auth/graphql/mutations/renewToken.ts
Normal file
@ -0,0 +1,18 @@
|
|||||||
|
import { gql } from '@apollo/client';
|
||||||
|
|
||||||
|
export const RENEW_TOKEN = gql`
|
||||||
|
mutation RenewToken($refreshToken: String!) {
|
||||||
|
renewToken(refreshToken: $refreshToken) {
|
||||||
|
tokens {
|
||||||
|
accessToken {
|
||||||
|
expiresAt
|
||||||
|
token
|
||||||
|
}
|
||||||
|
refreshToken {
|
||||||
|
token
|
||||||
|
expiresAt
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
`;
|
||||||
20
front/src/modules/auth/graphql/mutations/signUp.ts
Normal file
20
front/src/modules/auth/graphql/mutations/signUp.ts
Normal file
@ -0,0 +1,20 @@
|
|||||||
|
import { gql } from '@apollo/client';
|
||||||
|
|
||||||
|
export const SIGN_UP = gql`
|
||||||
|
mutation SignUp(
|
||||||
|
$email: String!
|
||||||
|
$password: String!
|
||||||
|
$workspaceInviteHash: String
|
||||||
|
) {
|
||||||
|
signUp(
|
||||||
|
email: $email
|
||||||
|
password: $password
|
||||||
|
workspaceInviteHash: $workspaceInviteHash
|
||||||
|
) {
|
||||||
|
loginToken {
|
||||||
|
expiresAt
|
||||||
|
token
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
`;
|
||||||
21
front/src/modules/auth/graphql/mutations/verify.ts
Normal file
21
front/src/modules/auth/graphql/mutations/verify.ts
Normal file
@ -0,0 +1,21 @@
|
|||||||
|
import { gql } from '@apollo/client';
|
||||||
|
|
||||||
|
export const VERIFY = gql`
|
||||||
|
mutation Verify($loginToken: String!) {
|
||||||
|
verify(loginToken: $loginToken) {
|
||||||
|
user {
|
||||||
|
...UserQueryFragment
|
||||||
|
}
|
||||||
|
tokens {
|
||||||
|
accessToken {
|
||||||
|
token
|
||||||
|
expiresAt
|
||||||
|
}
|
||||||
|
refreshToken {
|
||||||
|
token
|
||||||
|
expiresAt
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
`;
|
||||||
@ -1,2 +0,0 @@
|
|||||||
export * from './select';
|
|
||||||
export * from './update';
|
|
||||||
@ -1,133 +0,0 @@
|
|||||||
import { gql } from '@apollo/client';
|
|
||||||
|
|
||||||
export const CHALLENGE = gql`
|
|
||||||
mutation Challenge($email: String!, $password: String!) {
|
|
||||||
challenge(email: $email, password: $password) {
|
|
||||||
loginToken {
|
|
||||||
expiresAt
|
|
||||||
token
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
`;
|
|
||||||
|
|
||||||
export const SIGN_UP = gql`
|
|
||||||
mutation SignUp(
|
|
||||||
$email: String!
|
|
||||||
$password: String!
|
|
||||||
$workspaceInviteHash: String
|
|
||||||
) {
|
|
||||||
signUp(
|
|
||||||
email: $email
|
|
||||||
password: $password
|
|
||||||
workspaceInviteHash: $workspaceInviteHash
|
|
||||||
) {
|
|
||||||
loginToken {
|
|
||||||
expiresAt
|
|
||||||
token
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
`;
|
|
||||||
|
|
||||||
export const VERIFY = gql`
|
|
||||||
mutation Verify($loginToken: String!) {
|
|
||||||
verify(loginToken: $loginToken) {
|
|
||||||
user {
|
|
||||||
id
|
|
||||||
email
|
|
||||||
displayName
|
|
||||||
firstName
|
|
||||||
lastName
|
|
||||||
canImpersonate
|
|
||||||
supportUserHash
|
|
||||||
workspaceMember {
|
|
||||||
id
|
|
||||||
allowImpersonation
|
|
||||||
workspace {
|
|
||||||
id
|
|
||||||
domainName
|
|
||||||
displayName
|
|
||||||
logo
|
|
||||||
inviteHash
|
|
||||||
}
|
|
||||||
}
|
|
||||||
settings {
|
|
||||||
id
|
|
||||||
colorScheme
|
|
||||||
locale
|
|
||||||
}
|
|
||||||
}
|
|
||||||
tokens {
|
|
||||||
accessToken {
|
|
||||||
token
|
|
||||||
expiresAt
|
|
||||||
}
|
|
||||||
refreshToken {
|
|
||||||
token
|
|
||||||
expiresAt
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
`;
|
|
||||||
|
|
||||||
export const RENEW_TOKEN = gql`
|
|
||||||
mutation RenewToken($refreshToken: String!) {
|
|
||||||
renewToken(refreshToken: $refreshToken) {
|
|
||||||
tokens {
|
|
||||||
accessToken {
|
|
||||||
expiresAt
|
|
||||||
token
|
|
||||||
}
|
|
||||||
refreshToken {
|
|
||||||
token
|
|
||||||
expiresAt
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
`;
|
|
||||||
|
|
||||||
// TODO: Fragments should be used instead of duplicating the user fields !
|
|
||||||
export const IMPERSONATE = gql`
|
|
||||||
mutation Impersonate($userId: String!) {
|
|
||||||
impersonate(userId: $userId) {
|
|
||||||
user {
|
|
||||||
id
|
|
||||||
email
|
|
||||||
displayName
|
|
||||||
firstName
|
|
||||||
lastName
|
|
||||||
canImpersonate
|
|
||||||
supportUserHash
|
|
||||||
workspaceMember {
|
|
||||||
id
|
|
||||||
allowImpersonation
|
|
||||||
workspace {
|
|
||||||
id
|
|
||||||
domainName
|
|
||||||
displayName
|
|
||||||
logo
|
|
||||||
inviteHash
|
|
||||||
}
|
|
||||||
}
|
|
||||||
settings {
|
|
||||||
id
|
|
||||||
colorScheme
|
|
||||||
locale
|
|
||||||
}
|
|
||||||
}
|
|
||||||
tokens {
|
|
||||||
accessToken {
|
|
||||||
token
|
|
||||||
expiresAt
|
|
||||||
}
|
|
||||||
refreshToken {
|
|
||||||
token
|
|
||||||
expiresAt
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
`;
|
|
||||||
@ -3,11 +3,11 @@ import { Meta, StoryObj } from '@storybook/react';
|
|||||||
|
|
||||||
import { EntityBoard } from '@/ui/board/components/EntityBoard';
|
import { EntityBoard } from '@/ui/board/components/EntityBoard';
|
||||||
import { RecoilScope } from '@/ui/utilities/recoil-scope/components/RecoilScope';
|
import { RecoilScope } from '@/ui/utilities/recoil-scope/components/RecoilScope';
|
||||||
|
import { SortOrder } from '~/generated/graphql';
|
||||||
import { opportunitiesBoardOptions } from '~/pages/opportunities/opportunitiesBoardOptions';
|
import { opportunitiesBoardOptions } from '~/pages/opportunities/opportunitiesBoardOptions';
|
||||||
import { ComponentDecorator } from '~/testing/decorators/ComponentDecorator';
|
import { ComponentDecorator } from '~/testing/decorators/ComponentDecorator';
|
||||||
import { graphqlMocks } from '~/testing/graphqlMocks';
|
import { graphqlMocks } from '~/testing/graphqlMocks';
|
||||||
|
|
||||||
import { defaultPipelineProgressOrderBy } from '../../pipeline/queries';
|
|
||||||
import { HooksCompanyBoard } from '../components/HooksCompanyBoard';
|
import { HooksCompanyBoard } from '../components/HooksCompanyBoard';
|
||||||
import { CompanyBoardRecoilScopeContext } from '../states/recoil-scope-contexts/CompanyBoardRecoilScopeContext';
|
import { CompanyBoardRecoilScopeContext } from '../states/recoil-scope-contexts/CompanyBoardRecoilScopeContext';
|
||||||
|
|
||||||
@ -17,7 +17,13 @@ const meta: Meta<typeof EntityBoard> = {
|
|||||||
decorators: [
|
decorators: [
|
||||||
(Story) => (
|
(Story) => (
|
||||||
<RecoilScope SpecificContext={CompanyBoardRecoilScopeContext}>
|
<RecoilScope SpecificContext={CompanyBoardRecoilScopeContext}>
|
||||||
<HooksCompanyBoard orderBy={defaultPipelineProgressOrderBy} />
|
<HooksCompanyBoard
|
||||||
|
orderBy={[
|
||||||
|
{
|
||||||
|
createdAt: SortOrder.Asc,
|
||||||
|
},
|
||||||
|
]}
|
||||||
|
/>
|
||||||
<MemoryRouter>
|
<MemoryRouter>
|
||||||
<Story />
|
<Story />
|
||||||
</MemoryRouter>
|
</MemoryRouter>
|
||||||
|
|||||||
@ -5,11 +5,11 @@ import { CompanyBoardCard } from '@/companies/components/CompanyBoardCard';
|
|||||||
import { BoardCardIdContext } from '@/ui/board/contexts/BoardCardIdContext';
|
import { BoardCardIdContext } from '@/ui/board/contexts/BoardCardIdContext';
|
||||||
import { BoardColumnRecoilScopeContext } from '@/ui/board/states/recoil-scope-contexts/BoardColumnRecoilScopeContext';
|
import { BoardColumnRecoilScopeContext } from '@/ui/board/states/recoil-scope-contexts/BoardColumnRecoilScopeContext';
|
||||||
import { RecoilScope } from '@/ui/utilities/recoil-scope/components/RecoilScope';
|
import { RecoilScope } from '@/ui/utilities/recoil-scope/components/RecoilScope';
|
||||||
|
import { SortOrder } from '~/generated/graphql';
|
||||||
import { ComponentDecorator } from '~/testing/decorators/ComponentDecorator';
|
import { ComponentDecorator } from '~/testing/decorators/ComponentDecorator';
|
||||||
import { graphqlMocks } from '~/testing/graphqlMocks';
|
import { graphqlMocks } from '~/testing/graphqlMocks';
|
||||||
import { mockedPipelineProgressData } from '~/testing/mock-data/pipeline-progress';
|
import { mockedPipelineProgressData } from '~/testing/mock-data/pipeline-progress';
|
||||||
|
|
||||||
import { defaultPipelineProgressOrderBy } from '../../pipeline/queries';
|
|
||||||
import { HooksCompanyBoard } from '../components/HooksCompanyBoard';
|
import { HooksCompanyBoard } from '../components/HooksCompanyBoard';
|
||||||
import { CompanyBoardRecoilScopeContext } from '../states/recoil-scope-contexts/CompanyBoardRecoilScopeContext';
|
import { CompanyBoardRecoilScopeContext } from '../states/recoil-scope-contexts/CompanyBoardRecoilScopeContext';
|
||||||
|
|
||||||
@ -19,7 +19,13 @@ const meta: Meta<typeof CompanyBoardCard> = {
|
|||||||
decorators: [
|
decorators: [
|
||||||
(Story) => (
|
(Story) => (
|
||||||
<RecoilScope SpecificContext={CompanyBoardRecoilScopeContext}>
|
<RecoilScope SpecificContext={CompanyBoardRecoilScopeContext}>
|
||||||
<HooksCompanyBoard orderBy={defaultPipelineProgressOrderBy} />
|
<HooksCompanyBoard
|
||||||
|
orderBy={[
|
||||||
|
{
|
||||||
|
createdAt: SortOrder.Asc,
|
||||||
|
},
|
||||||
|
]}
|
||||||
|
/>
|
||||||
<RecoilScope SpecificContext={BoardColumnRecoilScopeContext}>
|
<RecoilScope SpecificContext={BoardColumnRecoilScopeContext}>
|
||||||
<BoardCardIdContext.Provider value={mockedPipelineProgressData[1].id}>
|
<BoardCardIdContext.Provider value={mockedPipelineProgressData[1].id}>
|
||||||
<MemoryRouter>
|
<MemoryRouter>
|
||||||
|
|||||||
@ -1,79 +0,0 @@
|
|||||||
import { useFilteredSearchEntityQuery } from '@/search/hooks/useFilteredSearchEntityQuery';
|
|
||||||
import { SingleEntitySelect } from '@/ui/input/relation-picker/components/SingleEntitySelect';
|
|
||||||
import { relationPickerSearchFilterScopedState } from '@/ui/input/relation-picker/states/relationPickerSearchFilterScopedState';
|
|
||||||
import { EntityForSelect } from '@/ui/input/relation-picker/types/EntityForSelect';
|
|
||||||
import { Entity } from '@/ui/input/relation-picker/types/EntityTypeForSelect';
|
|
||||||
import { useRecoilScopedState } from '@/ui/utilities/recoil-scope/hooks/useRecoilScopedState';
|
|
||||||
import {
|
|
||||||
Company,
|
|
||||||
User,
|
|
||||||
useSearchUserQuery,
|
|
||||||
useUpdateOneCompanyMutation,
|
|
||||||
} from '~/generated/graphql';
|
|
||||||
|
|
||||||
export type OwnProps = {
|
|
||||||
company: Pick<Company, 'id'> & {
|
|
||||||
accountOwner?: Pick<User, 'id' | 'displayName'> | null;
|
|
||||||
};
|
|
||||||
onSubmit?: () => void;
|
|
||||||
onCancel?: () => void;
|
|
||||||
};
|
|
||||||
|
|
||||||
type UserForSelect = EntityForSelect & {
|
|
||||||
entityType: Entity.User;
|
|
||||||
};
|
|
||||||
|
|
||||||
export function CompanyAccountOwnerPicker({
|
|
||||||
company,
|
|
||||||
onSubmit,
|
|
||||||
onCancel,
|
|
||||||
}: OwnProps) {
|
|
||||||
const [searchFilter] = useRecoilScopedState(
|
|
||||||
relationPickerSearchFilterScopedState,
|
|
||||||
);
|
|
||||||
const [updateCompany] = useUpdateOneCompanyMutation();
|
|
||||||
|
|
||||||
const companies = useFilteredSearchEntityQuery({
|
|
||||||
queryHook: useSearchUserQuery,
|
|
||||||
selectedIds: [company?.accountOwner?.id ?? ''],
|
|
||||||
searchFilter: searchFilter,
|
|
||||||
mappingFunction: (user) => ({
|
|
||||||
entityType: Entity.User,
|
|
||||||
id: user.id,
|
|
||||||
name: user.displayName,
|
|
||||||
avatarType: 'rounded',
|
|
||||||
avatarUrl: user.avatarUrl ?? '',
|
|
||||||
}),
|
|
||||||
orderByField: 'firstName',
|
|
||||||
searchOnFields: ['firstName', 'lastName'],
|
|
||||||
});
|
|
||||||
|
|
||||||
async function handleEntitySelected(
|
|
||||||
selectedUser: UserForSelect | null | undefined,
|
|
||||||
) {
|
|
||||||
if (selectedUser) {
|
|
||||||
await updateCompany({
|
|
||||||
variables: {
|
|
||||||
where: { id: company.id },
|
|
||||||
data: {
|
|
||||||
accountOwner: { connect: { id: selectedUser.id } },
|
|
||||||
},
|
|
||||||
},
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
onSubmit?.();
|
|
||||||
}
|
|
||||||
|
|
||||||
return (
|
|
||||||
<SingleEntitySelect
|
|
||||||
onEntitySelected={handleEntitySelected}
|
|
||||||
onCancel={onCancel}
|
|
||||||
entities={{
|
|
||||||
loading: companies.loading,
|
|
||||||
entitiesToSelect: companies.entitiesToSelect,
|
|
||||||
selectedEntity: companies.selectedEntities[0],
|
|
||||||
}}
|
|
||||||
/>
|
|
||||||
);
|
|
||||||
}
|
|
||||||
@ -3,7 +3,7 @@ import { relationPickerSearchFilterScopedState } from '@/ui/input/relation-picke
|
|||||||
import { EntityForSelect } from '@/ui/input/relation-picker/types/EntityForSelect';
|
import { EntityForSelect } from '@/ui/input/relation-picker/types/EntityForSelect';
|
||||||
import { useRecoilScopedState } from '@/ui/utilities/recoil-scope/hooks/useRecoilScopedState';
|
import { useRecoilScopedState } from '@/ui/utilities/recoil-scope/hooks/useRecoilScopedState';
|
||||||
|
|
||||||
import { useFilteredSearchCompanyQuery } from '../queries';
|
import { useFilteredSearchCompanyQuery } from '../hooks/useFilteredSearchCompanyQuery';
|
||||||
|
|
||||||
export type OwnProps = {
|
export type OwnProps = {
|
||||||
companyId: string | null;
|
companyId: string | null;
|
||||||
|
|||||||
@ -1,4 +1,4 @@
|
|||||||
import { useFilteredSearchCompanyQuery } from '@/companies/queries';
|
import { useFilteredSearchCompanyQuery } from '@/companies/hooks/useFilteredSearchCompanyQuery';
|
||||||
import { SingleEntitySelect } from '@/ui/input/relation-picker/components/SingleEntitySelect';
|
import { SingleEntitySelect } from '@/ui/input/relation-picker/components/SingleEntitySelect';
|
||||||
import { relationPickerSearchFilterScopedState } from '@/ui/input/relation-picker/states/relationPickerSearchFilterScopedState';
|
import { relationPickerSearchFilterScopedState } from '@/ui/input/relation-picker/states/relationPickerSearchFilterScopedState';
|
||||||
import { EntityForSelect } from '@/ui/input/relation-picker/types/EntityForSelect';
|
import { EntityForSelect } from '@/ui/input/relation-picker/types/EntityForSelect';
|
||||||
|
|||||||
@ -6,7 +6,7 @@ import { filterDropdownSelectedEntityIdScopedState } from '@/ui/filter-n-sort/st
|
|||||||
import { useRecoilScopedState } from '@/ui/utilities/recoil-scope/hooks/useRecoilScopedState';
|
import { useRecoilScopedState } from '@/ui/utilities/recoil-scope/hooks/useRecoilScopedState';
|
||||||
import { useRecoilScopedValue } from '@/ui/utilities/recoil-scope/hooks/useRecoilScopedValue';
|
import { useRecoilScopedValue } from '@/ui/utilities/recoil-scope/hooks/useRecoilScopedValue';
|
||||||
|
|
||||||
import { useFilteredSearchCompanyQuery } from '../queries';
|
import { useFilteredSearchCompanyQuery } from '../hooks/useFilteredSearchCompanyQuery';
|
||||||
|
|
||||||
export function FilterDropdownCompanySearchSelect({
|
export function FilterDropdownCompanySearchSelect({
|
||||||
context,
|
context,
|
||||||
|
|||||||
@ -3,7 +3,8 @@ import { getOperationName } from '@apollo/client/utilities';
|
|||||||
import { useRecoilCallback, useRecoilState } from 'recoil';
|
import { useRecoilCallback, useRecoilState } from 'recoil';
|
||||||
import { v4 as uuidv4 } from 'uuid';
|
import { v4 as uuidv4 } from 'uuid';
|
||||||
|
|
||||||
import { GET_PIPELINE_PROGRESS, GET_PIPELINES } from '@/pipeline/queries';
|
import { GET_PIPELINE_PROGRESS } from '@/pipeline/graphql/queries/getPipelineProgress';
|
||||||
|
import { GET_PIPELINES } from '@/pipeline/graphql/queries/getPipelines';
|
||||||
import { currentPipelineState } from '@/pipeline/states/currentPipelineState';
|
import { currentPipelineState } from '@/pipeline/states/currentPipelineState';
|
||||||
import { NewButton } from '@/ui/board/components/NewButton';
|
import { NewButton } from '@/ui/board/components/NewButton';
|
||||||
import { BoardColumnIdContext } from '@/ui/board/contexts/BoardColumnIdContext';
|
import { BoardColumnIdContext } from '@/ui/board/contexts/BoardColumnIdContext';
|
||||||
@ -15,7 +16,7 @@ import { usePreviousHotkeyScope } from '@/ui/utilities/hotkey/hooks/usePreviousH
|
|||||||
import { useRecoilScopedState } from '@/ui/utilities/recoil-scope/hooks/useRecoilScopedState';
|
import { useRecoilScopedState } from '@/ui/utilities/recoil-scope/hooks/useRecoilScopedState';
|
||||||
import { useCreateOneCompanyPipelineProgressMutation } from '~/generated/graphql';
|
import { useCreateOneCompanyPipelineProgressMutation } from '~/generated/graphql';
|
||||||
|
|
||||||
import { useFilteredSearchCompanyQuery } from '../queries';
|
import { useFilteredSearchCompanyQuery } from '../hooks/useFilteredSearchCompanyQuery';
|
||||||
|
|
||||||
export function NewCompanyProgressButton() {
|
export function NewCompanyProgressButton() {
|
||||||
const [isCreatingCard, setIsCreatingCard] = useState(false);
|
const [isCreatingCard, setIsCreatingCard] = useState(false);
|
||||||
|
|||||||
@ -0,0 +1,19 @@
|
|||||||
|
import { gql } from '@apollo/client';
|
||||||
|
|
||||||
|
export const COMPANY_FIELDS_FRAGMENT = gql`
|
||||||
|
fragment CompanyFieldsFragment on Company {
|
||||||
|
accountOwner {
|
||||||
|
id
|
||||||
|
email
|
||||||
|
displayName
|
||||||
|
avatarUrl
|
||||||
|
}
|
||||||
|
address
|
||||||
|
createdAt
|
||||||
|
domainName
|
||||||
|
employees
|
||||||
|
linkedinUrl
|
||||||
|
id
|
||||||
|
name
|
||||||
|
}
|
||||||
|
`;
|
||||||
@ -0,0 +1,9 @@
|
|||||||
|
import { gql } from '@apollo/client';
|
||||||
|
|
||||||
|
export const DELETE_MANY_COMPANIES = gql`
|
||||||
|
mutation DeleteManyCompanies($ids: [String!]) {
|
||||||
|
deleteManyCompany(where: { id: { in: $ids } }) {
|
||||||
|
count
|
||||||
|
}
|
||||||
|
}
|
||||||
|
`;
|
||||||
@ -0,0 +1,9 @@
|
|||||||
|
import { gql } from '@apollo/client';
|
||||||
|
|
||||||
|
export const INSERT_ONE_COMPANY = gql`
|
||||||
|
mutation InsertOneCompany($data: CompanyCreateInput!) {
|
||||||
|
createOneCompany(data: $data) {
|
||||||
|
...CompanyFieldsFragment
|
||||||
|
}
|
||||||
|
}
|
||||||
|
`;
|
||||||
@ -0,0 +1,12 @@
|
|||||||
|
import { gql } from '@apollo/client';
|
||||||
|
|
||||||
|
export const UPDATE_ONE_COMPANY = gql`
|
||||||
|
mutation UpdateOneCompany(
|
||||||
|
$where: CompanyWhereUniqueInput!
|
||||||
|
$data: CompanyUpdateInput!
|
||||||
|
) {
|
||||||
|
updateOneCompany(data: $data, where: $where) {
|
||||||
|
...CompanyFieldsFragment
|
||||||
|
}
|
||||||
|
}
|
||||||
|
`;
|
||||||
27
front/src/modules/companies/graphql/queries/getCompanies.ts
Normal file
27
front/src/modules/companies/graphql/queries/getCompanies.ts
Normal file
@ -0,0 +1,27 @@
|
|||||||
|
import { gql } from '@apollo/client';
|
||||||
|
|
||||||
|
export const GET_COMPANIES = gql`
|
||||||
|
query GetCompanies(
|
||||||
|
$orderBy: [CompanyOrderByWithRelationInput!]
|
||||||
|
$where: CompanyWhereInput
|
||||||
|
) {
|
||||||
|
companies: findManyCompany(orderBy: $orderBy, where: $where) {
|
||||||
|
id
|
||||||
|
domainName
|
||||||
|
name
|
||||||
|
createdAt
|
||||||
|
address
|
||||||
|
linkedinUrl
|
||||||
|
employees
|
||||||
|
_activityCount
|
||||||
|
accountOwner {
|
||||||
|
id
|
||||||
|
email
|
||||||
|
displayName
|
||||||
|
firstName
|
||||||
|
lastName
|
||||||
|
avatarUrl
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
`;
|
||||||
@ -1,8 +1,4 @@
|
|||||||
import { gql } from '@apollo/client';
|
import { gql } from '@apollo/client';
|
||||||
import { useSetRecoilState } from 'recoil';
|
|
||||||
|
|
||||||
import { genericEntitiesFamilyState } from '@/ui/editable-field/states/genericEntitiesFamilyState';
|
|
||||||
import { useGetCompanyQuery } from '~/generated/graphql';
|
|
||||||
|
|
||||||
export const GET_COMPANY = gql`
|
export const GET_COMPANY = gql`
|
||||||
query GetCompany($where: CompanyWhereUniqueInput!) {
|
query GetCompany($where: CompanyWhereUniqueInput!) {
|
||||||
@ -33,15 +29,3 @@ export const GET_COMPANY = gql`
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
`;
|
`;
|
||||||
|
|
||||||
export function useCompanyQuery(id: string) {
|
|
||||||
const updateCompanyShowPage = useSetRecoilState(
|
|
||||||
genericEntitiesFamilyState(id),
|
|
||||||
);
|
|
||||||
return useGetCompanyQuery({
|
|
||||||
variables: { where: { id } },
|
|
||||||
onCompleted: (data) => {
|
|
||||||
updateCompanyShowPage(data?.findUniqueCompany);
|
|
||||||
},
|
|
||||||
});
|
|
||||||
}
|
|
||||||
16
front/src/modules/companies/hooks/useCompanyQuery.ts
Normal file
16
front/src/modules/companies/hooks/useCompanyQuery.ts
Normal file
@ -0,0 +1,16 @@
|
|||||||
|
import { useSetRecoilState } from 'recoil';
|
||||||
|
|
||||||
|
import { genericEntitiesFamilyState } from '@/ui/editable-field/states/genericEntitiesFamilyState';
|
||||||
|
import { useGetCompanyQuery } from '~/generated/graphql';
|
||||||
|
|
||||||
|
export function useCompanyQuery(id: string) {
|
||||||
|
const updateCompanyShowPage = useSetRecoilState(
|
||||||
|
genericEntitiesFamilyState(id),
|
||||||
|
);
|
||||||
|
return useGetCompanyQuery({
|
||||||
|
variables: { where: { id } },
|
||||||
|
onCompleted: (data) => {
|
||||||
|
updateCompanyShowPage(data?.findUniqueCompany);
|
||||||
|
},
|
||||||
|
});
|
||||||
|
}
|
||||||
@ -1,7 +1,7 @@
|
|||||||
import { getOperationName } from '@apollo/client/utilities';
|
import { getOperationName } from '@apollo/client/utilities';
|
||||||
import { useRecoilState, useRecoilValue } from 'recoil';
|
import { useRecoilState, useRecoilValue } from 'recoil';
|
||||||
|
|
||||||
import { GET_PIPELINES } from '@/pipeline/queries';
|
import { GET_PIPELINES } from '@/pipeline/graphql/queries/getPipelines';
|
||||||
import { useResetTableRowSelection } from '@/ui/table/hooks/useResetTableRowSelection';
|
import { useResetTableRowSelection } from '@/ui/table/hooks/useResetTableRowSelection';
|
||||||
import { selectedRowIdsSelector } from '@/ui/table/states/selectors/selectedRowIdsSelector';
|
import { selectedRowIdsSelector } from '@/ui/table/states/selectors/selectedRowIdsSelector';
|
||||||
import { tableRowIdsState } from '@/ui/table/states/tableRowIdsState';
|
import { tableRowIdsState } from '@/ui/table/states/tableRowIdsState';
|
||||||
|
|||||||
@ -0,0 +1,32 @@
|
|||||||
|
import { ActivityTargetableEntityType } from '@/activities/types/ActivityTargetableEntity';
|
||||||
|
import { ActivityTargetableEntityForSelect } from '@/activities/types/ActivityTargetableEntityForSelect';
|
||||||
|
import { useFilteredSearchEntityQuery } from '@/search/hooks/useFilteredSearchEntityQuery';
|
||||||
|
import { useSearchCompanyQuery } from '~/generated/graphql';
|
||||||
|
import { getLogoUrlFromDomainName } from '~/utils';
|
||||||
|
|
||||||
|
export function useFilteredSearchCompanyQuery({
|
||||||
|
searchFilter,
|
||||||
|
selectedIds = [],
|
||||||
|
limit,
|
||||||
|
}: {
|
||||||
|
searchFilter: string;
|
||||||
|
selectedIds?: string[];
|
||||||
|
limit?: number;
|
||||||
|
}) {
|
||||||
|
return useFilteredSearchEntityQuery({
|
||||||
|
queryHook: useSearchCompanyQuery,
|
||||||
|
searchOnFields: ['name'],
|
||||||
|
orderByField: 'name',
|
||||||
|
selectedIds: selectedIds,
|
||||||
|
mappingFunction: (company) =>
|
||||||
|
({
|
||||||
|
id: company.id,
|
||||||
|
entityType: ActivityTargetableEntityType.Company,
|
||||||
|
name: company.name,
|
||||||
|
avatarUrl: getLogoUrlFromDomainName(company.domainName),
|
||||||
|
avatarType: 'squared',
|
||||||
|
} as ActivityTargetableEntityForSelect),
|
||||||
|
searchFilter,
|
||||||
|
limit,
|
||||||
|
});
|
||||||
|
}
|
||||||
@ -1,18 +0,0 @@
|
|||||||
import { reduceSortsToOrderBy } from '@/ui/filter-n-sort/helpers';
|
|
||||||
|
|
||||||
import { CompaniesSelectedSortType } from '../select';
|
|
||||||
|
|
||||||
describe('reduceSortsToOrderBy', () => {
|
|
||||||
it('should return an array of objects with the id as key and the order as value', () => {
|
|
||||||
const sorts = [
|
|
||||||
{ key: 'name', label: 'name', order: 'asc' },
|
|
||||||
{
|
|
||||||
key: 'domainName',
|
|
||||||
label: 'domainName',
|
|
||||||
order: 'desc',
|
|
||||||
},
|
|
||||||
] satisfies CompaniesSelectedSortType[];
|
|
||||||
const result = reduceSortsToOrderBy(sorts);
|
|
||||||
expect(result).toEqual([{ name: 'asc' }, { domainName: 'desc' }]);
|
|
||||||
});
|
|
||||||
});
|
|
||||||
@ -1,3 +0,0 @@
|
|||||||
export * from './select';
|
|
||||||
export * from './show';
|
|
||||||
export * from './update';
|
|
||||||
@ -1,82 +0,0 @@
|
|||||||
import { gql } from '@apollo/client';
|
|
||||||
|
|
||||||
import { ActivityTargetableEntityType } from '@/activities/types/ActivityTargetableEntity';
|
|
||||||
import { ActivityTargetableEntityForSelect } from '@/activities/types/ActivityTargetableEntityForSelect';
|
|
||||||
import { useFilteredSearchEntityQuery } from '@/search/hooks/useFilteredSearchEntityQuery';
|
|
||||||
import { SelectedSortType } from '@/ui/filter-n-sort/types/interface';
|
|
||||||
import {
|
|
||||||
CompanyOrderByWithRelationInput as Companies_Order_By,
|
|
||||||
CompanyWhereInput as Companies_Bool_Exp,
|
|
||||||
SortOrder as Order_By,
|
|
||||||
useGetCompaniesQuery,
|
|
||||||
useSearchCompanyQuery,
|
|
||||||
} from '~/generated/graphql';
|
|
||||||
import { getLogoUrlFromDomainName } from '~/utils';
|
|
||||||
|
|
||||||
export type CompaniesSelectedSortType = SelectedSortType<Companies_Order_By>;
|
|
||||||
|
|
||||||
export const GET_COMPANIES = gql`
|
|
||||||
query GetCompanies(
|
|
||||||
$orderBy: [CompanyOrderByWithRelationInput!]
|
|
||||||
$where: CompanyWhereInput
|
|
||||||
) {
|
|
||||||
companies: findManyCompany(orderBy: $orderBy, where: $where) {
|
|
||||||
id
|
|
||||||
domainName
|
|
||||||
name
|
|
||||||
createdAt
|
|
||||||
address
|
|
||||||
linkedinUrl
|
|
||||||
employees
|
|
||||||
_activityCount
|
|
||||||
accountOwner {
|
|
||||||
id
|
|
||||||
email
|
|
||||||
displayName
|
|
||||||
firstName
|
|
||||||
lastName
|
|
||||||
avatarUrl
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
`;
|
|
||||||
|
|
||||||
export function useCompaniesQuery(
|
|
||||||
orderBy: Companies_Order_By[],
|
|
||||||
where: Companies_Bool_Exp,
|
|
||||||
) {
|
|
||||||
return useGetCompaniesQuery({ variables: { orderBy, where } });
|
|
||||||
}
|
|
||||||
|
|
||||||
export function useFilteredSearchCompanyQuery({
|
|
||||||
searchFilter,
|
|
||||||
selectedIds = [],
|
|
||||||
limit,
|
|
||||||
}: {
|
|
||||||
searchFilter: string;
|
|
||||||
selectedIds?: string[];
|
|
||||||
limit?: number;
|
|
||||||
}) {
|
|
||||||
return useFilteredSearchEntityQuery({
|
|
||||||
queryHook: useSearchCompanyQuery,
|
|
||||||
searchOnFields: ['name'],
|
|
||||||
orderByField: 'name',
|
|
||||||
selectedIds: selectedIds,
|
|
||||||
mappingFunction: (company) =>
|
|
||||||
({
|
|
||||||
id: company.id,
|
|
||||||
entityType: ActivityTargetableEntityType.Company,
|
|
||||||
name: company.name,
|
|
||||||
avatarUrl: getLogoUrlFromDomainName(company.domainName),
|
|
||||||
avatarType: 'squared',
|
|
||||||
} as ActivityTargetableEntityForSelect),
|
|
||||||
searchFilter,
|
|
||||||
limit,
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
export const defaultOrderBy: Companies_Order_By[] = [
|
|
||||||
{
|
|
||||||
createdAt: Order_By.Desc,
|
|
||||||
},
|
|
||||||
];
|
|
||||||
@ -1,46 +0,0 @@
|
|||||||
import { gql } from '@apollo/client';
|
|
||||||
|
|
||||||
export const COMPANY_FIELDS_FRAGMENT = gql`
|
|
||||||
fragment CompanyFieldsFragment on Company {
|
|
||||||
accountOwner {
|
|
||||||
id
|
|
||||||
email
|
|
||||||
displayName
|
|
||||||
avatarUrl
|
|
||||||
}
|
|
||||||
address
|
|
||||||
createdAt
|
|
||||||
domainName
|
|
||||||
employees
|
|
||||||
linkedinUrl
|
|
||||||
id
|
|
||||||
name
|
|
||||||
}
|
|
||||||
`;
|
|
||||||
|
|
||||||
export const UPDATE_ONE_COMPANY = gql`
|
|
||||||
mutation UpdateOneCompany(
|
|
||||||
$where: CompanyWhereUniqueInput!
|
|
||||||
$data: CompanyUpdateInput!
|
|
||||||
) {
|
|
||||||
updateOneCompany(data: $data, where: $where) {
|
|
||||||
...CompanyFieldsFragment
|
|
||||||
}
|
|
||||||
}
|
|
||||||
`;
|
|
||||||
|
|
||||||
export const INSERT_ONE_COMPANY = gql`
|
|
||||||
mutation InsertOneCompany($data: CompanyCreateInput!) {
|
|
||||||
createOneCompany(data: $data) {
|
|
||||||
...CompanyFieldsFragment
|
|
||||||
}
|
|
||||||
}
|
|
||||||
`;
|
|
||||||
|
|
||||||
export const DELETE_MANY_COMPANIES = gql`
|
|
||||||
mutation DeleteManyCompanies($ids: [String!]) {
|
|
||||||
deleteManyCompany(where: { id: { in: $ids } }) {
|
|
||||||
count
|
|
||||||
}
|
|
||||||
}
|
|
||||||
`;
|
|
||||||
@ -17,6 +17,7 @@ import { useTableViewFields } from '@/views/hooks/useTableViewFields';
|
|||||||
import { useViewSorts } from '@/views/hooks/useViewSorts';
|
import { useViewSorts } from '@/views/hooks/useViewSorts';
|
||||||
import { currentViewIdState } from '@/views/states/currentViewIdState';
|
import { currentViewIdState } from '@/views/states/currentViewIdState';
|
||||||
import {
|
import {
|
||||||
|
SortOrder,
|
||||||
UpdateOneCompanyMutationVariables,
|
UpdateOneCompanyMutationVariables,
|
||||||
useGetCompaniesQuery,
|
useGetCompaniesQuery,
|
||||||
useUpdateOneCompanyMutation,
|
useUpdateOneCompanyMutation,
|
||||||
@ -24,8 +25,6 @@ import {
|
|||||||
import { companiesFilters } from '~/pages/companies/companies-filters';
|
import { companiesFilters } from '~/pages/companies/companies-filters';
|
||||||
import { availableSorts } from '~/pages/companies/companies-sorts';
|
import { availableSorts } from '~/pages/companies/companies-sorts';
|
||||||
|
|
||||||
import { defaultOrderBy } from '../../queries';
|
|
||||||
|
|
||||||
export function CompanyTable() {
|
export function CompanyTable() {
|
||||||
const currentViewId = useRecoilValue(currentViewIdState);
|
const currentViewId = useRecoilValue(currentViewIdState);
|
||||||
const orderBy = useRecoilScopedValue(
|
const orderBy = useRecoilScopedValue(
|
||||||
@ -61,7 +60,15 @@ export function CompanyTable() {
|
|||||||
<GenericEntityTableData
|
<GenericEntityTableData
|
||||||
getRequestResultKey="companies"
|
getRequestResultKey="companies"
|
||||||
useGetRequest={useGetCompaniesQuery}
|
useGetRequest={useGetCompaniesQuery}
|
||||||
orderBy={orderBy.length ? orderBy : defaultOrderBy}
|
orderBy={
|
||||||
|
orderBy.length
|
||||||
|
? orderBy
|
||||||
|
: [
|
||||||
|
{
|
||||||
|
createdAt: SortOrder.Desc,
|
||||||
|
},
|
||||||
|
]
|
||||||
|
}
|
||||||
whereFilters={whereFilters}
|
whereFilters={whereFilters}
|
||||||
filterDefinitionArray={companiesFilters}
|
filterDefinitionArray={companiesFilters}
|
||||||
setContextMenuEntries={setContextMenuEntries}
|
setContextMenuEntries={setContextMenuEntries}
|
||||||
|
|||||||
@ -0,0 +1,9 @@
|
|||||||
|
import { gql } from '@apollo/client';
|
||||||
|
|
||||||
|
export const DELETE_FAVORITE = gql`
|
||||||
|
mutation DeleteFavorite($where: FavoriteWhereInput!) {
|
||||||
|
deleteFavorite(where: $where) {
|
||||||
|
id
|
||||||
|
}
|
||||||
|
}
|
||||||
|
`;
|
||||||
@ -0,0 +1,14 @@
|
|||||||
|
import { gql } from '@apollo/client';
|
||||||
|
|
||||||
|
export const INSERT_COMPANY_FAVORITE = gql`
|
||||||
|
mutation InsertCompanyFavorite($data: FavoriteMutationForCompanyArgs!) {
|
||||||
|
createFavoriteForCompany(data: $data) {
|
||||||
|
id
|
||||||
|
company {
|
||||||
|
id
|
||||||
|
name
|
||||||
|
domainName
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
`;
|
||||||
@ -0,0 +1,15 @@
|
|||||||
|
import { gql } from '@apollo/client';
|
||||||
|
|
||||||
|
export const INSERT_PERSON_FAVORITE = gql`
|
||||||
|
mutation InsertPersonFavorite($data: FavoriteMutationForPersonArgs!) {
|
||||||
|
createFavoriteForPerson(data: $data) {
|
||||||
|
id
|
||||||
|
person {
|
||||||
|
id
|
||||||
|
firstName
|
||||||
|
lastName
|
||||||
|
displayName
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
`;
|
||||||
@ -1,14 +1,14 @@
|
|||||||
import { getOperationName } from '@apollo/client/utilities';
|
import { getOperationName } from '@apollo/client/utilities';
|
||||||
|
|
||||||
import { GET_COMPANY } from '@/companies/queries';
|
import { GET_COMPANY } from '@/companies/graphql/queries/getCompany';
|
||||||
import { GET_PERSON } from '@/people/queries/show';
|
import { GET_PERSON } from '@/people/graphql/queries/getPerson';
|
||||||
import {
|
import {
|
||||||
useDeleteFavoriteMutation,
|
useDeleteFavoriteMutation,
|
||||||
useInsertCompanyFavoriteMutation,
|
useInsertCompanyFavoriteMutation,
|
||||||
useInsertPersonFavoriteMutation,
|
useInsertPersonFavoriteMutation,
|
||||||
} from '~/generated/graphql';
|
} from '~/generated/graphql';
|
||||||
|
|
||||||
import { GET_FAVORITES } from '../queries/show';
|
import { GET_FAVORITES } from '../graphql/queries/getFavorites';
|
||||||
|
|
||||||
export function useFavorites() {
|
export function useFavorites() {
|
||||||
const [insertCompanyFavoriteMutation] = useInsertCompanyFavoriteMutation();
|
const [insertCompanyFavoriteMutation] = useInsertCompanyFavoriteMutation();
|
||||||
|
|||||||
@ -1,36 +0,0 @@
|
|||||||
import { gql } from '@apollo/client';
|
|
||||||
|
|
||||||
export const INSERT_PERSON_FAVORITE = gql`
|
|
||||||
mutation InsertPersonFavorite($data: FavoriteMutationForPersonArgs!) {
|
|
||||||
createFavoriteForPerson(data: $data) {
|
|
||||||
id
|
|
||||||
person {
|
|
||||||
id
|
|
||||||
firstName
|
|
||||||
lastName
|
|
||||||
displayName
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
`;
|
|
||||||
|
|
||||||
export const INSERT_COMPANY_FAVORITE = gql`
|
|
||||||
mutation InsertCompanyFavorite($data: FavoriteMutationForCompanyArgs!) {
|
|
||||||
createFavoriteForCompany(data: $data) {
|
|
||||||
id
|
|
||||||
company {
|
|
||||||
id
|
|
||||||
name
|
|
||||||
domainName
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
`;
|
|
||||||
|
|
||||||
export const DELETE_FAVORITE = gql`
|
|
||||||
mutation DeleteFavorite($where: FavoriteWhereInput!) {
|
|
||||||
deleteFavorite(where: $where) {
|
|
||||||
id
|
|
||||||
}
|
|
||||||
}
|
|
||||||
`;
|
|
||||||
@ -1,6 +1,6 @@
|
|||||||
import { Context } from 'react';
|
import { Context } from 'react';
|
||||||
|
|
||||||
import { useFilteredSearchPeopleQuery } from '@/people/queries';
|
import { useFilteredSearchPeopleQuery } from '@/people/hooks/useFilteredSearchPeopleQuery';
|
||||||
import { FilterDropdownEntitySearchSelect } from '@/ui/filter-n-sort/components/FilterDropdownEntitySearchSelect';
|
import { FilterDropdownEntitySearchSelect } from '@/ui/filter-n-sort/components/FilterDropdownEntitySearchSelect';
|
||||||
import { filterDropdownSearchInputScopedState } from '@/ui/filter-n-sort/states/filterDropdownSearchInputScopedState';
|
import { filterDropdownSearchInputScopedState } from '@/ui/filter-n-sort/states/filterDropdownSearchInputScopedState';
|
||||||
import { filterDropdownSelectedEntityIdScopedState } from '@/ui/filter-n-sort/states/filterDropdownSelectedEntityIdScopedState';
|
import { filterDropdownSelectedEntityIdScopedState } from '@/ui/filter-n-sort/states/filterDropdownSelectedEntityIdScopedState';
|
||||||
|
|||||||
@ -1,13 +1,17 @@
|
|||||||
import {
|
import {
|
||||||
PersonOrderByWithRelationInput,
|
PersonOrderByWithRelationInput,
|
||||||
|
SortOrder,
|
||||||
useGetPeopleQuery,
|
useGetPeopleQuery,
|
||||||
} from '~/generated/graphql';
|
} from '~/generated/graphql';
|
||||||
|
|
||||||
import { useSetPeopleEntityTable } from '../hooks/useSetPeopleEntityTable';
|
import { useSetPeopleEntityTable } from '../hooks/useSetPeopleEntityTable';
|
||||||
import { defaultOrderBy } from '../queries';
|
|
||||||
|
|
||||||
export function PeopleEntityTableData({
|
export function PeopleEntityTableData({
|
||||||
orderBy = defaultOrderBy,
|
orderBy = [
|
||||||
|
{
|
||||||
|
createdAt: SortOrder.Desc,
|
||||||
|
},
|
||||||
|
],
|
||||||
whereFilters,
|
whereFilters,
|
||||||
}: {
|
}: {
|
||||||
orderBy?: PersonOrderByWithRelationInput[];
|
orderBy?: PersonOrderByWithRelationInput[];
|
||||||
|
|||||||
@ -0,0 +1,11 @@
|
|||||||
|
import { gql } from '@apollo/client';
|
||||||
|
|
||||||
|
export const INSERT_PERSON_FRAGMENT = gql`
|
||||||
|
fragment InsertPersonFragment on Person {
|
||||||
|
id
|
||||||
|
firstName
|
||||||
|
lastName
|
||||||
|
displayName
|
||||||
|
createdAt
|
||||||
|
}
|
||||||
|
`;
|
||||||
@ -0,0 +1,9 @@
|
|||||||
|
import { gql } from '@apollo/client';
|
||||||
|
|
||||||
|
export const DELETE_MANY_PERSON = gql`
|
||||||
|
mutation DeleteManyPerson($ids: [String!]) {
|
||||||
|
deleteManyPerson(where: { id: { in: $ids } }) {
|
||||||
|
count
|
||||||
|
}
|
||||||
|
}
|
||||||
|
`;
|
||||||
@ -0,0 +1,9 @@
|
|||||||
|
import { gql } from '@apollo/client';
|
||||||
|
|
||||||
|
export const INSERT_ONE_PERSON = gql`
|
||||||
|
mutation InsertOnePerson($data: PersonCreateInput!) {
|
||||||
|
createOnePerson(data: $data) {
|
||||||
|
...InsertPersonFragment
|
||||||
|
}
|
||||||
|
}
|
||||||
|
`;
|
||||||
@ -0,0 +1,10 @@
|
|||||||
|
import { gql } from '@apollo/client';
|
||||||
|
|
||||||
|
export const REMOVE_PERSON_PICTURE = gql`
|
||||||
|
mutation RemovePersonPicture($where: PersonWhereUniqueInput!) {
|
||||||
|
updateOnePerson(data: { avatarUrl: null }, where: $where) {
|
||||||
|
id
|
||||||
|
avatarUrl
|
||||||
|
}
|
||||||
|
}
|
||||||
|
`;
|
||||||
@ -0,0 +1,27 @@
|
|||||||
|
import { gql } from '@apollo/client';
|
||||||
|
|
||||||
|
export const UPDATE_ONE_PERSON = gql`
|
||||||
|
mutation UpdateOnePerson(
|
||||||
|
$where: PersonWhereUniqueInput!
|
||||||
|
$data: PersonUpdateInput!
|
||||||
|
) {
|
||||||
|
updateOnePerson(data: $data, where: $where) {
|
||||||
|
id
|
||||||
|
city
|
||||||
|
company {
|
||||||
|
domainName
|
||||||
|
name
|
||||||
|
id
|
||||||
|
}
|
||||||
|
email
|
||||||
|
jobTitle
|
||||||
|
linkedinUrl
|
||||||
|
xUrl
|
||||||
|
firstName
|
||||||
|
lastName
|
||||||
|
displayName
|
||||||
|
phone
|
||||||
|
createdAt
|
||||||
|
}
|
||||||
|
}
|
||||||
|
`;
|
||||||
@ -0,0 +1,7 @@
|
|||||||
|
import { gql } from '@apollo/client';
|
||||||
|
|
||||||
|
export const UPDATE_PERSON_PICTURE = gql`
|
||||||
|
mutation UploadPersonPicture($id: String!, $file: Upload!) {
|
||||||
|
uploadPersonPicture(id: $id, file: $file)
|
||||||
|
}
|
||||||
|
`;
|
||||||
30
front/src/modules/people/graphql/queries/getPeople.ts
Normal file
30
front/src/modules/people/graphql/queries/getPeople.ts
Normal file
@ -0,0 +1,30 @@
|
|||||||
|
import { gql } from '@apollo/client';
|
||||||
|
|
||||||
|
export const GET_PEOPLE = gql`
|
||||||
|
query GetPeople(
|
||||||
|
$orderBy: [PersonOrderByWithRelationInput!]
|
||||||
|
$where: PersonWhereInput
|
||||||
|
$limit: Int
|
||||||
|
) {
|
||||||
|
people: findManyPerson(orderBy: $orderBy, where: $where, take: $limit) {
|
||||||
|
id
|
||||||
|
phone
|
||||||
|
email
|
||||||
|
city
|
||||||
|
firstName
|
||||||
|
lastName
|
||||||
|
displayName
|
||||||
|
jobTitle
|
||||||
|
linkedinUrl
|
||||||
|
xUrl
|
||||||
|
avatarUrl
|
||||||
|
createdAt
|
||||||
|
_activityCount
|
||||||
|
company {
|
||||||
|
id
|
||||||
|
name
|
||||||
|
domainName
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
`;
|
||||||
@ -1,8 +1,4 @@
|
|||||||
import { gql } from '@apollo/client';
|
import { gql } from '@apollo/client';
|
||||||
import { useSetRecoilState } from 'recoil';
|
|
||||||
|
|
||||||
import { genericEntitiesFamilyState } from '@/ui/editable-field/states/genericEntitiesFamilyState';
|
|
||||||
import { useGetPersonQuery } from '~/generated/graphql';
|
|
||||||
|
|
||||||
export const GET_PERSON = gql`
|
export const GET_PERSON = gql`
|
||||||
query GetPerson($id: String!) {
|
query GetPerson($id: String!) {
|
||||||
@ -37,15 +33,3 @@ export const GET_PERSON = gql`
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
`;
|
`;
|
||||||
|
|
||||||
export function usePersonQuery(id: string) {
|
|
||||||
const updatePersonShowPage = useSetRecoilState(
|
|
||||||
genericEntitiesFamilyState(id),
|
|
||||||
);
|
|
||||||
return useGetPersonQuery({
|
|
||||||
variables: { id },
|
|
||||||
onCompleted: (data) => {
|
|
||||||
updatePersonShowPage(data?.findUniquePerson);
|
|
||||||
},
|
|
||||||
});
|
|
||||||
}
|
|
||||||
10
front/src/modules/people/graphql/queries/getPersonCity.ts
Normal file
10
front/src/modules/people/graphql/queries/getPersonCity.ts
Normal file
@ -0,0 +1,10 @@
|
|||||||
|
import { gql } from '@apollo/client';
|
||||||
|
|
||||||
|
export const GET_PERSON_CITY = gql`
|
||||||
|
query GetPersonCityById($id: String!) {
|
||||||
|
person: findUniquePerson(id: $id) {
|
||||||
|
id
|
||||||
|
city
|
||||||
|
}
|
||||||
|
}
|
||||||
|
`;
|
||||||
@ -0,0 +1,10 @@
|
|||||||
|
import { gql } from '@apollo/client';
|
||||||
|
|
||||||
|
export const GET_PERSON_COMMENT_COUNT = gql`
|
||||||
|
query GetPersonCommentCountById($id: String!) {
|
||||||
|
person: findUniquePerson(id: $id) {
|
||||||
|
id
|
||||||
|
_activityCount
|
||||||
|
}
|
||||||
|
}
|
||||||
|
`;
|
||||||
14
front/src/modules/people/graphql/queries/getPersonCompany.ts
Normal file
14
front/src/modules/people/graphql/queries/getPersonCompany.ts
Normal file
@ -0,0 +1,14 @@
|
|||||||
|
import { gql } from '@apollo/client';
|
||||||
|
|
||||||
|
export const GET_PERSON_COMPANY = gql`
|
||||||
|
query GetPersonCompanyById($id: String!) {
|
||||||
|
person: findUniquePerson(id: $id) {
|
||||||
|
id
|
||||||
|
company {
|
||||||
|
id
|
||||||
|
name
|
||||||
|
domainName
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
`;
|
||||||
@ -0,0 +1,10 @@
|
|||||||
|
import { gql } from '@apollo/client';
|
||||||
|
|
||||||
|
export const GET_PERSON_CREATED_AT = gql`
|
||||||
|
query GetPersonCreatedAtById($id: String!) {
|
||||||
|
person: findUniquePerson(id: $id) {
|
||||||
|
id
|
||||||
|
createdAt
|
||||||
|
}
|
||||||
|
}
|
||||||
|
`;
|
||||||
10
front/src/modules/people/graphql/queries/getPersonEmail.ts
Normal file
10
front/src/modules/people/graphql/queries/getPersonEmail.ts
Normal file
@ -0,0 +1,10 @@
|
|||||||
|
import { gql } from '@apollo/client';
|
||||||
|
|
||||||
|
export const GET_PERSON_EMAIL = gql`
|
||||||
|
query GetPersonEmailById($id: String!) {
|
||||||
|
person: findUniquePerson(id: $id) {
|
||||||
|
id
|
||||||
|
email
|
||||||
|
}
|
||||||
|
}
|
||||||
|
`;
|
||||||
@ -0,0 +1,13 @@
|
|||||||
|
import { gql } from '@apollo/client';
|
||||||
|
|
||||||
|
export const GET_PERSON_NAMES_AND_COMMENT_COUNT = gql`
|
||||||
|
query GetPersonNamesAndCommentCountById($id: String!) {
|
||||||
|
person: findUniquePerson(id: $id) {
|
||||||
|
id
|
||||||
|
firstName
|
||||||
|
lastName
|
||||||
|
displayName
|
||||||
|
_activityCount
|
||||||
|
}
|
||||||
|
}
|
||||||
|
`;
|
||||||
10
front/src/modules/people/graphql/queries/getPersonPhone.ts
Normal file
10
front/src/modules/people/graphql/queries/getPersonPhone.ts
Normal file
@ -0,0 +1,10 @@
|
|||||||
|
import { gql } from '@apollo/client';
|
||||||
|
|
||||||
|
export const GET_PERSON_PHONE = gql`
|
||||||
|
query GetPersonPhoneById($id: String!) {
|
||||||
|
person: findUniquePerson(id: $id) {
|
||||||
|
id
|
||||||
|
phone
|
||||||
|
}
|
||||||
|
}
|
||||||
|
`;
|
||||||
@ -0,0 +1,31 @@
|
|||||||
|
import { ActivityTargetableEntityType } from '@/activities/types/ActivityTargetableEntity';
|
||||||
|
import { ActivityTargetableEntityForSelect } from '@/activities/types/ActivityTargetableEntityForSelect';
|
||||||
|
import { useFilteredSearchEntityQuery } from '@/search/hooks/useFilteredSearchEntityQuery';
|
||||||
|
import { useSearchPeopleQuery } from '~/generated/graphql';
|
||||||
|
|
||||||
|
export function useFilteredSearchPeopleQuery({
|
||||||
|
searchFilter,
|
||||||
|
selectedIds = [],
|
||||||
|
limit,
|
||||||
|
}: {
|
||||||
|
searchFilter: string;
|
||||||
|
selectedIds?: string[];
|
||||||
|
limit?: number;
|
||||||
|
}) {
|
||||||
|
return useFilteredSearchEntityQuery({
|
||||||
|
queryHook: useSearchPeopleQuery,
|
||||||
|
searchOnFields: ['firstName', 'lastName'],
|
||||||
|
orderByField: 'lastName',
|
||||||
|
selectedIds: selectedIds,
|
||||||
|
mappingFunction: (entity) =>
|
||||||
|
({
|
||||||
|
id: entity.id,
|
||||||
|
entityType: ActivityTargetableEntityType.Person,
|
||||||
|
name: `${entity.firstName} ${entity.lastName}`,
|
||||||
|
avatarUrl: entity.avatarUrl,
|
||||||
|
avatarType: 'rounded',
|
||||||
|
} as ActivityTargetableEntityForSelect),
|
||||||
|
searchFilter,
|
||||||
|
limit,
|
||||||
|
});
|
||||||
|
}
|
||||||
@ -11,7 +11,7 @@ import { selectedRowIdsSelector } from '@/ui/table/states/selectors/selectedRowI
|
|||||||
import { tableRowIdsState } from '@/ui/table/states/tableRowIdsState';
|
import { tableRowIdsState } from '@/ui/table/states/tableRowIdsState';
|
||||||
import { ActivityType, useDeleteManyPersonMutation } from '~/generated/graphql';
|
import { ActivityType, useDeleteManyPersonMutation } from '~/generated/graphql';
|
||||||
|
|
||||||
import { GET_PEOPLE } from '../queries';
|
import { GET_PEOPLE } from '../graphql/queries/getPeople';
|
||||||
|
|
||||||
export function usePersonTableContextMenuEntries() {
|
export function usePersonTableContextMenuEntries() {
|
||||||
const setContextMenuEntries = useSetRecoilState(contextMenuEntriesState);
|
const setContextMenuEntries = useSetRecoilState(contextMenuEntriesState);
|
||||||
|
|||||||
16
front/src/modules/people/hooks/usePersonQuery.ts
Normal file
16
front/src/modules/people/hooks/usePersonQuery.ts
Normal file
@ -0,0 +1,16 @@
|
|||||||
|
import { useSetRecoilState } from 'recoil';
|
||||||
|
|
||||||
|
import { genericEntitiesFamilyState } from '@/ui/editable-field/states/genericEntitiesFamilyState';
|
||||||
|
import { useGetPersonQuery } from '~/generated/graphql';
|
||||||
|
|
||||||
|
export function usePersonQuery(id: string) {
|
||||||
|
const updatePersonShowPage = useSetRecoilState(
|
||||||
|
genericEntitiesFamilyState(id),
|
||||||
|
);
|
||||||
|
return useGetPersonQuery({
|
||||||
|
variables: { id },
|
||||||
|
onCompleted: (data) => {
|
||||||
|
updatePersonShowPage(data?.findUniquePerson);
|
||||||
|
},
|
||||||
|
});
|
||||||
|
}
|
||||||
@ -11,7 +11,7 @@ import { selectedRowIdsSelector } from '@/ui/table/states/selectors/selectedRowI
|
|||||||
import { tableRowIdsState } from '@/ui/table/states/tableRowIdsState';
|
import { tableRowIdsState } from '@/ui/table/states/tableRowIdsState';
|
||||||
import { ActivityType, useDeleteManyPersonMutation } from '~/generated/graphql';
|
import { ActivityType, useDeleteManyPersonMutation } from '~/generated/graphql';
|
||||||
|
|
||||||
import { GET_PEOPLE } from '../queries';
|
import { GET_PEOPLE } from '../graphql/queries/getPeople';
|
||||||
|
|
||||||
export function usePersonTableActionBarEntries() {
|
export function usePersonTableActionBarEntries() {
|
||||||
const setActionBarEntries = useSetRecoilState(actionBarEntriesState);
|
const setActionBarEntries = useSetRecoilState(actionBarEntriesState);
|
||||||
|
|||||||
@ -1,22 +0,0 @@
|
|||||||
import { reduceSortsToOrderBy } from '@/ui/filter-n-sort/helpers';
|
|
||||||
|
|
||||||
import { PeopleSelectedSortType } from '../select';
|
|
||||||
|
|
||||||
describe('reduceSortsToOrderBy', () => {
|
|
||||||
it('should return an array of objects with the id as key and the order as value', () => {
|
|
||||||
const sorts = [
|
|
||||||
{
|
|
||||||
key: 'firstName',
|
|
||||||
label: 'firstName',
|
|
||||||
order: 'asc',
|
|
||||||
},
|
|
||||||
{
|
|
||||||
key: 'lastName',
|
|
||||||
label: 'lastName',
|
|
||||||
order: 'desc',
|
|
||||||
},
|
|
||||||
] satisfies PeopleSelectedSortType[];
|
|
||||||
const result = reduceSortsToOrderBy(sorts);
|
|
||||||
expect(result).toEqual([{ firstName: 'asc' }, { lastName: 'desc' }]);
|
|
||||||
});
|
|
||||||
});
|
|
||||||
@ -1,3 +0,0 @@
|
|||||||
export * from './select';
|
|
||||||
export * from './show';
|
|
||||||
export * from './update';
|
|
||||||
@ -1,156 +0,0 @@
|
|||||||
import { gql } from '@apollo/client';
|
|
||||||
|
|
||||||
import { ActivityTargetableEntityType } from '@/activities/types/ActivityTargetableEntity';
|
|
||||||
import { ActivityTargetableEntityForSelect } from '@/activities/types/ActivityTargetableEntityForSelect';
|
|
||||||
import { useFilteredSearchEntityQuery } from '@/search/hooks/useFilteredSearchEntityQuery';
|
|
||||||
import { SelectedSortType } from '@/ui/filter-n-sort/types/interface';
|
|
||||||
import {
|
|
||||||
PersonOrderByWithRelationInput as People_Order_By,
|
|
||||||
PersonWhereInput as People_Bool_Exp,
|
|
||||||
SortOrder,
|
|
||||||
useGetPeopleQuery,
|
|
||||||
useSearchPeopleQuery,
|
|
||||||
} from '~/generated/graphql';
|
|
||||||
|
|
||||||
export type PeopleSelectedSortType = SelectedSortType<People_Order_By>;
|
|
||||||
|
|
||||||
export const GET_PEOPLE = gql`
|
|
||||||
query GetPeople(
|
|
||||||
$orderBy: [PersonOrderByWithRelationInput!]
|
|
||||||
$where: PersonWhereInput
|
|
||||||
$limit: Int
|
|
||||||
) {
|
|
||||||
people: findManyPerson(orderBy: $orderBy, where: $where, take: $limit) {
|
|
||||||
id
|
|
||||||
phone
|
|
||||||
email
|
|
||||||
city
|
|
||||||
firstName
|
|
||||||
lastName
|
|
||||||
displayName
|
|
||||||
jobTitle
|
|
||||||
linkedinUrl
|
|
||||||
xUrl
|
|
||||||
avatarUrl
|
|
||||||
createdAt
|
|
||||||
_activityCount
|
|
||||||
company {
|
|
||||||
id
|
|
||||||
name
|
|
||||||
domainName
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
`;
|
|
||||||
|
|
||||||
export function usePeopleQuery(
|
|
||||||
orderBy: People_Order_By[],
|
|
||||||
where: People_Bool_Exp,
|
|
||||||
) {
|
|
||||||
return useGetPeopleQuery({
|
|
||||||
variables: { orderBy, where },
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
export function useFilteredSearchPeopleQuery({
|
|
||||||
searchFilter,
|
|
||||||
selectedIds = [],
|
|
||||||
limit,
|
|
||||||
}: {
|
|
||||||
searchFilter: string;
|
|
||||||
selectedIds?: string[];
|
|
||||||
limit?: number;
|
|
||||||
}) {
|
|
||||||
return useFilteredSearchEntityQuery({
|
|
||||||
queryHook: useSearchPeopleQuery,
|
|
||||||
searchOnFields: ['firstName', 'lastName'],
|
|
||||||
orderByField: 'lastName',
|
|
||||||
selectedIds: selectedIds,
|
|
||||||
mappingFunction: (entity) =>
|
|
||||||
({
|
|
||||||
id: entity.id,
|
|
||||||
entityType: ActivityTargetableEntityType.Person,
|
|
||||||
name: `${entity.firstName} ${entity.lastName}`,
|
|
||||||
avatarUrl: entity.avatarUrl,
|
|
||||||
avatarType: 'rounded',
|
|
||||||
} as ActivityTargetableEntityForSelect),
|
|
||||||
searchFilter,
|
|
||||||
limit,
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
export const defaultOrderBy: People_Order_By[] = [
|
|
||||||
{
|
|
||||||
createdAt: SortOrder.Desc,
|
|
||||||
},
|
|
||||||
];
|
|
||||||
|
|
||||||
export const GET_PERSON_PHONE = gql`
|
|
||||||
query GetPersonPhoneById($id: String!) {
|
|
||||||
person: findUniquePerson(id: $id) {
|
|
||||||
id
|
|
||||||
phone
|
|
||||||
}
|
|
||||||
}
|
|
||||||
`;
|
|
||||||
|
|
||||||
export const GET_PERSON_EMAIL = gql`
|
|
||||||
query GetPersonEmailById($id: String!) {
|
|
||||||
person: findUniquePerson(id: $id) {
|
|
||||||
id
|
|
||||||
email
|
|
||||||
}
|
|
||||||
}
|
|
||||||
`;
|
|
||||||
|
|
||||||
export const GET_PERSON_NAMES_AND_COMMENT_COUNT = gql`
|
|
||||||
query GetPersonNamesAndCommentCountById($id: String!) {
|
|
||||||
person: findUniquePerson(id: $id) {
|
|
||||||
id
|
|
||||||
firstName
|
|
||||||
lastName
|
|
||||||
displayName
|
|
||||||
_activityCount
|
|
||||||
}
|
|
||||||
}
|
|
||||||
`;
|
|
||||||
|
|
||||||
export const GET_PERSON_COMPANY = gql`
|
|
||||||
query GetPersonCompanyById($id: String!) {
|
|
||||||
person: findUniquePerson(id: $id) {
|
|
||||||
id
|
|
||||||
company {
|
|
||||||
id
|
|
||||||
name
|
|
||||||
domainName
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
`;
|
|
||||||
|
|
||||||
export const GET_PERSON_COMMENT_COUNT = gql`
|
|
||||||
query GetPersonCommentCountById($id: String!) {
|
|
||||||
person: findUniquePerson(id: $id) {
|
|
||||||
id
|
|
||||||
_activityCount
|
|
||||||
}
|
|
||||||
}
|
|
||||||
`;
|
|
||||||
|
|
||||||
export const GET_PERSON_CREATED_AT = gql`
|
|
||||||
query GetPersonCreatedAtById($id: String!) {
|
|
||||||
person: findUniquePerson(id: $id) {
|
|
||||||
id
|
|
||||||
createdAt
|
|
||||||
}
|
|
||||||
}
|
|
||||||
`;
|
|
||||||
|
|
||||||
export const GET_PERSON_CITY = gql`
|
|
||||||
query GetPersonCityById($id: String!) {
|
|
||||||
person: findUniquePerson(id: $id) {
|
|
||||||
id
|
|
||||||
city
|
|
||||||
}
|
|
||||||
}
|
|
||||||
`;
|
|
||||||
@ -1,68 +0,0 @@
|
|||||||
import { gql } from '@apollo/client';
|
|
||||||
|
|
||||||
export const UPDATE_ONE_PERSON = gql`
|
|
||||||
mutation UpdateOnePerson(
|
|
||||||
$where: PersonWhereUniqueInput!
|
|
||||||
$data: PersonUpdateInput!
|
|
||||||
) {
|
|
||||||
updateOnePerson(data: $data, where: $where) {
|
|
||||||
id
|
|
||||||
city
|
|
||||||
company {
|
|
||||||
domainName
|
|
||||||
name
|
|
||||||
id
|
|
||||||
}
|
|
||||||
email
|
|
||||||
jobTitle
|
|
||||||
linkedinUrl
|
|
||||||
xUrl
|
|
||||||
firstName
|
|
||||||
lastName
|
|
||||||
displayName
|
|
||||||
phone
|
|
||||||
createdAt
|
|
||||||
}
|
|
||||||
}
|
|
||||||
`;
|
|
||||||
|
|
||||||
export const INSERT_PERSON_FRAGMENT = gql`
|
|
||||||
fragment InsertPersonFragment on Person {
|
|
||||||
id
|
|
||||||
firstName
|
|
||||||
lastName
|
|
||||||
displayName
|
|
||||||
createdAt
|
|
||||||
}
|
|
||||||
`;
|
|
||||||
|
|
||||||
export const INSERT_ONE_PERSON = gql`
|
|
||||||
mutation InsertOnePerson($data: PersonCreateInput!) {
|
|
||||||
createOnePerson(data: $data) {
|
|
||||||
...InsertPersonFragment
|
|
||||||
}
|
|
||||||
}
|
|
||||||
`;
|
|
||||||
|
|
||||||
export const DELETE_MANY_PERSON = gql`
|
|
||||||
mutation DeleteManyPerson($ids: [String!]) {
|
|
||||||
deleteManyPerson(where: { id: { in: $ids } }) {
|
|
||||||
count
|
|
||||||
}
|
|
||||||
}
|
|
||||||
`;
|
|
||||||
|
|
||||||
export const UPDATE_PERSON_PICTURE = gql`
|
|
||||||
mutation UploadPersonPicture($id: String!, $file: Upload!) {
|
|
||||||
uploadPersonPicture(id: $id, file: $file)
|
|
||||||
}
|
|
||||||
`;
|
|
||||||
|
|
||||||
export const REMOVE_PERSON_PICTURE = gql`
|
|
||||||
mutation RemovePersonPicture($where: PersonWhereUniqueInput!) {
|
|
||||||
updateOnePerson(data: { avatarUrl: null }, where: $where) {
|
|
||||||
id
|
|
||||||
avatarUrl
|
|
||||||
}
|
|
||||||
}
|
|
||||||
`;
|
|
||||||
@ -17,6 +17,7 @@ import { useTableViewFields } from '@/views/hooks/useTableViewFields';
|
|||||||
import { useViewSorts } from '@/views/hooks/useViewSorts';
|
import { useViewSorts } from '@/views/hooks/useViewSorts';
|
||||||
import { currentViewIdState } from '@/views/states/currentViewIdState';
|
import { currentViewIdState } from '@/views/states/currentViewIdState';
|
||||||
import {
|
import {
|
||||||
|
SortOrder,
|
||||||
UpdateOnePersonMutationVariables,
|
UpdateOnePersonMutationVariables,
|
||||||
useGetPeopleQuery,
|
useGetPeopleQuery,
|
||||||
useUpdateOnePersonMutation,
|
useUpdateOnePersonMutation,
|
||||||
@ -24,8 +25,6 @@ import {
|
|||||||
import { peopleFilters } from '~/pages/people/people-filters';
|
import { peopleFilters } from '~/pages/people/people-filters';
|
||||||
import { availableSorts } from '~/pages/people/people-sorts';
|
import { availableSorts } from '~/pages/people/people-sorts';
|
||||||
|
|
||||||
import { defaultOrderBy } from '../../queries';
|
|
||||||
|
|
||||||
export function PeopleTable() {
|
export function PeopleTable() {
|
||||||
const currentViewId = useRecoilValue(currentViewIdState);
|
const currentViewId = useRecoilValue(currentViewIdState);
|
||||||
const orderBy = useRecoilScopedValue(
|
const orderBy = useRecoilScopedValue(
|
||||||
@ -61,7 +60,15 @@ export function PeopleTable() {
|
|||||||
<GenericEntityTableData
|
<GenericEntityTableData
|
||||||
getRequestResultKey="people"
|
getRequestResultKey="people"
|
||||||
useGetRequest={useGetPeopleQuery}
|
useGetRequest={useGetPeopleQuery}
|
||||||
orderBy={orderBy.length ? orderBy : defaultOrderBy}
|
orderBy={
|
||||||
|
orderBy.length
|
||||||
|
? orderBy
|
||||||
|
: [
|
||||||
|
{
|
||||||
|
createdAt: SortOrder.Desc,
|
||||||
|
},
|
||||||
|
]
|
||||||
|
}
|
||||||
whereFilters={whereFilters}
|
whereFilters={whereFilters}
|
||||||
filterDefinitionArray={peopleFilters}
|
filterDefinitionArray={peopleFilters}
|
||||||
setContextMenuEntries={setContextMenuEntries}
|
setContextMenuEntries={setContextMenuEntries}
|
||||||
|
|||||||
@ -0,0 +1,21 @@
|
|||||||
|
import { gql } from '@apollo/client';
|
||||||
|
|
||||||
|
export const CREATE_COMPANY_PIPELINE_PROGRESS = gql`
|
||||||
|
mutation CreateOneCompanyPipelineProgress(
|
||||||
|
$uuid: String!
|
||||||
|
$companyId: String!
|
||||||
|
$pipelineId: String!
|
||||||
|
$pipelineStageId: String!
|
||||||
|
) {
|
||||||
|
createOnePipelineProgress(
|
||||||
|
data: {
|
||||||
|
id: $uuid
|
||||||
|
company: { connect: { id: $companyId } }
|
||||||
|
pipeline: { connect: { id: $pipelineId } }
|
||||||
|
pipelineStage: { connect: { id: $pipelineStageId } }
|
||||||
|
}
|
||||||
|
) {
|
||||||
|
id
|
||||||
|
}
|
||||||
|
}
|
||||||
|
`;
|
||||||
@ -0,0 +1,9 @@
|
|||||||
|
import { gql } from '@apollo/client';
|
||||||
|
|
||||||
|
export const DELETE_PIPELINE_PROGRESS = gql`
|
||||||
|
mutation DeleteManyPipelineProgress($ids: [String!]) {
|
||||||
|
deleteManyPipelineProgress(where: { id: { in: $ids } }) {
|
||||||
|
count
|
||||||
|
}
|
||||||
|
}
|
||||||
|
`;
|
||||||
@ -0,0 +1,18 @@
|
|||||||
|
import { gql } from '@apollo/client';
|
||||||
|
|
||||||
|
export const UPDATE_PIPELINE_PROGRESS = gql`
|
||||||
|
mutation UpdateOnePipelineProgress(
|
||||||
|
$data: PipelineProgressUpdateInput!
|
||||||
|
$where: PipelineProgressWhereUniqueInput!
|
||||||
|
) {
|
||||||
|
updateOnePipelineProgress(where: $where, data: $data) {
|
||||||
|
id
|
||||||
|
amount
|
||||||
|
closeDate
|
||||||
|
probability
|
||||||
|
pointOfContact {
|
||||||
|
id
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
`;
|
||||||
@ -0,0 +1,15 @@
|
|||||||
|
import { gql } from '@apollo/client';
|
||||||
|
|
||||||
|
export const UPDATE_PIPELINE_PROGRESS_STAGE = gql`
|
||||||
|
mutation UpdateOnePipelineProgressStage(
|
||||||
|
$id: String
|
||||||
|
$pipelineStageId: String
|
||||||
|
) {
|
||||||
|
updateOnePipelineProgress(
|
||||||
|
where: { id: $id }
|
||||||
|
data: { pipelineStage: { connect: { id: $pipelineStageId } } }
|
||||||
|
) {
|
||||||
|
id
|
||||||
|
}
|
||||||
|
}
|
||||||
|
`;
|
||||||
@ -0,0 +1,11 @@
|
|||||||
|
import { gql } from '@apollo/client';
|
||||||
|
|
||||||
|
export const UPDATE_PIPELINE_STAGE = gql`
|
||||||
|
mutation UpdatePipelineStage($id: String, $data: PipelineStageUpdateInput!) {
|
||||||
|
updateOnePipelineStage(where: { id: $id }, data: $data) {
|
||||||
|
id
|
||||||
|
name
|
||||||
|
color
|
||||||
|
}
|
||||||
|
}
|
||||||
|
`;
|
||||||
@ -0,0 +1,26 @@
|
|||||||
|
import { gql } from '@apollo/client';
|
||||||
|
|
||||||
|
export const GET_PIPELINE_PROGRESS = gql`
|
||||||
|
query GetPipelineProgress(
|
||||||
|
$where: PipelineProgressWhereInput
|
||||||
|
$orderBy: [PipelineProgressOrderByWithRelationInput!]
|
||||||
|
) {
|
||||||
|
findManyPipelineProgress(where: $where, orderBy: $orderBy) {
|
||||||
|
id
|
||||||
|
pipelineStageId
|
||||||
|
companyId
|
||||||
|
personId
|
||||||
|
amount
|
||||||
|
closeDate
|
||||||
|
pointOfContactId
|
||||||
|
pointOfContact {
|
||||||
|
id
|
||||||
|
firstName
|
||||||
|
lastName
|
||||||
|
displayName
|
||||||
|
avatarUrl
|
||||||
|
}
|
||||||
|
probability
|
||||||
|
}
|
||||||
|
}
|
||||||
|
`;
|
||||||
17
front/src/modules/pipeline/graphql/queries/getPipelines.ts
Normal file
17
front/src/modules/pipeline/graphql/queries/getPipelines.ts
Normal file
@ -0,0 +1,17 @@
|
|||||||
|
import { gql } from '@apollo/client';
|
||||||
|
|
||||||
|
export const GET_PIPELINES = gql`
|
||||||
|
query GetPipelines($where: PipelineWhereInput) {
|
||||||
|
findManyPipeline(where: $where) {
|
||||||
|
id
|
||||||
|
name
|
||||||
|
pipelineProgressableType
|
||||||
|
pipelineStages {
|
||||||
|
id
|
||||||
|
name
|
||||||
|
color
|
||||||
|
index
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
`;
|
||||||
@ -1,2 +0,0 @@
|
|||||||
export * from './select';
|
|
||||||
export * from './update';
|
|
||||||
@ -1,57 +0,0 @@
|
|||||||
import { gql } from '@apollo/client';
|
|
||||||
|
|
||||||
import { SelectedSortType } from '@/ui/filter-n-sort/types/interface';
|
|
||||||
import {
|
|
||||||
PipelineProgressOrderByWithRelationInput as PipelineProgresses_Order_By,
|
|
||||||
SortOrder as Order_By,
|
|
||||||
} from '~/generated/graphql';
|
|
||||||
|
|
||||||
export type PipelineProgressesSelectedSortType =
|
|
||||||
SelectedSortType<PipelineProgresses_Order_By>;
|
|
||||||
|
|
||||||
export const GET_PIPELINES = gql`
|
|
||||||
query GetPipelines($where: PipelineWhereInput) {
|
|
||||||
findManyPipeline(where: $where) {
|
|
||||||
id
|
|
||||||
name
|
|
||||||
pipelineProgressableType
|
|
||||||
pipelineStages {
|
|
||||||
id
|
|
||||||
name
|
|
||||||
color
|
|
||||||
index
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
`;
|
|
||||||
|
|
||||||
export const GET_PIPELINE_PROGRESS = gql`
|
|
||||||
query GetPipelineProgress(
|
|
||||||
$where: PipelineProgressWhereInput
|
|
||||||
$orderBy: [PipelineProgressOrderByWithRelationInput!]
|
|
||||||
) {
|
|
||||||
findManyPipelineProgress(where: $where, orderBy: $orderBy) {
|
|
||||||
id
|
|
||||||
pipelineStageId
|
|
||||||
companyId
|
|
||||||
personId
|
|
||||||
amount
|
|
||||||
closeDate
|
|
||||||
pointOfContactId
|
|
||||||
pointOfContact {
|
|
||||||
id
|
|
||||||
firstName
|
|
||||||
lastName
|
|
||||||
displayName
|
|
||||||
avatarUrl
|
|
||||||
}
|
|
||||||
probability
|
|
||||||
}
|
|
||||||
}
|
|
||||||
`;
|
|
||||||
|
|
||||||
export const defaultPipelineProgressOrderBy: PipelineProgresses_Order_By[] = [
|
|
||||||
{
|
|
||||||
createdAt: Order_By.Asc,
|
|
||||||
},
|
|
||||||
];
|
|
||||||
@ -1,70 +0,0 @@
|
|||||||
import { gql } from '@apollo/client';
|
|
||||||
|
|
||||||
export const DELETE_PIPELINE_PROGRESS = gql`
|
|
||||||
mutation DeleteManyPipelineProgress($ids: [String!]) {
|
|
||||||
deleteManyPipelineProgress(where: { id: { in: $ids } }) {
|
|
||||||
count
|
|
||||||
}
|
|
||||||
}
|
|
||||||
`;
|
|
||||||
|
|
||||||
export const UPDATE_PIPELINE_STAGE = gql`
|
|
||||||
mutation UpdatePipelineStage($id: String, $data: PipelineStageUpdateInput!) {
|
|
||||||
updateOnePipelineStage(where: { id: $id }, data: $data) {
|
|
||||||
id
|
|
||||||
name
|
|
||||||
color
|
|
||||||
}
|
|
||||||
}
|
|
||||||
`;
|
|
||||||
|
|
||||||
export const UPDATE_PIPELINE_PROGRESS = gql`
|
|
||||||
mutation UpdateOnePipelineProgress(
|
|
||||||
$data: PipelineProgressUpdateInput!
|
|
||||||
$where: PipelineProgressWhereUniqueInput!
|
|
||||||
) {
|
|
||||||
updateOnePipelineProgress(where: $where, data: $data) {
|
|
||||||
id
|
|
||||||
amount
|
|
||||||
closeDate
|
|
||||||
probability
|
|
||||||
pointOfContact {
|
|
||||||
id
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
`;
|
|
||||||
|
|
||||||
export const UPDATE_PIPELINE_PROGRESS_STAGE = gql`
|
|
||||||
mutation UpdateOnePipelineProgressStage(
|
|
||||||
$id: String
|
|
||||||
$pipelineStageId: String
|
|
||||||
) {
|
|
||||||
updateOnePipelineProgress(
|
|
||||||
where: { id: $id }
|
|
||||||
data: { pipelineStage: { connect: { id: $pipelineStageId } } }
|
|
||||||
) {
|
|
||||||
id
|
|
||||||
}
|
|
||||||
}
|
|
||||||
`;
|
|
||||||
|
|
||||||
export const CREATE_COMPANY_PIPELINE_PROGRESS = gql`
|
|
||||||
mutation CreateOneCompanyPipelineProgress(
|
|
||||||
$uuid: String!
|
|
||||||
$companyId: String!
|
|
||||||
$pipelineId: String!
|
|
||||||
$pipelineStageId: String!
|
|
||||||
) {
|
|
||||||
createOnePipelineProgress(
|
|
||||||
data: {
|
|
||||||
id: $uuid
|
|
||||||
company: { connect: { id: $companyId } }
|
|
||||||
pipeline: { connect: { id: $pipelineId } }
|
|
||||||
pipelineStage: { connect: { id: $pipelineStageId } }
|
|
||||||
}
|
|
||||||
) {
|
|
||||||
id
|
|
||||||
}
|
|
||||||
}
|
|
||||||
`;
|
|
||||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user