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) ?? [];
|
||||
}, [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 { 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 {
|
||||
paginatedPeopleFragment,
|
||||
paginatedPeopleQuery,
|
||||
} from "#/hooks/graph/PeopleGraph";
|
||||
import type { SignatureDocumentsDialogPeopleQuery } from "#/__generated__/core/SignatureDocumentsDialogPeopleQuery.graphql";
|
||||
import type { SignatureDocumentsDialogPeopleRefetchQuery } from "#/__generated__/core/SignatureDocumentsDialogPeopleRefetchQuery.graphql";
|
||||
import { useFormWithSchema } from "#/hooks/useFormWithSchema";
|
||||
import { useMutationWithToasts } from "#/hooks/useMutationWithToasts";
|
||||
import { useOrganizationId } from "#/hooks/useOrganizationId";
|
||||
@@ -54,6 +49,54 @@ type Props = {
|
||||
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`
|
||||
mutation SignatureDocumentsDialogMutation(
|
||||
$input: BulkRequestSignaturesInput!
|
||||
@@ -148,10 +191,11 @@ function PeopleList({
|
||||
}) {
|
||||
const { __ } = useTranslate();
|
||||
const organizationId = useOrganizationId();
|
||||
const data = useLazyLoadQuery<PeopleGraphPaginatedQuery>(
|
||||
paginatedPeopleQuery,
|
||||
const data = useLazyLoadQuery<SignatureDocumentsDialogPeopleQuery>(
|
||||
signatureDocumentsDialogPeopleQuery,
|
||||
{
|
||||
organizationId,
|
||||
filter: { excludeContractEnded: true },
|
||||
},
|
||||
);
|
||||
const {
|
||||
@@ -159,9 +203,9 @@ function PeopleList({
|
||||
hasNext,
|
||||
loadNext,
|
||||
isLoadingNext,
|
||||
} = usePaginationFragment<PeopleListQuery, PeopleGraphPaginatedFragment$key>(
|
||||
paginatedPeopleFragment,
|
||||
data.organization as PeopleGraphPaginatedFragment$key,
|
||||
} = usePaginationFragment<SignatureDocumentsDialogPeopleRefetchQuery>(
|
||||
signatureDocumentsDialogPeopleFragment,
|
||||
data.organization,
|
||||
);
|
||||
const profiles = page.profiles.edges.map(edge => edge.node);
|
||||
return (
|
||||
|
||||
Reference in New Issue
Block a user