refactor: update API and dashboard components to replace projectId with environmentId for improved context handling and authorization checks

This commit is contained in:
Mauricio Siu
2025-09-01 20:39:58 -06:00
parent 399bcb0302
commit 39d48d8bdf
5 changed files with 17 additions and 14 deletions

View File

@@ -103,8 +103,6 @@ export const TemplateGenerator = ({ environmentId }: Props) => {
useState<TemplateInfo>(defaultTemplateInfo);
const utils = api.useUtils();
// Get environment data to extract projectId
const { data: environment } = api.environment.one.useQuery({ environmentId });
const haveAtleasOneProviderEnabled = aiSettings?.some(
(ai) => ai.isEnabled === true,
@@ -124,7 +122,7 @@ export const TemplateGenerator = ({ environmentId }: Props) => {
const onSubmit = async () => {
await mutateAsync({
projectId: environment?.projectId || "",
environmentId: environmentId,
id: templateInfo.details?.id || "",
name: templateInfo?.details?.name || "",
description: templateInfo?.details?.shortDescription || "",
@@ -142,7 +140,9 @@ export const TemplateGenerator = ({ environmentId }: Props) => {
toast.success("Compose Created");
setOpen(false);
// Invalidate the project query to refresh the environment data
await utils.project.one.invalidate();
await utils.environment.one.invalidate({
environmentId,
});
})
.catch(() => {
toast.error("Error creating the compose");