Skip to content

Commit

Permalink
add ui for mina names
Browse files Browse the repository at this point in the history
  • Loading branch information
VitalikKarpuk committed Feb 9, 2024
1 parent 431b612 commit b1fddd0
Show file tree
Hide file tree
Showing 92 changed files with 6,945 additions and 225 deletions.
70 changes: 70 additions & 0 deletions ui/assets/logo.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
4 changes: 4 additions & 0 deletions ui/assets/search.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
129 changes: 129 additions & 0 deletions ui/comman/config/tableConfig.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,129 @@
import { TableTemplates } from '../../components/molecules/table/templates';
import { SORT_BY, TableConfig } from '../types';

export const ScoringConfig: TableConfig[] = [
{
colName: 'validator',
headerText: 'Validator',
columnTemplate: TableTemplates.ACCOUNT_TEMPLATE,
fields: {
name: 'valName',
img: 'valImg',
pk: 'pk',
noRedirect: true,
},
view: {
sm: 8,
md: 14,
lg: 14,
},
},
{
colName: 'stake',
columnTemplate: TableTemplates.AMOUNT,
headerText: 'Stake',
fields: {
value: 'stake',
additionValue: 'protocol',
},
sortBy: SORT_BY.STAKE,
},
{
colName: 'score',
columnTemplate: TableTemplates.STRING,
headerText: 'Score',
fields: {
value: 'score',
postfix: '%',
},
sortBy: SORT_BY.SCORE,
},
{
colName: 'uptimeBySnark',
columnTemplate: TableTemplates.STRING,
fields: {
value: 'uptimePercent',
postfix: '%',
},
headerText: 'Uptime by Snark',
},
{
colName: 'votedMIPs',
columnTemplate: TableTemplates.STRING,
fields: {
value: 'votedMIPs',
},
headerText: '% Voted MIPs',
},
{
colName: 'win_Rate',
columnTemplate: TableTemplates.STRING,
fields: {
value: 'winRateAvg',
postfix: '%',
},
headerText: 'Win Rate',
},
];

export const testWorldConfig: TableConfig[] = [
{
colName: 'stake',
headerText: 'Validator',
columnTemplate: TableTemplates.ACCOUNT_TEMPLATE,
fields: {
name: 'name',
img: 'img',
pk: 'pk',
noRedirect: true,
},
view: {
sm: 4,
md: 8,
lg: 12,
},
},
{
colName: 'stake',
columnTemplate: TableTemplates.AMOUNT,
headerText: 'Stake',
fields: {
value: 'amountStaked',
additionValue: 'protocol',
},
sortBy: SORT_BY.STAKE,
},
{
colName: 'score',
columnTemplate: TableTemplates.STRING,
headerText: 'Score',
fields: {
value: 'emptyValue',
},
sortBy: SORT_BY.SCORE,
},
{
colName: 'uptimeBySnark',
columnTemplate: TableTemplates.STRING,
fields: {
value: 'emptyValue',
},
headerText: 'Uptime by Snark',
},
{
colName: 'votedMIPs',
columnTemplate: TableTemplates.STRING,
fields: {
value: 'emptyValue',
},
headerText: '% Voted MIPs',
},
{
colName: 'win_Rate',
columnTemplate: TableTemplates.STRING,
fields: {
value: 'emptyValue',
},
headerText: 'Win Rate',
},
];
4 changes: 4 additions & 0 deletions ui/comman/constants.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
export const NETWORK = 'testworld';
export const defaultWallet = 'B62qoTtn6hP2R1x5d4UQoJos9vjoNGxLhaQn5cSKneu25Q3wpmtPirT';
export const PUBLIC_APP_BASE_URL = 'https://minascan.io/';
export const POLLING_INTERVAL = 3000;
42 changes: 42 additions & 0 deletions ui/comman/helpers/formatNum.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
export const formatNum = (
num: number | string,
fixed?: number,
fixedLessOne?: boolean,
isNotFixed?: boolean
): string => {
if (num === null || num === undefined || (!Number(num) && Number(num) !== 0)) return '-';
const newNumber: number = Number(num);
if (newNumber === 0) return '0';
if (newNumber < 1 && newNumber > -1 && fixedLessOne) {
const arrPrecisionNumber: string[] = newNumber.toString().split('e');
if (arrPrecisionNumber.length > 1) {
const numberOfZero = arrPrecisionNumber[1];
const integerNumber = Number(Math.abs(Number(arrPrecisionNumber[0])));
const arrOfZero = new Array(Math.abs(Number(numberOfZero) || 0))?.fill(0);
arrOfZero[arrOfZero?.length - 1] = integerNumber.toFixed();
const firstNum = newNumber > 0 ? '0.' : '-0.';
arrOfZero.unshift(firstNum);
return arrOfZero.join('');
}
const arrNumbers = num.toString().split('.')?.[1]?.split('') || [];
const indexNumber = arrNumbers.findIndex((item) => Number(item) > 0);

const result = newNumber.toFixed(indexNumber + (fixed || 0));
if (result[result.length - 1] === '0') {
return result.slice(0, -1);
}

return result;
}

const number = isNotFixed ? newNumber.toString() : newNumber.toFixed(fixed);
const arr = number.split('.');
const int = arr[0].replace(/\B(?=(\d{3})+(?!\d))/g, ',');
if (arr[1] !== undefined) {
arr[1] = arr[1].replace(/0*$/, '');
}
if (arr[1] !== undefined && arr[1].trim() !== '') {
return int + '.' + arr[1];
}
return int;
};
1 change: 1 addition & 0 deletions ui/comman/helpers/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export { formatNum } from './formatNum';
85 changes: 85 additions & 0 deletions ui/comman/types.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,85 @@
import { TableTemplates } from '../components/molecules/table/templates';

export type View = {
sm: number;
md: number;
lg: number;
};

export type TableConfig = {
colName: string;
columnTemplate: TableTemplates;
fields?: {
value?: string;
additionValue?: string;
postfix?: string;
name?: string;
img?: string;
pk?: string;
getRedirectLink?: (value: string) => string;
noRedirectFromData?: string;
noHash?: boolean;
isCoinTable?: boolean;
noRedirect?: boolean;
};
sortBy?: SORT_BY;
headerText?: string;
view?: View;
style?: {
noGrow?: boolean;
width?: string;
justifyContent?: string;
maxWidth?: string;
minWidth?: string;
};
};

export type LimitOptions = { text: string; value: number }[];
export type TabSwitcherOptions = string[];

export type DataTable = {
data?: any[];
content?: any[];
size: number;
totalPages: number;
pageable: {
sort: {
sorted: boolean;
unsorted: boolean;
empty: boolean;
};
offset: number;
pageNumber: number;
pageSize: number;
unpaged: boolean;
paged: boolean;
};
last: boolean;
totalElements: number;
number: number;
sort: {
sorted: boolean;
unsorted: boolean;
empty: boolean;
};
first: boolean;
numberOfElements: number;
empty: boolean;
};

export enum SORT_BY {
SCORE = 'score',
STAKE = 'stake',
}

export enum ORDER_BY {
DESC = 'DESC',
ASC = 'ASC',
}

export enum DATA_STATUS {
INITIAL = 'initial',
LOADING = 'loading',
SUCCESS = 'success',
ERROR = 'error',
}
Loading

0 comments on commit b1fddd0

Please sign in to comment.