diff --git a/app/(gcforms)/[locale]/(form administration)/form-builder/[id]/components/dialogs/ApiKeyDialog/ApiKeyDialog.tsx b/app/(gcforms)/[locale]/(form administration)/form-builder/[id]/components/dialogs/ApiKeyDialog/ApiKeyDialog.tsx
index c1fc93f883..b3043c33b1 100644
--- a/app/(gcforms)/[locale]/(form administration)/form-builder/[id]/components/dialogs/ApiKeyDialog/ApiKeyDialog.tsx
+++ b/app/(gcforms)/[locale]/(form administration)/form-builder/[id]/components/dialogs/ApiKeyDialog/ApiKeyDialog.tsx
@@ -21,7 +21,12 @@ type APIKeyCustomEventDetails = {
id: string;
};
-export const ApiKeyDialog = () => {
+/**
+ * API Key Dialog
+ * @param isVaultDelivery - boolean - Allows skipping the save request when a form is already saving to the vault -- example a live form swapping to API mode
+ * @returns JSX.Element
+ */
+export const ApiKeyDialog = ({ isVaultDelivery = false }: { isVaultDelivery?: boolean }) => {
const dialog = useDialogRef();
const { Event } = useCustomEvent();
const { t } = useTranslation("form-builder");
@@ -73,15 +78,21 @@ export const ApiKeyDialog = () => {
setHasError(false);
setGenerating(true);
try {
- // First ensure all responses are sent to vault
- const result = await sendResponsesToVault({
- id: id,
- });
-
- if (result.error) {
- // Throw the generic key creation error
- // Handling as generic as we're in the process of creating a key
- throw new Error(result.error);
+ /*
+ Allows skipping the save request
+ if it's determined that the form responses
+ are already being delivered to the vault
+ */
+ if (!isVaultDelivery) {
+ const result = await sendResponsesToVault({
+ id: id,
+ });
+
+ if (result.error) {
+ // Throw the generic key creation error
+ // Handling as generic as we're in the process of creating a key
+ throw new Error(result.error);
+ }
}
const key = await _createKey(id);
diff --git a/app/(gcforms)/[locale]/(form administration)/form-builder/[id]/settings/components/ApiKeyButton.tsx b/app/(gcforms)/[locale]/(form administration)/form-builder/[id]/settings/components/ApiKeyButton.tsx
index 4f187a1525..304820d4d4 100644
--- a/app/(gcforms)/[locale]/(form administration)/form-builder/[id]/settings/components/ApiKeyButton.tsx
+++ b/app/(gcforms)/[locale]/(form administration)/form-builder/[id]/settings/components/ApiKeyButton.tsx
@@ -5,17 +5,22 @@ import { useTranslation } from "@i18n/client";
import { EventKeys, useCustomEvent } from "@lib/hooks/useCustomEvent";
import { DeleteKeyButton } from "./DeleteKeyButton";
import { SubmitButton as GenerateApiKeyButton } from "@clientComponents/globals/Buttons/SubmitButton";
+import { Theme } from "@clientComponents/globals/Buttons/themes";
import { useFormBuilderConfig } from "@lib/hooks/useFormBuilderConfig";
import { ResponseDeliveryHelpButtonWithApi } from "./dialogs/ResponseDeliveryHelpDialogApiWithApi";
type ApiKeyButtonProps = {
showDelete?: boolean;
i18nKey?: string;
+ theme?: Theme;
+ showHelp?: boolean;
};
export const ApiKeyButton = ({
showDelete = false,
i18nKey = "settings.api.generateKey",
+ theme = "primary",
+ showHelp = true,
}: ApiKeyButtonProps) => {
const { t } = useTranslation("form-builder");
const { id } = useParams();
@@ -36,13 +41,13 @@ export const ApiKeyButton = ({
{showDelete && apiKeyId ? (
<>
{t("assignUsersToTemplate")}
diff --git a/app/(gcforms)/[locale]/(form administration)/form-builder/[id]/settings/manage/ManageApiKey.tsx b/app/(gcforms)/[locale]/(form administration)/form-builder/[id]/settings/manage/ManageApiKey.tsx new file mode 100644 index 0000000000..283882f532 --- /dev/null +++ b/app/(gcforms)/[locale]/(form administration)/form-builder/[id]/settings/manage/ManageApiKey.tsx @@ -0,0 +1,22 @@ +"use client"; +import { useTranslation } from "@i18n/client"; +import { ApiKeyButton } from "../components/ApiKeyButton"; +import { SettingsApplicationsIcon } from "@serverComponents/icons"; +export const ManageApiKey = () => { + const { t } = useTranslation("form-builder"); + return ( +{t("switchToApiMode.description")}
+