Skip to content

Commit

Permalink
feat(web): hide phone number info (#1111)
Browse files Browse the repository at this point in the history
  • Loading branch information
LeezQ authored May 6, 2023
1 parent 425b782 commit e4d8141
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 3 deletions.
4 changes: 2 additions & 2 deletions web/src/pages/app/setting/UserInfo/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import clsx from "clsx";
import { t } from "i18next";

import { COLOR_MODE } from "@/constants";
import { formatDate } from "@/utils/format";
import { formatDate, hidePhoneNumber } from "@/utils/format";

import AuthDetail from "./AuthDetail";

Expand Down Expand Up @@ -57,7 +57,7 @@ export default function UserInfo() {
<Box className="mb-20 mt-8 text-lg">
<HStack spacing={8}>
<span className="w-[80px] text-grayModern-500">{t("SettingPanel.Tel")}:</span>
<span>{userInfo?.phone ? userInfo.phone : t("NoInfo")}</span>
<span>{userInfo?.phone ? hidePhoneNumber(userInfo.phone) : t("NoInfo")}</span>
</HStack>
<HStack spacing={8} className="mt-2">
<span className="w-[80px] text-grayModern-500">{t("SettingPanel.Registered")}:</span>
Expand Down
4 changes: 3 additions & 1 deletion web/src/pages/home/mods/Empty/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import { Button, useColorMode } from "@chakra-ui/react";
import clsx from "clsx";

import { COLOR_MODE } from "@/constants";
import { hidePhoneNumber } from "@/utils/format";

import CreateAppModal from "../CreateAppModal";

Expand Down Expand Up @@ -31,7 +32,8 @@ function Empty() {
<div style={{ height: "75vh", minHeight: "500px" }}>
<div className="flex h-full flex-col items-center justify-center">
<h2 className="text-3xl font-bold">
{t("HomePanel.Hello")} 👋 , {userInfo?.profile?.name || userInfo?.username}{" "}
{t("HomePanel.Hello")} 👋 ,{" "}
{hidePhoneNumber(userInfo?.profile?.name || userInfo?.username || "")}
{t("HomePanel.Welcome")}
</h2>
<p className="mx-auto mb-8 mt-10 w-[460px] text-xl">{t("HomePanel.Introduction")}</p>
Expand Down
4 changes: 4 additions & 0 deletions web/src/utils/format.ts
Original file line number Diff line number Diff line change
Expand Up @@ -87,3 +87,7 @@ export function formatPrice(price: number) {
export function convertMoney(money: number) {
return money * 100;
}

export function hidePhoneNumber(phone: string) {
return phone.replace(/(\d{3})\d{4}(\d{4})/, "$1****$2");
}

0 comments on commit e4d8141

Please sign in to comment.