You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@answer.apache.org by ro...@apache.org on 2024/09/03 03:59:19 UTC

(incubator-answer) 03/04: refactor: Update badge labels to use multiplication symbol instead of 'x'

This is an automated email from the ASF dual-hosted git repository.

robin0716 pushed a commit to branch test
in repository https://gitbox.apache.org/repos/asf/incubator-answer.git

commit ca8c4b40c653858dbcd3ad70e6c1790577bf755d
Author: robin <ro...@rnode.me>
AuthorDate: Tue Sep 3 11:05:03 2024 +0800

    refactor: Update badge labels to use multiplication symbol instead of 'x'
---
 ui/src/components/CardBadge/index.tsx                   | 10 ++++++----
 ui/src/pages/Badges/Detail/components/Badge/index.tsx   |  5 ++++-
 ui/src/pages/Users/Personal/components/NavBar/index.tsx |  1 -
 3 files changed, 10 insertions(+), 6 deletions(-)

diff --git a/ui/src/components/CardBadge/index.tsx b/ui/src/components/CardBadge/index.tsx
index fcb1bb9d..a2a0bd7d 100644
--- a/ui/src/components/CardBadge/index.tsx
+++ b/ui/src/components/CardBadge/index.tsx
@@ -49,14 +49,16 @@ const Index: FC<IProps> = ({
       className="card text-center badge-card"
       to={`/badges/${data.id}${urlSearchParams ? `?${urlSearchParams}` : ''}`}>
       <Card.Body>
-        {data.earned && badgePillType === 'earned' && (
+        {Number(data?.earned_count) > 0 && badgePillType === 'earned' && (
           <Badge bg="success" className="label">
-            {t('earned')}
+            {`${t('earned')}${
+              Number(data?.earned_count) > 1 ? ` ×${data.earned_count}` : ''
+            }`}
           </Badge>
         )}
 
-        {badgePillType === 'count' && Number(data?.earned_count) > 0 && (
-          <Badge pill bg="success" className="label">
+        {badgePillType === 'count' && Number(data?.earned_count) > 1 && (
+          <Badge pill bg="secondary" className="label">
             ×{data.earned_count}
           </Badge>
         )}
diff --git a/ui/src/pages/Badges/Detail/components/Badge/index.tsx b/ui/src/pages/Badges/Detail/components/Badge/index.tsx
index 29da1af6..a554a6bc 100644
--- a/ui/src/pages/Badges/Detail/components/Badge/index.tsx
+++ b/ui/src/pages/Badges/Detail/components/Badge/index.tsx
@@ -77,11 +77,14 @@ const Index: FC<IProps> = ({ data }) => {
                 </span>
               )}
 
-              {data.earned_count > 0 && (
+              {data.earned_count > 1 && (
                 <Badge bg="success">
                   {t('earned_×', { number: data.earned_count })}
                 </Badge>
               )}
+              {data.earned_count === 1 && (
+                <Badge bg="success">{t('earned')}</Badge>
+              )}
             </div>
           )}
         </div>
diff --git a/ui/src/pages/Users/Personal/components/NavBar/index.tsx b/ui/src/pages/Users/Personal/components/NavBar/index.tsx
index 5f4360ed..9c6d157a 100644
--- a/ui/src/pages/Users/Personal/components/NavBar/index.tsx
+++ b/ui/src/pages/Users/Personal/components/NavBar/index.tsx
@@ -60,7 +60,6 @@ const list = [
     name: 'votes',
   },
   {
-    role: 'self', // Only visible to author
     path: '/badges',
     name: 'badges',
   },