Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: profile statistics zero label #3965

Merged
merged 1 commit into from
Oct 28, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 7 additions & 7 deletions packages/components/src/UserStatistics/UserStatistics.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ export interface UserStatisticsProps {
howtoCount: number
usefulCount: number
researchCount: number
totalViews?: number
totalViews: number
sx?: ThemeUIStyleObject | undefined
}

Expand Down Expand Up @@ -74,40 +74,40 @@ export const UserStatistics = (props: UserStatisticsProps) => {
</InternalLink>
)}

{props.usefulCount && (
{props.usefulCount > 0 && (
<Flex data-testid="useful-stat">
<ElWithBeforeIcon icon={starActiveSVG} />
{`Useful: ${props.usefulCount}`}
</Flex>
)}

{props.howtoCount && (
{props.howtoCount > 0 && (
<InternalLink
to={'/how-to?q=' + props.userName}
sx={{ color: 'black' }}
data-testid="howto-link"
>
<Flex data-testid="howto-stat">
<ElWithBeforeIcon icon={HowToCountIcon} />
Howto:&nbsp;{props.howtoCount}
{`How-to: ${props.howtoCount}`}
</Flex>
</InternalLink>
)}

{props.researchCount && (
{props.researchCount > 0 && (
<InternalLink
to={'/research?q=' + props.userName}
sx={{ color: 'black' }}
data-testid="research-link"
>
<Flex data-testid="research-stat">
<ElWithBeforeIcon icon={ResearchIcon} />
Research:&nbsp;{props.researchCount}
{`Research: ${props.researchCount}`}
</Flex>
</InternalLink>
)}

{props.totalViews && (
{props.totalViews > 0 && (
<Flex data-testid="profile-views-stat">
<Icon glyph="view" size={22} />
<Box ml={1}>{`Views: ${props.totalViews}`}</Box>
Expand Down
3 changes: 2 additions & 1 deletion src/pages/User/content/MemberProfile.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,7 @@ export const MemberProfile = ({ docs, user }: IProps) => {
howtoCount={docs?.howtos.length || 0}
researchCount={docs?.research.length || 0}
usefulCount={user.totalUseful || 0}
totalViews={0}
sx={{ alignSelf: 'stretch' }}
/>
}
Expand All @@ -107,7 +108,7 @@ export const MemberProfile = ({ docs, user }: IProps) => {
researchCount={docs?.research.length || 0}
usefulCount={user.totalUseful || 0}
sx={{ alignSelf: 'stretch' }}
totalViews={user.total_views}
totalViews={user.total_views || 0}
/>
</AuthWrapper>
</Flex>
Expand Down
3 changes: 2 additions & 1 deletion src/pages/User/content/SpaceProfile.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -275,6 +275,7 @@ export const SpaceProfile = ({ user, docs }: IProps) => {
howtoCount={docs?.howtos.length || 0}
usefulCount={user.totalUseful || 0}
researchCount={docs?.research.length || 0}
totalViews={0}
/>
}
>
Expand All @@ -286,7 +287,7 @@ export const SpaceProfile = ({ user, docs }: IProps) => {
howtoCount={docs?.howtos.length || 0}
usefulCount={user.totalUseful || 0}
researchCount={docs?.research.length || 0}
totalViews={user.total_views}
totalViews={user.total_views || 0}
/>
</AuthWrapper>
</Box>
Expand Down
Loading