1 import React from "react"
2 import { NotificationItemProps } from "@/components/Notification/Item"
3 import clsx from "clsx"
4 import {
5 CheckCircleSolid,
6 ExclamationCircleSolid,
7 InformationCircleSolid,
8 XCircleSolid,
9 } from "@medusajs/icons"
10 import { Button } from "@/components/Button"
11
12 export type NotificationItemLayoutDefaultProps = NotificationItemProps & {
13 handleClose: () => void
14 closeButtonText?: string
15 }
16
17 export const NotificationItemLayoutDefault: React.FC<
18 NotificationItemLayoutDefaultProps
19 > = ({
20 type = "info",
21 title = "",
22 text = "",
23 children,
24 isClosable = true,
25 handleClose,
26 CustomIcon,
27 closeButtonText = "Close",
28 }) => {
29 return (
30 <div
31 className="bg-medusa-bg-base w-full h-full shadow-elevation-flyout dark:shadow-elevation-flyout-dark rounded-docs_DEFAULT"
32 data-testid="default-layout"
33 >
34 <div className={clsx("flex gap-docs_1 p-docs_1")}>
35 {type !== "none" && (
36 <div
37 className={clsx(
38 type !== "custom" && "w-docs_2 flex justify-center items-center"
39 )}
40 >
41 {type === "info" && (
42 <InformationCircleSolid className="text-medusa-tag-blue-icon" />
43 )}
44 {type === "error" && (
45 <XCircleSolid className="text-medusa-tag-red-icon" />
46 )}
47 {type === "warning" && (
48 <ExclamationCircleSolid className="text-medusa-tag-orange-icon" />
49 )}
50 {type === "success" && (
51 <CheckCircleSolid className="text-medusa-tag-green-icon" />
52 )}
53 {type === "custom" && CustomIcon}
54 </div>
55 )}
56 <span
57 className={clsx("text-compact-medium-plus", "text-medusa-fg-base")}
58 data-testid="layout-title"
59 >
60 {title}
61 </span>
62 </div>
63 {(text || children) && (
64 <div
65 className={clsx(
66 "flex pt-0 pr-docs_1 pb-docs_1.5 pl-docs_1 gap-docs_1",
67 "border-0 border-b border-solid border-medusa-border-base"
68 )}
69 data-testid="layout-content"
70 >
71 <div className="w-docs_2 flex-none"></div>
72 <div className={clsx("flex flex-col", children && "gap-docs_1")}>
73 {text && (
74 <span className={clsx("text-medium text-medusa-fg-subtle")}>
75 {text}
76 </span>
77 )}
78 {children}
79 </div>
80 </div>
81 )}
82 {isClosable && (
83 <div className={clsx("p-docs_1 flex justify-end items-center")}>
84 <Button onClick={handleClose}>{closeButtonText}</Button>
85 </div>
86 )}
87 </div>
88 )
89 }