forked from owid/owid-grapher
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathgdocsNotifications.tsx
44 lines (40 loc) · 1.34 KB
/
gdocsNotifications.tsx
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
import React from "react"
import { notification } from "antd"
import { OwidGdocErrorMessageType } from "@ourworldindata/utils"
import { match } from "ts-pattern"
type NotificationType = "success" | "info" | OwidGdocErrorMessageType
const openNotification = (
type: NotificationType,
title: string,
description: React.ReactNode
) => {
notification[type]({
message: title,
description,
placement: "bottomLeft",
closeIcon: <></>,
})
}
type SuccessNotificationType = "draft" | "published" | "unpublished"
export const openSuccessNotification = (type: SuccessNotificationType) => {
const content = match(type)
.with("draft", () => "Your changes have been saved as a draft.")
.with("published", () => (
<>
Your changes have been scheduled for publication.{" "}
<a href="/admin/deploys" target="deploy">
Check deploy progress
</a>
</>
))
.with("unpublished", () => (
<>
Your changes have been scheduled for unpublishing.{" "}
<a href="/admin/deploys" target="deploy">
Check deploy progress
</a>
</>
))
.exhaustive()
openNotification("success", "Document saved", <span>{content}</span>)
}