Kaynağa Gözat

Refactor some code

wip/alt-interface
Jared 2 yıl önce
ebeveyn
işleme
7a7062d029
4 değiştirilmiş dosya ile 58 ekleme ve 49 silme
  1. +11
    -1
      src/App.vue
  2. +0
    -5
      src/views/AboutView.vue
  3. +7
    -2
      src/views/AddFundView.vue
  4. +40
    -41
      src/views/FundView.vue

+ 11
- 1
src/App.vue Dosyayı Görüntüle

@@ -2,7 +2,9 @@
<nav class="navbar has-background-grey-dark" role="navigation" aria-label="main navigation">
<div class="navbar-brand">
<RouterLink to="/" class="navbar-item">
<span class="title is-3-desktop is-4-mobile has-text-white-ter">Beignet</span>
<span class="signet-logo title is-3-desktop is-4-mobile has-text-white-ter">
Beignet
</span>
</RouterLink>
<a role="button" class="navbar-burger" aria-label="menu" aria-expanded="false">
<span aria-hidden="true"></span>
@@ -101,6 +103,10 @@ footer
vertical-align middle
text-align center

.signet-logo
font-family Paytone
letter-spacing 1px

.michigan-icon
display inline-block
width 28px
@@ -110,4 +116,8 @@ footer
background-position center
background-size 28px
margin-left 4px

@font-face
font-family Paytone
src url("./assets/PaytoneOne-Regular.ttf")
</style>

+ 0
- 5
src/views/AboutView.vue Dosyayı Görüntüle

@@ -1,5 +0,0 @@
<template>
<div class="about">
<h1>This is an about page</h1>
</div>
</template>

+ 7
- 2
src/views/AddFundView.vue Dosyayı Görüntüle

@@ -20,9 +20,10 @@
<input class="input is-normal has-background-white has-text-black" type="text"
placeholder="Fund Wallet" aria-label="Fund Wallet" v-model="fundWallet">
</div>
<div class="control my-2">
<input class="input is-normal has-background-white has-text-black" type="text"
<div class="control my-2 is-flex is-flex-direction-row">
<input class="input is-normal has-background-white has-text-black mr-1" type="text"
placeholder="Selling Wallet" aria-label="Selling Wallet" v-model="sellWallet">
<button class="button is-success ml-1" @click="copyFundToSelling">Copy Fund</button>
</div>
<div class="control my-2">
<input class="input is-normal has-background-white has-text-black" type="text"
@@ -119,6 +120,10 @@ const submit = async () => {
}
}
};

const copyFundToSelling = () => {
sellWallet.value = fundWallet.value;
};
</script>

<style scoped lang="stylus">


+ 40
- 41
src/views/FundView.vue Dosyayı Görüntüle

@@ -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">


Yükleniyor…
İptal
Kaydet