Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bal 1644 - report in case management #2343

Closed
wants to merge 109 commits into from
Closed
Show file tree
Hide file tree
Changes from 69 commits
Commits
Show all changes
109 commits
Select commit Hold shift + click to select a range
a229547
feat: add new controller for busniess report get api
liorzblrn Apr 15, 2024
6fe5693
feat: add seed and new get alerts api
liorzblrn Apr 15, 2024
1888d2e
fix: remove executionDetails from alert reponse
liorzblrn Apr 16, 2024
d657ee4
feat: added initial onboarding alerts table & implemented Filters com…
chesterkmr Apr 16, 2024
2c03c6e
feat: updated callback to ongoing to format response for each report
Blokh Apr 21, 2024
fa0dd21
Merge branch 'dev' into blokh/feat/add-business-report-report-id
Blokh Apr 21, 2024
e849d29
feat: updated report return logic
Blokh Apr 21, 2024
9de6f37
Merge branch 'blokh/feat/add-business-report-report-id' of github.com…
Blokh Apr 21, 2024
35abd78
feat: added validation via zod
Blokh Apr 21, 2024
89d3169
feat: removed optional report id
Blokh Apr 21, 2024
fa8935c
feat(backoffice): business ongoing monitoring
alonp99 Apr 23, 2024
cfe515d
feat(backoffice): business ongoing monitoring
alonp99 Apr 23, 2024
dc05878
merged with dev
Blokh Apr 24, 2024
924ccaf
Merge branch 'dev' into blokh/feat/add-business-report-report-id
Blokh Apr 24, 2024
0d1ed0b
updated ongoing service
Blokh Apr 24, 2024
76cefc9
feat: updated business report logic and added business list fetching
Blokh Apr 25, 2024
549cb7d
updated callback handler hook
Blokh Apr 25, 2024
1d15b8c
Merge branch 'dev' into blokh/feat/add-business-report-report-id
Blokh Apr 25, 2024
e72ae5f
merged with dev
Blokh Apr 25, 2024
203f583
updated previousReport to previousReportSummary
Blokh Apr 30, 2024
0af4256
updated ongoing formats
Blokh Apr 30, 2024
5c21784
Merge branch 'dev' into blokh/feat/add-business-report-report-id
Blokh Apr 30, 2024
8d32745
merged with dev
Blokh Apr 30, 2024
8344bf7
feat: fixed generating filesync
Blokh Apr 30, 2024
1e976f2
fix: horrible merge
liorzblrn May 1, 2024
7b6347d
fix: merge
liorzblrn May 1, 2024
51cfc96
fix: merge 2
liorzblrn May 1, 2024
b5f36b4
fix: merge - fix lint
liorzblrn May 1, 2024
ae9c95f
fix: merge - fix tests
liorzblrn May 1, 2024
a8e1a1b
fix: rename config for jest
liorzblrn May 1, 2024
8ed47e5
chore(tm): adding mappings, brand names
alonp99 May 1, 2024
ba93150
Merge pull request #2330 from ballerine-io/bal-1880-ongoing-moitoring…
liorzam May 1, 2024
9f8d3c5
Merge branch 'dev' into blokh/feat/add-business-report-report-id
Blokh May 1, 2024
7c4055a
fix: alert def for ongoing merchant _ merge
liorzblrn May 1, 2024
a6eca5b
Merge branch 'bal-1880-ongoing-moitoring-alerts-merge' into bal-1880-…
liorzblrn May 1, 2024
13f68bb
fix: eslint
liorzblrn May 1, 2024
e2f6810
Merge branch 'dev' into bal-1880-ongoing-moitoring-alerts
Blokh May 2, 2024
610d9f7
added additionalInfo to Data analytics
Blokh May 2, 2024
36361bc
Merge branch 'dev' into blokh/feat/add-business-report-report-id
Blokh May 2, 2024
55cfca6
Merge branch 'dev' into bal-1644
chesterkmr May 5, 2024
4828e8c
Merge branch 'bal-1644-ongoing-alon' into bal-1644
chesterkmr May 5, 2024
ca2c60e
feat: update business report logic
Blokh May 5, 2024
7b672f3
Merge branch 'blokh/feat/add-business-report-report-id' into feature/…
Blokh May 5, 2024
b19d4a7
merged with blokh/feat/add-business-report-report-id
Blokh May 5, 2024
3fee08e
fix: cleanup & fixed layout
chesterkmr May 5, 2024
2c43c5d
feat: finished logic of merchant monitoring creation
Blokh May 5, 2024
5e7d0da
feat: business alerts boilerplate
chesterkmr May 6, 2024
9b843c2
Merge branch 'bal-1656-epic-reports-in-case-management' into bal-1644
chesterkmr May 6, 2024
41ce263
fix: types
chesterkmr May 6, 2024
11dd0f5
Merge remote-tracking branch 'origin' into bal-1656-epic-reports-in-c…
liorzblrn May 6, 2024
4cb5e8e
Merge branch 'bal-1656-epic-reports-in-case-management' into bal-1644
chesterkmr May 6, 2024
49ec5b6
feat: added business reports seed & ongoing monitoring table
chesterkmr May 6, 2024
6b303a9
feat: sync
chesterkmr May 6, 2024
4d68f6a
Merge branch 'dev' into blokh/feat/add-business-report-report-id
Blokh May 6, 2024
abcb568
Merge branch 'blokh/feat/add-business-report-report-id' into feature/…
Blokh May 6, 2024
e4edf2c
feat: finalized hook callback handler
Blokh May 6, 2024
5a309a3
feat: fixed ts issues
Blokh May 6, 2024
f14efa1
Merge branch 'dev' into blokh/feat/add-business-report-report-id
Blokh May 7, 2024
07be97d
Merge branch 'blokh/feat/add-business-report-report-id' into feature/…
Blokh May 7, 2024
0dc86f6
feat: updated alert logic and added testing
Blokh May 7, 2024
d73bcb0
Merge branch 'dev' into blokh/feat/add-business-report-report-id
Blokh May 7, 2024
7bf63b7
Merge branch 'blokh/feat/add-business-report-report-id' into feature/…
Blokh May 7, 2024
7fb50ab
fix(workflows-service): fixed bad import in zod-schemas.ts
Omri-Levy May 7, 2024
ff572dc
feat: revereted jest changes
Blokh May 8, 2024
6a1cc16
feat: added nest requirements and updated tests
Blokh May 8, 2024
1f65d71
feat: updated controller logic for processing
Blokh May 8, 2024
6e0bf69
feat: added zod validation and changes in alert logic
Blokh May 9, 2024
6da9f1d
Merge remote-tracking branch 'origin/feature/implement_ongoing_report…
chesterkmr May 9, 2024
5b8e07f
Feature/implement ongoing report alert #1959 #1656 (#2341)
Blokh May 9, 2024
ce8bf38
feat: finalized business alerts table
chesterkmr May 12, 2024
7443d11
feat: fixed alert service intg test
Blokh May 16, 2024
5181498
Merge branch 'dev' into blokh/feat/add-business-report-report-id
Blokh May 16, 2024
066f538
feat: merged wit hdev
Blokh May 16, 2024
4a34fe1
Merge branch 'dev' into blokh/feat/add-business-report-report-id
Blokh May 16, 2024
26aefad
Merge branch 'blokh/feat/add-business-report-report-id' into bal-1644
chesterkmr May 16, 2024
b1e4392
fixed imports
Blokh May 16, 2024
d0844c9
fix: post merge fixes
chesterkmr May 16, 2024
bce1800
feat: fix onboarding completion
Blokh May 16, 2024
330341d
fix: removed log
chesterkmr May 20, 2024
7ef11bb
fix: fixed missing alerts analysis page
chesterkmr May 20, 2024
33be864
feat: added on clear to useFilter
chesterkmr May 20, 2024
ab45535
feat: refactorted filters context
chesterkmr May 20, 2024
a0f7969
feat: refactored filters
chesterkmr May 21, 2024
6f4b1aa
fix: removed ts ignore
chesterkmr May 21, 2024
f074b33
feat: reverted filters
chesterkmr May 21, 2024
30ac7f4
feat: added transaction to handle pglocking
Blokh May 21, 2024
b721fa6
Merge branch 'bal-1644' of github.com:ballerine-io/ballerine into bal…
Blokh May 21, 2024
5fca5b1
fix: cleaned code duplicates & refactor
chesterkmr May 21, 2024
e0df50f
feat: refactored business alerts table
chesterkmr May 21, 2024
9452a57
fix: div to p
chesterkmr May 21, 2024
419de02
feat: merged with dev - fixed conflicts
Blokh May 21, 2024
05aaf9e
Merge branch 'dev' into blokh/feat/add-business-report-report-id
Blokh May 21, 2024
8747e79
feat: merged with dev
Blokh May 21, 2024
2a47598
feat: updated check alerts logic
Blokh May 21, 2024
fcbcca3
feat: updated executin details
Blokh May 21, 2024
2030bdb
Merge branch 'blokh/feat/add-business-report-report-id' into bal-1644
Blokh May 21, 2024
c446fc8
feat: fixed merge conflicts
Blokh May 21, 2024
5b02205
Merge remote-tracking branch 'origin/dev' into bal-1644
Blokh May 22, 2024
48bf1d3
feat: fixed conflicts with dev
Blokh May 22, 2024
410de81
feat: fixed report generation logic
Blokh May 22, 2024
45f1ebb
feat: updated create alert logic
Blokh May 23, 2024
521c48f
fix(*): pr comments
Omri-Levy May 23, 2024
c6c998d
fix(*): resolved conflicts
Omri-Levy May 23, 2024
ced6237
fix(backoffice-v2): wrong props type name
Omri-Levy May 23, 2024
4d9660b
fix(backoffice-v2): fixed type
Omri-Levy May 23, 2024
842ac68
refactor(*): removed uintentional commited code
Omri-Levy May 23, 2024
6aaceaf
refactor(backoffice-v2): no longer using the same accessor multiple t…
Omri-Levy May 23, 2024
fb9810b
fix(*): small fixes
Omri-Levy May 23, 2024
c6a0f23
fix: seed
chesterkmr May 28, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
59 changes: 40 additions & 19 deletions apps/backoffice-v2/src/Router/Router.tsx
Original file line number Diff line number Diff line change
@@ -1,28 +1,30 @@
import React, { FunctionComponent } from 'react';
import { env } from '@/common/env/env';
import { createBrowserRouter, RouterProvider } from 'react-router-dom';
import { RootError } from '@/pages/Root/Root.error';
import { Root } from '@/pages/Root/Root.page';
import { SignIn } from '@/pages/SignIn/SignIn.page';
import { Entity } from '@/pages/Entity/Entity.page';
import { Entities } from '@/pages/Entities/Entities.page';
import { RouteError } from '@/common/components/atoms/RouteError/RouteError';
import { CaseManagement } from '@/pages/CaseManagement/CaseManagement.page';
import { rootLoader } from '@/pages/Root/Root.loader';
import { entitiesLoader } from '@/pages/Entities/Entities.loader';
import { authenticatedLayoutLoader } from '@/domains/auth/components/AuthenticatedLayout/AuthenticatedLayout.loader';
import { entityLoader } from '@/pages/Entity/Entity.loader';
import { env } from '@/common/env/env';
import { AuthenticatedLayout } from '@/domains/auth/components/AuthenticatedLayout';
import { authenticatedLayoutLoader } from '@/domains/auth/components/AuthenticatedLayout/AuthenticatedLayout.loader';
import { UnauthenticatedLayout } from '@/domains/auth/components/UnauthenticatedLayout';
import { Locale } from '@/pages/Locale/Locale.page';
import { unauthenticatedLayoutLoader } from '@/domains/auth/components/UnauthenticatedLayout/UnauthenticatedLayout.loader';
import { Businesses } from '@/pages/Businesses/Businesses';
import { BusinessesAlerts } from '@/pages/BusinessesAlerts/BusinessesAlerts.page';
import { BusinessesAlertsAnalysisPage } from '@/pages/BusinessesAlertsAnalysis/BusinessesAlertsAnalysis.page';
import { CaseManagement } from '@/pages/CaseManagement/CaseManagement.page';
import { Document } from '@/pages/Document/Document.page';
import { entitiesLoader } from '@/pages/Entities/Entities.loader';
import { Entities } from '@/pages/Entities/Entities.page';
import { entityLoader } from '@/pages/Entity/Entity.loader';
import { Entity } from '@/pages/Entity/Entity.page';
import { Locale } from '@/pages/Locale/Locale.page';
import { NotFoundRedirect } from '@/pages/NotFound/NotFound';
import { TransactionMonitoringAlerts } from '@/pages/TransactionMonitoringAlerts/TransactionMonitoringAlerts.page';
import { TransactionMonitoring } from '@/pages/TransactionMonitoring/TransactionMonitoring';
import { TransactionMonitoringAlertsAnalysisPage } from '@/pages/TransactionMonitoringAlertsAnalysis/TransactionMonitoringAlertsAnalysis.page';
import { Profiles } from '@/pages/Profiles/Profiles.page';
import { Individuals } from '@/pages/Profiles/Individuals/Individuals.page';
import { Profiles } from '@/pages/Profiles/Profiles.page';
import { RootError } from '@/pages/Root/Root.error';
import { rootLoader } from '@/pages/Root/Root.loader';
import { Root } from '@/pages/Root/Root.page';
import { SignIn } from '@/pages/SignIn/SignIn.page';
import { TransactionMonitoring } from '@/pages/TransactionMonitoring/TransactionMonitoring';
import { TransactionMonitoringAlerts } from '@/pages/TransactionMonitoringAlerts/TransactionMonitoringAlerts.page';
import { FunctionComponent } from 'react';
import { RouterProvider, createBrowserRouter } from 'react-router-dom';

const router = createBrowserRouter([
{
Expand Down Expand Up @@ -114,7 +116,26 @@ const router = createBrowserRouter([
children: [
{
path: '/:locale/transaction-monitoring/alerts/:alertId',
element: <TransactionMonitoringAlertsAnalysisPage />,
element: <TransactionMonitoringAlerts />,
chesterkmr marked this conversation as resolved.
Show resolved Hide resolved
errorElement: <RouteError />,
},
],
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The route for TransactionMonitoringAlerts has been duplicated.

- element: <TransactionMonitoringAlerts />,
+ element: <TransactionMonitoringAlertsPage />,

Ensure that the correct component is used for the route.


Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation.

Suggested change
element: <TransactionMonitoringAlerts />,
errorElement: <RouteError />,
},
element: <TransactionMonitoringAlertsPage />,
errorElement: <RouteError />,
},

},
],
},
{
path: '/:locale/businesses',
element: <Businesses />,
errorElement: <RouteError />,
children: [
{
path: '/:locale/businesses/alerts',
element: <BusinessesAlerts />,
errorElement: <RouteError />,
children: [
{
path: '/:locale/businesses/alerts/:alertId',
element: <BusinessesAlertsAnalysisPage />,
errorElement: <RouteError />,
},
],
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { ReactNode, useCallback, useState } from 'react';
import { Separator } from '@/common/components/atoms/Separator/Separator';
import {
Badge,
Button,
Expand All @@ -9,13 +9,13 @@ import {
CommandItem,
CommandList,
CommandSeparator,
ctw,
Popover,
PopoverContent,
PopoverTrigger,
ctw,
} from '@ballerine/ui';
import { CheckIcon, PlusCircledIcon } from '@radix-ui/react-icons';
import { Separator } from '@/common/components/atoms/Separator/Separator';
import { ReactNode, useCallback, useState } from 'react';

interface IMultiSelectProps<
TOption extends {
Expand Down Expand Up @@ -46,6 +46,7 @@ export const MultiSelect = <
}: IMultiSelectProps<TOption>) => {
const [selected, setSelected] = useState(selectedValues);

console.log('title', { title });
const onSelectChange = useCallback(
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Remove debug logging to clean up the code.

-  console.log('title', { title });

Removing debug statements from production code helps in keeping the codebase clean and secure.


Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation.

Suggested change
console.log('title', { title });

chesterkmr marked this conversation as resolved.
Show resolved Hide resolved
(value: TOption['value']) => {
const isSelected = selected.some(selectedValue => selectedValue === value);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { ctw } from '@/common/utils/ctw/ctw';
import React, { ComponentProps, FunctionComponent } from 'react';
import { DownloadFileSvg } from '@/common/components/atoms/icons';
import { ctw } from '@/common/utils/ctw/ctw';
import { ComponentProps, FunctionComponent } from 'react';

export interface IDownloadFile extends ComponentProps<'div'> {
heading: string;
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
import { IFiltersHeaderProps } from '@/common/components/organisms/Filters/interfaces';
import { FunctionComponent } from 'react';

export const FiltersHeader: FunctionComponent<IFiltersHeaderProps> = ({ title }) => {
return typeof title === 'string' ? (
<h4 className={'leading-0 min-h-[16px] pb-7 text-xs font-bold'}>{title}</h4>
) : (
title
);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you explain this? Why was this needed, etc.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In case if custom styles or React.Node will be needed.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we will get considerably more value by using something like as or asChild or just children and passing className into ctw. Changing the markup depending on string to me is unpredictable. Otherwise if we make a re-usable filters component the heading will probably be a part of it and won't be elsewhere.

};
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
import { MultiselectFilterInput } from '@/common/components/organisms/Filters/filter-inputs/MultiSelectFilterInput';
import { IFilterInputParams } from '@/common/components/organisms/Filters/interfaces';
import { TFilterInputType } from '@/common/components/organisms/Filters/types';
import { FunctionComponent, useMemo } from 'react';

const getFilterInputComponent = (
type: TFilterInputType,
): React.ComponentType<IFilterInputParams> => {
chesterkmr marked this conversation as resolved.
Show resolved Hide resolved
if (type === 'multi-select')
return MultiselectFilterInput as React.ComponentType<IFilterInputParams>;

throw new Error(`Filter input for type ${type} not implemented.`);
};
chesterkmr marked this conversation as resolved.
Show resolved Hide resolved

export const FiltersInput: FunctionComponent<IFilterInputParams> = props => {
const InputComponent = useMemo(() => getFilterInputComponent(props.filter.type), [props.filter]);

return <InputComponent {...props} />;
};
chesterkmr marked this conversation as resolved.
Show resolved Hide resolved
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
import { useFiltersContext } from '@/common/components/organisms/Filters/context/hooks/useFiltersContext';
import {
IFilterDefinition,
IFiltersListProps,
} from '@/common/components/organisms/Filters/interfaces';
import { useFilter } from '@/common/hooks/useFilter/useFilter';
import { ctw } from '@/common/utils/ctw/ctw';
import { FunctionComponent, useCallback } from 'react';

export const FiltersList: FunctionComponent<IFiltersListProps> = ({ children, className }) => {
const { filters, values } = useFiltersContext();
const { onFilter } = useFilter();
const onClearSelect = useCallback(
(accessor: string) => () => {
onFilter(accessor)([]);
},
[onFilter],
);
chesterkmr marked this conversation as resolved.
Show resolved Hide resolved

return (
<div className={ctw('flex gap-x-2', className)}>
{filters.map(filterDefinition =>
children({
filter: filterDefinition,
value: values[filterDefinition.id],
clear: onClearSelect(filterDefinition.id),
inputParams: filterDefinition.params as IFilterDefinition['params'],
onChange: onFilter(filterDefinition.id),
}),
)}
</div>
);
};
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
import { FiltersProvider } from '@/common/components/organisms/Filters/context/FiltersProvider';
import { IFiltersProps } from '@/common/components/organisms/Filters/interfaces';
import { ctw } from '@ballerine/ui';
import { FunctionComponent } from 'react';

export const Filters: FunctionComponent<IFiltersProps> = ({
filters,
values = [],
children,
className,
onChange,
onClear,
}) => {
return (
<FiltersProvider filters={filters} values={values} onChange={onChange} onClear={onClear}>
<div className={ctw('flex flex-col', className)}>{children}</div>
</FiltersProvider>
);
};
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
import { IFiltersProviderProps } from '@/common/components/organisms/Filters/context/interfaces';
import { TFiltersContext } from '@/common/components/organisms/Filters/context/types';
import { createFilterValuesMap } from '@/common/components/organisms/Filters/context/utils/create-filter-values-map';
import { TFiltersInputID } from '@/common/components/organisms/Filters/types';
import { FunctionComponent, useCallback, useMemo } from 'react';
import { filtersContext } from './filters.context';

const { Provider } = filtersContext;

export const FiltersProvider: FunctionComponent<IFiltersProviderProps> = ({
chesterkmr marked this conversation as resolved.
Show resolved Hide resolved
children,
values,
filters,
onChange,
onClear,
}) => {
const handleChange = useCallback(
(id: TFiltersInputID, value: unknown) => {
onChange({ id, value });
},
[onChange],
);

const handleClear = useCallback(
(id: TFiltersInputID) => {
onClear(id);
},
[onClear],
);

const context: TFiltersContext = useMemo(
() => ({
values: createFilterValuesMap({ filters, values: values ?? [] }),
filters,
onChange: handleChange,
onClear: handleClear,
}),
[values, filters, handleChange, handleClear],
);

return <Provider value={context}>{children}</Provider>;
};
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
import { TFiltersContext } from '@/common/components/organisms/Filters/context/types';
import { createContext } from 'react';

const initialContext: TFiltersContext = {
filters: [],
values: {},
onChange: () => {
return;
},
onClear: () => {
return;
},
};

export const filtersContext = createContext(initialContext);
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
import { filtersContext } from '@/common/components/organisms/Filters/context/filters.context';
import { useContext } from 'react';

export const useFiltersContext = () => useContext(filtersContext);
chesterkmr marked this conversation as resolved.
Show resolved Hide resolved
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
import { IFiltersProps } from '@/common/components/organisms/Filters/interfaces';
import { AnyChildren } from '@ballerine/ui';

export interface IFiltersProviderProps
extends Pick<IFiltersProps, 'filters' | 'values' | 'onChange' | 'onClear'> {
children: AnyChildren;
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
import { IFilterDefinition } from '@/common/components/organisms/Filters/interfaces';
import { TFiltersInputID } from '@/common/components/organisms/Filters/types';

export type TFiltersValuesMap = Record<TFiltersInputID, unknown>;

export type TFiltersContext = {
filters: Array<IFilterDefinition<unknown>>;
values: TFiltersValuesMap;
onChange: (id: TFiltersInputID, value: unknown) => void;
onClear: (id: TFiltersInputID) => void;
};
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
import { TFiltersValuesMap } from '@/common/components/organisms/Filters/context/types';
import { IFilterDefinition, IFilterValue } from '@/common/components/organisms/Filters/interfaces';

export const createFilterValuesMap = ({
chesterkmr marked this conversation as resolved.
Show resolved Hide resolved
filters,
values,
}: {
filters: Array<IFilterDefinition<unknown>>;
values: IFilterValue[];
}) => {
const plainValues = values.reduce((object, value) => {
object[value.id] = value.value;

return object;
}, {} as Record<string, unknown>);

const valuesMap = filters.reduce((object, filter) => {
object[filter.id] = plainValues[filter.id] ?? filter.defaultValue;

return object;
}, {} as TFiltersValuesMap);

return valuesMap;
};
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
import { MultiSelect } from '@/common/components/atoms/MultiSelect/MultiSelect';
import { IFilterInputParams } from '@/common/components/organisms/Filters/interfaces';
import { FunctionComponent } from 'react';

export interface IMultiSelectFilterParams {
type: 'multi-select';
options: Array<{
name: string;
value: string;
}>;
}

export const MultiselectFilterInput: FunctionComponent<
IFilterInputParams<IMultiSelectFilterParams, string[]>
> = ({ inputParams, filter, value, onChange, clear }) => {
const { options } = inputParams;

return (
<MultiSelect
title={filter.label}
selectedValues={value ?? []}
onSelect={onChange}
onClearSelect={clear}
options={options || []}
/>
);
};
chesterkmr marked this conversation as resolved.
Show resolved Hide resolved
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
import { TFilterInputType, TFiltersInputID } from '@/common/components/organisms/Filters/types';
import { AnyChildren } from '@ballerine/ui';

export interface IFilterDefinition<TFilterParams = unknown> {
id: TFiltersInputID;
label: string;
params: TFilterParams;
defaultValue?: unknown;
type: TFilterInputType;
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ensure that the defaultValue in IFilterDefinition is typed based on TFilterParams to enhance type safety.


export interface IFilterInputParams<TInputParams = unknown, TInputValue = unknown> {
filter: IFilterDefinition;
inputParams: TInputParams;
value: TInputValue;
clear: () => void;
onChange: (value: Array<string | null>) => void;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Tip

Codebase Verification

The verification of the onChange callback usage in IFilterInputParams across the application shows a variety of implementations and expected types. The callback is used in multiple components and contexts, often with different parameter types such as string, number, arrays, or even more complex objects. This diversity in usage suggests that the type definition in IFilterInputParams might not be sufficiently generic or flexible to cover all use cases observed.

Given the variety of onChange implementations, it would be prudent to either:

  • Adjust the type definition in IFilterInputParams to be more inclusive or generic.
  • Ensure that specific instances of onChange usage that deviate from the defined type are intentional and correctly handled.

Here are some specific instances where the onChange type might need review or adjustment:

  • In DynamicForm.tsx, onChange is used with the type (formData: TFormData) => void;.
  • In DropdownInput.tsx, onChange is defined as (value: string, inputName: string) => void;.
  • In FacetedFilter.tsx, onChange is used with the type (values: string[]) => void;.

These examples indicate that the type definition of onChange in IFilterInputParams as (value: Array<string | null>) => void; might not be universally applicable or might require refinement to accommodate various usage contexts.

Analysis chain

Clarify the expected type for the onChange callback in IFilterInputParams to ensure it aligns with the actual usage in the application.

Scripts Executed

The following scripts were executed for the analysis:


Script:

#!/bin/bash
# Description: Verify the usage of `onChange` callback in `IFilterInputParams` to ensure it aligns with the expected type.

# Test: Search for the usage of `onChange` in the application. Expect: Consistent type usage.
rg --type typescript $'onChange'

Length of output: 66



Script:

#!/bin/bash
# Description: Verify the usage of `onChange` callback in `IFilterInputParams` to ensure it aligns with the expected type.

# Test: Search for the usage of `onChange` in the application. Expect: Consistent type usage.
rg --type ts $'onChange'

Length of output: 32699

}

export interface IFilterValue {
id: string;
value: unknown;
}

export interface IFiltersProps {
filters: Array<IFilterDefinition<unknown>>;
values?: IFilterValue[];
children: AnyChildren;
className?: string;
onChange: (value: IFilterValue) => void;
onClear: (id: TFiltersInputID) => void;
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Consider using a more specific type than unknown for values in IFiltersProps to improve type safety.


export interface IFiltersHeaderProps {
title: string | JSX.Element;
}

export interface IFiltersListProps {
className?: string;
children: (params: IFilterInputParams) => JSX.Element;
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
export type TFilterInputType = 'multi-select';
export type TFiltersInputID = string;
Loading
Loading