Skip to content

Commit

Permalink
Merge branch 'dev' into bal-3404-alerts-with-no-transactions
Browse files Browse the repository at this point in the history
  • Loading branch information
alonp99 authored Jan 21, 2025
2 parents be059d6 + d020900 commit 76a37f9
Show file tree
Hide file tree
Showing 19 changed files with 112 additions and 116 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ import { useFilterId } from '@/common/hooks/useFilterId/useFilterId';
import { useLocale } from '@/common/hooks/useLocale/useLocale';
import { useCustomerQuery } from '@/domains/customer/hooks/queries/useCustomerQuery/useCustomerQuery';
import { useFiltersQuery } from '@/domains/filters/hooks/queries/useFiltersQuery/useFiltersQuery';
import { MERCHANT_MONITORING_QUERY_PARAMS_KEY } from '@/pages/MerchantMonitoring/constants';
import { TRoutes, TRouteWithChildren } from '@/Router/types';

export const useNavbarLogic = () => {
Expand All @@ -22,7 +21,6 @@ export const useNavbarLogic = () => {
[filters],
);
const { data: customer } = useCustomerQuery();
const merchantMonitoringParams = sessionStorage.getItem(MERCHANT_MONITORING_QUERY_PARAMS_KEY);

const navItems = [
{
Expand All @@ -36,7 +34,7 @@ export const useNavbarLogic = () => {
{
text: 'Merchant Monitoring',
icon: <MonitorDot size={20} />,
href: `/en/merchant-monitoring${merchantMonitoringParams ?? ''}`,
href: `/en/merchant-monitoring`,
key: 'nav-item-merchant-monitoring',
},
]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,10 @@ import { TNoteableType } from '@/domains/notes/types';

export const useCreateNoteMutation = ({
onSuccess,
disableToast = false,
}: {
onSuccess?: <TData>(data: TData) => void;
disableToast: boolean;
}) => {
const queryClient = useQueryClient();

Expand Down Expand Up @@ -41,7 +43,9 @@ export const useCreateNoteMutation = ({
onSuccess: data => {
void queryClient.invalidateQueries();

toast.success(t(`toast:note_created.success`));
if (!disableToast) {
toast.success(t(`toast:note_created.success`));
}

onSuccess?.(data);
},
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,6 @@ import {
RISK_LEVEL_FILTER,
STATUS_LEVEL_FILTER,
} from '@/pages/MerchantMonitoring/schemas';
import { useLocation } from 'react-router-dom';
import { MERCHANT_MONITORING_QUERY_PARAMS_KEY } from '@/pages/MerchantMonitoring/constants';

const useDefaultDateRange = () => {
const [{ from, to }, setSearchParams] = useZodSearchParams(MerchantMonitoringSearchSchema);
Expand Down Expand Up @@ -61,11 +59,6 @@ export const useMerchantMonitoringLogic = () => {
setSearchParams,
] = useZodSearchParams(MerchantMonitoringSearchSchema, { replace: true });

const { search: searchString } = useLocation();
useEffect(() => {
sessionStorage.setItem(MERCHANT_MONITORING_QUERY_PARAMS_KEY, searchString);
}, [searchString]);

const { findings: findingsOptions, isLoading: isLoadingFindings } = useFindings();

const { data, isLoading: isLoadingBusinessReports } = useBusinessReportsQuery({
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -171,10 +171,10 @@ export const MerchantMonitoringBusinessReport: FunctionComponent = () => {
</FormControl>
<FormMessage />
<SelectContent>
{deboardingReasonOptions?.map(({ label, value }, index) => {
{deboardingReasonOptions?.map((option, index) => {
return (
<SelectItem key={index} value={value}>
{label}
<SelectItem key={index} value={option}>
{option}
</SelectItem>
);
})}
Expand Down Expand Up @@ -223,15 +223,12 @@ export const MerchantMonitoringBusinessReport: FunctionComponent = () => {
throw new Error('Merchant ID is missing');
}

turnOngoingMonitoringOn(
{ merchantId: businessReport.merchantId },
{
onSuccess: () => {
setIsDeboardModalOpen(false);
setIsDropdownOpen(false);
},
turnOngoingMonitoringOn(businessReport.merchantId, {
onSuccess: () => {
setIsDeboardModalOpen(false);
setIsDropdownOpen(false);
},
);
});
}}
variant={'ghost'}
className="justify-start"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,6 @@ import { handleZodError } from '@/common/utils/handle-zod-error/handle-zod-error
export type TurnOngoingMonitoringBody = z.infer<typeof TurnOngoingMonitoringBodySchema>;
export const TurnOngoingMonitoringBodySchema = z.object({
state: z.string(),
reason: z.string().optional(),
userReason: z.string().optional(),
});

export type TurnOngoingMonitoringResponse = z.infer<typeof TurnOngoingMonitoringResponseSchema>;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import { ParsedBooleanSchema, useReportTabs } from '@ballerine/ui';
import { t } from 'i18next';
import { capitalize } from 'lodash-es';
import { useCallback, useMemo } from 'react';
import { SubmitHandler, useForm } from 'react-hook-form';
import { useNavigate, useParams } from 'react-router-dom';
Expand All @@ -15,6 +16,7 @@ import {
MERCHANT_REPORT_TYPES_MAP,
} from '@/domains/business-reports/constants';
import { useBusinessReportByIdQuery } from '@/domains/business-reports/hooks/queries/useBusinessReportByIdQuery/useBusinessReportByIdQuery';
import { useCreateNoteMutation } from '@/domains/notes/hooks/mutations/useCreateNoteMutation/useCreateNoteMutation';
import { useNotesByNoteable } from '@/domains/notes/hooks/queries/useNotesByNoteable/useNotesByNoteable';
import { useToggleMonitoringMutation } from '@/pages/MerchantMonitoringBusinessReport/hooks/useToggleMonitoringMutation/useToggleMonitoringMutation';
import { isObject } from '@ballerine/common';
Expand Down Expand Up @@ -56,11 +58,11 @@ const statusToBadgeData = {
} as const;

const deboardingReasonOptions = [
{ value: 'fraud', label: 'Fraudulent Activity Detected' },
{ value: 'regulations', label: 'Non-Compliance with Regulations' },
{ value: 'disputes', label: 'Excessive Chargebacks or Disputes' },
{ value: 'expired', label: 'Business Relationship Ended' },
{ value: 'other', label: 'Other' },
'Fraudulent Activity Detected',
'Non-Compliance with Regulations',
'Excessive Chargebacks or Disputes',
'Business Relationship Ended',
'Other',
] as const;

export const useMerchantMonitoringBusinessReportLogic = () => {
Expand Down Expand Up @@ -92,12 +94,21 @@ export const useMerchantMonitoringBusinessReportLogic = () => {
throw new Error('Merchant ID is missing');
}

return turnOffMonitoringMutation.mutate({ merchantId: businessReport.merchantId, body: data });
return turnOffMonitoringMutation.mutate(businessReport.merchantId);
};

const { mutateAsync: mutateCreateNote } = useCreateNoteMutation({ disableToast: true });
const turnOnMonitoringMutation = useToggleMonitoringMutation({
state: 'on',
onSuccess: () => {
void mutateCreateNote({
content: 'Monitoring turned on',
entityId: businessReport?.merchantId ?? '',
entityType: 'Business',
noteableId: businessReport?.id ?? '',
noteableType: 'Report',
parentNoteId: null,
});
toast.success(t(`toast:business_monitoring_on.success`));
},
onError: error => {
Expand All @@ -112,6 +123,22 @@ export const useMerchantMonitoringBusinessReportLogic = () => {
const turnOffMonitoringMutation = useToggleMonitoringMutation({
state: 'off',
onSuccess: () => {
const { reason, userReason } = form.getValues();
const content = [
'Monitoring turned off',
reason ? `with reason: ${capitalize(reason)}` : null,
userReason ? `(${userReason})` : '',
]
.filter(Boolean)
.join(' ');
void mutateCreateNote({
content,
entityId: businessReport?.merchantId ?? '',
entityType: 'Business',
noteableId: businessReport?.id ?? '',
noteableType: 'Report',
parentNoteId: null,
});
setIsDeboardModalOpen(false);
setIsDropdownOpen(false);
form.reset();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,7 @@ import { useMutation, useQueryClient } from '@tanstack/react-query';
import { toast } from 'sonner';

import { HttpError } from '@/common/errors/http-error';
import {
turnOngoingMonitoring,
TurnOngoingMonitoringBody,
} from '@/pages/MerchantMonitoringBusinessReport/fetchers';
import { turnOngoingMonitoring } from '@/pages/MerchantMonitoringBusinessReport/fetchers';

export const useToggleMonitoringMutation = ({
state,
Expand All @@ -19,10 +16,8 @@ export const useToggleMonitoringMutation = ({
const queryClient = useQueryClient();

return useMutation({
mutationFn: async (data: {
merchantId: string;
body?: Omit<TurnOngoingMonitoringBody, 'state'>;
}) => turnOngoingMonitoring({ merchantId: data.merchantId, body: { ...data.body, state } }),
mutationFn: async (merchantId: string) =>
turnOngoingMonitoring({ merchantId, body: { state } }),
onSuccess: data => {
void queryClient.invalidateQueries();

Expand Down
7 changes: 7 additions & 0 deletions apps/kyb-app/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,12 @@
# kyb-app

## 0.3.113

### Patch Changes

- Updated dependencies
- @ballerine/ui@0.5.66

## 0.3.112

### Patch Changes
Expand Down
4 changes: 2 additions & 2 deletions apps/kyb-app/package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "@ballerine/kyb-app",
"private": true,
"version": "0.3.112",
"version": "0.3.113",
"type": "module",
"scripts": {
"dev": "vite",
Expand All @@ -19,7 +19,7 @@
"@ballerine/blocks": "0.2.32",
"@ballerine/common": "^0.9.66",
"@ballerine/workflow-browser-sdk": "0.6.85",
"@ballerine/ui": "0.5.65",
"@ballerine/ui": "0.5.66",
"@lukemorales/query-key-factory": "^1.0.3",
"@radix-ui/react-icons": "^1.3.0",
"@rjsf/core": "^5.9.0",
Expand Down
7 changes: 7 additions & 0 deletions packages/react-pdf-toolkit/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,12 @@
# @ballerine/react-pdf-toolkit

## 1.2.66

### Patch Changes

- Updated dependencies
- @ballerine/ui@0.5.66

## 1.2.65

### Patch Changes
Expand Down
4 changes: 2 additions & 2 deletions packages/react-pdf-toolkit/package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "@ballerine/react-pdf-toolkit",
"private": false,
"version": "1.2.65",
"version": "1.2.66",
"types": "./dist/build.d.ts",
"main": "./dist/react-pdf-toolkit.js",
"module": "./dist/react-pdf-toolkit.mjs",
Expand All @@ -27,7 +27,7 @@
},
"dependencies": {
"@ballerine/config": "^1.1.30",
"@ballerine/ui": "0.5.65",
"@ballerine/ui": "0.5.66",
"@react-pdf/renderer": "^3.1.14",
"@sinclair/typebox": "^0.31.7",
"ajv": "^8.12.0",
Expand Down
6 changes: 6 additions & 0 deletions packages/ui/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
# @ballerine/ui

## 0.5.66

### Patch Changes

- Fixed Date Picker popup flickering

## 0.5.65

### Patch Changes
Expand Down
2 changes: 1 addition & 1 deletion packages/ui/package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "@ballerine/ui",
"private": false,
"version": "0.5.65",
"version": "0.5.66",
"type": "module",
"main": "dist/index.js",
"types": "dist/index.d.ts",
Expand Down
Loading

0 comments on commit 76a37f9

Please sign in to comment.