fix: use application document invalidate instead

This commit is contained in:
Jack 2026-04-23 12:10:18 +01:00
parent a5ab5074e3
commit d9039c822c
No known key found for this signature in database
7 changed files with 21 additions and 14 deletions

View File

@ -71,9 +71,10 @@ interface Props {
}
export const SaveBitbucketProvider = ({ applicationId }: Props) => {
const utils = api.useUtils();
const { data: bitbucketProviders } =
api.bitbucket.bitbucketProviders.useQuery();
const { data, refetch } = api.application.one.useQuery({ applicationId });
const { data } = api.application.one.useQuery({ applicationId });
const { mutateAsync, isPending: isSavingBitbucketProvider } =
api.application.saveBitbucketProvider.useMutation();
@ -159,7 +160,7 @@ export const SaveBitbucketProvider = ({ applicationId }: Props) => {
})
.then(async () => {
toast.success("Service Provider Saved");
await refetch();
await utils.application.one.invalidate({ applicationId });
})
.catch(() => {
toast.error("Error saving the Bitbucket provider");

View File

@ -31,7 +31,8 @@ interface Props {
}
export const SaveDockerProvider = ({ applicationId }: Props) => {
const { data, refetch } = api.application.one.useQuery({ applicationId });
const utils = api.useUtils();
const { data } = api.application.one.useQuery({ applicationId });
const { mutateAsync } = api.application.saveDockerProvider.useMutation();
const form = useForm<DockerProvider>({
@ -65,7 +66,7 @@ export const SaveDockerProvider = ({ applicationId }: Props) => {
})
.then(async () => {
toast.success("Docker Provider Saved");
await refetch();
await utils.application.one.invalidate({ applicationId });
})
.catch(() => {
toast.error("Error saving the Docker provider");

View File

@ -23,7 +23,8 @@ interface Props {
}
export const SaveDragNDrop = ({ applicationId }: Props) => {
const { data, refetch } = api.application.one.useQuery({ applicationId });
const utils = api.useUtils();
const { data } = api.application.one.useQuery({ applicationId });
const { mutateAsync, isPending } =
api.application.dropDeployment.useMutation();
@ -54,7 +55,7 @@ export const SaveDragNDrop = ({ applicationId }: Props) => {
await mutateAsync(formData)
.then(async () => {
toast.success("Deployment saved");
await refetch();
await utils.application.one.invalidate({ applicationId });
})
.catch(() => {
toast.error("Error saving the deployment");

View File

@ -55,7 +55,8 @@ interface Props {
}
export const SaveGitProvider = ({ applicationId }: Props) => {
const { data, refetch } = api.application.one.useQuery({ applicationId });
const utils = api.useUtils();
const { data } = api.application.one.useQuery({ applicationId });
const { data: sshKeys } = api.sshKey.allForApps.useQuery();
const router = useRouter();
@ -99,7 +100,7 @@ export const SaveGitProvider = ({ applicationId }: Props) => {
})
.then(async () => {
toast.success("Git Provider Saved");
await refetch();
await utils.application.one.invalidate({ applicationId });
})
.catch(() => {
toast.error("Error saving the Git provider");

View File

@ -86,8 +86,9 @@ interface Props {
}
export const SaveGiteaProvider = ({ applicationId }: Props) => {
const utils = api.useUtils();
const { data: giteaProviders } = api.gitea.giteaProviders.useQuery();
const { data, refetch } = api.application.one.useQuery({ applicationId });
const { data } = api.application.one.useQuery({ applicationId });
const { mutateAsync, isPending: isSavingGiteaProvider } =
api.application.saveGiteaProvider.useMutation();
@ -174,7 +175,7 @@ export const SaveGiteaProvider = ({ applicationId }: Props) => {
})
.then(async () => {
toast.success("Service Provider Saved");
await refetch();
await utils.application.one.invalidate({ applicationId });
})
.catch(() => {
toast.error("Error saving the Gitea provider");

View File

@ -69,8 +69,9 @@ interface Props {
}
export const SaveGithubProvider = ({ applicationId }: Props) => {
const utils = api.useUtils();
const { data: githubProviders } = api.github.githubProviders.useQuery();
const { data, refetch } = api.application.one.useQuery({ applicationId });
const { data } = api.application.one.useQuery({ applicationId });
const { mutateAsync, isPending: isSavingGithubProvider } =
api.application.saveGithubProvider.useMutation();
@ -150,7 +151,7 @@ export const SaveGithubProvider = ({ applicationId }: Props) => {
})
.then(async () => {
toast.success("Service Provider Saved");
await refetch();
await utils.application.one.invalidate({ applicationId });
})
.catch(() => {
toast.error("Error saving the github provider");

View File

@ -72,8 +72,9 @@ interface Props {
}
export const SaveGitlabProvider = ({ applicationId }: Props) => {
const utils = api.useUtils();
const { data: gitlabProviders } = api.gitlab.gitlabProviders.useQuery();
const { data, refetch } = api.application.one.useQuery({ applicationId });
const { data } = api.application.one.useQuery({ applicationId });
const { mutateAsync, isPending: isSavingGitlabProvider } =
api.application.saveGitlabProvider.useMutation();
@ -169,7 +170,7 @@ export const SaveGitlabProvider = ({ applicationId }: Props) => {
})
.then(async () => {
toast.success("Service Provider Saved");
await refetch();
await utils.application.one.invalidate({ applicationId });
})
.catch(() => {
toast.error("Error saving the gitlab provider");