Skip to content

Commit

Permalink
feat(core): add icon to marketing notification
Browse files Browse the repository at this point in the history
  • Loading branch information
UncleSamtoshi committed May 10, 2024
1 parent 5ff1d2e commit 674d6c2
Show file tree
Hide file tree
Showing 13 changed files with 681 additions and 1 deletion.
56 changes: 56 additions & 0 deletions apps/admin-panel/generated.ts
Original file line number Diff line number Diff line change
Expand Up @@ -351,6 +351,7 @@ export type LocalizedNotificationContentInput = {
};

export type MarketingNotificationTriggerInput = {
readonly icon?: InputMaybe<NotificationIcon>;
readonly localizedNotificationContents: ReadonlyArray<LocalizedNotificationContentInput>;
readonly openDeepLink?: InputMaybe<OpenDeepLinkInput>;
readonly openExternalUrl?: InputMaybe<OpenExternalUrlInput>;
Expand Down Expand Up @@ -428,6 +429,61 @@ export type MutationUserUpdatePhoneArgs = {
input: UserUpdatePhoneInput;
};

export const NotificationIcon = {
ArrowLeft: 'ARROW_LEFT',
ArrowRight: 'ARROW_RIGHT',
Backspace: 'BACKSPACE',
Bank: 'BANK',
Bell: 'BELL',
Bitcoin: 'BITCOIN',
Book: 'BOOK',
BtcBook: 'BTC_BOOK',
CaretDown: 'CARET_DOWN',
CaretLeft: 'CARET_LEFT',
CaretRight: 'CARET_RIGHT',
CaretUp: 'CARET_UP',
Check: 'CHECK',
CheckCircle: 'CHECK_CIRCLE',
Close: 'CLOSE',
CloseCrossWithBackground: 'CLOSE_CROSS_WITH_BACKGROUND',
Coins: 'COINS',
CopyPaste: 'COPY_PASTE',
Dollar: 'DOLLAR',
Eye: 'EYE',
EyeSlash: 'EYE_SLASH',
Filter: 'FILTER',
Globe: 'GLOBE',
Graph: 'GRAPH',
Image: 'IMAGE',
Info: 'INFO',
Lightning: 'LIGHTNING',
Link: 'LINK',
Loading: 'LOADING',
MagnifyingGlass: 'MAGNIFYING_GLASS',
Map: 'MAP',
Menu: 'MENU',
Note: 'NOTE',
PaymentError: 'PAYMENT_ERROR',
PaymentPending: 'PAYMENT_PENDING',
PaymentSuccess: 'PAYMENT_SUCCESS',
Pencil: 'PENCIL',
People: 'PEOPLE',
QrCode: 'QR_CODE',
Question: 'QUESTION',
Rank: 'RANK',
Receive: 'RECEIVE',
Refresh: 'REFRESH',
Send: 'SEND',
Settings: 'SETTINGS',
Share: 'SHARE',
Transfer: 'TRANSFER',
User: 'USER',
Video: 'VIDEO',
Warning: 'WARNING',
WarningWithBackground: 'WARNING_WITH_BACKGROUND'
} as const;

export type NotificationIcon = typeof NotificationIcon[keyof typeof NotificationIcon];
export type OpenDeepLinkInput = {
readonly action?: InputMaybe<DeepLinkAction>;
readonly screen?: InputMaybe<DeepLinkScreen>;
Expand Down
1 change: 1 addition & 0 deletions core/api/src/app/admin/index.types.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ type AdminTriggerMarketingNotificationArgs = {
shouldSendPush: boolean
shouldAddToHistory: boolean
shouldAddToBulletin: boolean
icon?: Icon
localizedNotificationContents: {
title: string
body: string
Expand Down
2 changes: 2 additions & 0 deletions core/api/src/app/admin/trigger-marketing-notification.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ export const triggerMarketingNotification = async ({
openDeepLink,
openExternalUrl,
shouldSendPush,
icon,
shouldAddToHistory,
shouldAddToBulletin,
localizedNotificationContents,
Expand Down Expand Up @@ -51,6 +52,7 @@ export const triggerMarketingNotification = async ({
shouldSendPush,
shouldAddToHistory,
shouldAddToBulletin,
icon,
localizedContents: localizedNotificationContentsMap,
})
}
54 changes: 54 additions & 0 deletions core/api/src/domain/notifications/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,60 @@ export const DeepLinkAction = {
UpgradeAccountModal: "UpgradeAccountModal",
} as const

export const Icon = {
ArrowRight: "ArrowRight",
ArrowLeft: "ArrowLeft",
BackSpace: "BackSpace",
Bank: "Bank",
Bitcoin: "Bitcoin",
Book: "Book",
BtcBook: "BtcBook",
CaretDown: "CaretDown",
CaretLeft: "CaretLeft",
CaretRight: "CaretRight",
CaretUp: "CaretUp",
CheckCircle: "CheckCircle",
Check: "Check",
Close: "Close",
CloseCrossWithBackground: "CloseCrossWithBackground",
Coins: "Coins",
People: "People",
CopyPaste: "CopyPaste",
Dollar: "Dollar",
EyeSlash: "EyeSlash",
Eye: "Eye",
Filter: "Filter",
Globe: "Globe",
Graph: "Graph",
Image: "Image",
Info: "Info",
Lightning: "Lightning",
Link: "Link",
Loading: "Loading",
MagnifyingGlass: "MagnifyingGlass",
Map: "Map",
Menu: "Menu",
Pencil: "Pencil",
Note: "Note",
Rank: "Rank",
QrCode: "QrCode",
Question: "Question",
Receive: "Receive",
Send: "Send",
Settings: "Settings",
Share: "Share",
Transfer: "Transfer",
User: "User",
Video: "Video",
Warning: "Warning",
WarningWithBackground: "WarningWithBackground",
PaymentSuccess: "PaymentSuccess",
PaymentPending: "PaymentPending",
PaymentError: "PaymentError",
Bell: "Bell",
Refresh: "Refresh",
} as const

export const checkedToLocalizedNotificationTitle = (
title: string,
): LocalizedNotificationTitle | ValidationError => {
Expand Down
3 changes: 3 additions & 0 deletions core/api/src/domain/notifications/index.types.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,8 @@ type DeepLinkScreen =
type DeepLinkAction =
(typeof import("./index").DeepLinkAction)[keyof typeof import("./index").DeepLinkAction]

type Icon = (typeof import("./index").Icon)[keyof typeof import("./index").Icon]

type LocalizedNotificationTitle = string & { readonly brand: unique symbol }

type LocalizedNotificationBody = string & { readonly brand: unique symbol }
Expand Down Expand Up @@ -151,5 +153,6 @@ type TriggerMarketingNotificationArgs = {
shouldSendPush: boolean
shouldAddToHistory: boolean
shouldAddToBulletin: boolean
icon?: Icon
localizedContents: Map<UserLanguage, LocalizedNotificationContent>
}
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import DeepLinkScreen from "@/graphql/admin/types/scalar/deep-link-screen"
import SuccessPayload from "@/graphql/shared/types/payload/success-payload"
import DeepLinkAction from "@/graphql/admin/types/scalar/deep-link-action"
import ExternalUrl from "@/graphql/admin/types/scalar/external-url"
import NotificationIcon from "@/graphql/admin/types/scalar/notification-icon"

const LocalizedNotificationContentInput = GT.Input({
name: "LocalizedNotificationContentInput",
Expand Down Expand Up @@ -68,6 +69,9 @@ const MarketingNotificationTriggerInput = GT.Input({
openExternalUrl: {
type: OpenExternalUrlInput,
},
icon: {
type: NotificationIcon,
},
localizedNotificationContents: {
type: GT.NonNullList(LocalizedNotificationContentInput),
},
Expand All @@ -84,6 +88,7 @@ const MarketingNotificationTriggerMutation = GT.Field<
shouldSendPush: boolean
shouldAddToHistory: boolean
shouldAddToBulletin: boolean
icon: Icon | Error | undefined
openDeepLink:
| {
screen: DeepLinkScreen | Error | undefined
Expand Down Expand Up @@ -113,6 +118,7 @@ const MarketingNotificationTriggerMutation = GT.Field<
shouldSendPush,
shouldAddToHistory,
shouldAddToBulletin,
icon,
openDeepLink,
openExternalUrl,
localizedNotificationContents,
Expand Down Expand Up @@ -142,6 +148,10 @@ const MarketingNotificationTriggerMutation = GT.Field<
}
}

if (icon instanceof Error) {
return { errors: [{ message: icon.message }], success: false }
}

let nonErrorOpenExternalUrl = undefined
if (openExternalUrl) {
if (openExternalUrl.url instanceof Error) {
Expand Down Expand Up @@ -185,6 +195,7 @@ const MarketingNotificationTriggerMutation = GT.Field<
shouldSendPush,
shouldAddToHistory,
shouldAddToBulletin,
icon,
localizedNotificationContents: nonErrorLocalizedNotificationContents,
})

Expand Down
55 changes: 55 additions & 0 deletions core/api/src/graphql/admin/schema.graphql
Original file line number Diff line number Diff line change
Expand Up @@ -299,6 +299,7 @@ input LocalizedNotificationContentInput {
}

input MarketingNotificationTriggerInput {
icon: NotificationIcon
localizedNotificationContents: [LocalizedNotificationContentInput!]!
openDeepLink: OpenDeepLinkInput
openExternalUrl: OpenExternalUrlInput
Expand Down Expand Up @@ -350,6 +351,60 @@ type Mutation {
userUpdatePhone(input: UserUpdatePhoneInput!): AccountDetailPayload!
}

enum NotificationIcon {
ARROW_LEFT
ARROW_RIGHT
BACKSPACE
BANK
BELL
BITCOIN
BOOK
BTC_BOOK
CARET_DOWN
CARET_LEFT
CARET_RIGHT
CARET_UP
CHECK
CHECK_CIRCLE
CLOSE
CLOSE_CROSS_WITH_BACKGROUND
COINS
COPY_PASTE
DOLLAR
EYE
EYE_SLASH
FILTER
GLOBE
GRAPH
IMAGE
INFO
LIGHTNING
LINK
LOADING
MAGNIFYING_GLASS
MAP
MENU
NOTE
PAYMENT_ERROR
PAYMENT_PENDING
PAYMENT_SUCCESS
PENCIL
PEOPLE
QR_CODE
QUESTION
RANK
RECEIVE
REFRESH
SEND
SETTINGS
SHARE
TRANSFER
USER
VIDEO
WARNING
WARNING_WITH_BACKGROUND
}

"""An address for an on-chain bitcoin destination"""
scalar OnChainAddress

Expand Down
Loading

0 comments on commit 674d6c2

Please sign in to comment.