|
|
@@ -290,6 +290,11 @@ const maxBonus = ref(0); |
|
|
|
const bonus = ref(undefined as Bonus | undefined); |
|
|
|
const amountHeld = ref(fund.value.total.amountHeld); |
|
|
|
const amountAvailable = ref(fund.value.fundInfo.amountAvailable); |
|
|
|
const contributions: Ref<Contribution[]> = ref(fund.value.contributions.list ?? []); |
|
|
|
const offset = ref(contributions.value.length); |
|
|
|
const total = ref(fund.value.contributions.total); |
|
|
|
const requesting = ref(false); |
|
|
|
const contributionsLoading = ref(false); |
|
|
|
|
|
|
|
const getCurrentBonus = () => { |
|
|
|
if (!fund.value) throw new Error('Fund not found!'); |
|
|
@@ -318,10 +323,6 @@ const calculateReward = (bought: number) => { |
|
|
|
|
|
|
|
document.title = `Beignet - ${fund.value.fundInfo.title}`; |
|
|
|
|
|
|
|
const contributions: Ref<Contribution[]> = ref(fund.value.contributions.list ?? []); |
|
|
|
const offset = ref(contributions.value.length); |
|
|
|
const total = ref(fund.value.contributions.total); |
|
|
|
|
|
|
|
watch(selectedDate, async (newVal) => { |
|
|
|
offset.value = 0; |
|
|
|
const conts = await controller.post< |
|
|
@@ -342,27 +343,6 @@ watch(selectedDate, async (newVal) => { |
|
|
|
total.value = fund.value.contributions.total; |
|
|
|
}); |
|
|
|
|
|
|
|
watch(enableConsolidation, async () => { |
|
|
|
offset.value = 0; |
|
|
|
const conts = await controller.post< |
|
|
|
GetContributionsResponse, GetContributionsRequest |
|
|
|
>( |
|
|
|
'GetContributions', |
|
|
|
{ |
|
|
|
id: identifier, |
|
|
|
offset: offset.value, |
|
|
|
forDate: selectedDate.value, |
|
|
|
consolidateContributions: enableConsolidation.value, |
|
|
|
}, |
|
|
|
); |
|
|
|
if (!fund.value) throw new Error('Fund not found'); |
|
|
|
if (!conts) throw new Error('Contributions not found'); |
|
|
|
contributions.value = conts.list; |
|
|
|
offset.value = contributions.value.length; |
|
|
|
total.value = fund.value.contributions.total; |
|
|
|
}); |
|
|
|
|
|
|
|
const contributionsLoading = ref(false); |
|
|
|
const loadMoreIfNeeded = async (e: Event) => { |
|
|
|
const target = e.target as Element | null; |
|
|
|
const canLoadMore = () => target |
|
|
@@ -399,6 +379,41 @@ const { |
|
|
|
}, |
|
|
|
); |
|
|
|
|
|
|
|
const makeContribution = async () => { |
|
|
|
if (!fund.value) throw new Error('Fund not found'); |
|
|
|
if (!requesting.value && pk.value && amt.value && amt.value <= amountAvailable.value) { |
|
|
|
requesting.value = true; |
|
|
|
await controller.post<SuccessResponse, ContributeRequest>('Contribute', { |
|
|
|
privateKey: pk.value, |
|
|
|
amount: amt.value, |
|
|
|
rewardFund: fund.value.fundInfo.id, |
|
|
|
}); |
|
|
|
requesting.value = false; |
|
|
|
pk.value = ''; |
|
|
|
amt.value = undefined; |
|
|
|
} |
|
|
|
}; |
|
|
|
|
|
|
|
watch(enableConsolidation, async () => { |
|
|
|
offset.value = 0; |
|
|
|
const conts = await controller.post< |
|
|
|
GetContributionsResponse, GetContributionsRequest |
|
|
|
>( |
|
|
|
'GetContributions', |
|
|
|
{ |
|
|
|
id: identifier, |
|
|
|
offset: offset.value, |
|
|
|
forDate: selectedDate.value, |
|
|
|
consolidateContributions: enableConsolidation.value, |
|
|
|
}, |
|
|
|
); |
|
|
|
if (!fund.value) throw new Error('Fund not found'); |
|
|
|
if (!conts) throw new Error('Contributions not found'); |
|
|
|
contributions.value = conts.list; |
|
|
|
offset.value = contributions.value.length; |
|
|
|
total.value = fund.value.contributions.total; |
|
|
|
}); |
|
|
|
|
|
|
|
watch(data, (newVal) => { |
|
|
|
if (!fund.value) throw new Error('Fund not found'); |
|
|
|
getCurrentBonus(); |
|
|
@@ -422,22 +437,6 @@ watch(data, (newVal) => { |
|
|
|
amountAvailable.value -= v.amount; |
|
|
|
} |
|
|
|
}); |
|
|
|
|
|
|
|
const requesting = ref(false); |
|
|
|
const makeContribution = async () => { |
|
|
|
if (!fund.value) throw new Error('Fund not found'); |
|
|
|
if (!requesting.value && pk.value && amt.value && amt.value <= amountAvailable.value) { |
|
|
|
requesting.value = true; |
|
|
|
await controller.post<SuccessResponse, ContributeRequest>('Contribute', { |
|
|
|
privateKey: pk.value, |
|
|
|
amount: amt.value, |
|
|
|
rewardFund: fund.value.fundInfo.id, |
|
|
|
}); |
|
|
|
requesting.value = false; |
|
|
|
pk.value = ''; |
|
|
|
amt.value = undefined; |
|
|
|
} |
|
|
|
}; |
|
|
|
</script> |
|
|
|
|
|
|
|
<style scoped lang="stylus"> |
|
|
|