Skip to content

Commit

Permalink
reset form changes if user decided to choose the existing source/dest…
Browse files Browse the repository at this point in the history
…ination (#15517)
  • Loading branch information
dizel852 authored Aug 12, 2022
1 parent 8b55ca3 commit da5b837
Showing 1 changed file with 4 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import CreateConnectionContent from "components/CreateConnectionContent";
import HeadTitle from "components/HeadTitle";
import StepsMenu from "components/StepsMenu";

import { useFormChangeTrackerService } from "hooks/services/FormChangeTracker";
import { useGetDestination } from "hooks/services/useDestinationHook";
import { useGetSource } from "hooks/services/useSourceHook";
import useRouter from "hooks/useRouter";
Expand Down Expand Up @@ -70,6 +71,7 @@ function usePreloadData(): {

export const CreationFormPage: React.FC = () => {
const { location, push } = useRouter();
const { clearAllFormChanges } = useFormChangeTrackerService();

// TODO: Probably there is a better way to figure it out instead of just checking third elem
const locationType = location.pathname.split("/")[3];
Expand All @@ -93,6 +95,7 @@ export const CreationFormPage: React.FC = () => {
const { destinationDefinition, sourceDefinition, source, destination } = usePreloadData();

const onSelectExistingSource = (id: string) => {
clearAllFormChanges();
push("", {
state: {
...(location.state as Record<string, unknown>),
Expand All @@ -104,6 +107,7 @@ export const CreationFormPage: React.FC = () => {
};

const onSelectExistingDestination = (id: string) => {
clearAllFormChanges();
push("", {
state: {
...(location.state as Record<string, unknown>),
Expand Down

0 comments on commit da5b837

Please sign in to comment.