Skip to content

Commit

Permalink
Merge pull request #138 from PotLock/fix/donation
Browse files Browse the repository at this point in the history
Fix/donation
  • Loading branch information
kurodenjiro authored Jan 30, 2024
2 parents c5da420 + 3fe81a2 commit c8d4256
Show file tree
Hide file tree
Showing 7 changed files with 226 additions and 89 deletions.
5 changes: 4 additions & 1 deletion apps/potlock/widget/Cart/BreakdownSummary.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -154,7 +154,8 @@ const handleDonate = () => {
// }
// }
const transactions = [];
Object.entries(props.cart).forEach(([projectId, { ft, amount, referrerId, potId }]) => {

Object.entries(props.cart).forEach(([projectId, { ft, amount, referrerId, note, potId }]) => {
const amountFloat = parseFloat(amount || 0);
const amountIndivisible = props.SUPPORTED_FTS[ft].toIndivisible(amountFloat);
const donateContractArgs = {};
Expand All @@ -165,6 +166,7 @@ const handleDonate = () => {
} else {
donateContractArgs.recipient_id = projectId;
donateContractArgs.referrer_id = referrerId;
donateContractArgs.message = note;
}
transactions.push({
contractName: potId ?? donationContractId,
Expand All @@ -173,6 +175,7 @@ const handleDonate = () => {
deposit: amountIndivisible.toString(),
});
});

const now = Date.now();
Near.call(transactions);
// NB: we won't get here if user used a web wallet, as it will redirect to the wallet
Expand Down
11 changes: 9 additions & 2 deletions apps/potlock/widget/Cart/CheckoutItem.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -231,7 +231,8 @@ return (
amount,
props.cart[projectId]?.ft,
props.cart[projectId]?.referrerId,
props.cart[projectId]?.potId
props.cart[projectId]?.potId,
props.cart[projectId]?.note
); // TODO: update this to use selected FT ID
},
inputStyles: {
Expand All @@ -250,7 +251,13 @@ return (
],
value: { text: props.cart[projectId]?.ft, value: props.cart[projectId]?.ft },
onChange: ({ text, value }) => {
props.updateCartItem(projectId, undefined, value, props.cart[projectId]?.potId);
props.updateCartItem(
projectId,
undefined,
value,
props.cart[projectId]?.potId,
Storage.get("note")
);
},
containerStyles: {
width: "auto",
Expand Down
22 changes: 20 additions & 2 deletions apps/potlock/widget/Components/ListSection.jsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,13 @@
const { ownerId, removeProjectsFromCart, addProjectsToCart, setIsCartModalOpen, tab } = props;
const {
ownerId,
removeProjectsFromCart,
addProjectsToCart,
setIsCartModalOpen,
tab,
setAmount,
setProjectId,
setNote,
} = props;
const filterList = [
"Newest to Oldest",
"Oldest to Newest",
Expand Down Expand Up @@ -462,7 +471,7 @@ return (
src={`${ownerId}/widget/Components.ProjectCard`}
props={{
...item,
...props,
referrerId: props.referrerId,
ownerId: ownerId,
showModal: true,
transactionHashes: props.transactionHashes,
Expand All @@ -476,6 +485,15 @@ return (
setIsCartModalOpen: (isOpen) => {
setIsCartModalOpen(isOpen);
},
setAmount: (value) => {
setAmount(value);
},
setProjectId: (id) => {
setProjectId(id);
},
setNote: (note) => {
setNote(note);
},
totalAmount: (donations) => totalAmount(donations),
}}
key={key}
Expand Down
Loading

0 comments on commit c8d4256

Please sign in to comment.