Skip to content
This repository was archived by the owner on Oct 27, 2023. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
40 commits
Select commit Hold shift + click to select a range
acfdf1a
Bepro 1370 fix UI bounty hall logos main nav logo and bounty hero sta…
MarcusviniciusLsantos Mar 8, 2023
46ad43d
DEV-982 Know Your Client (#860)
moshmage Mar 9, 2023
640ce2a
Bepro 1414 is possible to config fees to 100 (#882)
vhcsilva Mar 9, 2023
b48480e
fix condition to update network (#908)
MarcusviniciusLsantos Mar 9, 2023
7e517c3
Bepro 1465 explore icon not aligned with rest of nav (#909)
MarcusviniciusLsantos Mar 9, 2023
466eada
fix fundedAmount logic (#905)
MarcusviniciusLsantos Mar 9, 2023
43ede48
fix order disabled disputed button (#904)
MarcusviniciusLsantos Mar 9, 2023
80a23f6
adding text-truncate (#917)
MarcusviniciusLsantos Mar 13, 2023
461ea3d
Bepro 1410 governance tab missing individual fees configuration (#902)
vhcsilva Mar 14, 2023
25db483
adding currency and amount (#920)
vhcsilva Mar 21, 2023
fefd6b3
Bepro 1474 filter options dont work on bounty hall (#921)
vhcsilva Mar 21, 2023
fedc87e
redirect to curators page and change condition to handle default tab …
vhcsilva Mar 21, 2023
e81bee7
Bepro 1486 apply new navbar design (#924)
vhcsilva Mar 21, 2023
6cae9a2
Dev 961 multichain - vhcsilva (#931)
vhcsilva Mar 22, 2023
c7c4951
adding new profile page style (#923)
vhcsilva Mar 22, 2023
4eac694
Dev 1501 new events (#928)
vhcsilva Mar 22, 2023
1a1eb13
Bepro 1498 create network item component (#933)
MarcusviniciusLsantos Mar 23, 2023
4456ec8
adjusting payments endpoint to new logic
MarcusviniciusLsantos Mar 24, 2023
ac3c66c
adjusting styles form-control and date icon
MarcusviniciusLsantos Mar 24, 2023
bfb0513
adding CalendarBlank svg to use in css content
MarcusviniciusLsantos Mar 24, 2023
313a2bd
refactoring Payments-list to new logic
MarcusviniciusLsantos Mar 24, 2023
5b4f6da
adding all networks logic to payments
MarcusviniciusLsantos Mar 24, 2023
8e6881e
adjusting Payment interface
MarcusviniciusLsantos Mar 24, 2023
f9d3cc9
adding bg and new params to payment-item
MarcusviniciusLsantos Mar 24, 2023
69af460
adding handleNetworkLink to Button network-item
MarcusviniciusLsantos Mar 24, 2023
339aefe
Bepro 1499 support multi network on my bounties and multi network des…
vhcsilva Mar 24, 2023
a5efe28
Merge branch 'dev' of https://github.com/bepronetwork/web-network int…
MarcusviniciusLsantos Mar 24, 2023
277b780
adjusting totalConverted
MarcusviniciusLsantos Mar 24, 2023
ee236a3
script done (#936)
vhcsilva Mar 27, 2023
3d699fc
Merge branch 'dev' into BEPRO-1498-redesign-payments-page-multi-netwo…
MarcusviniciusLsantos Mar 27, 2023
ef8d25e
Use chainid data (#937)
moshmage Mar 28, 2023
17ad5ff
Merge branch 'dev' into BEPRO-1498-redesign-payments-page-multi-netwo…
MarcusviniciusLsantos Mar 28, 2023
27f510c
fix save network and token relation (#940)
vhcsilva Mar 28, 2023
fc2d8ed
fix kyc navigation and kyc-logic on bounty.tsx
moshmage Mar 29, 2023
4c227f2
Merge branch 'dev' into BEPRO-1498-redesign-payments-page-multi-netwo…
MarcusviniciusLsantos Mar 29, 2023
58cc5cc
adding logic to total payments by network
MarcusviniciusLsantos Mar 30, 2023
f3736c1
Merge branch 'BEPRO-1498-redesign-payments-page-multi-network-only' o…
MarcusviniciusLsantos Mar 30, 2023
a6dda34
Merge branch 'dev' of https://github.com/bepronetwork/web-network int…
MarcusviniciusLsantos Mar 30, 2023
c45e430
Merge branch 'dev' into BEPRO-1498-redesign-payments-page-multi-netwo…
MarcusviniciusLsantos Apr 3, 2023
ecacee9
Merge branch 'dev' into BEPRO-1498-redesign-payments-page-multi-netwo…
MarcusviniciusLsantos Apr 3, 2023
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
3 changes: 3 additions & 0 deletions assets/CalendarBlank.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 1 addition & 1 deletion components/profile/network-item.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@ export default function NetworkItem({
<FlexRow>
{renderAmount()}
{handleNetworkLink && (
<Button className="button-gray-850 ms-3">
<Button className="button-gray-850 ms-3" onClick={handleNetworkLink}>
<span>{t("go-to-network")}</span>{" "}
<ArrowUpRight className="w-9-p h-9-p" />
</Button>
Expand Down
63 changes: 47 additions & 16 deletions components/profile/pages/payments.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -15,14 +15,22 @@ import {useAppState} from "contexts/app-state";

import {formatNumberToCurrency} from "helpers/formatNumber";

import { Network } from "interfaces/network";
import {Payment} from "interfaces/payments";

import {getCoinPrice} from "services/coingecko";

import useApi from "x-hooks/use-api";

export interface TotalFiatNetworks {
tokenAddress: string;
value: number;
price: number;
networkId: number;
}

export default function PaymentsPage() {
const { t } = useTranslation(["common", "profile"]);
const { t } = useTranslation(["common", "profile", "custom-network"]);

const defaultOptions = [
{
Expand All @@ -39,8 +47,10 @@ export default function PaymentsPage() {
},
];

const [totalEuro, setTotalEuro] = useState(0);
const [totalFiat, setTotalFiat] = useState(0);
const [totalFiatNetworks, setTotalFiatNetworks] = useState<TotalFiatNetworks[]>([])
const [payments, setPayments] = useState<Payment[]>([]);
const [networks, setNetworks] = useState<Network[]>([]);
const [hasNoConvertedToken, setHasNoConvertedToken] = useState(false);

const {state} = useAppState();
Expand All @@ -62,27 +72,43 @@ export default function PaymentsPage() {
}

useEffect(() => {
if (!state.currentUser?.walletAddress || !state.Service?.network?.active?.name) return;
if (!state.currentUser?.walletAddress) return;

getPayments(state.currentUser.walletAddress, startDate, endDate).then(setPayments);
}, [state.currentUser?.walletAddress, startDate, endDate]);

getPayments(state.currentUser.walletAddress, state.Service?.network?.active.name, startDate, endDate)
.then(setPayments);
}, [state.currentUser?.walletAddress, state.Service?.network?.active?.name, startDate, endDate]);
useEffect(() => {
if (!payments) return;
const allNetworks: Network[] = [];
payments.map((payment) => {
if (
!networks.find((network) => network?.id === payment?.issue?.network?.id) &&
!allNetworks.find((network) => network?.id === payment?.issue?.network?.id)
) {
allNetworks.push(payment?.issue?.network);
setNetworks(allNetworks);
}
});
}, [payments]);

useEffect(() => {
if (!payments?.length) return;

Promise.all(payments.map(async (payment) => ({
tokenAddress: payment.issue.transactionalToken.address,
tokenAddress: payment?.issue?.transactionalToken?.address,
value: payment.ammount,
price: await getCoinPrice(payment.issue.transactionalToken.symbol, state?.Settings.currency.defaultFiat),
price: await getCoinPrice(payment?.issue?.transactionalToken?.symbol, state?.Settings.currency.defaultFiat),
networkId: payment?.issue?.network_id
}))).then((tokens) => {
const totalConverted = tokens.reduce((acc, token) => acc + token.value * (token.price || 0),
0);
const noConverted = !!tokens.find((token) => token.price === undefined);

setTotalEuro(totalConverted);

setTotalFiatNetworks(tokens)
setTotalFiat(totalConverted);
setHasNoConvertedToken(noConverted);
});

}, [payments]);

function onChangeDate(e: ChangeEvent<HTMLInputElement>,
Expand Down Expand Up @@ -112,10 +138,10 @@ export default function PaymentsPage() {
</span>
<div className="caption-large bg-dark-gray py-2 px-3 border-radius-8">
<span className="text-white">
{formatNumberToCurrency(totalEuro)}
{formatNumberToCurrency(totalFiat)}
</span>

<span className="text-gray ml-1">{t("currencies.euro")}</span>
<span className="text-gray ml-1">{state?.Settings?.currency?.defaultFiat}</span>
</div>
</>
)}
Expand Down Expand Up @@ -168,9 +194,14 @@ export default function PaymentsPage() {
</FlexRow>

<FlexRow className="justify-content-center">
<FlexColumn>
{payments?.length > 0 ? (
<PaymentsList payments={payments} />
<FlexColumn className="col-12">
{networks?.length > 0 ? (
<PaymentsList
payments={payments}
networks={networks}
totalNetworks={totalFiatNetworks}
symbol={state?.Settings?.currency?.defaultFiat?.toUpperCase()}
/>
) : (
<NothingFound description={t("filters.no-records-found")} />
)}
Expand All @@ -179,4 +210,4 @@ export default function PaymentsPage() {
</FlexColumn>
</ProfileLayout>
);
}
}
12 changes: 10 additions & 2 deletions components/profile/payment-item.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ export default function PaymentItem({
handleItemClick,
}: Payment) {
const CONTAINER_CLASSES = [
"justify-content-between align-items-center bg-transparent",
"justify-content-between align-items-center bg-gray-950",
"border border-dark-gray border-radius-8 mb-2 py-3 px-4",
];

Expand All @@ -38,7 +38,15 @@ export default function PaymentItem({
</FlexRow>
</FlexColumn>

<Button color="light-gray" onClick={() => handleItemClick(issue?.issueId)} outline>
<Button
color="light-gray"
onClick={() =>
handleItemClick(issue?.issueId,
issue?.network?.chain?.chainShortName,
issue?.network?.name)
}
outline
>
<span className="text-white text-nowrap">
{labelBounty} #{issue?.issueId}
</span>
Expand Down
76 changes: 61 additions & 15 deletions components/profile/payments-list.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,38 +3,84 @@ import { useRouter } from "next/router";

import PaymentItem from "components/profile/payment-item";

import { Network } from "interfaces/network";
import { Payment } from "interfaces/payments";

import { useNetwork} from "x-hooks/use-network";
import { useNetwork } from "x-hooks/use-network";

import NetworkColumns from "./network-columns";
import NetworkItem from "./network-item";
import { TotalFiatNetworks } from "./pages/payments";
import { FlexColumn } from "./wallet-balance";

interface PaymentsListProps {
payments: Payment[];
networks: Network[];
totalNetworks: TotalFiatNetworks[];
symbol: string;
}

// TODO: Add InfiniteScroll and pagination
export default function PaymentsList({ payments }: PaymentsListProps) {
export default function PaymentsList({
payments,
networks,
totalNetworks,
symbol
}: PaymentsListProps) {
const { push } = useRouter();
const { t } = useTranslation(["common", "profile", "bounty"]);

const { getURLWithNetwork } = useNetwork();

function handleItemClick(issueId: string) {
const [repoId, id] = issueId.split('/')
function handleItemClick(issueId: string, chainName: string, networkName: string) {
const [repoId, id] = issueId.split("/");

push(getURLWithNetwork("/bounty", { id, repoId, chain: chainName, network: networkName}));
}

push(getURLWithNetwork('/bounty', { id, repoId }));
function handleAmount(networkId: number) {
return totalNetworks
.filter((n) => n?.networkId === networkId)
.reduce((acc, token) => acc + token.value * (token.price || 0), 0);
}

if (!payments) return null;
if (!payments || !networks) return null;
return (
<>
{payments &&
payments?.map((payment: Payment) =>
PaymentItem({
...payment,
labelToken: t("misc.$token"),
labelBounty: t("bounty:label"),
handleItemClick
}))}
<NetworkColumns
columns={[
t("custom-network:steps.network-information.fields.name.default"),
"Total payments",
"Network link",
]}
/>
{networks &&
networks?.map((network, key) => (
<NetworkItem
key={key}
type="network"
networkName={network?.name}
iconNetwork={network?.logoIcon}
handleNetworkLink={() => {
push(getURLWithNetwork("/", { chain: network?.chain?.chainName, network: network?.name }))
}}
amount={handleAmount(network?.id)}
symbol={symbol}
>
<FlexColumn className="col-12">
{payments &&
payments
?.filter((p) => network?.id === p?.issue?.network?.id)
.map((payment: Payment) =>
PaymentItem({
...payment,
labelToken: t("misc.$token"),
labelBounty: t("bounty:label"),
handleItemClick,
}))}
</FlexColumn>
</NetworkItem>
))}
</>
);
}
}
2 changes: 1 addition & 1 deletion interfaces/payments.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,5 +9,5 @@ export interface Payment {
transactionHash: string;
labelBounty?: string;
labelToken?: string;
handleItemClick: (issueId: string) => void
handleItemClick: (issueId: string, chainName: string, networkName: string) => void
}
34 changes: 16 additions & 18 deletions pages/api/payments/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,28 +4,18 @@ import {Op} from "sequelize";

import models from "db/models";

import {chainFromHeader} from "helpers/chain-from-header";
import {resJsonMessage} from "helpers/res-json-message";

import {LogAccess} from "middleware/log-access";
import {WithValidChainId} from "middleware/with-valid-chain-id";
import WithCors from "middleware/withCors";

async function get(req: NextApiRequest, res: NextApiResponse) {
const {wallet, networkName, startDate, endDate} = req.query;
const {wallet, startDate, endDate} = req.query;

const chain = await chainFromHeader(req);
const networks = await models.network.findAll({});

const network = await models.network.findOne({
where: {
name: {
[Op.iLike]: String(networkName).replaceAll(" ", "-")
},
chain_id: {[Op.eq]: +chain?.chainId}
}
});

if (!network) return resJsonMessage("Invalid network", res, 404);
if (!networks) return resJsonMessage("Network not found", res, 404);

let filter: {
createdAt?: {
Expand Down Expand Up @@ -55,11 +45,19 @@ async function get(req: NextApiRequest, res: NextApiResponse) {

const payments = await models.userPayments.findAll({
include: [
{
association: "issue",
where: { network_id: network.id },
include:[{ association: "transactionalToken" }]
}
{
association: "issue",
where: {
network_id: { [Op.in]: networks.map((network) => network.id) },
},
include: [
{ association: "transactionalToken" },
{
association: "network",
include: [{ association: "chain", attributes: ["chainShortName"] }],
},
],
},
],
where: {
address: {
Expand Down
5 changes: 1 addition & 4 deletions styles/styles.scss
Original file line number Diff line number Diff line change
Expand Up @@ -271,8 +271,6 @@ li {
}
}



// familys
.family-Regular {
font-family: "Space Grotesk", sans-serif;
Expand Down Expand Up @@ -574,14 +572,13 @@ label {


input[type="date"]::-webkit-calendar-picker-indicator {
background-color: $white !important;
border-radius: 5px;
content: url(../assets/CalendarBlank.svg);
}

input[type="date"]::-webkit-calendar-picker-indicator:hover {
transform:scale(1.2);
cursor:pointer;
background-color: rgba($white, 0.2);
}

.input-group-border {
Expand Down
5 changes: 2 additions & 3 deletions x-hooks/use-api.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,6 @@ import { Token } from "interfaces/token";
import {api} from "services/api";
import { WinStorage } from "services/win-storage";

import {Entities, Events} from "types/dappkit";

import {updateSupportedChains} from "../contexts/reducers/change-supported-chains";
import {toastError, toastSuccess} from "../contexts/reducers/change-toaster";
Expand Down Expand Up @@ -217,9 +216,9 @@ export default function useApi() {
.catch(() => null);
}

async function getPayments(wallet: string, networkName = DEFAULT_NETWORK_NAME, startDate: string, endDate: string) {
async function getPayments(wallet: string, startDate: string, endDate: string) {
const dates = startDate ? { startDate, endDate } : { endDate }
const params = new URLSearchParams({ wallet, networkName, ...dates }).toString();
const params = new URLSearchParams({ wallet, ...dates }).toString();

return api
.get<IssueData[]>(`/payments?${params}`)
Expand Down