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

feat: Added grouping qi activities by date #398

Merged
merged 2 commits into from
Oct 30, 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
4 changes: 2 additions & 2 deletions background/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -511,7 +511,7 @@ export default class Main extends BaseService<never> {
const { balances } = currentAccountState
for (const assetSymbol in balances) {
const { asset, amount } = balances[assetSymbol].assetAmount
let newBalance = BigInt(0)
let newBalance = amount ?? BigInt(0)
if (isSmartContractFungibleAsset(asset)) {
if (
getExtendedZoneForAddress(asset.contractAddress, false) !==
Expand All @@ -525,7 +525,7 @@ export default class Main extends BaseService<never> {
asset.contractAddress
)
).amount
} else {
} else if (!isBuiltInNetworkBaseAsset(asset, selectedAccount.network)) {
logger.error(
`Unknown asset type for balance checker, asset: ${asset.symbol}`
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import React, { useState } from "react"
import { useTranslation } from "react-i18next"
import { selectCurrentAccountUtxoActivities } from "@pelagus/pelagus-background/redux-slices/selectors"
import { QiTransactionDB } from "@pelagus/pelagus-background/services/transactions/types"
import _ from "lodash"
import UtxoActivityModal from "../UtxoActivityModal/UtxoActivityModal"
import SharedUtxoActivityTab from "../../../Shared/_newDeisgn/utxoActivityTab/SharedUtxoActivityTab"
import { useBackgroundSelector } from "../../../../hooks"
Expand Down Expand Up @@ -41,27 +42,40 @@ const UtxoActivityList = () => {
</span>
)

const groupedQiActivities = _(qiActivities)
.groupBy((v) =>
new Date(v.timestamp).toLocaleDateString("en-US", {
month: "long",
day: "numeric",
timeZone: "UTC",
})
)
.value()

return (
<>
<div className="qi-activity-list">
{qiActivities.map((activity) => (
<button
key={activity.hash}
className="qi-activity-item"
type="button"
aria-label={activity.hash}
onClick={() => reviewQiActivityHandle(activity)}
>
<SharedUtxoActivityTab
aria-label={activity.hash}
status={activity.status}
type={activity.type}
value={activity.value}
{Object.entries(groupedQiActivities).map(([date, activities]) => (
<div className="qi-activity-list">
<h3 className="date-heading">{date}</h3>
{activities.map((activity) => (
<button
key={activity.hash}
/>
</button>
))}
</div>
className="qi-activity-item"
type="button"
aria-label={activity.hash}
onClick={() => reviewQiActivityHandle(activity)}
>
<SharedUtxoActivityTab
aria-label={activity.hash}
status={activity.status}
type={activity.type}
value={activity.value}
key={activity.hash}
/>
</button>
))}
</div>
))}

{qiActivity && isOpenUtxoActivityModal && (
<UtxoActivityModal
Expand All @@ -74,7 +88,15 @@ const UtxoActivityList = () => {
.qi-activity-list {
display: flex;
flex-direction: column;
margin-bottom: 8px;
margin-bottom: 16px;
}

.date-heading {
font-weight: 500;
font-size: 12px;
line-height: 18px;
color: var(--secondary-text);
margin: 0 24px 4px 24px;
}

.qi-activity-item {
Expand Down