Skip to content

Saleor Core: the high performance, composable, headless commerce API.

Prevent navigating user to non-existent category

dominik-zeglend985b4bfcd1d
diff --git a/saleor/static/dashboard-next/categories/views/CategoryCreate.tsx b/saleor/static/dashboard-next/categories/views/CategoryCreate.tsx
index 352dda30d1..0e7b0f09c0 100644
--- a/saleor/static/dashboard-next/categories/views/CategoryCreate.tsx
+++ b/saleor/static/dashboard-next/categories/views/CategoryCreate.tsx
@@ -8,7 +8,7 @@ import { getMutationState, maybe } from "../../misc";
import CategoryCreatePage from "../components/CategoryCreatePage";
import { TypedCategoryCreateMutation } from "../mutations";
import { CategoryCreate } from "../types/CategoryCreate";
-import { categoryUrl } from "../urls";
+import { categoryListUrl, categoryUrl } from "../urls";
interface CategoryCreateViewProps {
parentId: string;
@@ -46,7 +46,11 @@ export const CategoryCreateView: React.StatelessComponent<
[]
)}
disabled={createCategoryResult.loading}
- onBack={() => navigate(categoryUrl(parentId))}
+ onBack={() =>
+ navigate(
+ parentId ? categoryUrl(parentId) : categoryListUrl
+ )
+ }
onSubmit={formData =>
createCategory({
variables: {