Skip to content

Commit

Permalink
chore: remove storing reason in metadata
Browse files Browse the repository at this point in the history
  • Loading branch information
r4zendev committed Jan 21, 2025
1 parent a5bf82e commit 9854689
Show file tree
Hide file tree
Showing 6 changed files with 10 additions and 32 deletions.
Original file line number Diff line number Diff line change
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
Expand Up @@ -94,7 +94,7 @@ 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 });
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
Original file line number Diff line number Diff line change
Expand Up @@ -160,8 +160,6 @@ export class BusinessControllerExternal {
featureConfig: {
[FEATURE_LIST.ONGOING_MERCHANT_REPORT]: {
enabled: isEnabled,
reason: data.reason ?? null,
userReason: data.userReason ?? null,
disabledAt: isEnabled ? null : new Date().getTime(),
},
},
Expand Down
Original file line number Diff line number Diff line change
@@ -1,19 +1,9 @@
import { ApiProperty } from '@nestjs/swagger';
import { IsIn, IsOptional, IsString } from 'class-validator';
import { IsIn, IsString } from 'class-validator';

export class BusinessMonitoringPatchDto {
@ApiProperty({ type: String, required: true })
@IsString()
@IsIn(['on', 'off'])
state!: 'on' | 'off';

@ApiProperty({ type: String, required: false })
@IsOptional()
@IsString()
reason?: string;

@ApiProperty({ type: String, required: false })
@IsOptional()
@IsString()
userReason?: string;
}

0 comments on commit 9854689

Please sign in to comment.