Skip to content

Commit

Permalink
Merge branch 'main' of https://github.com/PotLock/bos-app into feat/c…
Browse files Browse the repository at this point in the history
…heck-humanity-after
  • Loading branch information
M-Rb3 committed Apr 24, 2024
2 parents d02734e + 4b7d2a1 commit 2367f04
Show file tree
Hide file tree
Showing 6 changed files with 33 additions and 83 deletions.
2 changes: 1 addition & 1 deletion apps/potlock/widget/Components/Donors.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -223,7 +223,7 @@ const [allDonations, totalsByDonor, sortedDonations] = useMemo(() => {
accumulator[currentDonation.donor_id] = {
amount:
(accumulator[currentDonation.donor_id].amount || 0) +
calcNetDonationAmount(currentDonation),
(currentDonation.ft_id === "near" ? calcNetDonationAmount(currentDonation) : 0),
...currentDonation,
};
return accumulator;
Expand Down
30 changes: 26 additions & 4 deletions apps/potlock/widget/Components/DonorsTrx.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ const nearLogo =

const { ownerId } = VM.require("potlock.near/widget/constants");

const { getTimePassed, _address, calcNetDonationAmount, reverseArr } = VM.require(
const { getTimePassed, _address, reverseArr } = VM.require(
`potlock.near/widget/Components.DonorsUtils`
);

Expand Down Expand Up @@ -140,6 +140,10 @@ const ProfileImg = ({ address }) => (
<Widget src="mob.near/widget/ProfileImage" props={{ accountId: address, style: {} }} />
);

const NEAR_DECEMIALS = 24;

const calcNetDonationAmount = (amount, decimals) => Big(amount).div(Big(`1e${decimals}`));

return allDonations.length ? (
<Container>
<div className="transcation">
Expand All @@ -152,8 +156,25 @@ return allDonations.length ? (
{reverseArr(allDonations)
.slice((currentPage - 1) * perPage, currentPage * perPage)
.map((donation) => {
const { donor_id, recipient_id, donated_at_ms, donated_at, project_id } = donation;
const {
donor_id,
recipient_id,
donated_at_ms,
donated_at,
project_id,
ft_id,
total_amount,
} = donation;
const projectId = recipient_id || project_id;
const isNear = ft_id === "near";

const frMetaDate = !isNear ? Near.view(ft_id, "ft_metadata", {}) : null;
const assetIcon = isNear ? nearLogo : frMetaDate.icon;

const decimals = isNear ? NEAR_DECEMIALS : frMetaDate.decimals;

console.log("decimals", decimals);

return (
<TrRow>
<a
Expand All @@ -175,8 +196,9 @@ return allDonations.length ? (
</a>

<div className="price">
<img src={nearLogo} alt="NEAR" />
{calcNetDonationAmount(donation).toFixed(2)}
<img src={assetIcon} alt={ft_id} />

{decimals ? calcNetDonationAmount(total_amount, decimals).toFixed(2) : "-"}
</div>

<div>{getTimePassed(donated_at_ms || donated_at)} ago</div>
Expand Down
2 changes: 2 additions & 0 deletions apps/potlock/widget/Pots/Applications.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@ const { getTimePassed, _address } = VM.require(`${ownerId}/widget/Components.Don
_address: (address) => address,
};

const MAX_APPLICATION_MESSAGE_LENGTH = 1000;

const applications = PotSDK.getApplications(potId);

const getApplicationCount = (sortVal) => {
Expand Down
4 changes: 3 additions & 1 deletion apps/potlock/widget/Pots/Header.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -65,12 +65,13 @@ const applicationExists = existingApplication || applicationSuccess;

const now = Date.now();
const publicRoundOpen = now >= public_round_start_ms && now < public_round_end_ms;
const publicRoundEnded = now > public_round_end_ms;

const applicationOpen = now >= application_start_ms && now < application_end_ms;

const canApply = applicationOpen && !applicationExists && !userIsChefOrGreater;

const canPayoutsBeSet = userIsChefOrGreater && !cooldown_end_ms && !all_paid_out;
const canPayoutsBeSet = userIsChefOrGreater && !all_paid_out && publicRoundEnded;

const canPayoutsBeProcessed = userIsAdminOrGreater && now >= cooldown_end_ms && !all_paid_out;

Expand Down Expand Up @@ -155,6 +156,7 @@ const Fund = styled.div`
`;
const ButtonsWrapper = styled.div`
display: flex;
flex-wrap: wrap;
gap: 2rem;
a,
button {
Expand Down
76 changes: 0 additions & 76 deletions apps/potlock/widget/Pots/Sponsors.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -61,12 +61,6 @@ const Container = styled.div`
}
`;

const OuterTextContainer = styled.div`
display: flex;
flex-direction: row;
gap: 10px;
`;

const TableContainer = styled.div`
display: flex;
flex-direction: column;
Expand All @@ -76,76 +70,6 @@ const TableContainer = styled.div`
padding-bottom: 1rem;
`;

const Header = styled.div`
display: flex;
flex-direction: row;
align-items: center;
justify-content: space-between;
background: #f6f5f3;
width: 100%;
`;

const HeaderItem = styled.div`
display: flex;
flex-direction: row;
align-items: space-between;
justify-content: flex-start;
padding: 10px 20px;
width: 24%;
@media screen and (min-width: 390px) and (max-width: 768px) {
padding: 10px 15px;
}
@media screen and (max-width: 390px) {
padding: 10px;
}
`;

const HeaderItemText = styled.div`
color: #292929;
font-size: 14px;
font-weight: 600;
line-height: 24px;
@media screen and (max-width: 390px) {
font-size: 12px;
}
`;

const Row = styled.div`
display: flex;
flex-direction: row;
align-items: center;
justify-content: space-between;
width: 100%;
`;

const RowItem = styled.div`
display: flex;
flex-direction: row;
align-items: center;
justify-content: flex-start;
gap: 20px;
padding: 20px;
width: 24%;
@media screen and (min-width: 390px) and (max-width: 768px) {
padding: 10px 15px;
gap: 10px;
}
@media screen and (max-width: 390px) {
padding: 10px;
gap: 0px;
}
`;

const RowText = styled.div`
color: #292929;
font-size: 14px;
font-weight: 400;
line-height: 24px;
@media screen and (max-width: 390px) {
font-size: 12px;
}
`;

const { base_currency } = potDetail;

const maxRowItemLength = 14;
Expand Down
2 changes: 1 addition & 1 deletion apps/potlock/widget/Project/ListPage.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -507,7 +507,7 @@ const [projects, approvedProjects] = useMemo(() => {
return [allRegistrations, approvedProjects];
}, allRegistrations);

const featuredProjectIds = ["magicbuild.near", "potlock.near", "yearofchef.near"];
const featuredProjectIds = ["v1.foodbank.near", "potlock.near", "yearofchef.near"];
const featuredProjects = useMemo(
() => projects.filter((project) => featuredProjectIds.includes(project.registrant_id)),
projects
Expand Down

0 comments on commit 2367f04

Please sign in to comment.