plane/apps/app/components/toast-alert/index.tsx

75 lines
2.6 KiB
TypeScript
Raw Normal View History

2022-11-19 14:21:26 +00:00
import React from "react";
// hooks
Refactoring Phase 1 (#199) * style: added cta at the bottom of sidebar, added missing icons as well, showing dynamic workspace member count on workspace dropdown * refractor: running parallel request, made create/edit label function to async function * fix: sidebar dropdown content going below kanban items outside click detection in need help dropdown * refractor: making parallel api calls fix: create state input comes at bottom, create state input gets on focus automatically, form is getting submitted on enter click * refactoring file structure and signin page * style: changed text and added spinner for signing in loading * refractor: removed unused type * fix: my issue cta in profile page sending to 404 page * fix: added new s3 bucket url in next.config.js file increased image modal height * packaging UI components * eslint config * eslint fixes * refactoring changes * build fixes * minor fixes * adding todo comments for reference * refactor: cleared unused imports and re ordered imports * refactor: removed unused imports * fix: added workspace argument to useissues hook * refactor: removed api-routes file, unnecessary constants * refactor: created helpers folder, removed unnecessary constants * refactor: new context for issue view * refactoring issues page * build fixes * refactoring * refactor: create issue modal * refactor: module ui * fix: sub-issues mutation * fix: create more option in create issue modal * description form debounce issue * refactor: global component for assignees list * fix: link module interface * fix: priority icons and sub-issues count added * fix: cycle mutation in issue details page * fix: remove issue from cycle mutation * fix: create issue modal in home page * fix: removed unnecessary props * fix: updated create issue form status * fix: settings auth breaking * refactor: issue details page Co-authored-by: Dakshesh Jain <dakshesh.jain14@gmail.com> Co-authored-by: Dakshesh Jain <65905942+dakshesh14@users.noreply.github.com> Co-authored-by: venkatesh-soulpage <venkatesh.marreboyina@soulpageit.com> Co-authored-by: Aaryan Khandelwal <aaryankhandu123@gmail.com> Co-authored-by: Anmol Singh Bhatia <anmolsinghbhatia1001@gmail.com>
2023-01-26 18:12:20 +00:00
import useToast from "hooks/use-toast";
// icons
2023-04-28 06:07:52 +00:00
import { LinkIcon, XMarkIcon } from "@heroicons/react/24/outline";
import { ErrorIcon, SuccessIcon } from "components/icons";
2022-11-19 14:21:26 +00:00
const ToastAlerts = () => {
const { alerts, removeAlert } = useToast();
if (!alerts) return null;
return (
2023-04-28 06:07:52 +00:00
<div className="pointer-events-none fixed top-5 right-5 z-50 h-full w-96 space-y-5 overflow-hidden rounded-md">
2022-11-19 14:21:26 +00:00
{alerts.map((alert) => (
2023-04-28 06:07:52 +00:00
<div
className="relative flex flex-col items-center justify-center gap-2 overflow-hidden rounded-md border-[2px] border-brand-surface-2 bg-brand-base px-4 py-3 text-sm text-brand-base shadow-md"
key={alert.id}
>
2022-11-19 14:21:26 +00:00
<div className="absolute top-1 right-1">
<button
type="button"
2023-04-28 06:07:52 +00:00
className="pointer-events-auto inline-flex rounded-md p-1.5 text-brand-secondary"
2022-11-19 14:21:26 +00:00
onClick={() => removeAlert(alert.id)}
>
<span className="sr-only">Dismiss</span>
2023-04-28 06:07:52 +00:00
<XMarkIcon className="h-4 w-4" aria-hidden="true" />
2022-11-19 14:21:26 +00:00
</button>
</div>
2023-04-28 06:07:52 +00:00
{alert.type !== "info" ? (
<>
<div className="flex w-full items-center gap-2.5">
2022-11-19 14:21:26 +00:00
{alert.type === "success" ? (
2023-04-28 06:07:52 +00:00
<SuccessIcon className="h-4 w-4" />
2022-11-19 14:21:26 +00:00
) : alert.type === "error" ? (
2023-04-28 06:07:52 +00:00
<ErrorIcon className="h-4 w-4" />
2022-11-19 14:21:26 +00:00
) : (
2023-04-28 06:07:52 +00:00
""
2022-11-19 14:21:26 +00:00
)}
2023-04-28 06:07:52 +00:00
<p
className={`font-medium ${
alert.type === "success"
? "text-brand-base"
: alert.type === "error"
? "bg-[#ef476f]"
: alert.type === "warning"
? "bg-[#e98601]"
: "bg-[#1B9aaa]"
}`}
>
{alert.title}
</p>
2022-11-19 14:21:26 +00:00
</div>
2023-04-28 06:07:52 +00:00
<div className="flex w-full items-center justify-start text-brand-secondary">
<p className="text-left">{alert.message}</p>
2022-11-19 14:21:26 +00:00
</div>
2023-04-28 06:07:52 +00:00
</>
) : (
<div className="flex w-full items-center justify-center gap-2.5 py-2 text-brand-secondary">
{alert.iconType === "copy" && (
<span>
<LinkIcon className="h-4 w-4" />
</span>
)}
<p className="font-medium italic">{alert.title}</p>
2022-11-19 14:21:26 +00:00
</div>
2023-04-28 06:07:52 +00:00
)}
2022-11-19 14:21:26 +00:00
</div>
))}
</div>
);
};
export default ToastAlerts;