import { FC } from "react"; import { Controller, useForm } from "react-hook-form"; // ui import { Button } from "@plane/ui"; // hooks import useToast from "hooks/use-toast"; // services import { UserService } from "services/user.service"; // types import { IUserEmailNotificationSettings } from "@plane/types"; interface IEmailNotificationFormProps { data: IUserEmailNotificationSettings; } // services const userService = new UserService(); export const EmailNotificationForm: FC = (props) => { const { data } = props; // toast const { setToastAlert } = useToast(); // form data const { handleSubmit, control, setValue, formState: { isSubmitting, isDirty, dirtyFields }, } = useForm({ defaultValues: { ...data, }, }); const onSubmit = async (formData: IUserEmailNotificationSettings) => { // Get the dirty fields from the form data and create a payload let payload = {}; Object.keys(dirtyFields).forEach((key) => { payload = { ...payload, [key]: formData[key as keyof IUserEmailNotificationSettings], }; }); await userService .updateCurrentUserEmailNotificationSettings(payload) .then(() => setToastAlert({ title: "Success", type: "success", message: "Email Notification Settings updated successfully", }) ) .catch((err) => console.error(err)); }; return ( <>
Email notifications
Stay in the loop on Issues you are subscribed to. Enable this to get notified.
Notify me when:
{/* Notification Settings */}
Property changes
Notify me when issue’s properties like assignees, priority, estimates or anything else changes.
( onChange(!value)} className="w-3.5 h-3.5 mx-2 cursor-pointer !border-custom-border-100" /> )} />
State Change
Notify me when the issues moves to a different state
( { setValue("issue_completed", !value); onChange(!value); }} className="w-3.5 h-3.5 mx-2 cursor-pointer" /> )} />
Issue completed
Notify me only when an issue is completed
( onChange(!value)} className="w-3.5 h-3.5 mx-2 cursor-pointer" /> )} />
Comments
Notify me when someone leaves a comment on the issue
( onChange(!value)} className="w-3.5 h-3.5 mx-2 cursor-pointer" /> )} />
Mentions
Notify me only when someone mentions me in the comments or description
( onChange(!value)} className="w-3.5 h-3.5 mx-2 cursor-pointer" /> )} />
); };