Simplify editable cell signature

Signed-off-by: Jonathan <contact@grafikart.fr>
This commit is contained in:
Jonathan
2025-11-14 19:22:46 +01:00
committed by Émile Ré
parent cb5daab175
commit 789775f2fe
21 changed files with 762 additions and 451 deletions

View File

@@ -52,7 +52,7 @@ export const createAssetMutation = graphql`
$connections: [ID!]!
) {
createAsset(input: $input) {
assetEdge @prependEdge(connections: $connections) {
assetEdge @appendEdge(connections: $connections) {
node {
id
snapshotId

View File

@@ -12,14 +12,23 @@ import type { PeopleGraphPaginatedQuery } from "./__generated__/PeopleGraphPagin
import type { PeopleGraphPaginatedFragment$key } from "./__generated__/PeopleGraphPaginatedFragment.graphql";
import { useConfirm, useToast } from "@probo/ui";
import type { PeopleGraphDeleteMutation } from "./__generated__/PeopleGraphDeleteMutation.graphql";
import { promisifyMutation, sprintf, formatError, type GraphQLError } from "@probo/helpers";
import {
promisifyMutation,
sprintf,
formatError,
type GraphQLError,
} from "@probo/helpers";
import { useTranslate } from "@probo/i18n";
const peopleQuery = graphql`
export const peopleQuery = graphql`
query PeopleGraphQuery($organizationId: ID!, $filter: PeopleFilter) {
organization: node(id: $organizationId) {
... on Organization {
peoples(first: 1000, orderBy: { direction: ASC, field: FULL_NAME }, filter: $filter) {
peoples(
first: 1000
orderBy: { direction: ASC, field: FULL_NAME }
filter: $filter
) {
edges {
node {
id
@@ -36,14 +45,17 @@ const peopleQuery = graphql`
/**
* Return a list of people (used for people selectors)
*/
export function usePeople(organizationId: string, { excludeContractEnded }: { excludeContractEnded?: boolean } = {}) {
export function usePeople(
organizationId: string,
{ excludeContractEnded }: { excludeContractEnded?: boolean } = {},
) {
const data = useLazyLoadQuery<PeopleGraphQuery>(
peopleQuery,
{
organizationId: organizationId,
filter: excludeContractEnded ? { excludeContractEnded: true } : null,
},
{ fetchPolicy: "network-only" }
{ fetchPolicy: "network-only" },
);
return useMemo(() => {
return data.organization?.peoples?.edges.map((edge) => edge.node) ?? [];
@@ -66,7 +78,10 @@ export const paginatedPeopleFragment = graphql`
@refetchable(queryName: "PeopleListQuery")
@argumentDefinitions(
first: { type: "Int", defaultValue: 50 }
order: { type: "PeopleOrder", defaultValue: { direction: ASC, field: FULL_NAME } }
order: {
type: "PeopleOrder"
defaultValue: { direction: ASC, field: FULL_NAME }
}
filter: { type: "PeopleFilter", defaultValue: null }
after: { type: "CursorKey", defaultValue: null }
before: { type: "CursorKey", defaultValue: null }
@@ -98,12 +113,12 @@ export const paginatedPeopleFragment = graphql`
`;
export function usePeopleQuery(
queryRef: PreloadedQuery<PeopleGraphPaginatedQuery>
queryRef: PreloadedQuery<PeopleGraphPaginatedQuery>,
) {
const data = usePreloadedQuery(paginatedPeopleQuery, queryRef);
const pagination = usePaginationFragment(
paginatedPeopleFragment,
data.organization as PeopleGraphPaginatedFragment$key
data.organization as PeopleGraphPaginatedFragment$key,
);
const people = pagination.data.peoples?.edges.map((edge) => edge.node);
return {
@@ -128,7 +143,7 @@ export const PeopleConnectionKey = "PeopleGraphPaginatedQuery_peoples";
export const useDeletePeople = (
people: { id?: string; fullName?: string },
connectionId: string
connectionId: string,
) => {
const [mutate] = useMutation<PeopleGraphDeleteMutation>(deletePeopleMutation);
const confirm = useConfirm();
@@ -151,18 +166,21 @@ export const useDeletePeople = (
}).catch((error) => {
toast({
title: __("Error"),
description: formatError(__("Failed to delete people"), error as GraphQLError),
description: formatError(
__("Failed to delete people"),
error as GraphQLError,
),
variant: "error",
});
}),
{
message: sprintf(
__(
'This will permanently delete "%s". This action cannot be undone.'
'This will permanently delete "%s". This action cannot be undone.',
),
people.fullName
people.fullName,
),
}
},
);
};
};

View File

@@ -37,7 +37,7 @@ export function useCreateVendorMutation() {
{
successMessage: __("Vendor created successfully."),
errorMessage: __("Failed to create vendor"),
}
},
);
}
@@ -54,7 +54,7 @@ const deleteVendorMutation = graphql`
export const useDeleteVendor = (
vendor: { id?: string; name?: string },
connectionId: string
connectionId: string,
) => {
const [mutate] = useMutation<VendorGraphDeleteMutation>(deleteVendorMutation);
const confirm = useConfirm();
@@ -77,11 +77,11 @@ export const useDeleteVendor = (
{
message: sprintf(
__(
'This will permanently delete vendor "%s". This action cannot be undone.'
'This will permanently delete vendor "%s". This action cannot be undone.',
),
vendor.name
vendor.name,
),
}
},
);
};
};
@@ -171,7 +171,7 @@ export const vendorNodeQuery = graphql`
}
`;
const vendorsSelectQuery = graphql`
export const vendorsSelectQuery = graphql`
query VendorGraphSelectQuery($organizationId: ID!) {
organization: node(id: $organizationId) {
... on Organization {
@@ -195,7 +195,7 @@ export function useVendors(organizationId: string) {
{
organizationId: organizationId,
},
{ fetchPolicy: "network-only" }
{ fetchPolicy: "network-only" },
);
return useMemo(() => {
return data.organization?.vendors?.edges.map((edge) => edge.node) ?? [];

View File

@@ -1,5 +1,5 @@
/**
* @generated SignedSource<<0f47a0632a7158414d8c87cf9de16a7a>>
* @generated SignedSource<<9ebcbef6d786f85d0b88c881d1478938>>
* @lightSyntaxTransform
* @nogrep
*/
@@ -262,7 +262,7 @@ return {
"alias": null,
"args": null,
"filters": null,
"handle": "prependEdge",
"handle": "appendEdge",
"key": "",
"kind": "LinkedHandle",
"name": "assetEdge",
@@ -290,6 +290,6 @@ return {
};
})();
(node as any).hash = "1d36f3080ab525417516779740f5977c";
(node as any).hash = "92fca40d88a9ea68f013e9953d46388e";
export default node;