40 lines
1.1 KiB
TypeScript
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"),
|
|
}
|
|
);
|
|
}
|