diff --git a/.eslintrc.js b/.eslintrc.js
index 6b12d72670..c1d11bd2be 100644
--- a/.eslintrc.js
+++ b/.eslintrc.js
@@ -24,7 +24,10 @@ module.exports = {
'import/no-named-default': 'error',
'import/no-anonymous-default-export': 'error',
'import/dynamic-import-chunkname': 'error',
- '@typescript-eslint/no-unused-vars': ['error', { argsIgnorePattern: '^_' }],
+ '@typescript-eslint/no-unused-vars': [
+ 'error',
+ { argsIgnorePattern: '^_', varsIgnorePattern: '^_' },
+ ],
},
settings: {
react: {
diff --git a/pages/accountLists/[accountListId]/tasks.tsx b/pages/accountLists/[accountListId]/tasks.tsx
index 2a4a7aa629..71bf4f3ad6 100644
--- a/pages/accountLists/[accountListId]/tasks.tsx
+++ b/pages/accountLists/[accountListId]/tasks.tsx
@@ -3,23 +3,21 @@ import Head from 'next/head';
import { GetServerSideProps } from 'next';
import { getSession } from 'next-auth/client';
import { useTranslation } from 'react-i18next';
-import { castArray, pick } from 'lodash/fp';
import { parse } from 'query-string';
import { useRouter } from 'next/router';
import { useApp } from '../../../src/components/App';
import TaskHome from '../../../src/components/Task/Home';
import { TaskFilter } from '../../../src/components/Task/List/List';
-import reduceObject from '../../../src/lib/reduceObject';
export const initialFilterFromPath = (path: string): TaskFilter => {
- let initialFilter = {};
+ let initialFilter: TaskFilter = {};
const queryString = path.split('?')[1];
if (queryString) {
const filter = parse(queryString);
- initialFilter = reduceObject(
- (result: TaskFilter, value: string | string[], key: string) => {
+ initialFilter = Object.entries(filter).reduce(
+ (result: TaskFilter, [key, value]) => {
switch (key) {
case 'completed':
result.completed = value === 'true';
@@ -36,28 +34,34 @@ export const initialFilterFromPath = (path: string): TaskFilter => {
result.startAt.min = value.toString();
break;
default:
- result[key.replace('[]', '')] = castArray(value);
+ result[key.replace('[]', '')] = Array.isArray(value)
+ ? value
+ : [value];
}
return result;
},
{},
- filter,
);
- initialFilter = pick(
- [
- 'userIds',
- 'tags',
- 'contactIds',
- 'activityType',
- 'completed',
- 'wildcardSearch',
- 'startAt',
- ],
- initialFilter,
- );
+ const {
+ userIds,
+ tags,
+ contactIds,
+ activityType,
+ completed,
+ wildcardSearch,
+ startAt,
+ } = initialFilter;
- return initialFilter;
+ return {
+ userIds,
+ tags,
+ contactIds,
+ activityType,
+ completed,
+ wildcardSearch,
+ startAt,
+ };
}
};
diff --git a/src/components/App/Provider.tsx b/src/components/App/Provider.tsx
index f3d6ff8915..1c4825dca2 100644
--- a/src/components/App/Provider.tsx
+++ b/src/components/App/Provider.tsx
@@ -6,7 +6,6 @@ import React, {
Dispatch,
} from 'react';
import { v4 as uuidv4 } from 'uuid';
-import { omit, remove, find } from 'lodash/fp';
import TaskDrawer, { TaskDrawerProps } from '../Task/Drawer/Drawer';
import theme from '../../theme';
import rootReducer, { Action, AppState } from './rootReducer';
@@ -39,12 +38,10 @@ const AppProvider = ({ initialState, children }: Props): ReactElement => {
const id = uuidv4();
if (
!taskDrawerProps.taskId ||
- !find(
- {
- taskId: taskDrawerProps.taskId,
- showCompleteForm: taskDrawerProps.showCompleteForm,
- },
- taskDrawers,
+ !taskDrawers.find(
+ ({ taskId, showCompleteForm }) =>
+ taskId === taskDrawerProps.taskId &&
+ showCompleteForm === taskDrawerProps.showCompleteForm,
)
) {
setTaskDrawers([
@@ -56,7 +53,9 @@ const AppProvider = ({ initialState, children }: Props): ReactElement => {
taskDrawerProps.onClose && taskDrawerProps.onClose();
setTimeout(
() =>
- setTaskDrawers((taskDrawers) => remove({ id }, taskDrawers)),
+ setTaskDrawers((taskDrawers) =>
+ taskDrawers.filter(({ id: taskId }) => taskId !== id),
+ ),
theme.transitions.duration.leavingScreen,
);
},
@@ -74,9 +73,11 @@ const AppProvider = ({ initialState, children }: Props): ReactElement => {
return (
{children}
- {taskDrawers.map((props: TaskDrawerPropsWithId) => (
-
- ))}
+ {taskDrawers.map((props: TaskDrawerPropsWithId) => {
+ const { id, ...taskDrawerProps } = props;
+
+ return ;
+ })}
);
};
diff --git a/src/components/Dashboard/ThisWeek/PartnerCare/PartnerCare.tsx b/src/components/Dashboard/ThisWeek/PartnerCare/PartnerCare.tsx
index 3c5b1a0cef..14f6ff7bbf 100644
--- a/src/components/Dashboard/ThisWeek/PartnerCare/PartnerCare.tsx
+++ b/src/components/Dashboard/ThisWeek/PartnerCare/PartnerCare.tsx
@@ -21,7 +21,7 @@ import CakeIcon from '@material-ui/icons/Cake';
import FavoriteIcon from '@material-ui/icons/Favorite';
import { Skeleton } from '@material-ui/lab';
import { motion } from 'framer-motion';
-import { uniqBy } from 'lodash/fp';
+import uniqBy from 'lodash/fp/uniqBy';
import { useTranslation } from 'react-i18next';
import Link from 'next/link';
import { dayMonthFormat } from '../../../../lib/intlFormat';
diff --git a/src/components/Layouts/Primary/TopBar/NotificationMenu/Item/Item.tsx b/src/components/Layouts/Primary/TopBar/NotificationMenu/Item/Item.tsx
index 8ead1060cc..5045b9a71d 100644
--- a/src/components/Layouts/Primary/TopBar/NotificationMenu/Item/Item.tsx
+++ b/src/components/Layouts/Primary/TopBar/NotificationMenu/Item/Item.tsx
@@ -13,7 +13,6 @@ import {
import { Skeleton } from '@material-ui/lab';
import React, { ReactElement } from 'react';
import { useTranslation } from 'react-i18next';
-import { cloneDeep, isFunction } from 'lodash/fp';
import { isSameMonth } from 'date-fns';
import { AcknowledgeUserNotificationMutation } from '../../../../../../../types/AcknowledgeUserNotificationMutation';
import {
@@ -102,14 +101,19 @@ const NotificationMenuItem = ({
after: null,
},
};
- const data = cloneDeep(cache.readQuery(query));
+ const dataFromCache = cache.readQuery(query);
+ const data = {
+ userNotifications: {
+ ...dataFromCache.userNotifications,
+ },
+ };
data.userNotifications.unreadCount--;
cache.writeQuery({ ...query, data });
optimisticResponse = false;
},
});
}
- if (isFunction(onClick)) onClick();
+ if (typeof onClick === 'function') onClick();
};
let message;
diff --git a/src/components/Layouts/Primary/TopBar/NotificationMenu/NotificationMenu.tsx b/src/components/Layouts/Primary/TopBar/NotificationMenu/NotificationMenu.tsx
index 646c878639..d0bd4ce98c 100644
--- a/src/components/Layouts/Primary/TopBar/NotificationMenu/NotificationMenu.tsx
+++ b/src/components/Layouts/Primary/TopBar/NotificationMenu/NotificationMenu.tsx
@@ -13,7 +13,6 @@ import React, { ReactElement, useEffect, useState } from 'react';
import NotificationsIcon from '@material-ui/icons/Notifications';
import { gql, useMutation, useLazyQuery } from '@apollo/client';
import { useTranslation } from 'react-i18next';
-import { cloneDeep } from 'lodash/fp';
import { useApp } from '../../../../App';
import { GetNotificationsQuery } from '../../../../../../types/GetNotificationsQuery';
import { AcknowledgeAllUserNotificationsMutation } from '../../../../../../types/AcknowledgeAllUserNotificationsMutation';
@@ -105,7 +104,12 @@ const NotificationMenu = (): ReactElement => {
after: null,
},
};
- const data = cloneDeep(cache.readQuery(query));
+ const dataFromCache = cache.readQuery(query);
+ const data = {
+ userNotifications: {
+ ...dataFromCache.userNotifications,
+ },
+ };
data.userNotifications.unreadCount = 0;
data.userNotifications.edges = data.userNotifications.edges.map(
({ node }) => ({
diff --git a/src/components/Layouts/Primary/TopBar/TopBar.tsx b/src/components/Layouts/Primary/TopBar/TopBar.tsx
index 0bc8fd6f20..a0e67837ab 100644
--- a/src/components/Layouts/Primary/TopBar/TopBar.tsx
+++ b/src/components/Layouts/Primary/TopBar/TopBar.tsx
@@ -26,7 +26,6 @@ import MenuIcon from '@material-ui/icons/Menu';
import clsx from 'clsx';
import { useTranslation } from 'react-i18next';
import { signout } from 'next-auth/client';
-import { compact } from 'lodash/fp';
import NextLink from 'next/link';
import { GetTopBarQuery } from '../../../../../types/GetTopBarQuery';
import { SIDE_BAR_MINIMIZED_WIDTH, SIDE_BAR_WIDTH } from '../SideBar/SideBar';
@@ -366,9 +365,9 @@ const TopBar = ({ open, handleOpenChange }: Props): ReactElement => {
{data.user.firstName[0]}
@@ -400,7 +399,7 @@ const TopBar = ({ open, handleOpenChange }: Props): ReactElement => {
{(data?.user?.admin ||
- !!data?.user?.administrativeOrganizations?.nodes?.length) && (
+ data?.user?.administrativeOrganizations?.nodes?.length) && (