TP-53770 | fixed comments

This commit is contained in:
Aman Chaturvedi
2024-04-30 17:24:49 +05:30
parent 5b4a57832a
commit 755f741caa
8 changed files with 56 additions and 34 deletions

View File

@@ -41,7 +41,6 @@ export const getFeeWaiveHistory = async (loanAccountNumber: string) => {
})
.then((res) => {
if (res.data) {
console.log('res.data', res.data);
return res.data;
}
return null;
@@ -62,7 +61,6 @@ export const postFeeWaiver = async (loanAccountNumber: string, payload: IFeeWaiv
})
.then((res) => {
if (res.data) {
console.log('res.data', res.data);
return res.data;
}
return null;

View File

@@ -1124,3 +1124,5 @@ export const HIT_SLOP = {
};
export const LITMUS_URL = 'https://longhorn.navi.com/litmus';
export const API_ERROR_MESSAGE = 'Oops! something went wrong';

View File

@@ -11,6 +11,7 @@ import { sendApiToClickstreamEvent } from '../../services/clickstreamEventServic
import { instrumentApmRoutes } from './apmUtils';
import { handleLogout } from '../../action/authActions';
import {
API_ERROR_MESSAGE,
REQUEST_TO_UNBLOCK_FOR_IMPERSONATION,
REQUEST_TYPE_TO_BLOCK_FOR_IMPERSONATION,
} from '../../common/Constants';
@@ -297,7 +298,7 @@ axiosInstance.interceptors.response.use(
) {
toast({
type: 'error',
text1: typeof errorString === 'string' ? errorString : 'Oops! something went wrong',
text1: typeof errorString === 'string' ? errorString : API_ERROR_MESSAGE,
});
}

View File

@@ -13,7 +13,7 @@ const EmiScheduleSlice = createSlice({
initialState,
reducers: {
setEmiSchedule: (state, action) => {
const { loanAccountNumber, emiSchedule } = action.payload;
const { loanAccountNumber, emiSchedule = [] } = action.payload;
const transformedEmiData = emiSchedule.map(feeWaiveTransformedEmiData);
state[loanAccountNumber] = {
data: transformedEmiData,

View File

@@ -3,20 +3,12 @@ import React from 'react';
import { formatAmount } from '@rn-ui-lib/utils/amount';
import { GenericStyles } from '@rn-ui-lib/styles';
import Text from '@rn-ui-lib/components/Text';
import { EmiFeeActions, IEmiItem } from './interfaces';
import { IEmiBreakup } from './interfaces';
import HourGlassIcon from '@rn-ui-lib/icons/HourGlassIcon';
import AnimatedNumbers from '@rn-ui-lib/components/animatedNumbers/AnimatedNumber';
import dayjs from 'dayjs';
interface IEmiBreakup {
emiData: IEmiItem;
}
const PenaltyWaivedLabelMap = {
[EmiFeeActions.ADJUST]: 'Penalty waived / held',
[EmiFeeActions.WAIVE]: 'Penalty waived',
[EmiFeeActions.HOLD]: 'Penalty held',
};
import { BUSINESS_TIME_FORMAT } from '@rn-ui-lib/utils/dates';
import { getPenaltyWaivedLabel } from './utils';
const EmiBreakup: React.FC<IEmiBreakup> = ({ emiData }) => {
const {
@@ -32,12 +24,7 @@ const EmiBreakup: React.FC<IEmiBreakup> = ({ emiData }) => {
} = emiData || {};
const paidAmountGreaterThanZero = totalDueAmountPaid > 0;
const waivedOrHoldAmountGreaterThanZero = waiverOrHoldAmount > 0;
let penaltyWaivedLabel = PenaltyWaivedLabelMap[action || EmiFeeActions.HOLD];
if (totalDueWaivedAmount > 0) {
penaltyWaivedLabel = 'Penalty waived';
} else if (totalDueHoldAmount > 0) {
penaltyWaivedLabel = 'Penalty held';
}
let penaltyWaivedLabel = getPenaltyWaivedLabel(action, totalDueWaivedAmount, totalDueHoldAmount);
return (
<View>
@@ -71,7 +58,7 @@ const EmiBreakup: React.FC<IEmiBreakup> = ({ emiData }) => {
<HourGlassIcon />
</View>
<Text light small>
(till {dayjs(heldUntil).format('hh:mm a')} today)
(till {dayjs(heldUntil).format(BUSINESS_TIME_FORMAT)} today)
</Text>
</View>
) : null}

View File

@@ -21,7 +21,7 @@ import { postFeeWaiver } from '@actions/emiActions';
import { useAppDispatch } from '@hooks';
import { UnifiedCaseDetailsTypes, getCaseUnifiedData } from '@actions/caseApiActions';
import FullScreenLoader from '@rn-ui-lib/components/FullScreenLoader';
import { feeWaiveTransformedEmiData } from './utils';
import { feeWaiveTransformedEmiData, getFeeWaiveBtnLabel } from './utils';
import { EmiFeeActionLabelMap } from './constants';
interface IFeeWaiver {
@@ -51,16 +51,7 @@ const FeeWaiver: React.FC<IFeeWaiver> = (props) => {
const disabled = !Number(waivedValue) || showError;
const canShowAdjustmentModal =
action === EmiFeeActions.ADJUST && Number(waivedValue) > totalDueAmountUnpaid;
let buttonTitle = action === EmiFeeActions.WAIVE ? 'Waive Fee' : 'Hold fee (till 11:59pm)';
if (action === EmiFeeActions.ADJUST) {
buttonTitle = 'Waive / Hold';
if (Number(waivedValue) && Number(waivedValue) < totalDueAmountUnpaid) {
buttonTitle = 'Hold fee (till 11:59pm)';
}
if (Number(waivedValue) >= totalDueAmountUnpaid) {
buttonTitle = 'Waive fee';
}
}
const buttonTitle = getFeeWaiveBtnLabel(action, Number(waivedValue), totalDueAmountUnpaid);
const dispatch = useAppDispatch();

View File

@@ -136,3 +136,13 @@ export enum EmiFeeActions {
HOLD = 'HOLD',
ADJUST = 'ADJUST',
}
export interface IEmiBreakup {
emiData: IEmiItem;
}
export const PenaltyWaivedLabelMap = {
[EmiFeeActions.ADJUST]: 'Penalty waived / held',
[EmiFeeActions.WAIVE]: 'Penalty waived',
[EmiFeeActions.HOLD]: 'Penalty held',
};

View File

@@ -5,6 +5,7 @@ import {
IFeeWaiverHistory,
IFeeWaiverHistorySectionList,
IFilteredEmiData,
PenaltyWaivedLabelMap,
} from './interfaces';
export const getFilteredData = (
@@ -80,7 +81,7 @@ export const feeWaiveTransformedEmiData = (emiItem: IEmiItem): IEmiItem => {
emiItem || {};
const waiverOrHoldAmount = totalDueHoldAmount || totalDueWaivedAmount || 0;
const action = getEmiFeeAction(emiItem);
const showInfoIcon = Boolean(action && (!isWaivable && !maxAmountAlreadyWaived));
const showInfoIcon = Boolean(action && !isWaivable && !maxAmountAlreadyWaived);
return {
...emiItem,
waiverOrHoldAmount,
@@ -89,3 +90,35 @@ export const feeWaiveTransformedEmiData = (emiItem: IEmiItem): IEmiItem => {
showInfoIcon,
};
};
export const getPenaltyWaivedLabel = (
action: EmiFeeActions | null = EmiFeeActions.HOLD,
totalDueWaivedAmount: number,
totalDueHoldAmount: number
) => {
let label = PenaltyWaivedLabelMap[action || EmiFeeActions.HOLD];
if (totalDueWaivedAmount > 0) {
label = 'Penalty waived';
} else if (totalDueHoldAmount > 0) {
label = 'Penalty held';
}
return label;
};
export const getFeeWaiveBtnLabel = (
action: EmiFeeActions | null = EmiFeeActions.HOLD,
waivedValue: number,
totalDueAmountUnpaid: number
) => {
let buttonTitle = action === EmiFeeActions.WAIVE ? 'Waive Fee' : 'Hold fee (till 11:59pm)';
if (action === EmiFeeActions.ADJUST) {
buttonTitle = 'Waive / Hold';
if (waivedValue && waivedValue < totalDueAmountUnpaid) {
buttonTitle = 'Hold fee (till 11:59pm)';
}
if (waivedValue >= totalDueAmountUnpaid) {
buttonTitle = 'Waive fee';
}
}
return buttonTitle;
};