diff --git a/pages/_app.tsx b/pages/_app.tsx index 9963ad3eb..a3c7637aa 100644 --- a/pages/_app.tsx +++ b/pages/_app.tsx @@ -5,20 +5,21 @@ import React, { useEffect } from 'react'; import { CookiesProvider } from 'react-cookie'; import { Provider } from 'react-redux'; import ErrorBoundary from '@/components/Error/ErrorBoundary'; +import { CURRENT_ENVIRONMENT } from '@/config/endpoints'; +import { siteRoutes } from '@/config/routes'; +import { AuthContextProvider } from '@/core/context/AuthContext'; +import { CookiesProviderTracking } from '@/core/context/CookiesContext'; +import { FeatureFlagsProvider } from '@/core/context/FeatureFlagsProvider'; +import { ThemeProvider } from '@/core/context/ThemeContext'; +import { store } from '@/core/store/store'; +import { getAuthFromStorage } from '@/core/utils/authStorage'; +import { parseCookie } from '@/core/utils/cookieHelpers'; +import * as gtag from '@/core/utils/gtag'; +import type { CookiesInterface } from '@/core/utils/typesHelpers'; +import { ContainerNotification } from '@/stories/components/Notification/Notification'; +import { SEOHead } from '@/stories/components/SEOHead/SEOHead'; +import AppLayout from '@/stories/containers/AppLayout/AppLayout'; import { featureFlags } from '../feature-flags/feature-flags'; -import { CURRENT_ENVIRONMENT } from '../src/config/endpoints'; -import { AuthContextProvider } from '../src/core/context/AuthContext'; -import { CookiesProviderTracking } from '../src/core/context/CookiesContext'; -import { FeatureFlagsProvider } from '../src/core/context/FeatureFlagsProvider'; -import { ThemeProvider } from '../src/core/context/ThemeContext'; -import { store } from '../src/core/store/store'; -import { getAuthFromStorage } from '../src/core/utils/authStorage'; -import { parseCookie } from '../src/core/utils/cookieHelpers'; -import * as gtag from '../src/core/utils/gtag'; -import { ContainerNotification } from '../src/stories/components/Notification/Notification'; -import { SEOHead } from '../src/stories/components/SEOHead/SEOHead'; -import AppLayout from '../src/stories/containers/AppLayout/AppLayout'; -import type { CookiesInterface } from '../src/core/utils/typesHelpers'; import type { EmotionCache } from '@emotion/react'; import type { NextPage, NextPageContext } from 'next'; import type { AppProps } from 'next/app'; @@ -59,7 +60,7 @@ function MyApp(props: MyAppProps) { useEffect(() => { const authData = getAuthFromStorage(); if (props.pageProps?.protected && (isEmpty(authData) || !authData?.authToken)) { - router.push('/login'); + router.push(siteRoutes.login); } }, [props.pageProps?.protected, router]); diff --git a/src/components/AdvancedInnerTable/AdvancedInnerTable.tsx b/src/components/AdvancedInnerTable/AdvancedInnerTable.tsx index 864684e90..b4c894463 100644 --- a/src/components/AdvancedInnerTable/AdvancedInnerTable.tsx +++ b/src/components/AdvancedInnerTable/AdvancedInnerTable.tsx @@ -1,6 +1,6 @@ import { styled } from '@mui/material'; import React, { useId } from 'react'; -import { OpenModalTransparency } from '@/views/CoreUnitBudgetStatement/BudgetStatementtUtils'; +import { OpenModalTransparency } from '@/views/CoreUnitBudgetStatement/BudgetStatementUtils'; import { TransparencyEmptyTable } from '@/views/CoreUnitBudgetStatement/components/Placeholders/TransparencyEmptyTable'; import { NumberCell } from './NumberCell/NumberCell'; import { TextCell } from './TextCell/TextCell'; diff --git a/src/components/AdvancedInnerTable/BasicModal/useModalCategory.ts b/src/components/AdvancedInnerTable/BasicModal/useModalCategory.ts index cacdef4f3..ddb04efdf 100644 --- a/src/components/AdvancedInnerTable/BasicModal/useModalCategory.ts +++ b/src/components/AdvancedInnerTable/BasicModal/useModalCategory.ts @@ -1,4 +1,5 @@ -import _ from 'lodash'; +import has from 'lodash/has'; +import some from 'lodash/some'; import { useCallback, useMemo, useState } from 'react'; import type { ExpenseCategory, ParsedExpenseCategoryWithExpanded } from '@ses/core/models/dto/expenseCategoriesDTO'; @@ -50,9 +51,9 @@ export const useModalCategory = (expenseCategories: ExpenseCategory[] = []) => { if (category) { setAllCategory(category); } - const hasExpandedElement = _.some( + const hasExpandedElement = some( allCategory, - (element) => _.has(element, 'isExpanded') && element.isExpanded === true + (element) => has(element, 'isExpanded') && element.isExpanded === true ); if (hasExpandedElement) { diff --git a/src/components/BudgetStatement/BudgetStatementActuals/BreakdownActualsSection/BreakdownActualsSection.stories.tsx b/src/components/BudgetStatement/BudgetStatementActuals/BreakdownActualsSection/BreakdownActualsSection.stories.tsx index 7df206f5a..83ea0156a 100644 --- a/src/components/BudgetStatement/BudgetStatementActuals/BreakdownActualsSection/BreakdownActualsSection.stories.tsx +++ b/src/components/BudgetStatement/BudgetStatementActuals/BreakdownActualsSection/BreakdownActualsSection.stories.tsx @@ -1,6 +1,6 @@ import { DateTime } from 'luxon'; import { createThemeModeVariants } from '@/core/utils/storybook/factories'; -import { renderWallet } from '@/views/CoreUnitBudgetStatement/BudgetStatementtUtils'; +import { renderWallet } from '@/views/CoreUnitBudgetStatement/BudgetStatementUtils'; import BreakdownSection from './BreakdownActualsSection'; import type { Meta } from '@storybook/react'; diff --git a/src/components/BudgetStatement/BudgetStatementActuals/TotalActualSection/TotalActualSection.stories.tsx b/src/components/BudgetStatement/BudgetStatementActuals/TotalActualSection/TotalActualSection.stories.tsx index 5eb3db3ff..a49388c53 100644 --- a/src/components/BudgetStatement/BudgetStatementActuals/TotalActualSection/TotalActualSection.stories.tsx +++ b/src/components/BudgetStatement/BudgetStatementActuals/TotalActualSection/TotalActualSection.stories.tsx @@ -3,7 +3,7 @@ import type { InnerTableColumn, InnerTableRow } from '@/components/AdvancedInner import { InnerTableColumnBuilder } from '@/core/businessLogic/tableBuilderColumns'; import { InnerTableRowBuilder } from '@/core/businessLogic/tableBuilderRow'; import { createThemeModeVariants } from '@/core/utils/storybook/factories'; -import { renderWallet } from '@/views/CoreUnitBudgetStatement/BudgetStatementtUtils'; +import { renderWallet } from '@/views/CoreUnitBudgetStatement/BudgetStatementUtils'; import TotalWalletSections from './TotalActualSection'; import type { Meta } from '@storybook/react'; const mainTableColumns = [ diff --git a/src/components/BudgetStatement/BudgetStatementActuals/useBudgetStatementActuals.ts b/src/components/BudgetStatement/BudgetStatementActuals/useBudgetStatementActuals.ts index 705eac809..4b2682cd0 100644 --- a/src/components/BudgetStatement/BudgetStatementActuals/useBudgetStatementActuals.ts +++ b/src/components/BudgetStatement/BudgetStatementActuals/useBudgetStatementActuals.ts @@ -1,12 +1,12 @@ import { useCategoriesModalContext } from '@ses/core/context/CategoryModalContext'; import { API_MONTH_TO_FORMAT } from '@ses/core/utils/date'; import { capitalizeSentence, getWalletWidthForWallets, toKebabCase } from '@ses/core/utils/string'; -import _ from 'lodash'; +import sortBy from 'lodash/sortBy'; +import sumBy from 'lodash/sumBy'; import { useRouter } from 'next/router'; import { useEffect, useMemo, useRef, useState } from 'react'; import type { InnerTableColumn, InnerTableRow } from '@/components/AdvancedInnerTable/types'; - -import { renderWallet } from '@/views/CoreUnitBudgetStatement/BudgetStatementtUtils'; +import { renderWallet } from '@/views/CoreUnitBudgetStatement/BudgetStatementUtils'; import { getActualsBreakdownColumns, getActualsBreakdownItemsForWallet, @@ -54,7 +54,7 @@ export const useBudgetStatementActuals = ( } }); - return _.sortBy(Object.values(dict), 'id'); + return sortBy(Object.values(dict), 'id'); }, [propsCurrentMonth, budgetStatements]); const currentBudgetStatement = useMemo( @@ -66,8 +66,8 @@ export const useBudgetStatementActuals = ( const budgetTotalMonthlyBudget = useMemo( () => - _.sumBy(currentBudgetStatement?.budgetStatementWallet, (wallet) => - _.sumBy( + sumBy(currentBudgetStatement?.budgetStatementWallet, (wallet) => + sumBy( wallet.budgetStatementLineItem.filter((item) => item.month === currentMonth), (item) => item?.budgetCap ?? 0 ) @@ -77,8 +77,8 @@ export const useBudgetStatementActuals = ( const budgetTotalForecast = useMemo( () => - _.sumBy(currentBudgetStatement?.budgetStatementWallet, (wallet) => - _.sumBy( + sumBy(currentBudgetStatement?.budgetStatementWallet, (wallet) => + sumBy( wallet.budgetStatementLineItem.filter((item) => item.month === currentMonth), (item) => item?.forecast ?? 0 ) @@ -88,8 +88,8 @@ export const useBudgetStatementActuals = ( const budgetTotalActual = useMemo( () => - _.sumBy(currentBudgetStatement?.budgetStatementWallet, (wallet) => - _.sumBy( + sumBy(currentBudgetStatement?.budgetStatementWallet, (wallet) => + sumBy( wallet.budgetStatementLineItem.filter((item) => item.month === currentMonth), (item) => item?.actual ?? 0 ) @@ -99,8 +99,8 @@ export const useBudgetStatementActuals = ( const budgetTotalPayment = useMemo( () => - _.sumBy(currentBudgetStatement?.budgetStatementWallet, (wallet) => - _.sumBy( + sumBy(currentBudgetStatement?.budgetStatementWallet, (wallet) => + sumBy( wallet.budgetStatementLineItem.filter((item) => item.month === currentMonth), (item) => item?.payment ?? 0 ) diff --git a/src/components/BudgetStatement/BudgetStatementForecast/ForecastBreakdownSection/ForecastBreakdownSection.stories.tsx b/src/components/BudgetStatement/BudgetStatementForecast/ForecastBreakdownSection/ForecastBreakdownSection.stories.tsx index a92f83213..7af386dd0 100644 --- a/src/components/BudgetStatement/BudgetStatementForecast/ForecastBreakdownSection/ForecastBreakdownSection.stories.tsx +++ b/src/components/BudgetStatement/BudgetStatementForecast/ForecastBreakdownSection/ForecastBreakdownSection.stories.tsx @@ -1,7 +1,7 @@ import { DateTime } from 'luxon'; import { createThemeModeVariants } from '@/core/utils/storybook/factories'; -import { renderWallet } from '@/views/CoreUnitBudgetStatement/BudgetStatementtUtils'; -import ProgressiveIndicator from '../ProgresiveIndicator'; +import { renderWallet } from '@/views/CoreUnitBudgetStatement/BudgetStatementUtils'; +import ProgressiveIndicator from '../ProgressiveIndicator'; import ForecastBreakdownSection from './ForecastBreakdownSection'; import type { Meta } from '@storybook/react'; diff --git a/src/components/BudgetStatement/BudgetStatementForecast/ProgresiveIndicator.tsx b/src/components/BudgetStatement/BudgetStatementForecast/ProgressiveIndicator.tsx similarity index 100% rename from src/components/BudgetStatement/BudgetStatementForecast/ProgresiveIndicator.tsx rename to src/components/BudgetStatement/BudgetStatementForecast/ProgressiveIndicator.tsx diff --git a/src/components/BudgetStatement/BudgetStatementForecast/TotalForecastSection/TotalForecastSection.stories.tsx b/src/components/BudgetStatement/BudgetStatementForecast/TotalForecastSection/TotalForecastSection.stories.tsx index c58917632..d6d809931 100644 --- a/src/components/BudgetStatement/BudgetStatementForecast/TotalForecastSection/TotalForecastSection.stories.tsx +++ b/src/components/BudgetStatement/BudgetStatementForecast/TotalForecastSection/TotalForecastSection.stories.tsx @@ -4,9 +4,9 @@ import type { InnerTableColumn, InnerTableRow } from '@/components/AdvancedInner import { InnerTableRowBuilder } from '@/core/businessLogic/tableBuilderRow'; import { createThemeModeVariants } from '@/core/utils/storybook/factories'; -import { renderWallet } from '@/views/CoreUnitBudgetStatement/BudgetStatementtUtils'; +import { renderWallet } from '@/views/CoreUnitBudgetStatement/BudgetStatementUtils'; import HeaderWithIcon from '../HeaderWithIcon/HeaderWithIcon'; -import ProgressiveIndicator from '../ProgresiveIndicator'; +import ProgressiveIndicator from '../ProgressiveIndicator'; import TotalForecastSection from './TotalForecastSection'; import type { Meta } from '@storybook/react'; diff --git a/src/components/BudgetStatement/BudgetStatementForecast/useBudgetStatementForecast.tsx b/src/components/BudgetStatement/BudgetStatementForecast/useBudgetStatementForecast.tsx index 448e8e42c..a6be574b9 100644 --- a/src/components/BudgetStatement/BudgetStatementForecast/useBudgetStatementForecast.tsx +++ b/src/components/BudgetStatement/BudgetStatementForecast/useBudgetStatementForecast.tsx @@ -1,14 +1,13 @@ import { styled } from '@mui/material'; import { API_MONTH_TO_FORMAT } from '@ses/core/utils/date'; import { capitalizeSentence, getWalletWidthForWallets, toKebabCase } from '@ses/core/utils/string'; - -import _ from 'lodash'; +import isEmpty from 'lodash/isEmpty'; +import sortBy from 'lodash/sortBy'; import { useRouter } from 'next/router'; import { useEffect, useMemo, useRef, useState } from 'react'; import type { InnerTableColumn, InnerTableRow } from '@/components/AdvancedInnerTable/types'; - import HeaderWithIcon from '@/components/BudgetStatement/BudgetStatementForecast/HeaderWithIcon/HeaderWithIcon'; -import { renderWallet } from '@/views/CoreUnitBudgetStatement/BudgetStatementtUtils'; +import { renderWallet } from '@/views/CoreUnitBudgetStatement/BudgetStatementUtils'; import { getBudgetCapForMonthOnBudgetStatement, getBudgetCapForMonthOnWalletOnBudgetStatement, @@ -31,8 +30,7 @@ import { getForecastBreakdownColumns, } from '@/views/CoreUnitBudgetStatement/utils/forecastTableHelpers'; import replacePaymentTopup from '@/views/CoreUnitBudgetStatement/utils/helpers'; -import ProgressiveIndicator from './ProgresiveIndicator'; - +import ProgressiveIndicator from './ProgressiveIndicator'; import type { BudgetStatement } from '@ses/core/models/interfaces/budgetStatement'; import type { BudgetStatementWallet } from '@ses/core/models/interfaces/budgetStatementWallet'; import type { DateTime } from 'luxon'; @@ -59,7 +57,7 @@ export const useBudgetStatementForecast = (currentMonth: DateTime, budgetStateme } }); - return _.sortBy(Object.values(dict), 'id'); + return sortBy(Object.values(dict), 'id'); }, [currentMonth, budgetStatements]); const breakdownTabs = useMemo(() => { @@ -79,7 +77,7 @@ export const useBudgetStatementForecast = (currentMonth: DateTime, budgetStateme const breakdownTitleRef = useRef(null); useEffect(() => { - if (selectedBreakdown && !_.isEmpty(headerIds)) { + if (selectedBreakdown && !isEmpty(headerIds)) { setThirdIndex(Math.max(headerIds.indexOf(selectedBreakdown), 0)); } }, [selectedBreakdown, headerIds]); diff --git a/src/components/BudgetStatement/BudgetStatementMkrVesting/useBudgetStatementMkrVesting.tsx b/src/components/BudgetStatement/BudgetStatementMkrVesting/useBudgetStatementMkrVesting.tsx index 737afdd0b..b34106dd2 100644 --- a/src/components/BudgetStatement/BudgetStatementMkrVesting/useBudgetStatementMkrVesting.tsx +++ b/src/components/BudgetStatement/BudgetStatementMkrVesting/useBudgetStatementMkrVesting.tsx @@ -1,5 +1,7 @@ import { API_MONTH_TO_FORMAT } from '@ses/core/utils/date'; -import _ from 'lodash'; +import first from 'lodash/first'; +import orderBy from 'lodash/orderBy'; +import sumBy from 'lodash/sumBy'; import { useMemo } from 'react'; import type { InnerTableColumn, InnerTableRow } from '@/components/AdvancedInnerTable/types'; import ToolTipMkrVesting from './ToolTipMkrVesting'; @@ -24,7 +26,7 @@ export const useTransparencyMkrVesting = (currentMonth: DateTime, budgetStatemen return []; } - return _.sumBy(currentBudgetStatement?.budgetStatementMKRVest ?? [], (mkr) => mkr.mkrAmount); + return sumBy(currentBudgetStatement?.budgetStatementMKRVest ?? [], (mkr) => mkr.mkrAmount); }, [currentMonth, budgetStatements, currentBudgetStatement?.budgetStatementMKRVest]); const totalOldAmount = useMemo(() => { @@ -32,11 +34,11 @@ export const useTransparencyMkrVesting = (currentMonth: DateTime, budgetStatemen return []; } - return _.sumBy(currentBudgetStatement?.budgetStatementMKRVest ?? [], (mkr) => mkr.mkrAmountOld); + return sumBy(currentBudgetStatement?.budgetStatementMKRVest ?? [], (mkr) => mkr.mkrAmountOld); }, [currentMonth, budgetStatements, currentBudgetStatement?.budgetStatementMKRVest]); const fTEs = useMemo( - () => _.first(currentBudgetStatement?.budgetStatementFTEs)?.ftes ?? 'N/A', + () => first(currentBudgetStatement?.budgetStatementFTEs)?.ftes ?? 'N/A', [currentBudgetStatement?.budgetStatementFTEs] ); @@ -76,7 +78,7 @@ export const useTransparencyMkrVesting = (currentMonth: DateTime, budgetStatemen const mainTableItems: InnerTableRow[] = useMemo(() => { const result: InnerTableRow[] = []; - const mkrVestingsOrdered = _.orderBy(mkrVestings, 'vestingDate', 'asc'); + const mkrVestingsOrdered = orderBy(mkrVestings, 'vestingDate', 'asc'); mkrVestingsOrdered.forEach((mkrVesting) => { result.push({ diff --git a/src/components/BudgetStatement/BudgetStatementTransferRequest/components/TransferRequestSection/TransferRequestSection.stories.tsx b/src/components/BudgetStatement/BudgetStatementTransferRequest/components/TransferRequestSection/TransferRequestSection.stories.tsx index 0614c1eba..45b59265d 100644 --- a/src/components/BudgetStatement/BudgetStatementTransferRequest/components/TransferRequestSection/TransferRequestSection.stories.tsx +++ b/src/components/BudgetStatement/BudgetStatementTransferRequest/components/TransferRequestSection/TransferRequestSection.stories.tsx @@ -1,7 +1,7 @@ import { DateTime } from 'luxon'; import type { InnerTableColumn, InnerTableRow } from '@/components/AdvancedInnerTable/types'; import { createThemeModeVariants } from '@/core/utils/storybook/factories'; -import { renderWallet } from '@/views/CoreUnitBudgetStatement/BudgetStatementtUtils'; +import { renderWallet } from '@/views/CoreUnitBudgetStatement/BudgetStatementUtils'; import { TargetValueThreeMonths } from '../TargetValueThreeMonths/TargetValueThreeMonths'; import TransferRequestSection from './TransferRequestSection'; import type { Meta } from '@storybook/react'; diff --git a/src/components/BudgetStatement/BudgetStatementTransferRequest/useBudgetStatementTransferRequest.tsx b/src/components/BudgetStatement/BudgetStatementTransferRequest/useBudgetStatementTransferRequest.tsx index d1d85cca1..b72a355f3 100644 --- a/src/components/BudgetStatement/BudgetStatementTransferRequest/useBudgetStatementTransferRequest.tsx +++ b/src/components/BudgetStatement/BudgetStatementTransferRequest/useBudgetStatementTransferRequest.tsx @@ -3,7 +3,7 @@ import { formatNumber } from '@ses/core/utils/string'; import { DateTime } from 'luxon'; import { useCallback, useMemo } from 'react'; import type { InnerTableColumn, InnerTableRow } from '@/components/AdvancedInnerTable/types'; -import { TotalTargetBalance, renderWallet } from '@/views/CoreUnitBudgetStatement/BudgetStatementtUtils'; +import { TotalTargetBalance, renderWallet } from '@/views/CoreUnitBudgetStatement/BudgetStatementUtils'; import { useBudgetStatementForecast } from '../BudgetStatementForecast/useBudgetStatementForecast'; import { TargetValueThreeMonths } from './components/TargetValueThreeMonths/TargetValueThreeMonths'; diff --git a/src/core/businessLogic/coreUnits.ts b/src/core/businessLogic/coreUnits.ts index 94ba9c1e3..0ae102ee7 100644 --- a/src/core/businessLogic/coreUnits.ts +++ b/src/core/businessLogic/coreUnits.ts @@ -1,4 +1,6 @@ -import _ from 'lodash'; +import orderBy from 'lodash/orderBy'; +import sortBy from 'lodash/sortBy'; +import sum from 'lodash/sum'; import { DateTime, Interval } from 'luxon'; import { LinkTypeEnum } from '../enums/linkTypeEnum'; import { BudgetStatus } from '../models/dto/coreUnitDTO'; @@ -126,7 +128,7 @@ const getLatestBudgetStatementWithFTE = (budgetStatements: BudgetStatement[]): B }); }); - const orderBudget = _.orderBy(arrayItemsFts, 'month'); + const orderBudget = orderBy(arrayItemsFts, 'month'); return orderBudget.length > 0 ? orderBudget[orderBudget.length - 1] : null; }; @@ -227,7 +229,7 @@ export const getExpenditureAmountFromCoreUnit = (cu: CoreUnit) => { export const getPercentFromCoreUnit = (cu: CoreUnit) => { const value = getExpenditureValueFromCoreUnit(cu); - const budgetCap = _.sum(getBudgetCapsFromCoreUnit(cu)); + const budgetCap = sum(getBudgetCapsFromCoreUnit(cu)); if (value === 0) return 0; if (budgetCap === 0) return 0; @@ -255,7 +257,7 @@ export const getLast3ExpenditureValuesFromCoreUnit = (cu: CoreUnit) => { export const getCurrentOrLastMonthWithData = (budgetStatements: BudgetStatement[]) => { const currentMonth = DateTime.now().startOf('month'); - const orderedStatements = _.sortBy(budgetStatements, (bs) => bs.month).reverse(); + const orderedStatements = sortBy(budgetStatements, (bs) => bs.month).reverse(); for (const bs of orderedStatements) { for (const wallet of bs.budgetStatementWallet) { @@ -278,8 +280,8 @@ export const getLastMonthWithActualOrForecast = (budgetStatements: BudgetStateme // The budget statements should be provided in a descending date order but // it's better to order it client side to avoid future issues const orderedStatements = ascending - ? _.sortBy(budgetStatements, (bs) => bs.month) - : _.sortBy(budgetStatements, (bs) => bs.month).reverse(); + ? sortBy(budgetStatements, (bs) => bs.month) + : sortBy(budgetStatements, (bs) => bs.month).reverse(); for (const bs of orderedStatements) { for (const wallet of bs.budgetStatementWallet) { @@ -309,7 +311,7 @@ export const getLastUpdateForBudgetStatement = (element: WithActivityFeed, budge if (!activityFeed?.length) return undefined; - _.sortBy(activityFeed, (af) => af.created_at).reverse(); + sortBy(activityFeed, (af) => af.created_at).reverse(); return DateTime.fromISO(activityFeed[0].created_at); }; @@ -317,7 +319,7 @@ export const getLastUpdateForBudgetStatement = (element: WithActivityFeed, budge export const getLast3MonthsWithData = (budgetStatements: BudgetStatement[]) => { // The budget statements should be provided in a descending date order but // it's better to order it client side to avoid future issues - const orderedStatements = _.sortBy(budgetStatements, (bs) => bs.month).reverse(); + const orderedStatements = sortBy(budgetStatements, (bs) => bs.month).reverse(); for (const bs of orderedStatements) { for (const wallet of bs.budgetStatementWallet) { diff --git a/src/core/utils/finances.ts b/src/core/utils/finances.ts index 734c70e06..45e1e8ff4 100644 --- a/src/core/utils/finances.ts +++ b/src/core/utils/finances.ts @@ -1,5 +1,5 @@ -// File for calc -import _ from 'lodash'; +import orderBy from 'lodash/orderBy'; +import sumBy from 'lodash/sumBy'; import { API_MONTH_TO_FORMAT } from './date'; import { capitalizeSentence } from './string'; import type { BudgetStatement } from '../models/interfaces/budgetStatement'; @@ -22,22 +22,22 @@ export const getAllWallets = (propBudgetStatements: BudgetStatement[] | undefine } }); - return _.sortBy(Object.values(dict), 'id'); + return orderBy(Object.values(dict), 'id'); }; export const getWalletForecast = (wallet: BudgetStatementWallet, currentMonth: string) => - _.sumBy( + sumBy( wallet?.budgetStatementLineItem.filter((item) => item.month === currentMonth), (i) => i.forecast ?? 0 ); export const getWalletActual = (wallet: BudgetStatementWallet, currentMonth: string) => - _.sumBy( + sumBy( wallet?.budgetStatementLineItem.filter((item) => item.month === currentMonth), (i) => i.actual ?? 0 ); export const getWalletPayment = (wallet: BudgetStatementWallet, currentMonth: string) => - _.sumBy( + sumBy( wallet?.budgetStatementLineItem.filter((item) => item.month === currentMonth), (i) => i.payment ?? 0 ); @@ -46,24 +46,24 @@ export const getWalletDifference = (wallet: BudgetStatementWallet, currentMonth: getWalletForecast(wallet, currentMonth) - getWalletActual(wallet, currentMonth); export const budgetTotalForecast = (currentBudgetStatement: BudgetStatement, currentMonth: string) => - _.sumBy(currentBudgetStatement?.budgetStatementWallet, (wallet) => - _.sumBy( + sumBy(currentBudgetStatement?.budgetStatementWallet, (wallet) => + sumBy( wallet.budgetStatementLineItem.filter((item) => item.month === currentMonth), (item) => item?.forecast ?? 0 ) ); export const budgetTotalActual = (currentBudgetStatement: BudgetStatement, currentMonth: string) => - _.sumBy(currentBudgetStatement?.budgetStatementWallet, (wallet) => - _.sumBy( + sumBy(currentBudgetStatement?.budgetStatementWallet, (wallet) => + sumBy( wallet.budgetStatementLineItem.filter((item) => item.month === currentMonth), (item) => item?.actual ?? 0 ) ); export const budgetTotalPayment = (currentBudgetStatement: BudgetStatement, currentMonth: string) => - _.sumBy(currentBudgetStatement?.budgetStatementWallet, (wallet) => - _.sumBy( + sumBy(currentBudgetStatement?.budgetStatementWallet, (wallet) => + sumBy( wallet.budgetStatementLineItem.filter((item) => item.month === currentMonth), (item) => item?.payment ?? 0 ) @@ -73,13 +73,13 @@ export const budgetTotalDifference = (wallet: BudgetStatement, currentMonth: str budgetTotalForecast(wallet, currentMonth) - budgetTotalActual(wallet, currentMonth); export const getGroupForecast = (group: BudgetStatementLineItem[], currentMonth: string) => - _.sumBy( + sumBy( group.filter((item) => item.month === currentMonth), (item) => item.forecast ?? 0 ); export const getGroupActual = (group: BudgetStatementLineItem[], currentMonth: string) => - _.sumBy( + sumBy( group.filter((item) => item.month === currentMonth), (item) => item.actual ?? 0 ); diff --git a/src/stories/components/CoreUnitSummary/CoreUnitSummary.tsx b/src/stories/components/CoreUnitSummary/CoreUnitSummary.tsx index 4fdb85cde..02e74a02e 100644 --- a/src/stories/components/CoreUnitSummary/CoreUnitSummary.tsx +++ b/src/stories/components/CoreUnitSummary/CoreUnitSummary.tsx @@ -1,6 +1,6 @@ import { Collapse, Typography, styled, useMediaQuery } from '@mui/material'; import { siteRoutes } from '@ses/config/routes'; -import _ from 'lodash'; +import isEmpty from 'lodash/isEmpty'; import { useRouter } from 'next/router'; import React, { forwardRef, useCallback, useMemo } from 'react'; import { useCoreUnitsTableView } from '@/views/CoreUnitsIndex/useCoreUnitsTableView'; @@ -49,7 +49,7 @@ export const CoreUnitSummary = forwardRef( const searchText = useMemo(() => getStringParam('searchText', router.query), [router.query]); const cu = data?.find((cu) => cu.shortCode === code); - const buildCULabel = () => (!_.isEmpty(cu) ? `${cu?.shortCode ?? ''} - ${cu?.name}` : ''); + const buildCULabel = () => (!isEmpty(cu) ? `${cu?.shortCode ?? ''} - ${cu?.name}` : ''); const filteredData = useMemo(() => { const { filteredData: filtered } = filterData({ diff --git a/src/views/CoreUnitBudgetStatement/BudgetStatementtUtils.tsx b/src/views/CoreUnitBudgetStatement/BudgetStatementUtils.tsx similarity index 100% rename from src/views/CoreUnitBudgetStatement/BudgetStatementtUtils.tsx rename to src/views/CoreUnitBudgetStatement/BudgetStatementUtils.tsx diff --git a/src/views/CoreUnitBudgetStatement/utils/actualsTableHelpers.tsx b/src/views/CoreUnitBudgetStatement/utils/actualsTableHelpers.tsx index f2f441a47..ba557778a 100644 --- a/src/views/CoreUnitBudgetStatement/utils/actualsTableHelpers.tsx +++ b/src/views/CoreUnitBudgetStatement/utils/actualsTableHelpers.tsx @@ -1,6 +1,6 @@ import groupBy from 'lodash/groupBy'; import type { InnerTableColumn, InnerTableRow, RowType } from '@/components/AdvancedInnerTable/types'; -import { OpenModalTransparency } from '../BudgetStatementtUtils'; +import { OpenModalTransparency } from '../BudgetStatementUtils'; import { getCommentsFromCategory, getGroupActual, diff --git a/src/views/CoreUnitBudgetStatement/utils/budgetStatementsUtils.ts b/src/views/CoreUnitBudgetStatement/utils/budgetStatementsUtils.ts index 1f1d6da69..3408e4869 100644 --- a/src/views/CoreUnitBudgetStatement/utils/budgetStatementsUtils.ts +++ b/src/views/CoreUnitBudgetStatement/utils/budgetStatementsUtils.ts @@ -1,6 +1,5 @@ import { API_MONTH_TO_FORMAT } from '@ses/core/utils/date'; -import _ from 'lodash'; - +import sumBy from 'lodash/sumBy'; import type { InnerTableColumn } from '@/components/AdvancedInnerTable/types'; import type { BudgetStatement } from '@ses/core/models/interfaces/budgetStatement'; import type { @@ -19,37 +18,37 @@ export const hasGroupExpenses = (wallet: BudgetStatementWallet, group: string, m .some((x) => (x.actual || x.forecast) && x.month === month); export const getGroupActual = (group: BudgetStatementLineItem[], month: string) => - _.sumBy( + sumBy( group.filter((item) => item.month === month), (item) => item.actual ?? 0 ); export const getWalletMonthlyBudget = (wallet: BudgetStatementWallet, month: string) => - _.sumBy( + sumBy( wallet.budgetStatementLineItem.filter((item) => item.month === month), (i) => i.budgetCap ?? 0 ); export const getWalletActual = (wallet: BudgetStatementWallet, month: string) => - _.sumBy( + sumBy( wallet?.budgetStatementLineItem.filter((item) => item.month === month), (i) => i.actual ?? 0 ); export const getGroupMonthlyBudget = (group: BudgetStatementLineItem[], month: string) => - _.sumBy( + sumBy( group.filter((item) => item.month === month), (item) => item.budgetCap ?? 0 ); export const getGroupForecast = (group: BudgetStatementLineItem[], month: string) => - _.sumBy( + sumBy( group.filter((item) => item.month === month), (item) => item.forecast ?? 0 ); export const getWalletForecast = (wallet: BudgetStatementWallet, month: string) => - _.sumBy( + sumBy( wallet.budgetStatementLineItem.filter((item) => item.month === month), (i) => i.forecast ?? 0 ); @@ -61,13 +60,13 @@ export const getWalletDifference = (wallet: BudgetStatementWallet, month: string getWalletForecast(wallet, month) - getWalletActual(wallet, month); export const getGroupPayment = (group: BudgetStatementLineItem[], month: string) => - _.sumBy( + sumBy( group.filter((item) => item.month === month), (item) => item.payment ?? 0 ); export const getWalletPayment = (wallet: BudgetStatementWallet, month: string) => - _.sumBy( + sumBy( wallet?.budgetStatementLineItem.filter((item) => item.month === month), (i) => i.payment ?? 0 ); @@ -128,7 +127,7 @@ export const getForecastForMonthOnWalletOnBudgetStatement = ( if (!wallet) return 0; - return _.sumBy( + return sumBy( wallet?.budgetStatementLineItem.filter((item) => item.month === month.toFormat(API_MONTH_TO_FORMAT)), (i) => i.forecast ?? 0 ); @@ -151,7 +150,7 @@ export const getBudgetCapForMonthOnWalletOnBudgetStatement = ( if (!wallet) return 0; - return _.sumBy( + return sumBy( wallet?.budgetStatementLineItem.filter((item) => item.month === month?.toFormat(API_MONTH_TO_FORMAT)), (i) => i.budgetCap ?? 0 ); @@ -198,8 +197,8 @@ export const getForecastSumForMonth = ( ) => { const budgetStatement = budgetStatements?.find((x) => x.month === currentMonth.toFormat(API_MONTH_TO_FORMAT)) ?? null; - return _.sumBy(budgetStatement?.budgetStatementWallet, (wallet) => - _.sumBy( + return sumBy(budgetStatement?.budgetStatementWallet, (wallet) => + sumBy( wallet?.budgetStatementLineItem?.filter((item) => item.month === month.toFormat(API_MONTH_TO_FORMAT)), (item) => item.forecast ?? 0 ) @@ -227,8 +226,8 @@ export const getBudgetCapForMonthOnBudgetStatement = ( ) => { const budgetStatement = budgetStatements?.find((x) => x.month === currentMonth.toFormat(API_MONTH_TO_FORMAT)) ?? null; - return _.sumBy(budgetStatement?.budgetStatementWallet, (wallet) => - _.sumBy( + return sumBy(budgetStatement?.budgetStatementWallet, (wallet) => + sumBy( wallet?.budgetStatementLineItem?.filter((item) => item.month === month.toFormat(API_MONTH_TO_FORMAT)), (item) => item.budgetCap ?? 0 ) @@ -273,28 +272,28 @@ export const getLineItemsForWalletOnMonth = ( }; export const getLineItemForecastSumForMonth = (items: BudgetStatementLineItem[], month: DateTime) => - _.sumBy( + sumBy( items.filter((item) => item.month === month.toFormat(API_MONTH_TO_FORMAT)), (item) => item.forecast ?? 0 ); export const getLineItemForecastSumForMonths = (items: BudgetStatementLineItem[], months: DateTime[]) => { const formattedMonths = months.map((x) => x.toFormat(API_MONTH_TO_FORMAT)); - return _.sumBy( + return sumBy( items.filter((item) => formattedMonths.includes(item.month ?? '')), (item) => item.forecast ?? 0 ); }; export const getBudgetCapForMonthOnLineItem = (items: BudgetStatementLineItem[], month: DateTime) => - _.sumBy( + sumBy( items.filter((item) => item.month === month.toFormat(API_MONTH_TO_FORMAT)), (item) => item.budgetCap ?? 0 ); export const getTotalQuarterlyBudgetCapOnLineItem = (items: BudgetStatementLineItem[], months: DateTime[]) => { const formattedMonths = months.map((x) => x.toFormat(API_MONTH_TO_FORMAT)); - return _.sumBy( + return sumBy( items.filter((item) => formattedMonths.indexOf(item.month ?? '') > -1), (item) => item.budgetCap ?? 0 ); diff --git a/src/views/CoreUnitBudgetStatement/utils/forecastHelper.ts b/src/views/CoreUnitBudgetStatement/utils/forecastHelper.ts index d7fae6e35..124ba192f 100644 --- a/src/views/CoreUnitBudgetStatement/utils/forecastHelper.ts +++ b/src/views/CoreUnitBudgetStatement/utils/forecastHelper.ts @@ -1,7 +1,7 @@ import { ExpenditureLevel } from '@ses/core/enums/expenditureLevelEnum'; import { API_MONTH_TO_FORMAT } from '@ses/core/utils/date'; import { percentageRespectTo } from '@ses/core/utils/math'; -import _ from 'lodash'; +import sumBy from 'lodash/sumBy'; import type { BudgetStatement } from '@ses/core/models/interfaces/budgetStatement'; import type { BudgetStatementLineItem, @@ -158,7 +158,7 @@ export const getTransferRequestSource = (wallet: BudgetStatementWallet): Source export const getWalletMonthlyBudgetForeCast = (wallet: BudgetStatementWallet, month: string) => { const itemsSum = wallet.budgetStatementLineItem.filter((item) => item.month === month); if (itemsSum.length === 0) return 'N/A'; - return _.sumBy(itemsSum, (i) => i.budgetCap ?? 0); + return sumBy(itemsSum, (i) => i.budgetCap ?? 0); }; export const getForecastForMonthOnWalletOnBudgetStatementOrNA = ( @@ -180,7 +180,7 @@ export const getForecastForMonthOnWalletOnBudgetStatementOrNA = ( (item) => item.month === month.toFormat(API_MONTH_TO_FORMAT) ); if (itemsToSum.length === 0) return 'N/A'; - return _.sumBy( + return sumBy( wallet?.budgetStatementLineItem.filter((item) => item.month === month.toFormat(API_MONTH_TO_FORMAT)), (i) => i.forecast ?? 0 ); @@ -239,8 +239,8 @@ export const getBudgetCapForMonthOnBudgetStatementForeCast = ( ) => { const budgetStatement = budgetStatements?.find((x) => x.month === currentMonth.toFormat(API_MONTH_TO_FORMAT)) ?? null; let countNumber = 0; - const sumTotal = _.sumBy(budgetStatement?.budgetStatementWallet, (wallet) => - _.sumBy( + const sumTotal = sumBy(budgetStatement?.budgetStatementWallet, (wallet) => + sumBy( wallet?.budgetStatementLineItem?.filter((item) => item.month === month.toFormat(API_MONTH_TO_FORMAT)), (item) => { countNumber++; @@ -276,7 +276,7 @@ export const getBudgetCapForMonthOnWalletOnBudgetStatementForeCast = ( (item) => item.month === month?.toFormat(API_MONTH_TO_FORMAT) ); if (arrayItems.length === 0) return 'N/A'; - const moment = _.sumBy( + const moment = sumBy( wallet?.budgetStatementLineItem.filter((item) => item.month === month?.toFormat(API_MONTH_TO_FORMAT)), (i) => i.budgetCap ?? 9 ); @@ -291,7 +291,7 @@ export const getBudgetCapForMonthOnLineItemForeCast = ( let countNumber = 0; const itemsSum = items.filter((item) => item.month === month.toFormat(API_MONTH_TO_FORMAT)); if (itemsSum.length === 0) return 'N/A'; - const sumTotal = _.sumBy(itemsSum, (item) => { + const sumTotal = sumBy(itemsSum, (item) => { countNumber++; return item.budgetCap ?? 0; }); diff --git a/src/views/CoreUnitBudgetStatement/utils/forecastTableHelpers.tsx b/src/views/CoreUnitBudgetStatement/utils/forecastTableHelpers.tsx index 1bc2fc16e..befd6fea6 100644 --- a/src/views/CoreUnitBudgetStatement/utils/forecastTableHelpers.tsx +++ b/src/views/CoreUnitBudgetStatement/utils/forecastTableHelpers.tsx @@ -1,7 +1,7 @@ import groupBy from 'lodash/groupBy'; import type { InnerTableColumn, InnerTableRow, RowType } from '@/components/AdvancedInnerTable/types'; -import ProgressiveIndicator from '@/components/BudgetStatement/BudgetStatementForecast/ProgresiveIndicator'; +import ProgressiveIndicator from '@/components/BudgetStatement/BudgetStatementForecast/ProgressiveIndicator'; import { getBudgetCapForMonthOnLineItem, getBudgetCapForMonthOnWalletOnBudgetStatement, diff --git a/src/views/RecognizedDelegatesBudgetStatement/components/DelegatesActuals/useDelegatesActuals.ts b/src/views/RecognizedDelegatesBudgetStatement/components/DelegatesActuals/useDelegatesActuals.ts index c6d9999f7..adebbe929 100644 --- a/src/views/RecognizedDelegatesBudgetStatement/components/DelegatesActuals/useDelegatesActuals.ts +++ b/src/views/RecognizedDelegatesBudgetStatement/components/DelegatesActuals/useDelegatesActuals.ts @@ -1,4 +1,6 @@ -import _ from 'lodash'; +import groupBy from 'lodash/groupBy'; +import isEmpty from 'lodash/isEmpty'; +import sumBy from 'lodash/sumBy'; import { useCallback, useEffect, useMemo, useRef, useState } from 'react'; import type { InnerTableColumn, InnerTableRow, RowType } from '@/components/AdvancedInnerTable/types'; import { useUrlAnchor } from '@/core/hooks/useUrlAnchor'; @@ -20,7 +22,7 @@ import { getWalletPayment, } from '@/core/utils/finances'; import { getWalletWidthForWallets } from '@/core/utils/string'; -import { renderWallet } from '@/views/CoreUnitBudgetStatement/BudgetStatementtUtils'; +import { renderWallet } from '@/views/CoreUnitBudgetStatement/BudgetStatementUtils'; import type { DateTime } from 'luxon'; export const useDelegatesActuals = (propsCurrentMonth: DateTime, budgetStatements: BudgetStatement[] | undefined) => { @@ -52,7 +54,7 @@ export const useDelegatesActuals = (propsCurrentMonth: DateTime, budgetStatement const getGroupPayment = useCallback( (group: BudgetStatementLineItem[]) => - _.sumBy( + sumBy( group.filter((item) => item.month === currentMonth), (item) => item.payment ?? 0 ), @@ -95,7 +97,7 @@ export const useDelegatesActuals = (propsCurrentMonth: DateTime, budgetStatement }, [breakdownTabsActuals]); useEffect(() => { - if (!scrolled && anchor && !_.isEmpty(headerIdsActuals) && headerIdsActuals.includes(anchor)) { + if (!scrolled && anchor && !isEmpty(headerIdsActuals) && headerIdsActuals.includes(anchor)) { setScrolled(true); let offset = (breakdownTitleRef?.current?.offsetTop || 0) - 260; const windowsWidth = Math.max(document.documentElement.clientWidth || 0, window.innerWidth || 0); @@ -277,7 +279,7 @@ export const useDelegatesActuals = (propsCurrentMonth: DateTime, budgetStatement const getBreakdownItems = useCallback( (items: BudgetStatementLineItem[], type?: RowType) => { const result: InnerTableRow[] = []; - const grouped = _.groupBy(items, (item) => item.group); + const grouped = groupBy(items, (item) => item.group); for (const groupedKey in grouped) { if ( @@ -288,7 +290,7 @@ export const useDelegatesActuals = (propsCurrentMonth: DateTime, budgetStatement continue; } - const groupedCategory = _.groupBy(grouped[groupedKey], (item) => item.budgetCategory); + const groupedCategory = groupBy(grouped[groupedKey], (item) => item.budgetCategory); let i = 1; for (const groupedCatKey in groupedCategory) { diff --git a/src/views/RecognizedDelegatesBudgetStatement/components/DelegatesForecast/useDelegatesForecast.ts b/src/views/RecognizedDelegatesBudgetStatement/components/DelegatesForecast/useDelegatesForecast.ts index f41d799b7..1ec11d307 100644 --- a/src/views/RecognizedDelegatesBudgetStatement/components/DelegatesForecast/useDelegatesForecast.ts +++ b/src/views/RecognizedDelegatesBudgetStatement/components/DelegatesForecast/useDelegatesForecast.ts @@ -1,4 +1,6 @@ -import _ from 'lodash'; +import groupBy from 'lodash/groupBy'; +import isEmpty from 'lodash/isEmpty'; +import sumBy from 'lodash/sumBy'; import { useEffect, useMemo, useRef, useState, useCallback } from 'react'; import type { InnerTableColumn, InnerTableRow, RowType } from '@/components/AdvancedInnerTable/types'; import { useUrlAnchor } from '@/core/hooks/useUrlAnchor'; @@ -7,7 +9,7 @@ import type { BudgetStatementLineItem } from '@/core/models/interfaces/budgetSta import { API_MONTH_TO_FORMAT } from '@/core/utils/date'; import { getAllWallets } from '@/core/utils/finances'; import { getWalletWidthForWallets } from '@/core/utils/string'; -import { renderWallet } from '@/views/CoreUnitBudgetStatement/BudgetStatementtUtils'; +import { renderWallet } from '@/views/CoreUnitBudgetStatement/BudgetStatementUtils'; import type { DateTime } from 'luxon'; export const useDelegatesForecast = (currentMonth: DateTime, propBudgetStatements: BudgetStatement[]) => { @@ -37,7 +39,7 @@ export const useDelegatesForecast = (currentMonth: DateTime, propBudgetStatement if (!wallet) return 0; - return _.sumBy( + return sumBy( wallet?.budgetStatementLineItem.filter((item) => item.month === month.toFormat(API_MONTH_TO_FORMAT)), (i) => i.forecast ?? 0 ); @@ -60,7 +62,7 @@ export const useDelegatesForecast = (currentMonth: DateTime, propBudgetStatement if (!wallet) return 0; - return _.sumBy( + return sumBy( wallet?.budgetStatementLineItem.filter((item) => item.month === month?.toFormat(API_MONTH_TO_FORMAT)), (i) => i.budgetCap ?? 0 ); @@ -110,8 +112,8 @@ export const useDelegatesForecast = (currentMonth: DateTime, propBudgetStatement const budgetStatement = budgetStatements?.find((x) => x.month === currentMonth.toFormat(API_MONTH_TO_FORMAT)) ?? null; - return _.sumBy(budgetStatement?.budgetStatementWallet, (wallet) => - _.sumBy( + return sumBy(budgetStatement?.budgetStatementWallet, (wallet) => + sumBy( wallet?.budgetStatementLineItem?.filter((item) => item.month === month.toFormat(API_MONTH_TO_FORMAT)), (item) => item.forecast ?? 0 ) @@ -139,8 +141,8 @@ export const useDelegatesForecast = (currentMonth: DateTime, propBudgetStatement const budgetStatement = budgetStatements?.find((x) => x.month === currentMonth.toFormat(API_MONTH_TO_FORMAT)) ?? null; - return _.sumBy(budgetStatement?.budgetStatementWallet, (wallet) => - _.sumBy( + return sumBy(budgetStatement?.budgetStatementWallet, (wallet) => + sumBy( wallet?.budgetStatementLineItem?.filter((item) => item.month === month.toFormat(API_MONTH_TO_FORMAT)), (item) => item.budgetCap ?? 0 ) @@ -188,28 +190,28 @@ export const useDelegatesForecast = (currentMonth: DateTime, propBudgetStatement }; const getLineItemForecastSumForMonth = (items: BudgetStatementLineItem[], month: DateTime) => - _.sumBy( + sumBy( items.filter((item) => item.month === month.toFormat(API_MONTH_TO_FORMAT)), (item) => item.forecast ?? 0 ); const getLineItemForecastSumForMonths = (items: BudgetStatementLineItem[], months: DateTime[]) => { const formattedMonths = months.map((x) => x.toFormat(API_MONTH_TO_FORMAT)); - return _.sumBy( + return sumBy( items.filter((item) => formattedMonths.indexOf(item.month ?? '') > -1), (item) => item.forecast ?? 0 ); }; const getBudgetCapForMonthOnLineItem = (items: BudgetStatementLineItem[], month: DateTime) => - _.sumBy( + sumBy( items.filter((item) => item.month === month.toFormat(API_MONTH_TO_FORMAT)), (item) => item.budgetCap ?? 0 ); const getTotalQuarterlyBudgetCapOnLineItem = (items: BudgetStatementLineItem[], months: DateTime[]) => { const formattedMonths = months.map((x) => x.toFormat(API_MONTH_TO_FORMAT)); - return _.sumBy( + return sumBy( items.filter((item) => formattedMonths.indexOf(item.month ?? '') > -1), (item) => item.budgetCap ?? 0 ); @@ -230,7 +232,7 @@ export const useDelegatesForecast = (currentMonth: DateTime, propBudgetStatement const [scrolled, setScrolled] = useState(false); useEffect(() => { - if (!scrolled && anchor && !_.isEmpty(headerIdsForecast) && headerIdsForecast.includes(anchor)) { + if (!scrolled && anchor && !isEmpty(headerIdsForecast) && headerIdsForecast.includes(anchor)) { setScrolled(true); let offset = (breakdownTitleRefForecast?.current?.offsetTop || 0) - 260; const windowsWidth = Math.max(document.documentElement.clientWidth || 0, window.innerWidth || 0); @@ -245,7 +247,7 @@ export const useDelegatesForecast = (currentMonth: DateTime, propBudgetStatement }, [anchor, headerIdsForecast, scrolled]); useEffect(() => { - if (anchor && !_.isEmpty(headerIdsForecast)) { + if (anchor && !isEmpty(headerIdsForecast)) { setThirdIndexForecast(Math.max(headerIdsForecast.indexOf(anchor), 0)); } }, [anchor, headerIdsForecast]); @@ -527,7 +529,7 @@ export const useDelegatesForecast = (currentMonth: DateTime, propBudgetStatement }; for (const groupedKey in grouped) { - const groupedCategory = _.groupBy(grouped[groupedKey], (item) => item.budgetCategory); + const groupedCategory = groupBy(grouped[groupedKey], (item) => item.budgetCategory); let i = 1; for (const groupedCatKey in groupedCategory) { @@ -703,7 +705,7 @@ export const useDelegatesForecast = (currentMonth: DateTime, propBudgetStatement ], }); - const groupedHeadCount = _.groupBy( + const groupedHeadCount = groupBy( ungrouped.filter((x) => x.headcountExpense), (item) => item.group ); @@ -724,7 +726,7 @@ export const useDelegatesForecast = (currentMonth: DateTime, propBudgetStatement ], }); - const groupedNonHeadCount = _.groupBy( + const groupedNonHeadCount = groupBy( ungrouped.filter((x) => !x.headcountExpense), (item) => item.group );