fix(EmailNotifications): fix ui switch
Build and Push Docker image / build-and-push (push) Successful in 2m4s
Details
Build and Push Docker image / build-and-push (push) Successful in 2m4s
Details
This commit is contained in:
parent
5f2fda2f96
commit
1a3f2ff824
|
@ -34,6 +34,8 @@ import {getUserName} from "@/components/users/modals/util.tsx";
|
||||||
import {isNotEmpty, useForm} from "@mantine/form";
|
import {isNotEmpty, useForm} from "@mantine/form";
|
||||||
import {useMutation} from "@tanstack/react-query";
|
import {useMutation} from "@tanstack/react-query";
|
||||||
import {showSuccessNotification} from "@/components/util.tsx";
|
import {showSuccessNotification} from "@/components/util.tsx";
|
||||||
|
import {CheckboxCard} from "@/components/input/CheckboxCard";
|
||||||
|
import {useEffect} from "react";
|
||||||
|
|
||||||
export default function UserMenuModal() {
|
export default function UserMenuModal() {
|
||||||
const {value, handler} = useUserMenu()
|
const {value, handler} = useUserMenu()
|
||||||
|
@ -49,17 +51,23 @@ export default function UserMenuModal() {
|
||||||
const {showDebug, toggleShowDebug} = useShowDebug()
|
const {showDebug, toggleShowDebug} = useShowDebug()
|
||||||
|
|
||||||
const formValues = useForm({
|
const formValues = useForm({
|
||||||
initialValues: {
|
initialValues: {},
|
||||||
sn: user?.sn ?? "",
|
|
||||||
givenName: user?.givenName ?? "",
|
|
||||||
muteEmailNotifications: user?.muteEmailNotifications ?? false
|
|
||||||
},
|
|
||||||
validate: {
|
validate: {
|
||||||
sn: isNotEmpty('Bitte gebe deinen Nachnamen ein'),
|
sn: isNotEmpty('Bitte gebe deinen Nachnamen ein'),
|
||||||
givenName: isNotEmpty('Bitte gebe deinen Vornamen ein'),
|
givenName: isNotEmpty('Bitte gebe deinen Vornamen ein'),
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
|
useEffect(() => {
|
||||||
|
const values = {
|
||||||
|
sn: user?.sn ?? "",
|
||||||
|
givenName: user?.givenName ?? "",
|
||||||
|
muteEmailNotifications: user?.muteEmailNotifications ?? false
|
||||||
|
}
|
||||||
|
formValues.setInitialValues(values)
|
||||||
|
formValues.setValues(values)
|
||||||
|
}, [user]);
|
||||||
|
|
||||||
const mutation = useMutation({
|
const mutation = useMutation({
|
||||||
mutationFn: async () => {
|
mutationFn: async () => {
|
||||||
if (formValues.validate().hasErrors || !user) {
|
if (formValues.validate().hasErrors || !user) {
|
||||||
|
@ -71,9 +79,8 @@ export default function UserMenuModal() {
|
||||||
})
|
})
|
||||||
},
|
},
|
||||||
onSuccess: () => {
|
onSuccess: () => {
|
||||||
showSuccessNotification("Dein Name wurde erfolgreich gespeichert")
|
showSuccessNotification("Gespeichert")
|
||||||
refreshUser()
|
refreshUser()
|
||||||
formValues.reset()
|
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
|
@ -219,15 +226,16 @@ export default function UserMenuModal() {
|
||||||
</>
|
</>
|
||||||
}
|
}
|
||||||
|
|
||||||
<Switch
|
<CheckboxCard
|
||||||
label={"Email Benachrichtigungen stummschalten"}
|
label={"Email Benachrichtigungen stummschalten"}
|
||||||
description={"Hier kannst du Email Benachrichtigungen für Gruppennachrichten stummschalten. " +
|
description={"Du erhältst keine Benachrichtigungen per Email für neu Chatnachrichten. " +
|
||||||
"Du erhältst weiterhin Benachrichtigungen für Ankündigungen."}
|
"Für Ankündigungen und wichtige Informationen bekommst du weiterhin Nachrichten."
|
||||||
{...formValues.getInputProps("muteEmailNotifications", {type: "checkbox"})}
|
}
|
||||||
|
{...formValues.getInputProps("muteEmailNotifications", {type: 'checkbox'})}
|
||||||
/>
|
/>
|
||||||
|
|
||||||
<Group justify={"center"}>
|
<Group justify={"center"}>
|
||||||
<Tooltip label={"Account Einstellungen"}>
|
<Tooltip label={"Account Einstellungen speichern"}>
|
||||||
<ActionIcon
|
<ActionIcon
|
||||||
variant={"transparent"}
|
variant={"transparent"}
|
||||||
aria-label={"update account"}
|
aria-label={"update account"}
|
||||||
|
|
Loading…
Reference in New Issue