@development-framework/dm-core
Advanced tools
Comparing version 1.6.3 to 1.6.4
# Changelog | ||
## [1.6.4](https://github.com/equinor/dm-core-packages/compare/dm-core-v1.6.3...dm-core-v1.6.4) (2023-10-11) | ||
### Bug Fixes | ||
* Select correct recipes when switching views ([#610](https://github.com/equinor/dm-core-packages/issues/610)) ([88b8c8c](https://github.com/equinor/dm-core-packages/commit/88b8c8ca22238db2b0f033b90d63e79422c52a5f)) | ||
## [1.6.3](https://github.com/equinor/dm-core-packages/compare/dm-core-v1.6.2...dm-core-v1.6.3) (2023-10-10) | ||
@@ -4,0 +11,0 @@ |
@@ -43,11 +43,21 @@ "use strict"; | ||
setInitialUiRecipe(response.data.initialUiRecipe); | ||
setUiRecipes(response.data.uiRecipes ?? []); | ||
setUiRecipes(response.data.uiRecipes); | ||
setError(null); | ||
}) | ||
.catch((error) => setError(error.response?.data || null)) | ||
.finally(() => setLoading(false)); | ||
.catch((error) => { | ||
setError(error.response?.data || null); | ||
}) | ||
.finally(() => { | ||
setLoading(false); | ||
}); | ||
}, [typeRef]); | ||
return { blueprint, initialUiRecipe, uiRecipes, isLoading, error }; | ||
return { | ||
blueprint, | ||
initialUiRecipe, | ||
uiRecipes, | ||
isLoading, | ||
error, | ||
}; | ||
}; | ||
exports.useBlueprint = useBlueprint; | ||
//# sourceMappingURL=useBlueprint.js.map |
@@ -30,3 +30,3 @@ /// <reference types="react" /> | ||
* @param recipeName - Name of recipe to find (optional) | ||
* @param noInit - Do not return any initialRecipes | ||
* @param dimensions - The recipes dimensions | ||
* @returns A list containing the blueprint document, a boolean representing the loading state, and an Error, if any. | ||
@@ -33,0 +33,0 @@ */ |
@@ -60,29 +60,39 @@ "use strict"; | ||
* @param recipeName - Name of recipe to find (optional) | ||
* @param noInit - Do not return any initialRecipes | ||
* @param dimensions - The recipes dimensions | ||
* @returns A list containing the blueprint document, a boolean representing the loading state, and an Error, if any. | ||
*/ | ||
const useRecipe = (typeRef, recipeName, dimensions = '') => { | ||
const { initialUiRecipe, uiRecipes, isLoading: isBlueprintLoading, error, } = (0, index_1.useBlueprint)(typeRef); | ||
const { getUiPlugin } = (0, index_1.useUiPlugins)(); | ||
const [foundRecipe, setFoundRecipe] = (0, react_1.useState)(); | ||
const [findRecipeError, setFindRecipeError] = (0, react_1.useState)(null); | ||
const [isLoading, setLoading] = (0, react_1.useState)(true); | ||
const [error, setError] = (0, react_1.useState)(null); | ||
const dmssAPI = (0, index_1.useDMSS)(); | ||
const { name } = (0, react_1.useContext)(index_1.ApplicationContext); | ||
(0, react_1.useEffect)(() => { | ||
if (isBlueprintLoading) | ||
return; | ||
try { | ||
setFoundRecipe(findRecipe(uiRecipes, initialUiRecipe, recipeName, dimensions)); | ||
} | ||
catch (error) { | ||
console.error(error); | ||
const errorResponse = { | ||
type: 'RecipeSelectionError', | ||
debug: `type: "${typeRef}"`, | ||
message: error.message, | ||
}; | ||
setFindRecipeError(errorResponse); | ||
} | ||
}, [isBlueprintLoading]); | ||
setLoading(true); | ||
dmssAPI | ||
.blueprintGet({ typeRef: typeRef, context: name }) | ||
.then((response) => { | ||
try { | ||
setFoundRecipe(findRecipe(response.data.uiRecipes, response.data.initialUiRecipe, recipeName, dimensions)); | ||
} | ||
catch (error) { | ||
console.error(error); | ||
const errorResponse = { | ||
type: 'RecipeSelectionError', | ||
debug: `type: "${typeRef}"`, | ||
message: error.message, | ||
}; | ||
setFindRecipeError(errorResponse); | ||
} | ||
}) | ||
.catch((error) => setError(error.response?.data || null)) | ||
.finally(() => { | ||
setLoading(false); | ||
}); | ||
}, [typeRef, recipeName, dimensions]); | ||
return { | ||
recipe: isBlueprintLoading ? undefined : foundRecipe, | ||
isLoading: isBlueprintLoading, | ||
recipe: isLoading ? undefined : foundRecipe, | ||
isLoading, | ||
error: error ?? findRecipeError, | ||
@@ -89,0 +99,0 @@ getUiPlugin, |
{ | ||
"name": "@development-framework/dm-core", | ||
"version": "1.6.3", | ||
"version": "1.6.4", | ||
"license": "MIT", | ||
@@ -5,0 +5,0 @@ "peerDependencies": { |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
1921428
30323