diff --git a/apps/client/src/locales/en.yml b/apps/client/src/locales/en.yml index cdc3b77..66efcec 100644 --- a/apps/client/src/locales/en.yml +++ b/apps/client/src/locales/en.yml @@ -59,6 +59,8 @@ email-callbacks: label: Webhook secret placeholder: eg. 1234567890 random-secret: Random secret + rotate: Rotate secret + cannot-read-secret: For security reasons, the secret cannot be read, you can change it by clicking the rotate button. allowed-origins: title: Allowed email origins description: Configure the addresses that are allowed to send emails to your email address, leave empty to allow all. diff --git a/apps/client/src/locales/fr.yml b/apps/client/src/locales/fr.yml index 7dfcdc4..35fdcdf 100644 --- a/apps/client/src/locales/fr.yml +++ b/apps/client/src/locales/fr.yml @@ -43,6 +43,19 @@ email-callbacks: description: Choisissez un nom d'utilisateur et un domaine pour votre adresse email. random-address: Adresse aléatoire placeholder: ex. john.doe + webhook: + title: Webhook + description: Configurez votre webhook pour recevoir les emails envoyés à votre adresse email. + url: + label: URL du webhook + placeholder: ex. https://example.com/callback + random-url: URL aléatoire + secret: + label: Secret du webhook + placeholder: ex. 1234567890 + random-secret: Secret aléatoire + rotate: Régénérer le secret + cannot-read-secret: Pour des raisons de sécurité, le secret ne peut pas être lu, vous pouvez le modifier en cliquant sur le bouton de rotation. allowed-origins: title: Origines autorisées description: Configurez les adresses qui sont autorisées à envoyer des emails à votre adresse email, laissez vide pour autoriser toutes les adresses. diff --git a/apps/client/src/modules/email-callbacks/components/email-callback-form.component.tsx b/apps/client/src/modules/email-callbacks/components/email-callback-form.component.tsx index 357703e..3558ac3 100644 --- a/apps/client/src/modules/email-callbacks/components/email-callback-form.component.tsx +++ b/apps/client/src/modules/email-callbacks/components/email-callback-form.component.tsx @@ -10,7 +10,7 @@ import { TextField, TextFieldLabel, TextFieldRoot } from '@/modules/ui/component import { safely } from '@corentinth/chisels'; import { generateId } from '@corentinth/friendly-ids'; import { type FormStore, insert, remove, reset, setValue } from '@modular-forms/solid'; -import { type Component, For, type JSX } from 'solid-js'; +import { type Component, createSignal, For, type JSX, Show } from 'solid-js'; import * as v from 'valibot'; import { emailUsernameRegex } from '../email-callbacks.constants'; import { generateEmailCallbackSecret } from '../email-callbacks.models'; @@ -37,6 +37,7 @@ export const EmailCallbackForm: Component<{ }> = (props) => { const { t } = useI18n(); const { config } = useConfig(); + const [getShowUpdateWebhookSecretForm, setShowUpdateWebhookSecretForm] = createSignal(false); const { availableDomains } = config.emailCallbacks; @@ -120,6 +121,18 @@ export const EmailCallbackForm: Component<{ }, }); + const getShowWebhookSecretForm = () => { + if (props.emailCallback === undefined) { + return true; + } + + if (props.emailCallback.hasWebhookSecret) { + return getShowUpdateWebhookSecretForm(); + } + + return false; + }; + return (