Skip to content

Commit

Permalink
Merge branch 'develop' into estimate-fully-rented-rent
Browse files Browse the repository at this point in the history
  • Loading branch information
NandyBa committed Aug 17, 2024
2 parents 417c038 + 08ba640 commit 553a319
Show file tree
Hide file tree
Showing 45 changed files with 813 additions and 223 deletions.
8 changes: 6 additions & 2 deletions .github/workflows/branch.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,8 @@ name: Test and deploy to branch
on:
push:
branches:
# - preprod
- master
- preprod
- develop

jobs:
Expand Down Expand Up @@ -75,4 +76,7 @@ jobs:
git pull origin ${DOCKER_BRANCH}
docker compose --file docker-compose-branch.yml pull
docker login -u ${{ secrets.DOCKER_LOGIN }} -p ${{ secrets.DOCKER_PASSWD }} ${DOCKER_REGISTRY}
THEGRAPH_API_KEY=${{ secrets.THEGRAPH_API_KEY }} COMMUNITY_API_KEY=${{ secrets.COMMUNITY_API_KEY }} docker compose --project-name ${{ github.ref_name }}-dashboard --file docker-compose-branch.yml up -d'
THEGRAPH_API_KEY=${{ secrets.THEGRAPH_API_KEY }} \
COMMUNITY_API_KEY=${{ secrets.COMMUNITY_API_KEY }} \
HOSTNAME=${{ github.ref_name == 'master' && 'dashboard.realt.community' || 'dashboard.${DOCKER_BRANCH}.realt.community' }} \
docker compose --project-name ${{ github.ref_name }}-dashboard --file docker-compose-branch.yml up -d'
77 changes: 0 additions & 77 deletions .github/workflows/prod.yml

This file was deleted.

2 changes: 1 addition & 1 deletion .prettierrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ module.exports = {
'^i18next(.*)',
'^(?!(src|../|./))(.*)',
'^src(.*)$',
'^(.*)$'
'^(.*)$',
],
importOrderSeparation: true,
importOrderSortSpecifiers: true,
Expand Down
2 changes: 1 addition & 1 deletion docker-compose-branch.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ services:
- traefik-realt
labels:
- 'traefik.enable=true'
- 'traefik.http.routers.dashboard-${DOCKER_BRANCH}.rule=Host(`dashboard.${DOCKER_BRANCH}.realt.community`)'
- 'traefik.http.routers.dashboard-${DOCKER_BRANCH}.rule=Host(`${HOSTNAME}`)'
- 'traefik.http.routers.dashboard-${DOCKER_BRANCH}.entrypoints=websecure'
- 'traefik.http.services.dashboard-${DOCKER_BRANCH}.loadbalancer.server.port=3000'
restart: always
Expand Down
21 changes: 0 additions & 21 deletions docker-compose-prod.yml

This file was deleted.

6 changes: 3 additions & 3 deletions next.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,11 @@ const nextConfig = {
outputStandalone: true,
},
images: {
domains: ['realt.co']
domains: ['realt.co'],
},
publicRuntimeConfig: {
version,
},
};
}

module.exports = nextConfig;
module.exports = nextConfig
4 changes: 2 additions & 2 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "realtoken-dashboard-v2",
"version": "2.3.0",
"version": "2.3.3",
"scripts": {
"dev": "next dev",
"build": "next build",
Expand Down
2 changes: 1 addition & 1 deletion postcss.config.cjs
Original file line number Diff line number Diff line change
Expand Up @@ -11,4 +11,4 @@ module.exports = {
},
},
},
};
}
Binary file added src/assets/favicon.ico
Binary file not shown.
1 change: 1 addition & 0 deletions src/assets/index.ts
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
export { default as Logo } from './logo.png'
export { default as Favicon } from './favicon.ico'
10 changes: 6 additions & 4 deletions src/components/assetsView/AssetsView.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import { useSelector } from 'react-redux'

import { Grid } from '@mantine/core'

import { useRWA } from 'src/hooks/useRWA'
import { selectUserRealtokens } from 'src/store/features/wallets/walletsSelector'

import { AssetsViewSearch, useAssetsViewSearch } from './AssetsViewSearch'
Expand All @@ -19,11 +20,12 @@ export const AssetsView: FC = () => {
const { choosenAssetView } = useAssetsViewSelect()

const realtokens = useSelector(selectUserRealtokens)
const rwa = useRWA()

const data = useMemo(
() => assetsViewFilterFunction(realtokens.filter(assetSearchFunction)),
[realtokens, assetSearchFunction, assetsViewFilterFunction],
)
const data = useMemo(() => {
const assets = rwa ? [...realtokens, rwa] : realtokens
return assetsViewFilterFunction(assets.filter(assetSearchFunction))
}, [realtokens, rwa, assetSearchFunction, assetsViewFilterFunction])

return realtokens.length ? (
<>
Expand Down
11 changes: 7 additions & 4 deletions src/components/assetsView/AssetsViewSearch.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,10 @@ import { useTranslation } from 'react-i18next'

import { TextInput } from '@mantine/core'

import { UserRealtoken } from 'src/store/features/wallets/walletsSelector'
import {
RWARealtoken,
UserRealtoken,
} from 'src/store/features/wallets/walletsSelector'

import { useInputStyles } from '../inputs/useInputStyles'

Expand Down Expand Up @@ -36,11 +39,11 @@ export function useAssetsViewSearch() {
[assetSearch],
)

function assetSearchFunction(realtoken: UserRealtoken) {
function assetSearchFunction(asset: UserRealtoken | RWARealtoken) {
return (
!cleanSearch ||
realtoken.shortName.toLowerCase().includes(cleanSearch) ||
realtoken.fullName.toLowerCase().includes(cleanSearch)
asset.shortName.toLowerCase().includes(cleanSearch) ||
asset.fullName.toLowerCase().includes(cleanSearch)
)
}

Expand Down
14 changes: 9 additions & 5 deletions src/components/assetsView/filters/AssetsViewRentStatusFilter.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,10 @@ import { useTranslation } from 'react-i18next'

import { Select } from '@mantine/core'

import { UserRealtoken } from 'src/store/features/wallets/walletsSelector'
import {
RWARealtoken,
UserRealtoken,
} from 'src/store/features/wallets/walletsSelector'

import { useInputStyles } from '../../inputs/useInputStyles'
import { AssetRentStatusType } from '../types'
Expand Down Expand Up @@ -58,16 +61,17 @@ AssetsViewRentStatusFilter.displayName = 'AssetsViewRentStatusFilter'
export function useAssetsViewRentStatusFilter(
filter: AssetsViewRentStatusFilterModel,
) {
function assetRentStatusFilterFunction(asset: UserRealtoken) {
function assetRentStatusFilterFunction(asset: UserRealtoken | RWARealtoken) {
const Asset = asset as UserRealtoken
switch (filter.rentStatus) {
case AssetRentStatusType.ALL:
return true
case AssetRentStatusType.RENTED:
return asset.rentStatus === 'full'
return Asset.rentStatus === 'full'
case AssetRentStatusType.PARTIALLY_RENTED:
return asset.rentStatus === 'partial'
return Asset.rentStatus === 'partial'
case AssetRentStatusType.NOT_RENTED:
return asset.rentStatus === 'none'
return Asset.rentStatus === 'none'
}
}

Expand Down
12 changes: 8 additions & 4 deletions src/components/assetsView/filters/AssetsViewRmmStatusFilter.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,10 @@ import { useTranslation } from 'react-i18next'

import { Select } from '@mantine/core'

import { UserRealtoken } from 'src/store/features/wallets/walletsSelector'
import {
RWARealtoken,
UserRealtoken,
} from 'src/store/features/wallets/walletsSelector'

import { useInputStyles } from '../../inputs/useInputStyles'
import { AssetRmmStatusType } from '../types'
Expand Down Expand Up @@ -53,14 +56,15 @@ AssetsViewRmmStatusFilter.displayName = 'AssetsViewRmmStatusFilter'
export function useAssetsViewRmmStatusFilter(
filter: AssetsViewRmmStatusFilterModel,
) {
function assetRmmStatusFilterFunction(asset: UserRealtoken) {
function assetRmmStatusFilterFunction(asset: UserRealtoken | RWARealtoken) {
const Asset = asset as UserRealtoken
switch (filter.rmmStatus) {
case AssetRmmStatusType.ALL:
return true
case AssetRmmStatusType.AVAILABLE:
return asset.isRmmAvailable
return Asset.isRmmAvailable
case AssetRmmStatusType.NOT_AVAILABLE:
return !asset.isRmmAvailable
return !Asset.isRmmAvailable
}
}

Expand Down
47 changes: 29 additions & 18 deletions src/components/assetsView/filters/AssetsViewSort.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,10 @@ import { useSelector } from 'react-redux'
import { Grid, Select, Switch } from '@mantine/core'

import { selectTransfersIsLoaded } from 'src/store/features/transfers/transfersSelector'
import { UserRealtoken } from 'src/store/features/wallets/walletsSelector'
import {
RWARealtoken,
UserRealtoken,
} from 'src/store/features/wallets/walletsSelector'

import { useInputStyles } from '../../inputs/useInputStyles'
import { AssetSortType } from '../types'
Expand Down Expand Up @@ -90,42 +93,50 @@ export const AssetsViewSort: FC<AssetsViewSortProps> = ({
AssetsViewSort.displayName = 'AssetsViewSort'

export function useAssetsViewSort(filter: AssetsViewSortFilter) {
function assetSortFunction(a: UserRealtoken, b: UserRealtoken) {
function assetSortFunction(
a: UserRealtoken | RWARealtoken,
b: UserRealtoken | RWARealtoken,
) {
const value = getAssetSortValue(a, b)
return filter.sortReverse ? value * -1 : value
}
function getAssetSortValue(a: UserRealtoken, b: UserRealtoken) {
function getAssetSortValue(
a: UserRealtoken | RWARealtoken,
b: UserRealtoken | RWARealtoken,
) {
const A = a as UserRealtoken
const B = b as UserRealtoken
switch (filter.sortBy) {
case AssetSortType.VALUE:
return b.value - a.value
return B.value - A.value
case AssetSortType.APR:
return b.annualPercentageYield - a.annualPercentageYield
return B.annualPercentageYield - A.annualPercentageYield
case AssetSortType.RENT:
return b.amount * b.netRentDayPerToken - a.amount * a.netRentDayPerToken
return B.amount * B.netRentDayPerToken - A.amount * A.netRentDayPerToken
case AssetSortType.RENT_START:
return b.rentStartDate.date.localeCompare(a.rentStartDate.date)
return B.rentStartDate.date.localeCompare(A.rentStartDate.date)
case AssetSortType.NAME:
return a.shortName.localeCompare(b.shortName)
return A.shortName.localeCompare(b.shortName)
case AssetSortType.SUPPLY:
return b.totalInvestment - a.totalInvestment
return B.totalInvestment - A.totalInvestment
case AssetSortType.TOKEN:
return b.amount - a.amount
return B.amount - A.amount
case AssetSortType.TOTAL_UNIT:
return b.totalUnits - a.totalUnits
return B.totalUnits - A.totalUnits
case AssetSortType.RENTED_UNIT:
return b.rentedUnits - a.rentedUnits
return B.rentedUnits - A.rentedUnits
case AssetSortType.OCCUPANCY:
return b.rentedUnits / b.totalUnits - a.rentedUnits / a.totalUnits
return B.rentedUnits / B.totalUnits - A.rentedUnits / A.totalUnits
case AssetSortType.INITIAL_LAUNCH:
return b.initialLaunchDate?.date.localeCompare(
a.initialLaunchDate?.date,
return B.initialLaunchDate?.date.localeCompare(
A.initialLaunchDate?.date,
)
case AssetSortType.UNIT_PRICE_COST:
return (b.unitPriceCost ?? 0) - (a.unitPriceCost ?? 0)
return (B.unitPriceCost ?? 0) - (A.unitPriceCost ?? 0)
case AssetSortType.UNREALIZED_CAPITAL_GAIN:
return (b.unrealizedCapitalGain ?? 0) - (a.unrealizedCapitalGain ?? 0)
return (B.unrealizedCapitalGain ?? 0) - (A.unrealizedCapitalGain ?? 0)
case AssetSortType.LAST_CHANGE:
return b.lastChanges.localeCompare(a.lastChanges) ?? 0
return B.lastChanges.localeCompare(A.lastChanges) ?? 0
}
}

Expand Down
Loading

0 comments on commit 553a319

Please sign in to comment.