Skip to content

Commit

Permalink
show back button on error
Browse files Browse the repository at this point in the history
  • Loading branch information
ciyer committed Nov 10, 2023
1 parent 64e796a commit dd0c1dc
Showing 1 changed file with 20 additions and 2 deletions.
22 changes: 20 additions & 2 deletions client/src/features/projectsV2/new/ProjectV2New.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -16,12 +16,17 @@
* limitations under the License.
*/

import { useCallback } from "react";
import { useDispatch } from "react-redux";

import { Button } from "reactstrap";

import { Loader } from "../../../components/Loader";
import FormSchema from "../../../components/formschema/FormSchema";

import { usePostProjectsMutation } from "../api/projectV2.api";
import type { NewProjectV2State } from "./projectV2New.slice";
import { useNewProjectV2Selector } from "./projectV2New.slice";
import { setCurrentStep, useNewProjectV2Selector } from "./projectV2New.slice";
import ProjectV2NewForm from "./ProjectV2NewForm";

function ProjectV2NewAccessStepHeader() {
Expand Down Expand Up @@ -81,6 +86,12 @@ function ProjectV2NewRepositoryStepHeader() {

function ProjectV2BeingCreated() {
const { project } = useNewProjectV2Selector((state) => state);
const dispatch = useDispatch();

const previousStep = useCallback(() => {
dispatch(setCurrentStep(0));
}, [dispatch]);

const [createProject, result] = usePostProjectsMutation();
const newProject = {
name: project.metadata.name,
Expand Down Expand Up @@ -109,7 +120,14 @@ function ProjectV2BeingCreated() {
}

if (result.isError || result.data == null) {
return <div>Something went wrong...</div>;
return (
<div>
<p>Something went wrong.</p>
<div className="d-flex justify-content-between">
<Button onClick={previousStep}>Back</Button>
</div>
</div>
);
}
return <div>Project created</div>;
}
Expand Down

0 comments on commit dd0c1dc

Please sign in to comment.