Better handling of document versions

Signed-off-by: Sacha Al Himdani <sacha@getprobo.com>
This commit is contained in:
Sacha Al Himdani
2025-08-08 15:12:06 +02:00
parent 81e7cd3574
commit a43328560a
12 changed files with 621 additions and 83 deletions

View File

@@ -3,6 +3,7 @@ import { graphql } from "relay-runtime";
import { useMutationWithToasts } from "../useMutationWithToasts";
import type { DocumentGraphDeleteMutation } from "./__generated__/DocumentGraphDeleteMutation.graphql";
import type { DocumentGraphSendSigningNotificationsMutation } from "./__generated__/DocumentGraphSendSigningNotificationsMutation.graphql";
import type { DocumentGraphDeleteDraftMutation } from "./__generated__/DocumentGraphDeleteDraftMutation.graphql";
export const documentsQuery = graphql`
query DocumentGraphListQuery($organizationId: ID!) {
@@ -13,15 +14,14 @@ export const documentsQuery = graphql`
}
`;
export const DocumentsConnectionKey = "DocumentsPageFragment_documents";
export const DocumentsConnectionKey = "DocumentsListQuery_documents";
const deleteDocumentMutation = graphql`
mutation DocumentGraphDeleteMutation(
$input: DeleteDocumentInput!
$connections: [ID!]!
) {
deleteDocument(input: $input) {
deletedDocumentId @deleteEdge(connections: $connections)
deletedDocumentId @deleteRecord
}
}
`;
@@ -38,6 +38,29 @@ export function useDeleteDocumentMutation() {
);
}
const deleteDraftDocumentVersionMutation = graphql`
mutation DocumentGraphDeleteDraftMutation(
$input: DeleteDraftDocumentVersionInput!
$connections: [ID!]!
) {
deleteDraftDocumentVersion(input: $input) {
deletedDocumentVersionId @deleteEdge(connections: $connections)
}
}
`;
export function useDeleteDraftDocumentVersionMutation() {
const { __ } = useTranslate();
return useMutationWithToasts<DocumentGraphDeleteDraftMutation>(
deleteDraftDocumentVersionMutation,
{
successMessage: __("Draft deleted successfully."),
errorMessage: __("Failed to delete draft. Please try again."),
}
);
}
const sendSigningNotificationsMutation = graphql`
mutation DocumentGraphSendSigningNotificationsMutation(
$input: SendSigningNotificationsInput!