Filter people with ended contracts from signature request dialog
Move the paginated people query from PeopleGraph.ts into SignatureDocumentsDialog.tsx following colocated query conventions and pass excludeContractEnded: true to hide people whose contract has ended. Signed-off-by: Sacha Al Himdani <sacha@getprobo.com>
This commit is contained in:
@@ -63,56 +63,3 @@ export function usePeople(
|
|||||||
return data.organization?.profiles?.edges.map(edge => edge.node) ?? [];
|
return data.organization?.profiles?.edges.map(edge => edge.node) ?? [];
|
||||||
}, [data]);
|
}, [data]);
|
||||||
}
|
}
|
||||||
|
|
||||||
export const paginatedPeopleQuery = graphql`
|
|
||||||
query PeopleGraphPaginatedQuery($organizationId: ID!) {
|
|
||||||
organization: node(id: $organizationId) {
|
|
||||||
id
|
|
||||||
... on Organization {
|
|
||||||
...PeopleGraphPaginatedFragment
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
`;
|
|
||||||
|
|
||||||
export const paginatedPeopleFragment = graphql`
|
|
||||||
fragment PeopleGraphPaginatedFragment on Organization
|
|
||||||
@refetchable(queryName: "PeopleListQuery")
|
|
||||||
@argumentDefinitions(
|
|
||||||
first: { type: "Int", defaultValue: 50 }
|
|
||||||
order: {
|
|
||||||
type: "ProfileOrder"
|
|
||||||
defaultValue: { direction: ASC, field: FULL_NAME }
|
|
||||||
}
|
|
||||||
filter: { type: "ProfileFilter", defaultValue: null }
|
|
||||||
after: { type: "CursorKey", defaultValue: null }
|
|
||||||
before: { type: "CursorKey", defaultValue: null }
|
|
||||||
last: { type: "Int", defaultValue: null }
|
|
||||||
) {
|
|
||||||
canCreatePeople: permission(action: "iam:membership-profile:create")
|
|
||||||
profiles(
|
|
||||||
first: $first
|
|
||||||
after: $after
|
|
||||||
last: $last
|
|
||||||
before: $before
|
|
||||||
orderBy: $order
|
|
||||||
filter: $filter
|
|
||||||
) @connection(key: "PeopleGraphPaginatedQuery_profiles") {
|
|
||||||
__id
|
|
||||||
edges {
|
|
||||||
node {
|
|
||||||
id
|
|
||||||
fullName
|
|
||||||
emailAddress
|
|
||||||
kind
|
|
||||||
position
|
|
||||||
additionalEmailAddresses
|
|
||||||
contractStartDate
|
|
||||||
contractEndDate
|
|
||||||
canDelete: permission(action: "iam:membership-profile:delete")
|
|
||||||
canUpdate: permission(action: "iam:membership-profile:update")
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
`;
|
|
||||||
|
|||||||
@@ -36,14 +36,9 @@ import { useLazyLoadQuery, usePaginationFragment } from "react-relay";
|
|||||||
import { graphql } from "relay-runtime";
|
import { graphql } from "relay-runtime";
|
||||||
import { z } from "zod";
|
import { z } from "zod";
|
||||||
|
|
||||||
import type { PeopleGraphPaginatedFragment$key } from "#/__generated__/core/PeopleGraphPaginatedFragment.graphql";
|
|
||||||
import type { PeopleGraphPaginatedQuery } from "#/__generated__/core/PeopleGraphPaginatedQuery.graphql";
|
|
||||||
import type { PeopleListQuery } from "#/__generated__/core/PeopleListQuery.graphql";
|
|
||||||
import type { SignatureDocumentsDialogMutation } from "#/__generated__/core/SignatureDocumentsDialogMutation.graphql";
|
import type { SignatureDocumentsDialogMutation } from "#/__generated__/core/SignatureDocumentsDialogMutation.graphql";
|
||||||
import {
|
import type { SignatureDocumentsDialogPeopleQuery } from "#/__generated__/core/SignatureDocumentsDialogPeopleQuery.graphql";
|
||||||
paginatedPeopleFragment,
|
import type { SignatureDocumentsDialogPeopleRefetchQuery } from "#/__generated__/core/SignatureDocumentsDialogPeopleRefetchQuery.graphql";
|
||||||
paginatedPeopleQuery,
|
|
||||||
} from "#/hooks/graph/PeopleGraph";
|
|
||||||
import { useFormWithSchema } from "#/hooks/useFormWithSchema";
|
import { useFormWithSchema } from "#/hooks/useFormWithSchema";
|
||||||
import { useMutationWithToasts } from "#/hooks/useMutationWithToasts";
|
import { useMutationWithToasts } from "#/hooks/useMutationWithToasts";
|
||||||
import { useOrganizationId } from "#/hooks/useOrganizationId";
|
import { useOrganizationId } from "#/hooks/useOrganizationId";
|
||||||
@@ -54,6 +49,54 @@ type Props = {
|
|||||||
onSave: () => void;
|
onSave: () => void;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
const signatureDocumentsDialogPeopleQuery = graphql`
|
||||||
|
query SignatureDocumentsDialogPeopleQuery(
|
||||||
|
$organizationId: ID!
|
||||||
|
$filter: ProfileFilter
|
||||||
|
) {
|
||||||
|
organization: node(id: $organizationId) {
|
||||||
|
id
|
||||||
|
... on Organization {
|
||||||
|
...SignatureDocumentsDialogPeopleFragment
|
||||||
|
@arguments(filter: $filter)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
`;
|
||||||
|
|
||||||
|
const signatureDocumentsDialogPeopleFragment = graphql`
|
||||||
|
fragment SignatureDocumentsDialogPeopleFragment on Organization
|
||||||
|
@refetchable(queryName: "SignatureDocumentsDialogPeopleRefetchQuery")
|
||||||
|
@argumentDefinitions(
|
||||||
|
first: { type: "Int", defaultValue: 50 }
|
||||||
|
order: {
|
||||||
|
type: "ProfileOrder"
|
||||||
|
defaultValue: { direction: ASC, field: FULL_NAME }
|
||||||
|
}
|
||||||
|
filter: { type: "ProfileFilter", defaultValue: null }
|
||||||
|
after: { type: "CursorKey", defaultValue: null }
|
||||||
|
before: { type: "CursorKey", defaultValue: null }
|
||||||
|
last: { type: "Int", defaultValue: null }
|
||||||
|
) {
|
||||||
|
profiles(
|
||||||
|
first: $first
|
||||||
|
after: $after
|
||||||
|
last: $last
|
||||||
|
before: $before
|
||||||
|
orderBy: $order
|
||||||
|
filter: $filter
|
||||||
|
) @connection(key: "SignatureDocumentsDialog_profiles") {
|
||||||
|
edges {
|
||||||
|
node {
|
||||||
|
id
|
||||||
|
fullName
|
||||||
|
emailAddress
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
`;
|
||||||
|
|
||||||
const documentsSignatureMutation = graphql`
|
const documentsSignatureMutation = graphql`
|
||||||
mutation SignatureDocumentsDialogMutation(
|
mutation SignatureDocumentsDialogMutation(
|
||||||
$input: BulkRequestSignaturesInput!
|
$input: BulkRequestSignaturesInput!
|
||||||
@@ -148,10 +191,11 @@ function PeopleList({
|
|||||||
}) {
|
}) {
|
||||||
const { __ } = useTranslate();
|
const { __ } = useTranslate();
|
||||||
const organizationId = useOrganizationId();
|
const organizationId = useOrganizationId();
|
||||||
const data = useLazyLoadQuery<PeopleGraphPaginatedQuery>(
|
const data = useLazyLoadQuery<SignatureDocumentsDialogPeopleQuery>(
|
||||||
paginatedPeopleQuery,
|
signatureDocumentsDialogPeopleQuery,
|
||||||
{
|
{
|
||||||
organizationId,
|
organizationId,
|
||||||
|
filter: { excludeContractEnded: true },
|
||||||
},
|
},
|
||||||
);
|
);
|
||||||
const {
|
const {
|
||||||
@@ -159,9 +203,9 @@ function PeopleList({
|
|||||||
hasNext,
|
hasNext,
|
||||||
loadNext,
|
loadNext,
|
||||||
isLoadingNext,
|
isLoadingNext,
|
||||||
} = usePaginationFragment<PeopleListQuery, PeopleGraphPaginatedFragment$key>(
|
} = usePaginationFragment<SignatureDocumentsDialogPeopleRefetchQuery>(
|
||||||
paginatedPeopleFragment,
|
signatureDocumentsDialogPeopleFragment,
|
||||||
data.organization as PeopleGraphPaginatedFragment$key,
|
data.organization,
|
||||||
);
|
);
|
||||||
const profiles = page.profiles.edges.map(edge => edge.node);
|
const profiles = page.profiles.edges.map(edge => edge.node);
|
||||||
return (
|
return (
|
||||||
|
|||||||
Reference in New Issue
Block a user