Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Another/add campaigns services #16

Merged
merged 9 commits into from
Jan 17, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
5 changes: 4 additions & 1 deletion src/assets/data/contracts/alfajores.json
Original file line number Diff line number Diff line change
Expand Up @@ -68,5 +68,8 @@
"WeightedPool2TokensFactory": "",
"WeightedPoolFactory": "0x997252b17F61fFc6Ca2fDDd7fa1Cb0cdb98f202D",
"YearnLinearPoolFactory": "",
"Multicall": "0xca11bde05977b3631167028862be2a173976ca11"
"Multicall": "0xca11bde05977b3631167028862be2a173976ca11",
"SimpleMinter": "0xEc9EC0e51DBfA5aB969d91313C64f7eEF0348272",
"RFNFT": "0x1D2540EFe05f5b53abABb7Be1780B370Bd3407aE",
"RFP": "0x1b5a1fDdd235d9a4c73F061318E017Bb52aCD444"
}
14 changes: 14 additions & 0 deletions src/assets/images/icons/coins/RFP.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 src/components/_global/BalTable/TotalsRow.vue
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ function getHorizontalStickyClass(index: number) {
:class="[
getHorizontalStickyClass(0),
isColumnStuck ? 'isSticky' : '',
'text-left p-6 bg-white dark:bg-gray-850 border-t dark:border-gray-900 align-top',
'text-center p-6 bg-white dark:bg-gray-850 border-t dark:border-gray-900 align-center',
]"
>
<span class="font-semibold text-left"> Total </span>
Expand Down
120 changes: 99 additions & 21 deletions src/components/contextual/pages/dashboard/Cards/RefiProfileCard.vue
Original file line number Diff line number Diff line change
@@ -1,77 +1,134 @@
<script setup lang="ts">
import NFTImage from '@/assets/images/mocks/NFT.png';
import { useRFNFT } from '@/composables/campaigns/useRFNFT';
import useBreakpoints from '@/composables/useBreakpoints';
import useWeb3 from '@/services/web3/useWeb3';

const { startConnectWithInjectedProvider } = useWeb3();
const { isMobile, bp } = useBreakpoints();

const { NFTData, isLoading, MintNFT, isMintingNFT } = useRFNFT();
const { isWalletReady } = useWeb3();

const nftImageSrc = computed(() => NFTData.value?.imageData || NFTImage);

//TODO: Remove this ugly method and use a better one like all the info in the NFTData :)
const levels = ref([
{ nextLevel: '100', votes: 1 },
{ nextLevel: '250', votes: 10 },
{ nextLevel: '500', votes: 30 },
{ nextLevel: '1000', votes: 75 },
{ nextLevel: '2000', votes: 150 },
{ nextLevel: 'MAX', votes: 250 },
]);
Another-DevX marked this conversation as resolved.
Show resolved Hide resolved
</script>
<template>
<template v-if="isMobile">
<BalCard v-if="bp === 'xs'">
<div class="flex flex-col gap-5 justify-center items-start px-4 h-fit">
<img :src="NFTImage" class="w-full h-full rounded-md bg-slate-500" />
<img :src="nftImageSrc" class="w-full h-full rounded-md bg-slate-500" />
<div class="flex flex-col gap-10 w-full">
<div class="flex flex-col gap-4">
<h3 class="self-start text-lg">Connect wallet</h3>
<h3 v-if="!isWalletReady" class="self-start text-lg">
Connect wallet
</h3>
<h3 v-else-if="!isLoading" class="self-start text-lg">
{{ NFTData?.name }}
</h3>
<div class="flex justify-between items-center text-base">
<p>Voting Power</p>
<p>- Votes</p>
<p v-if="NFTData">{{ NFTData.attributes[1].value }} Votes</p>
<p v-else>- Votes</p>
</div>
</div>
<div class="w-full border-t-2" />
<div class="flex flex-col gap-1">
<div class="flex justify-between items-center text-base">
<p>My Points</p>
<p>- RFP</p>
<p class="text-sm">My Points</p>
<p v-if="isLoading" class="text-sm">- RFP</p>
<p v-else class="text-sm">{{ NFTData?.points }} RFP</p>
</div>
<div
class="flex justify-between items-center text-base text-disabled"
>
<p>Next level</p>
<p>- RFP</p>
<p class="text-sm">Next level</p>
<p v-if="NFTData" class="text-sm">
{{ levels[NFTData?.id - 1].nextLevel }} RFP
</p>
<p v-else class="text-sm">- RFP</p>
</div>
</div>
<BalBtn
color="gradient"
v-if="!isWalletReady"
color="gradient-blue-light"
class="self-end w-fit"
size="sm"
@click="startConnectWithInjectedProvider"
>Connect wallet</BalBtn
>
<BalBtn
v-else
:color="isMintingNFT ? 'gray' : 'gradient-blue-light'"
:disabled="isMintingNFT"
class="self-end w-fit"
size="sm"
@click="() => MintNFT()"
>Mint NFT</BalBtn
>
</div>
</div>
</BalCard>
<BalCard v-else>
<div class="flex flex-row gap-5 justify-center items-start px-4 h-80">
<img :src="NFTImage" class="w-48 h-full rounded-md bg-slate-500" />
<img :src="nftImageSrc" class="w-48 h-full rounded-md bg-slate-500" />
<div class="flex flex-col gap-10 w-full">
<div class="flex flex-col gap-4">
<h3 class="self-start text-lg">Connect wallet</h3>
<h3 v-if="!isWalletReady" class="self-start text-lg">
Connect wallet
</h3>
<h3 v-else-if="!isLoading" class="self-start text-lg">
{{ NFTData?.name }}
</h3>
<div class="flex justify-between items-center text-base">
<p>Voting Power</p>
<p>- Votes</p>
<p v-if="NFTData">{{ NFTData.attributes[1].value }} Votes</p>
<p v-else>- Votes</p>
</div>
</div>
<div class="w-full border-t-2" />
<div class="flex flex-col gap-1">
<div class="flex justify-between items-center text-base">
<p>My Points</p>
<p>- RFP</p>
<p class="text-sm">My Points</p>
<p v-if="isLoading" class="text-sm">- RFP</p>
<p v-else class="text-sm">{{ NFTData?.points }} RFP</p>
</div>
<div
class="flex justify-between items-center text-base text-disabled"
>
<p>Next level</p>
<p>- RFP</p>
<p class="text-sm">Next level</p>
<p v-if="NFTData" class="text-sm">
{{ levels[NFTData?.id - 1].nextLevel }} RFP
</p>
<p v-else class="text-sm">- RFP</p>
</div>
</div>
<BalBtn
color="gradient"
v-if="!isWalletReady"
color="gradient-blue-light"
class="self-end w-fit"
size="sm"
@click="startConnectWithInjectedProvider"
>Connect wallet</BalBtn
>
<BalBtn
v-else
:color="isMintingNFT ? 'gray' : 'gradient-blue-light'"
:disabled="isMintingNFT"
class="self-end w-fit"
size="sm"
@click="() => MintNFT()"
>Mint NFT</BalBtn
>
</div>
</div>
</BalCard>
Expand All @@ -82,37 +139,58 @@ const { isMobile, bp } = useBreakpoints();
class="flex flex-row gap-8 justify-center items-center h-full h-[265px]"
>
<img
:src="NFTImage"
:src="nftImageSrc"
class="rounded-md h-[224px] w-[168px] bg-slate-500"
/>
<div class="flex flex-col gap-6 w-full">
<div class="flex flex-col gap-4">
<h3 class="self-start text-lg">Connect wallet</h3>
<h3 v-if="!isWalletReady" class="self-start text-lg">
Connect wallet
</h3>
<h3 v-else-if="!isLoading && NFTData" class="self-start text-lg">
{{ NFTData.name }}
</h3>
<h3 v-else class="self-start text-lg">Mint NFT</h3>
<div class="flex justify-between items-center text-base">
<p>Voting Power</p>
<p>- Votes</p>
<p v-if="NFTData">{{ NFTData.attributes[1].value }} Votes</p>
<p v-else>- Votes</p>
</div>
</div>
<div class="w-full border-t-2" />
<div class="flex flex-col gap-1">
<div class="flex justify-between items-center text-base">
<p class="text-sm">My Points</p>
<p class="text-sm">- RFP</p>
<p v-if="isLoading" class="text-sm">- RFP</p>
<p v-else class="text-sm">{{ NFTData?.points }} RFP</p>
</div>
<div
class="flex justify-between items-center text-base text-disabled"
>
<p class="text-sm">Next level</p>
<p class="text-sm">- RFP</p>
<p v-if="NFTData" class="text-sm">
{{ levels[NFTData?.id - 1].nextLevel }} RFP
</p>
<p v-else class="text-sm">- RFP</p>
</div>
</div>
<BalBtn
v-if="!isWalletReady"
color="gradient-blue-light"
class="self-end w-fit"
size="sm"
@click="startConnectWithInjectedProvider"
>Connect wallet</BalBtn
>
<BalBtn
v-else
:color="isMintingNFT ? 'gray' : 'gradient-blue-light'"
:disabled="isMintingNFT"
class="self-end w-fit"
size="sm"
@click="() => MintNFT()"
>Mint NFT</BalBtn
>
</div>
</div>
</div>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,9 @@ import { useI18n } from 'vue-i18n';
import useBreakpoints from '@/composables/useBreakpoints';
import { ColumnDefinition } from '@/components/_global/BalTable/types';
import useNumbers, { FNumFormats } from '@/composables/useNumbers';
import RFP from '@/assets/images/icons/coins/RFP.svg';
import { useAllocations } from '@/composables/campaigns/useAllocations';

/**
* TYPES
*/
Expand All @@ -21,18 +24,21 @@ export type ClaimRow = {
*/
const { t } = useI18n();
const { fNum } = useNumbers();

const { currentAllocation, isLoading, claimReward } = useAllocations();
watch(currentAllocation, () => {
console.debug(currentAllocation.value);
});
/**
* STATE
*/
// ref<ColumnDefinition<RewardRow>[]>
const columns = ref<ColumnDefinition<ClaimRow>[]>([
{
name: t('token'),
id: 'icons',
accessor: 'icons',
id: 'icon',
accessor: 'uri',
Cell: 'iconsColumnCell',
width: 50,
width: 100,
noGrow: true,
},
{
Expand All @@ -41,15 +47,15 @@ const columns = ref<ColumnDefinition<ClaimRow>[]>([
align: 'right',
width: 150,
totalsCell: 'totalAmountCell',
accessor: ({ amount }) => `${fNum(amount, FNumFormats.token)} BAL`,
accessor: ({ amount }) => `${fNum(amount, FNumFormats.token)}`,
},
{
name: t('value'),
id: 'value',
align: 'right',
width: 150,
totalsCell: 'totalValueCell',
accessor: ({ value }) => fNum(value, FNumFormats.fiat),
accessor: ({ value }) => value,
},
{
name: '',
Expand All @@ -61,7 +67,19 @@ const columns = ref<ColumnDefinition<ClaimRow>[]>([
},
]);

const rewardsData = [];
const selectedRows = ref([]);

const handleButtonClick = () => {
claimReward();
};

const rewardsData = [
{
icon: RFP,
amount: currentAllocation,
value: 'NFT XP',
},
];

const { upToLargeBreakpoint } = useBreakpoints();
</script>
Expand All @@ -75,33 +93,37 @@ const { upToLargeBreakpoint } = useBreakpoints();
>
<BalTable
:columns="columns"
sticky="both"
:data="rewardsData"
:isLoading="true"
:isLoading="isLoading"
skeletonClass="h-24"
:square="upToLargeBreakpoint"
>
<template #claimColumnCell="{ amount }">
<div class="py-4 px-6">
<ClaimBalBtn :label="$t('claim')" :amount="amount" />
</div>
</template>
<!-- <template #totalAmountCell>
<div class="flex justify-end">
{{ fNum(totalClaimAmount, FNumFormats.token) }} BAL
<template #iconsColumnCell>
<div class="flex gap-4 justify-center items-center w-full">
<img :src="RFP" class="w-6 h-6" />
<p class="text-base font-normal">RFPs</p>
</div>
</template>
<template #totalValueCell>
<div class="flex justify-end">
{{ fNum(totalClaimValue, FNumFormats.fiat) }}
<template #claimColumnCell="{ row }">
<div class="py-4 px-6">
<input
v-model="selectedRows"
:value="row"
type="checkbox"
class="w-5 h-5 bg-transparent border-2 border-disabled cursor-pointer"
/>
</div>
</template>
<template #claimTotalCell>
<ClaimBalBtn
:label="$t('claimAll')"
:gauges="allGauges"
:amount="totalClaimAmount"
/>
</template> -->
<BalBtn
:color="selectedRows.length ? 'blue' : 'gray'"
class="w-fit"
size="sm"
@click="handleButtonClick"
>Claim</BalBtn
>
</template>
</BalTable>
</BalCard>
</template>
Loading