diff --git a/apps/app/components/analytics/custom-analytics/sidebar.tsx b/apps/app/components/analytics/custom-analytics/sidebar.tsx index b533df519..418d87c4a 100644 --- a/apps/app/components/analytics/custom-analytics/sidebar.tsx +++ b/apps/app/components/analytics/custom-analytics/sidebar.tsx @@ -23,6 +23,7 @@ import { import { ContrastIcon, LayerDiagonalIcon } from "components/icons"; // helpers import { renderShortDate } from "helpers/date-time.helper"; +import { renderEmoji } from "helpers/emoji.helper"; // types import { IAnalyticsParams, @@ -221,7 +222,7 @@ export const AnalyticsSidebar: React.FC = ({
{project.emoji ? ( - {String.fromCodePoint(parseInt(project.emoji))} + {renderEmoji(project.emoji)} ) : project.icon_prop ? (
@@ -336,7 +337,7 @@ export const AnalyticsSidebar: React.FC = ({
{projectDetails?.emoji ? (
- {String.fromCodePoint(parseInt(projectDetails.emoji))} + {renderEmoji(projectDetails.emoji)}
) : projectDetails?.icon_prop ? (
diff --git a/apps/app/components/emoji-icon-picker/index.tsx b/apps/app/components/emoji-icon-picker/index.tsx index f8f8e54e9..fecba1c15 100644 --- a/apps/app/components/emoji-icon-picker/index.tsx +++ b/apps/app/components/emoji-icon-picker/index.tsx @@ -10,7 +10,7 @@ import emojis from "./emojis.json"; import icons from "./icons.json"; // helpers import { getRecentEmojis, saveRecentEmoji } from "./helpers"; -import { getRandomEmoji } from "helpers/common.helper"; +import { getRandomEmoji, renderEmoji } from "helpers/emoji.helper"; // hooks import useOutsideClickDetector from "hooks/use-outside-click-detector"; @@ -101,7 +101,7 @@ const EmojiIconPicker: React.FC = ({ label, value, onChange, onIconColorC setIsOpen(false); }} > - {String.fromCodePoint(parseInt(emoji))} + {renderEmoji(emoji)} ))}
@@ -121,7 +121,7 @@ const EmojiIconPicker: React.FC = ({ label, value, onChange, onIconColorC setIsOpen(false); }} > - {String.fromCodePoint(parseInt(emoji))} + {renderEmoji(emoji)} ))}
diff --git a/apps/app/components/project/create-project-modal.tsx b/apps/app/components/project/create-project-modal.tsx index 06fc73348..f17558d9b 100644 --- a/apps/app/components/project/create-project-modal.tsx +++ b/apps/app/components/project/create-project-modal.tsx @@ -21,7 +21,7 @@ import { XMarkIcon } from "@heroicons/react/24/outline"; import { ImagePickerPopover } from "components/core"; import EmojiIconPicker from "components/emoji-icon-picker"; // helpers -import { getRandomEmoji } from "helpers/common.helper"; +import { getRandomEmoji, renderEmoji } from "helpers/emoji.helper"; // types import { ICurrentUserResponse, IProject } from "types"; // fetch-keys @@ -232,7 +232,7 @@ export const CreateProjectModal: React.FC = (props) => { {value.name} ) : ( - String.fromCodePoint(parseInt(value)) + renderEmoji(value) ) ) : ( "Icon" diff --git a/apps/app/components/project/single-project-card.tsx b/apps/app/components/project/single-project-card.tsx index 9b7bf1c99..b4fe9c1b1 100644 --- a/apps/app/components/project/single-project-card.tsx +++ b/apps/app/components/project/single-project-card.tsx @@ -24,6 +24,7 @@ import { // helpers import { renderShortDateWithYearFormat } from "helpers/date-time.helper"; import { copyTextToClipboard, truncateText } from "helpers/string.helper"; +import { renderEmoji } from "helpers/emoji.helper"; // types import type { IFavoriteProject, IProject } from "types"; // fetch-keys @@ -184,7 +185,7 @@ export const SingleProjectCard: React.FC = ({

{project.name}

{project.emoji ? ( - {String.fromCodePoint(parseInt(project.emoji))} + {renderEmoji(project.emoji)} ) : project.icon_prop ? ( = ({
{project.emoji ? ( - {String.fromCodePoint(parseInt(project.emoji))} + {renderEmoji(project.emoji)} ) : project.icon_prop ? (
diff --git a/apps/app/helpers/common.helper.ts b/apps/app/helpers/common.helper.ts index 887fe8052..4220a7174 100644 --- a/apps/app/helpers/common.helper.ts +++ b/apps/app/helpers/common.helper.ts @@ -16,23 +16,3 @@ export const debounce = (func: any, wait: number, immediate: boolean = false) => if (callNow) func(...args); }; }; - -export const getRandomEmoji = () => { - const emojis = [ - "8986", - "9200", - "128204", - "127773", - "127891", - "127947", - "128076", - "128077", - "128187", - "128188", - "128512", - "128522", - "128578", - ]; - - return emojis[Math.floor(Math.random() * emojis.length)]; -}; diff --git a/apps/app/helpers/emoji.helper.ts b/apps/app/helpers/emoji.helper.ts new file mode 100644 index 000000000..f16d0021c --- /dev/null +++ b/apps/app/helpers/emoji.helper.ts @@ -0,0 +1,25 @@ +export const getRandomEmoji = () => { + const emojis = [ + "8986", + "9200", + "128204", + "127773", + "127891", + "127947", + "128076", + "128077", + "128187", + "128188", + "128512", + "128522", + "128578", + ]; + + return emojis[Math.floor(Math.random() * emojis.length)]; +}; + +export const renderEmoji = (emoji: string) => { + if (!emoji) return; + + return isNaN(parseInt(emoji)) ? emoji : String.fromCodePoint(parseInt(emoji)); +}; diff --git a/apps/app/pages/[workspaceSlug]/projects/[projectId]/settings/index.tsx b/apps/app/pages/[workspaceSlug]/projects/[projectId]/settings/index.tsx index 92b55cebe..e8ac1d9d0 100644 --- a/apps/app/pages/[workspaceSlug]/projects/[projectId]/settings/index.tsx +++ b/apps/app/pages/[workspaceSlug]/projects/[projectId]/settings/index.tsx @@ -27,6 +27,8 @@ import { DangerButton, } from "components/ui"; import { BreadcrumbItem, Breadcrumbs } from "components/breadcrumbs"; +// helpers +import { renderEmoji } from "helpers/emoji.helper"; // types import { IProject, IWorkspace } from "types"; import type { NextPage } from "next"; @@ -186,7 +188,7 @@ const GeneralSettings: NextPage = () => { {value.name} ) : ( - String.fromCodePoint(parseInt(value)) + renderEmoji(value) ) ) : ( "Icon"