feat(projects): authorize home channel admins

Signed-off-by: John Tennant <jtennant@squareup.com>
This commit is contained in:
John Tennant
2026-08-31 15:49:10 -04:00
parent bc006f6708
commit eb18afaacd
28 changed files with 1628 additions and 116 deletions

View File

@@ -0,0 +1,28 @@
import { useMutation, useQueryClient } from "@tanstack/react-query";
import { projectsQueryKey } from "@/features/projects/hooks";
import type { Project } from "@/features/projects/projectModels";
import { removeProjectRelatedChannel } from "@/features/projects/projectRelatedChannelRevision";
import { markProjectDataAuthoritative } from "@/features/projects/projectSnapshot";
export function useRemoveProjectRelatedChannelMutation() {
const queryClient = useQueryClient();
return useMutation({
mutationFn: ({
channelId,
project,
}: {
channelId: string;
project: Project;
}) => removeProjectRelatedChannel(project, channelId),
onSuccess: (project) => {
markProjectDataAuthoritative(project, "local-write");
queryClient.setQueryData<Project[]>(projectsQueryKey, (current = []) =>
current.map((candidate) =>
candidate.id === project.id ? project : candidate,
),
);
void queryClient.invalidateQueries({ queryKey: projectsQueryKey });
},
});
}