Skip to content

Commit

Permalink
chore: Reset delivery option when creating API key (#4794)
Browse files Browse the repository at this point in the history
* reset template store for delivery option
  • Loading branch information
timarney authored Dec 6, 2024
1 parent c759963 commit efe6d7d
Showing 1 changed file with 8 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ import { logMessage } from "@lib/logger";
import { sendResponsesToVault } from "@formBuilder/actions";
import { useFormBuilderConfig } from "@lib/hooks/useFormBuilderConfig";
import { GenerateKeySuccess } from "./GenerateKeySuccess";
import { useTemplateStore } from "@lib/store/useTemplateStore";

type APIKeyCustomEventDetails = {
id: string;
Expand All @@ -31,6 +32,10 @@ export const ApiKeyDialog = ({ isVaultDelivery = false }: { isVaultDelivery?: bo
const { Event } = useCustomEvent();
const { t } = useTranslation("form-builder");

const { resetDeliveryOption } = useTemplateStore((s) => ({
resetDeliveryOption: s.resetDeliveryOption,
}));

// Setup + Open dialog
const [id, setId] = useState<string>("");
const [isOpen, setIsOpen] = useState(false);
Expand Down Expand Up @@ -93,6 +98,9 @@ export const ApiKeyDialog = ({ isVaultDelivery = false }: { isVaultDelivery?: bo
// Handling as generic as we're in the process of creating a key
throw new Error(result.error);
}

// Sync the template store with the new delivery option
resetDeliveryOption();
}

const key = await _createKey(id);
Expand Down

0 comments on commit efe6d7d

Please sign in to comment.