feat(TEAMMSBMOB-14856): утилиты перенесены в lib, добавлены описания функций
This commit is contained in:
@@ -4,9 +4,9 @@ import * as S from './CreditAccount.styles';
|
||||
import CashBlue from './assets/Cash_blue.png';
|
||||
import { LOCALIZATION } from './localization';
|
||||
import type { CreditAccountProps } from './types';
|
||||
import { getDaysLeft } from '@/shared/models/getDaysLeft/getDaysLeft';
|
||||
import { getDeclensionDay } from '@/shared/models/getDeclensionDay/getDeclensionDay';
|
||||
import { getFormattedBalance } from '@/shared/models/getFormattedMoney/getFormattedBalance';
|
||||
import { getDaysLeft } from '@/shared/lib/getDaysLeft/getDaysLeft';
|
||||
import { getDeclensionDay } from '@/shared/lib/getDeclensionDay/getDeclensionDay';
|
||||
import { getFormattedBalance } from '@/shared/lib/getFormattedBalance/getFormattedBalance';
|
||||
import { DashboardAccount } from '@/shared/ui/components';
|
||||
|
||||
const CreditAccount = ({ creditAccount }: CreditAccountProps) => {
|
||||
|
||||
@@ -3,9 +3,9 @@ import { Text, Title } from '@fractal-ui/styling';
|
||||
import * as S from './DepositAccount.styles';
|
||||
import SafeBlack from './assets/Safe_black.png';
|
||||
import type { DepositAccountProps } from './types';
|
||||
import { getDeclensionDay } from '@/shared/models/getDeclensionDay/getDeclensionDay';
|
||||
import { getFormattedDate } from '@/shared/models/getFormattedDate/getFormattedDate';
|
||||
import { getFormattedBalance } from '@/shared/models/getFormattedMoney/getFormattedBalance';
|
||||
import { getDeclensionDay } from '@/shared/lib/getDeclensionDay/getDeclensionDay';
|
||||
import { getFormattedBalance } from '@/shared/lib/getFormattedBalance/getFormattedBalance';
|
||||
import { getFormattedDate } from '@/shared/lib/getFormattedDate/getFormattedDate';
|
||||
import { DashboardAccount } from '@/shared/ui/components';
|
||||
|
||||
const DepositAccount = ({ depositAccount }: DepositAccountProps) => {
|
||||
|
||||
@@ -4,7 +4,7 @@ import { Text, Title } from '@fractal-ui/styling';
|
||||
import * as S from './FinancialAccount.styles';
|
||||
import WalletIcon from './assets/Wallet.png';
|
||||
import type { AccountProps } from './types';
|
||||
import { getFormattedBalance } from '@/shared/models/getFormattedMoney/getFormattedBalance';
|
||||
import { getFormattedBalance } from '@/shared/lib/getFormattedBalance/getFormattedBalance';
|
||||
import { DashboardAccount } from '@/shared/ui/components';
|
||||
|
||||
const FinancialAccount = ({ financialAccount }: AccountProps) => {
|
||||
|
||||
@@ -0,0 +1,12 @@
|
||||
/**
|
||||
*
|
||||
* @param timestampStart - Числовое значение даты начала.
|
||||
* @param timestampEnd - Числовое значение даты окончания.
|
||||
* @returns Разница в днях.
|
||||
*/
|
||||
|
||||
export const getDaysLeft = (timestampStart: number, timestampEnd: number) => {
|
||||
const diffInMs = timestampEnd - timestampStart;
|
||||
|
||||
return Math.floor(diffInMs / (1000 * 60 * 60 * 24));
|
||||
};
|
||||
+5
@@ -1,3 +1,8 @@
|
||||
/**
|
||||
* @param day - Числовое значение дня.
|
||||
* @returns Возвращает склонение слова "день" в зависимости от числа.
|
||||
*/
|
||||
|
||||
export const getDeclensionDay = (day: number) => {
|
||||
const absDay = Math.abs(day);
|
||||
const absDayString = absDay.toString();
|
||||
@@ -0,0 +1,10 @@
|
||||
/**
|
||||
*
|
||||
* @param money - Числовое значение баланса.
|
||||
* @param currency - Код валюты.
|
||||
* @param maximumFractionDigits - Максимальное количество чисел после запятой.
|
||||
* @returns - Отформатированный баланс в формате "12 980 100,00 ₽".
|
||||
*/
|
||||
|
||||
export const getFormattedBalance = (money: number, currency: Intl.NumberFormatOptions['currency'] = 'RUB', maximumFractionDigits = 2) =>
|
||||
new Intl.NumberFormat('ru-RU', { style: 'currency', currency, maximumFractionDigits }).format(money);
|
||||
+6
-1
@@ -1,5 +1,10 @@
|
||||
/**
|
||||
*
|
||||
* @param timestamp - Числовое значение даты.
|
||||
* @returns Дата в формате "25 июня 2025".
|
||||
*/
|
||||
|
||||
export const getFormattedDate = (timestamp: number) =>
|
||||
// Пример: 25 июня 2025
|
||||
new Intl.DateTimeFormat('ru-RU', {
|
||||
day: 'numeric',
|
||||
month: 'long',
|
||||
@@ -1,5 +0,0 @@
|
||||
export const getDaysLeft = (timestampStart: number, timestampEnd: number) => {
|
||||
const diffInMs = timestampEnd - timestampStart;
|
||||
|
||||
return Math.floor(diffInMs / (1000 * 60 * 60 * 24));
|
||||
};
|
||||
@@ -1,2 +0,0 @@
|
||||
export const getFormattedBalance = (money: number, currency: Intl.NumberFormatOptions['currency'] = 'RUB', maximumFractionDigits = 2) =>
|
||||
new Intl.NumberFormat('ru-RU', { style: 'currency', currency, maximumFractionDigits }).format(money);
|
||||
@@ -3,7 +3,7 @@ import { Text, Title } from '@fractal-ui/styling';
|
||||
import { LOCALIZATION } from '../../constants/localization';
|
||||
import type { BalanceProps } from '../../models/types';
|
||||
import * as S from './Balance.styles';
|
||||
import { getFormattedBalance } from '@/shared/models/getFormattedMoney/getFormattedBalance';
|
||||
import { getFormattedBalance } from '@/shared/lib/getFormattedBalance/getFormattedBalance';
|
||||
import BalanceAd from '@/widgets/Balance/ui/BalanceAd';
|
||||
import BalanceCurrencies from '@/widgets/Balance/ui/BalanceCurrencies';
|
||||
import BalanceStatistics from '@/widgets/Balance/ui/BalanceStatistics/BalanceStatistics';
|
||||
|
||||
@@ -6,7 +6,7 @@ import { lightTheme, Title } from '@fractal-ui/styling';
|
||||
import { LOCALIZATION } from '../../constants/localization';
|
||||
import type { PreApprovedProps } from '../../models/types';
|
||||
import * as S from './BalanceAd.styles';
|
||||
import { getFormattedBalance } from '@/shared/models/getFormattedMoney/getFormattedBalance';
|
||||
import { getFormattedBalance } from '@/shared/lib/getFormattedBalance/getFormattedBalance';
|
||||
|
||||
const BalanceAd = ({ onClose, preApprovedMoney, preApprovedPercent, depositIncomeMoney, type }: PreApprovedProps) => {
|
||||
const formattedPreApprovedMoney = useMemo(() => getFormattedBalance(preApprovedMoney, 'RUB', 0), [preApprovedMoney]);
|
||||
|
||||
+1
-1
@@ -3,7 +3,7 @@ import { ArrowsIcons } from '@fractal-ui/library';
|
||||
import { Text } from '@fractal-ui/styling';
|
||||
import type { BalanceStatisticsProps } from '../../models/types';
|
||||
import * as S from './BalanceStatistics.styles';
|
||||
import { getFormattedBalance } from '@/shared/models/getFormattedMoney/getFormattedBalance';
|
||||
import { getFormattedBalance } from '@/shared/lib/getFormattedBalance/getFormattedBalance';
|
||||
|
||||
const BalanceStatistics = ({ incomeMoney, expenseMoney }: BalanceStatisticsProps) => {
|
||||
const formattedIncome = useMemo(() => getFormattedBalance(incomeMoney), [incomeMoney]);
|
||||
|
||||
Reference in New Issue
Block a user