Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ export const ApiKeyButton = ({
<>
<GenerateApiKeyButton
loading={false}
className="mr-2"
theme={theme}
disabled={Boolean(apiKeyId)}
onClick={() => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -101,25 +101,28 @@ export const ResponseDelivery = () => {
const [purposeOption, setPurposeOption] = useState(formPurpose as PurposeOption);

/*--------------------------------------------*
* Save Delivery Option
* Save security attribute
*--------------------------------------------*/
const saveDeliveryOptions = useCallback(async () => {
updateSecurityAttribute(classification);

const resultAttribute = (await updateTemplateSecurityAttribute({
id,
securityAttribute: classification,
})) as FormServerError;

if (resultAttribute?.error) {
toast.error(<ErrorSaving errorCode={FormServerErrorCodes.DELIVERY_OPTION} />, "wide");
return;
}
const saveSecurityAttribute = useCallback(
async (classification: ClassificationType) => {
updateSecurityAttribute(classification);

const resultAttribute = (await updateTemplateSecurityAttribute({
id,
securityAttribute: classification,
})) as FormServerError;

if (resultAttribute?.error) {
toast.error(<ErrorSaving errorCode={FormServerErrorCodes.DELIVERY_OPTION} />, "wide");
return;
}

toast.success(t("settingsResponseDelivery.savedSuccessMessage"));
toast.success(t("settingsResponseDelivery.savedSuccessMessage"));

refreshData && refreshData();
}, [t, refreshData, id, classification, updateSecurityAttribute]);
refreshData && refreshData();
},
[t, refreshData, id, updateSecurityAttribute]
);

/*--------------------------------------------*
* Save form purpose option
Expand Down Expand Up @@ -165,8 +168,9 @@ export const ResponseDelivery = () => {
setDeliveryOptionValue(DeliveryOption.vault);
}
setClassification(value);
saveSecurityAttribute(value);
},
[deliveryOptionValue]
[deliveryOptionValue, saveSecurityAttribute]
);

const handleDeleteApiKey = useCallback(() => {
Expand Down Expand Up @@ -200,11 +204,9 @@ export const ResponseDelivery = () => {
lang={lang}
isPublished={isPublished}
classification={classification}
disabled={hasApiKey}
handleUpdateClassification={handleUpdateClassification}
/>
</div>

<div className="mb-10">
<h2 className="mb-6">{t("settingsResponseDelivery.title")}</h2>

Expand Down Expand Up @@ -296,19 +298,9 @@ export const ResponseDelivery = () => {
<ApiDocNotes />
</div>
)}
{deliveryOptionValue !== DeliveryOption.api && !hasApiKey && (
<>
<Button
// disabled={!isValid || isPublished}
disabled={isPublished}
theme="secondary"
onClick={saveDeliveryOptions}
>
{t("settingsResponseDelivery.saveButton")}
</Button>
<ResponseDeliveryHelpButtonWithApi />
</>
)}
<div>
<ResponseDeliveryHelpButtonWithApi />
</div>
</div>

{/*--------------------------------------------*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@ export const ResponseDeliveryHelpButtonWithApi = () => {

return (
<>
<InfoIcon className="ml-4 inline-block size-5" />
<InfoIcon className="inline-block size-5" />
<div className="ml-2 inline-block">
<Button onClick={handleOpenDialog} theme="link">
{t("settingsResponseDelivery.responseDeliveryHelpWithApi.cta")}
Expand Down
1 change: 1 addition & 0 deletions next-env.d.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
/// <reference types="next" />
/// <reference types="next/image-types/global" />
/// <reference path="./.next/types/routes.d.ts" />

// NOTE: This file should not be edited
// see https://nextjs.org/docs/app/api-reference/config/typescript for more information.
Loading