Badge notifications ui changes
This commit is contained in:
parent
f03e5d7af0
commit
4f5c93be96
|
@ -1,10 +1,10 @@
|
||||||
import { User } from 'common/user'
|
import { User } from 'common/user'
|
||||||
import { NextRouter } from 'next/router'
|
|
||||||
import { useEffect, useState } from 'react'
|
import { useEffect, useState } from 'react'
|
||||||
import { getBadgesByRarity } from 'common/badge'
|
import { getBadgesByRarity } from 'common/badge'
|
||||||
import { Row } from 'web/components/layout/row'
|
import { Row } from 'web/components/layout/row'
|
||||||
import clsx from 'clsx'
|
import clsx from 'clsx'
|
||||||
import { BadgesModal } from 'web/components/profile/badges-modal'
|
import { BadgesModal } from 'web/components/profile/badges-modal'
|
||||||
|
import { ParsedUrlQuery } from 'querystring'
|
||||||
|
|
||||||
export const goldClassName = 'text-amber-400'
|
export const goldClassName = 'text-amber-400'
|
||||||
export const silverClassName = 'text-gray-500'
|
export const silverClassName = 'text-gray-500'
|
||||||
|
@ -12,16 +12,16 @@ export const bronzeClassName = 'text-amber-900'
|
||||||
|
|
||||||
export function BadgeDisplay(props: {
|
export function BadgeDisplay(props: {
|
||||||
user: User | undefined | null
|
user: User | undefined | null
|
||||||
router?: NextRouter
|
query: ParsedUrlQuery
|
||||||
}) {
|
}) {
|
||||||
const { user, router } = props
|
const { user, query } = props
|
||||||
const [showBadgesModal, setShowBadgesModal] = useState(false)
|
const [showBadgesModal, setShowBadgesModal] = useState(false)
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
if (!router) return
|
const showBadgesModal = query['show'] == 'badges'
|
||||||
const showBadgesModal = router.query['show'] === 'badges'
|
|
||||||
setShowBadgesModal(showBadgesModal)
|
setShowBadgesModal(showBadgesModal)
|
||||||
}, [router])
|
// eslint-disable-next-line react-hooks/exhaustive-deps
|
||||||
|
}, [])
|
||||||
// get number of badges of each rarity type
|
// get number of badges of each rarity type
|
||||||
const badgesByRarity = getBadgesByRarity(user)
|
const badgesByRarity = getBadgesByRarity(user)
|
||||||
const badgesByRarityItems = Object.entries(badgesByRarity).map(
|
const badgesByRarityItems = Object.entries(badgesByRarity).map(
|
||||||
|
|
|
@ -50,8 +50,8 @@ export function UserPage(props: { user: User }) {
|
||||||
setShowConfetti(claimedMana)
|
setShowConfetti(claimedMana)
|
||||||
const query = { ...router.query }
|
const query = { ...router.query }
|
||||||
if (query.claimedMana || query.show) {
|
if (query.claimedMana || query.show) {
|
||||||
delete query['claimed-mana']
|
const queriesToDelete = ['claimed-mana', 'show', 'badge']
|
||||||
delete query['show']
|
queriesToDelete.forEach((key) => delete query[key])
|
||||||
router.replace(
|
router.replace(
|
||||||
{
|
{
|
||||||
pathname: router.pathname,
|
pathname: router.pathname,
|
||||||
|
@ -102,7 +102,7 @@ export function UserPage(props: { user: User }) {
|
||||||
</span>
|
</span>
|
||||||
<Row className="sm:text-md -mt-1 items-center gap-x-3 text-sm ">
|
<Row className="sm:text-md -mt-1 items-center gap-x-3 text-sm ">
|
||||||
<span className={' text-greyscale-4'}>@{user.username}</span>
|
<span className={' text-greyscale-4'}>@{user.username}</span>
|
||||||
<BadgeDisplay user={user} router={router} />
|
<BadgeDisplay user={user} query={router.query} />
|
||||||
</Row>
|
</Row>
|
||||||
</Col>
|
</Col>
|
||||||
{isCurrentUser && (
|
{isCurrentUser && (
|
||||||
|
|
|
@ -826,7 +826,8 @@ function NotificationFrame(props: {
|
||||||
subtitle: string
|
subtitle: string
|
||||||
children: React.ReactNode
|
children: React.ReactNode
|
||||||
isChildOfGroup?: boolean
|
isChildOfGroup?: boolean
|
||||||
showUserName?: boolean
|
hideUserName?: boolean
|
||||||
|
hideLinkToGroupOrQuestion?: boolean
|
||||||
}) {
|
}) {
|
||||||
const {
|
const {
|
||||||
notification,
|
notification,
|
||||||
|
@ -834,7 +835,8 @@ function NotificationFrame(props: {
|
||||||
highlighted,
|
highlighted,
|
||||||
subtitle,
|
subtitle,
|
||||||
children,
|
children,
|
||||||
showUserName,
|
hideUserName,
|
||||||
|
hideLinkToGroupOrQuestion,
|
||||||
} = props
|
} = props
|
||||||
const {
|
const {
|
||||||
sourceType,
|
sourceType,
|
||||||
|
@ -888,7 +890,7 @@ function NotificationFrame(props: {
|
||||||
}
|
}
|
||||||
>
|
>
|
||||||
<div>
|
<div>
|
||||||
{showUserName && (
|
{!hideUserName && (
|
||||||
<UserLink
|
<UserLink
|
||||||
name={sourceUserName || ''}
|
name={sourceUserName || ''}
|
||||||
username={sourceUserUsername || ''}
|
username={sourceUserUsername || ''}
|
||||||
|
@ -900,7 +902,9 @@ function NotificationFrame(props: {
|
||||||
{isChildOfGroup ? (
|
{isChildOfGroup ? (
|
||||||
<RelativeTimestamp time={notification.createdTime} />
|
<RelativeTimestamp time={notification.createdTime} />
|
||||||
) : (
|
) : (
|
||||||
|
!hideLinkToGroupOrQuestion && (
|
||||||
<QuestionOrGroupLink notification={notification} />
|
<QuestionOrGroupLink notification={notification} />
|
||||||
|
)
|
||||||
)}
|
)}
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
@ -1034,7 +1038,8 @@ function BadgeNotification(props: {
|
||||||
isChildOfGroup={isChildOfGroup}
|
isChildOfGroup={isChildOfGroup}
|
||||||
highlighted={highlighted}
|
highlighted={highlighted}
|
||||||
subtitle={subtitle}
|
subtitle={subtitle}
|
||||||
showUserName={false}
|
hideUserName={true}
|
||||||
|
hideLinkToGroupOrQuestion={true}
|
||||||
>
|
>
|
||||||
<Row>
|
<Row>
|
||||||
<span>{sourceText} 🎉</span>
|
<span>{sourceText} 🎉</span>
|
||||||
|
|
Loading…
Reference in New Issue
Block a user