Files
probo/apps/console/src/hooks/graph/OrganizationGraph.ts
Sacha Al Himdani 9a33f7b771 Manage errors
Signed-off-by: Sacha Al Himdani <sacha@getprobo.com>
2025-10-31 15:14:56 +01:00

40 lines
1.1 KiB
TypeScript

import { graphql } from "relay-runtime";
import { useTranslate } from "@probo/i18n";
import { useMutationWithToasts } from "../useMutationWithToasts";
import type { OrganizationGraphDeleteMutation } from "./__generated__/OrganizationGraphDeleteMutation.graphql";
export const organizationViewQuery = graphql`
query OrganizationGraph_ViewQuery($organizationId: ID!) {
node(id: $organizationId) {
... on Organization {
id
name
...SettingsPageFragment
}
}
}
`;
const deleteOrganizationMutation = graphql`
mutation OrganizationGraphDeleteMutation(
$input: DeleteOrganizationInput!
$connections: [ID!]!
) {
deleteOrganization(input: $input) {
deletedOrganizationId @deleteEdge(connections: $connections)
}
}
`;
export function useDeleteOrganizationMutation() {
const { __ } = useTranslate();
return useMutationWithToasts<OrganizationGraphDeleteMutation>(
deleteOrganizationMutation,
{
successMessage: __("Organization deleted successfully."),
errorMessage: __("Failed to delete organization"),
}
);
}