Skip to content

Commit

Permalink
fix(inbox): fix format data inbox for txs (#1627)
Browse files Browse the repository at this point in the history
  • Loading branch information
NguyenHuy1812 authored Mar 26, 2024
1 parent b7a7edb commit dc7c750
Showing 1 changed file with 19 additions and 4 deletions.
23 changes: 19 additions & 4 deletions src/commands/inbox/index/processor.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,9 @@ import {
EmojiKey,
emojis,
getEmoji,
getEmojiToken,
getEmojiURL,
TokenEmojiKey,
} from "utils/common"
import { APIError } from "errors"
import { composeEmbedMessage } from "ui/discord/embed"
Expand All @@ -23,7 +25,7 @@ type Context = {
page: number
}

const PAGE_SIZE = 5
const PAGE_SIZE = 10

export async function render(userDiscordId: string, ctx: Context) {
const dataProfile = await profile.getByDiscord(userDiscordId)
Expand Down Expand Up @@ -162,9 +164,22 @@ function toDescriptionList(list: any[], offset = 0) {
const date = new Date(el.created_at)
const t = `<t:${Math.floor(date.getTime() / 1000)}:R>`

return `${getEmoji(`NUM_${i + 1 + offset}` as EmojiKey)} ${t} ${
ActionTypeToEmoji(el.type) ?? getEmoji("ANIMATED_QUESTION_MARK", true)
} ${el.content}`
let formatContent = el.content.replace("Send", "+")
// Define the regex pattern to match the currency and amount
let regex = /(\+|\-) (\d+(\.\d+)? [A-Z]+) /g

// Replace the pattern with the formatted string
formatContent = formatContent.replace(regex, "**$&**")
if (el.token && el.token !== undefined) {
formatContent =
getEmojiToken(el.token.symbol as TokenEmojiKey) + formatContent
} else {
formatContent = getEmoji("ANIMATED_COIN_1", true) + formatContent
}

return `${getEmoji(
`NUM_${i + 1 + offset}` as EmojiKey,
)} ${t} ${formatContent}`
})
.join("\n")

Expand Down

0 comments on commit dc7c750

Please sign in to comment.