chore: pr feedbacks
This commit is contained in:
parent
1a2a5079b8
commit
a16681a096
2 changed files with 8 additions and 6 deletions
|
|
@ -57,6 +57,9 @@ const defaultValuesForType = {
|
||||||
slack: {
|
slack: {
|
||||||
type: "slack" as const,
|
type: "slack" as const,
|
||||||
webhookUrl: "",
|
webhookUrl: "",
|
||||||
|
channel: "",
|
||||||
|
username: "",
|
||||||
|
iconEmoji: "",
|
||||||
},
|
},
|
||||||
discord: {
|
discord: {
|
||||||
type: "discord" as const,
|
type: "discord" as const,
|
||||||
|
|
@ -103,7 +106,9 @@ const defaultValuesForType = {
|
||||||
export const CreateNotificationForm = ({ onSubmit, mode = "create", initialValues, formId, className }: Props) => {
|
export const CreateNotificationForm = ({ onSubmit, mode = "create", initialValues, formId, className }: Props) => {
|
||||||
const form = useForm<NotificationFormValues>({
|
const form = useForm<NotificationFormValues>({
|
||||||
resolver: arktypeResolver(cleanSchema as unknown as typeof formSchema),
|
resolver: arktypeResolver(cleanSchema as unknown as typeof formSchema),
|
||||||
defaultValues: initialValues,
|
defaultValues: initialValues || {
|
||||||
|
name: "",
|
||||||
|
},
|
||||||
resetOptions: {
|
resetOptions: {
|
||||||
keepDefaultValues: true,
|
keepDefaultValues: true,
|
||||||
keepDirtyValues: false,
|
keepDirtyValues: false,
|
||||||
|
|
@ -116,7 +121,7 @@ export const CreateNotificationForm = ({ onSubmit, mode = "create", initialValue
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
if (!initialValues) {
|
if (!initialValues) {
|
||||||
form.reset({
|
form.reset({
|
||||||
name: form.getValues().name,
|
name: form.getValues().name || "",
|
||||||
...defaultValuesForType[watchedType as keyof typeof defaultValuesForType],
|
...defaultValuesForType[watchedType as keyof typeof defaultValuesForType],
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -121,10 +121,7 @@ async function decryptSensitiveFields(config: NotificationConfig): Promise<Notif
|
||||||
botToken: await cryptoUtils.resolveSecret(config.botToken),
|
botToken: await cryptoUtils.resolveSecret(config.botToken),
|
||||||
};
|
};
|
||||||
case "generic":
|
case "generic":
|
||||||
return {
|
return config;
|
||||||
...config,
|
|
||||||
url: await cryptoUtils.resolveSecret(config.url),
|
|
||||||
};
|
|
||||||
case "custom":
|
case "custom":
|
||||||
return {
|
return {
|
||||||
...config,
|
...config,
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue