This commit is contained in:
2026-05-12 07:54:32 +03:00
parent 0faa8b9d2d
commit d49449c30c
187 changed files with 4826 additions and 5884 deletions

View File

@@ -1,6 +1,6 @@
import { useState } from "react"
import { useSWRConfig } from "swr"
import { backendApi, getAssetsListKey } from "infra/backend-api"
import { backendApi, getAssetsListKey, getProjectAssetsKey } from "infra/backend-api"
import { ASSETS_DASHBOARD_LIST_PARAMS } from "../config/assets.config"
import { toError } from "../lib/to-error"
@@ -19,8 +19,15 @@ export const useCreateAsset = (): CreateAssetAction => {
setIsCreating(true)
try {
const createdAsset = await backendApi.assets.createAsset(input)
await mutate(getAssetsListKey(ASSETS_DASHBOARD_LIST_PARAMS))
const { projectSlug, ...request } = input
const createdAsset = projectSlug
? await backendApi.projects.createProjectAsset({ projectSlug }, request)
: await backendApi.assets.createAsset(request)
await Promise.all([
mutate(getAssetsListKey(ASSETS_DASHBOARD_LIST_PARAMS)),
projectSlug ? mutate(getProjectAssetsKey(projectSlug, ASSETS_DASHBOARD_LIST_PARAMS)) : Promise.resolve(),
])
return createdAsset
} catch (caughtError) {