mirror of
https://github.com/Portabase/portabase.git
synced 2026-07-14 11:16:13 +02:00
Working on UX/UI of the notification system.
This commit is contained in:
@@ -14,17 +14,22 @@ import {NotificationChannel} from "@/db/schema/09_notification-channel";
|
||||
type OrganizationNotifierAddModalProps = {
|
||||
notificationChannel?: NotificationChannel
|
||||
organization?: OrganizationWithMembers;
|
||||
open: boolean;
|
||||
onOpenChangeAction: (open: boolean) => void;
|
||||
}
|
||||
|
||||
|
||||
export const NotifierAddEditModal = ({organization, notificationChannel}: OrganizationNotifierAddModalProps) => {
|
||||
export const NotifierAddEditModal = ({
|
||||
organization,
|
||||
notificationChannel,
|
||||
open,
|
||||
onOpenChangeAction
|
||||
}: OrganizationNotifierAddModalProps) => {
|
||||
|
||||
const isCreate = !Boolean(notificationChannel);
|
||||
|
||||
const [open, setOpen] = useState(false);
|
||||
|
||||
return (
|
||||
<Dialog open={open} onOpenChange={setOpen}>
|
||||
<Dialog open={open} onOpenChange={onOpenChangeAction}>
|
||||
<DialogTrigger asChild>
|
||||
{isCreate ?
|
||||
<Button>
|
||||
@@ -49,7 +54,7 @@ export const NotifierAddEditModal = ({organization, notificationChannel}: Organi
|
||||
<NotifierForm
|
||||
defaultValues={notificationChannel}
|
||||
organization={organization}
|
||||
onSuccessAction={() => setOpen(false)}
|
||||
onSuccessAction={() => onOpenChangeAction(false)}
|
||||
/>
|
||||
</DialogContent>
|
||||
</Dialog>
|
||||
|
||||
+5
@@ -8,6 +8,7 @@ import {
|
||||
updateNotificationChannelAction
|
||||
} from "@/components/wrappers/dashboard/common/notifier/notifier-form/notifier-form.action";
|
||||
import {toast} from "sonner";
|
||||
import {useState} from "react";
|
||||
|
||||
export type EditNotifierButtonProps = {
|
||||
notificationChannel: NotificationChannel;
|
||||
@@ -15,6 +16,8 @@ export type EditNotifierButtonProps = {
|
||||
|
||||
export const EditNotifierButton = ({notificationChannel}: EditNotifierButtonProps) => {
|
||||
const router = useRouter();
|
||||
const [isAddModalOpen, setIsAddModalOpen] = useState(false);
|
||||
|
||||
|
||||
const mutation = useMutation({
|
||||
mutationFn: async (value: boolean) => {
|
||||
@@ -49,6 +52,8 @@ export const EditNotifierButton = ({notificationChannel}: EditNotifierButtonProp
|
||||
/>
|
||||
<NotifierAddEditModal
|
||||
notificationChannel={notificationChannel}
|
||||
open={isAddModalOpen}
|
||||
onOpenChangeAction={setIsAddModalOpen}
|
||||
/>
|
||||
</>
|
||||
);
|
||||
|
||||
@@ -45,7 +45,6 @@ export const NotifierForm = ({onSuccessAction, organization, defaultValues}: Not
|
||||
|
||||
});
|
||||
|
||||
|
||||
const mutationCreateOrganisation = useMutation({
|
||||
mutationFn: async (values: NotificationChannelFormType) => {
|
||||
|
||||
@@ -61,11 +60,11 @@ export const NotifierForm = ({onSuccessAction, organization, defaultValues}: Not
|
||||
|
||||
if (inner?.success) {
|
||||
toast.success(inner.actionSuccess?.message);
|
||||
// onSuccessAction?.();
|
||||
onSuccessAction?.();
|
||||
router.refresh();
|
||||
} else {
|
||||
toast.error(inner?.actionError?.message);
|
||||
// onSuccessAction?.();
|
||||
onSuccessAction?.();
|
||||
}
|
||||
}
|
||||
});
|
||||
@@ -134,7 +133,7 @@ export const NotifierForm = ({onSuccessAction, organization, defaultValues}: Not
|
||||
|
||||
<div className="flex gap-4 justify-end">
|
||||
{defaultValues && (
|
||||
<NotifierTestChannelButton notificationChannel={defaultValues} />
|
||||
<NotifierTestChannelButton notificationChannel={defaultValues}/>
|
||||
)}
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user