Adding
This commit is contained in:
@@ -0,0 +1,45 @@
|
||||
import moxios from 'moxios';
|
||||
import {applyMiddleware, createStore} from 'redux';
|
||||
import rootReducer from '../store/Store';
|
||||
import thunk from 'redux-thunk';
|
||||
import {getAllAlerts} from './AlertActions';
|
||||
|
||||
const testStore = (initialState: any) => {
|
||||
const createStoreWithMiddleware = applyMiddleware(thunk)(createStore);
|
||||
return createStoreWithMiddleware(rootReducer, initialState);
|
||||
};
|
||||
|
||||
describe('getAllAlerts action', () => {
|
||||
beforeEach(() => {
|
||||
moxios.install();
|
||||
});
|
||||
|
||||
afterEach(() => {
|
||||
moxios.uninstall();
|
||||
});
|
||||
|
||||
test('Store updates correctly', () => {
|
||||
const expectedState = {
|
||||
"alerts": [
|
||||
{stuff: 1}
|
||||
]
|
||||
};
|
||||
const store = testStore(expectedState);
|
||||
|
||||
moxios.wait(() => {
|
||||
const request = moxios.requests.mostRecent();
|
||||
request.respondWith({
|
||||
status: 200,
|
||||
response: expectedState
|
||||
});
|
||||
});
|
||||
|
||||
const beginningState = store.getState().alertState;
|
||||
store.dispatch(getAllAlerts()).then(() => {
|
||||
const newState = store.getState().alertState;
|
||||
expect(newState).toEqual(expectedState);
|
||||
expect(newState).not.toEqual(beginningState);
|
||||
});
|
||||
|
||||
});
|
||||
});
|
||||
@@ -0,0 +1,141 @@
|
||||
// Import redux types
|
||||
import { ActionCreator, Dispatch } from 'redux';
|
||||
import { ThunkAction } from 'redux-thunk';
|
||||
import axios from 'axios';
|
||||
|
||||
// Import Alert Typing
|
||||
import { IAlert, IAlertState } from '../reducers/AlertReducer';
|
||||
import Configuration from '../shared/configuration/Configuration';
|
||||
import ServerLogging from '../shared/logging/ServerLogging';
|
||||
import UrlFormatting from '../shared/formatting/UrlFormatting';
|
||||
import moment from 'moment';
|
||||
import DateConversions from '../shared/conversions/DateConversions';
|
||||
import {getUser} from '../adalConfig';
|
||||
|
||||
const cloneDeep = require('lodash.clonedeep');
|
||||
|
||||
// Create Action Constants
|
||||
export enum AlertActionTypes {
|
||||
GET_ALL = 'GET_ALL',
|
||||
GET_ALL_ACTIONS = 'GET_ALL_ACTIONS',
|
||||
MARK_ALERT_READ = 'MARK_ALERT_READ',
|
||||
}
|
||||
|
||||
// Interface for Get All Action Type
|
||||
export interface IAlertGetAllAction {
|
||||
type: AlertActionTypes.GET_ALL;
|
||||
alerts: IAlert[];
|
||||
}
|
||||
|
||||
export interface IAlertGetAllActionsAction {
|
||||
type: AlertActionTypes.GET_ALL_ACTIONS;
|
||||
actions: IAlert[];
|
||||
}
|
||||
|
||||
export interface IAlertMarkReadAction {
|
||||
type: AlertActionTypes.MARK_ALERT_READ,
|
||||
alert: IAlert;
|
||||
}
|
||||
|
||||
/*
|
||||
Combine the action types with a union (we assume there are more)
|
||||
example: export type AlertActions = IGetAllAction | IGetOneAction ...
|
||||
*/
|
||||
export type AlertActions = IAlertGetAllAction | IAlertGetAllActionsAction | IAlertMarkReadAction;
|
||||
|
||||
const convertServerDataToAlerts = (alerts: IAlert[]): IAlert[] => {
|
||||
return alerts.map((alert) => convertServerDataToAlert(alert));
|
||||
}
|
||||
|
||||
const convertServerDataToAlert = (alert: IAlert): IAlert => {
|
||||
alert.dateMarkedRead = DateConversions.utcToMoment(alert.dateMarkedRead);
|
||||
alert.dateAdded = DateConversions.utcToMoment(alert.dateAdded)!;
|
||||
return alert;
|
||||
};
|
||||
|
||||
const createAPIReadyAlert = (alert: IAlert) => {
|
||||
const clonedAlert = cloneDeep(alert);
|
||||
clonedAlert.dateAdded = DateConversions.momentToUTC(alert.dateAdded);
|
||||
clonedAlert.dateMarkedRead = DateConversions.momentToUTC(alert.dateMarkedRead);
|
||||
return clonedAlert;
|
||||
}
|
||||
|
||||
/* Get All Action
|
||||
<Promise<Return Type>, State Interface, Type of Param, Type of Action> */
|
||||
export const getAllAlerts: ActionCreator<
|
||||
ThunkAction<Promise<any>, IAlertState, null, IAlertGetAllAction>
|
||||
> = () => {
|
||||
const url = Configuration.PrefixRepoApiUrl(Configuration.Get.urls.repoApi.alerts_unread);
|
||||
return async (dispatch: Dispatch) => {
|
||||
try {
|
||||
const response = await axios.get(url);
|
||||
const convertedAlerts = convertServerDataToAlerts(response.data);
|
||||
dispatch({
|
||||
alerts: convertedAlerts,
|
||||
type: AlertActionTypes.GET_ALL,
|
||||
});
|
||||
} catch (err) {
|
||||
ServerLogging.ResolveErrorWithToast(err,{
|
||||
action: "Get All Alerts",
|
||||
user: getUser().userName,
|
||||
url: url
|
||||
});
|
||||
}
|
||||
};
|
||||
};
|
||||
|
||||
// @TODO, the action should just take the type of alert to load?
|
||||
export const getAllActions: ActionCreator<
|
||||
ThunkAction<Promise<any>, IAlertState, null, IAlertGetAllActionsAction>
|
||||
> = () => {
|
||||
const url = Configuration.PrefixRepoApiUrl(Configuration.Get.urls.repoApi.alerts_action_needed);
|
||||
return async (dispatch: Dispatch) => {
|
||||
try {
|
||||
const response = await axios.get(url);
|
||||
dispatch({
|
||||
actions: response.data,
|
||||
type: AlertActionTypes.GET_ALL_ACTIONS,
|
||||
});
|
||||
} catch (err) {
|
||||
ServerLogging.ResolveErrorWithToast(err,{
|
||||
action: "Get All Actions",
|
||||
user: getUser().userName,
|
||||
url: url
|
||||
});
|
||||
}
|
||||
};
|
||||
};
|
||||
|
||||
export const markAlertRead: ActionCreator<
|
||||
ThunkAction<Promise<any>, IAlertState, null, IAlertMarkReadAction>
|
||||
> = (alert: IAlert) => {
|
||||
const alertPostURL = UrlFormatting.ReplaceURLParams(
|
||||
Configuration.PrefixRepoApiUrl(Configuration.Get.urls.repoApi.alerts_put),
|
||||
{ key: 'alertId', value: alert.id },
|
||||
);
|
||||
return async (dispatch: Dispatch) => {
|
||||
try {
|
||||
const clonedAlert = cloneDeep(alert) as IAlert;
|
||||
clonedAlert.dateMarkedRead = moment();
|
||||
const revertedAlert = createAPIReadyAlert(clonedAlert);
|
||||
|
||||
|
||||
const response = await axios.put(
|
||||
alertPostURL,
|
||||
revertedAlert,
|
||||
);
|
||||
|
||||
dispatch({
|
||||
type: AlertActionTypes.MARK_ALERT_READ,
|
||||
alert: response.data,
|
||||
});
|
||||
} catch (err) {
|
||||
ServerLogging.ResolveErrorWithToast(err,{
|
||||
action: "Mark Alert Read",
|
||||
user: getUser().userName,
|
||||
url: alertPostURL,
|
||||
arguments: alert
|
||||
});
|
||||
}
|
||||
}
|
||||
};
|
||||
@@ -0,0 +1,344 @@
|
||||
import axios from "axios";
|
||||
import { LocationChangeAction } from "connected-react-router";
|
||||
import { toast } from "react-toastify";
|
||||
import { ActionCreator, Dispatch } from "redux";
|
||||
import { ThunkAction } from "redux-thunk";
|
||||
import { IAuctionAssignment, IAuctionAssignmentPostRequest, IAuctionAssignmentState, IAutoIMS, IFloorPriceCalculationResultSet, IFloorPriceValuesUsed } from "../reducers/AuctionAssignmentReducer";
|
||||
import RepoAccountService from "../services/RepoAccountService";
|
||||
import Configuration from "../shared/configuration/Configuration";
|
||||
import DateConversions from "../shared/conversions/DateConversions";
|
||||
import AsyncState from "../shared/enumerations/AsyncState";
|
||||
import UrlFormatting from "../shared/formatting/UrlFormatting";
|
||||
import ServerLogging from "../shared/logging/ServerLogging";
|
||||
import ToastDefaults from "../shared/notifications/ToastDefaults";
|
||||
import IAsyncStateContainer from "../shared/types/IAsyncStateContainer";
|
||||
import {getUser} from '../adalConfig'
|
||||
|
||||
const cloneDeep = require("lodash.clonedeep");
|
||||
|
||||
export enum AuctionAssignmentActionTypes {
|
||||
GET_FLOOR_PRICE = "AUCTION_ASSIGNMENT_GET_FLOOR_PRICE",
|
||||
INSERT = "AUCTION_ASSIGNMENT_INSERT",
|
||||
INSERT_FROM_POST = "AUCTION_ASSIGNMENT_INTSERT_FROM_POST",
|
||||
INSERT_MULTIPLE = "AUCTION_ASSIGNMENT_INSERT_MULTIPLE",
|
||||
SET_SELECTED_AUCTION_ASSIGNMENT = "AUCTION_ASSIGNMENT_SET_SELECTED"
|
||||
}
|
||||
|
||||
export interface IAuctionAssignmentGetFloorPrice {
|
||||
type: AuctionAssignmentActionTypes.GET_FLOOR_PRICE;
|
||||
floorPriceCalculationResultSet: IAsyncStateContainer<IFloorPriceCalculationResultSet>;
|
||||
}
|
||||
|
||||
export interface IAuctionAssignmentInsert {
|
||||
type: AuctionAssignmentActionTypes.INSERT;
|
||||
auctionAssignment: IAuctionAssignment;
|
||||
}
|
||||
|
||||
export interface IAuctionAssignmentInsertFromPost {
|
||||
type: AuctionAssignmentActionTypes.INSERT_FROM_POST;
|
||||
auctionAssignmentResponse: IAuctionAssignmentPostRequest;
|
||||
}
|
||||
|
||||
export interface IAuctionAssignmentInsertMultiple {
|
||||
type: AuctionAssignmentActionTypes.INSERT_MULTIPLE;
|
||||
auctionAssignments: IAuctionAssignment[];
|
||||
}
|
||||
|
||||
export interface IAuctionAssignmentSetSelected {
|
||||
type: AuctionAssignmentActionTypes.SET_SELECTED_AUCTION_ASSIGNMENT;
|
||||
auctionAssignmentId: IAsyncStateContainer<number>;
|
||||
}
|
||||
|
||||
export type AuctionAssignmentActions =
|
||||
IAuctionAssignmentGetFloorPrice |
|
||||
IAuctionAssignmentInsert |
|
||||
IAuctionAssignmentInsertMultiple |
|
||||
IAuctionAssignmentInsertFromPost |
|
||||
IAuctionAssignmentSetSelected |
|
||||
LocationChangeAction;
|
||||
|
||||
const convertServerDataToAuctionAssignment = (auctionAssignment: IAuctionAssignment): void => {
|
||||
auctionAssignment.dateSubmitted = DateConversions.utcToMoment(auctionAssignment.dateSubmitted);
|
||||
auctionAssignment.holdUntil = DateConversions.utcToMoment(auctionAssignment.holdUntil);
|
||||
auctionAssignment.redeemedDate = DateConversions.utcToMoment(auctionAssignment.redeemedDate);
|
||||
auctionAssignment.sentTitleDocsDate = DateConversions.utcToMoment(auctionAssignment.sentTitleDocsDate);
|
||||
|
||||
if (auctionAssignment.autoIMS) {
|
||||
const autoIMS: IAutoIMS = auctionAssignment.autoIMS;
|
||||
autoIMS.assignmentAccepted = DateConversions.utcToMoment(autoIMS.assignmentAccepted);
|
||||
autoIMS.dateReceivedFromAutoIMS = DateConversions.utcToMoment(autoIMS.dateReceivedFromAutoIMS);
|
||||
autoIMS.scheduledSaleDate = DateConversions.utcToMoment(autoIMS.scheduledSaleDate);
|
||||
autoIMS.soldDate = DateConversions.utcToMoment(autoIMS.soldDate);
|
||||
autoIMS.clientCancelled = DateConversions.utcToMoment(autoIMS.clientCancelled);
|
||||
autoIMS.inspectedDate = DateConversions.utcToMoment(autoIMS.inspectedDate);
|
||||
autoIMS.dateofLoss = DateConversions.utcToMoment(autoIMS.dateofLoss);
|
||||
autoIMS.datePickedUp = DateConversions.utcToMoment(autoIMS.datePickedUp);
|
||||
autoIMS.dateEnteredAutoIMS = DateConversions.utcToMoment(autoIMS.dateEnteredAutoIMS);
|
||||
autoIMS.fundsSent = DateConversions.utcToMoment(autoIMS.fundsSent);
|
||||
autoIMS.titleReceived = DateConversions.utcToMoment(autoIMS.titleReceived);
|
||||
autoIMS.titleReturned = DateConversions.utcToMoment(autoIMS.titleReturned);
|
||||
autoIMS.shipmentDate = DateConversions.utcToMoment(autoIMS.shipmentDate);
|
||||
|
||||
auctionAssignment.autoIMS = autoIMS;
|
||||
}
|
||||
|
||||
if (auctionAssignment.floorPriceValuesUsed) {
|
||||
convertServerDataToFloorPriceValuesUsed(auctionAssignment.floorPriceValuesUsed);
|
||||
}
|
||||
};
|
||||
|
||||
const convertServerDataToFloorPriceValuesUsed = (floorPriceValuesUsed: IFloorPriceValuesUsed): void => {
|
||||
floorPriceValuesUsed.collateralValuation.lookupDate = DateConversions.utcToMoment(floorPriceValuesUsed.collateralValuation.lookupDate);
|
||||
};
|
||||
|
||||
const createAPIReadyAuctionAssignment = (auctionAssignment: IAuctionAssignment): any => {
|
||||
const result = cloneDeep(auctionAssignment);
|
||||
result.dateSubmitted = DateConversions.momentToUTC(auctionAssignment.dateSubmitted);
|
||||
result.holdUntil = DateConversions.momentToUTC(auctionAssignment.holdUntil);
|
||||
result.redeemedDate = DateConversions.momentToUTC(auctionAssignment.redeemedDate);
|
||||
result.titleSentNotificationDate = DateConversions.momentToUTC(auctionAssignment.sentTitleDocsDate);
|
||||
|
||||
if (auctionAssignment.autoIMS) {
|
||||
const autoIMS: any = cloneDeep(auctionAssignment.autoIMS);
|
||||
autoIMS.assignmentAccepted = DateConversions.momentToUTC(autoIMS.assignmentAccepted);
|
||||
autoIMS.dateReceivedFromAutoIMS = DateConversions.momentToUTC(autoIMS.dateReceivedFromAutoIMS);
|
||||
autoIMS.scheduledSaleDate = DateConversions.momentToUTC(autoIMS.scheduledSaleDate);
|
||||
autoIMS.soldDate = DateConversions.momentToUTC(autoIMS.soldDate);
|
||||
autoIMS.clientCancelled = DateConversions.momentToUTC(autoIMS.clientCancelled);
|
||||
autoIMS.inspectedDate = DateConversions.momentToUTC(autoIMS.inspectedDate);
|
||||
autoIMS.dateofLoss = DateConversions.momentToUTC(autoIMS.dateofLoss);
|
||||
autoIMS.datePickedUp = DateConversions.momentToUTC(autoIMS.datePickedUp);
|
||||
autoIMS.dateEnteredAutoIMS = DateConversions.momentToUTC(autoIMS.dateEnteredAutoIMS);
|
||||
autoIMS.fundsSent = DateConversions.momentToUTC(autoIMS.fundsSent);
|
||||
autoIMS.titleReceived = DateConversions.momentToUTC(autoIMS.titleReceived);
|
||||
autoIMS.titleReturned = DateConversions.momentToUTC(autoIMS.titleReturned);
|
||||
autoIMS.shipmentDate = DateConversions.momentToUTC(autoIMS.shipmentDate);
|
||||
|
||||
result.autoIMS = autoIMS;
|
||||
}
|
||||
|
||||
if (auctionAssignment.floorPriceValuesUsed) {
|
||||
const valuesUsed: any = cloneDeep(auctionAssignment.floorPriceValuesUsed);
|
||||
const collateralValuation: any = cloneDeep(auctionAssignment.floorPriceValuesUsed.collateralValuation);
|
||||
collateralValuation.LookUpDate = DateConversions.momentToUTC(collateralValuation.LookUpDate);
|
||||
valuesUsed.collateralValuation = collateralValuation;
|
||||
|
||||
result.valuesUsed = valuesUsed;
|
||||
}
|
||||
|
||||
return result;
|
||||
};
|
||||
|
||||
const createAPIReadyAuctionAssignmentPostRequest = (auctionAssignmentPostRequest: IAuctionAssignmentPostRequest) => {
|
||||
return {
|
||||
auctionAssignment: createAPIReadyAuctionAssignment(auctionAssignmentPostRequest.auctionAssignment),
|
||||
collaterals: auctionAssignmentPostRequest.collaterals,
|
||||
vehicleLocation: auctionAssignmentPostRequest.vehicleLocation,
|
||||
primaryCollateralId: auctionAssignmentPostRequest.primaryCollateralId,
|
||||
};
|
||||
};
|
||||
|
||||
const convertServerDataToAuctionAssignmentPostRequest = (auctionAssignmentPostRequest: IAuctionAssignmentPostRequest): IAuctionAssignmentPostRequest => {
|
||||
auctionAssignmentPostRequest.collaterals.map((collateral) => RepoAccountService.ConvertResponseToCollateral(collateral));
|
||||
convertServerDataToAuctionAssignment(auctionAssignmentPostRequest.auctionAssignment);
|
||||
return {
|
||||
auctionAssignment: auctionAssignmentPostRequest.auctionAssignment,
|
||||
collaterals: auctionAssignmentPostRequest.collaterals,
|
||||
vehicleLocation: auctionAssignmentPostRequest.vehicleLocation,
|
||||
primaryCollateralId: auctionAssignmentPostRequest.primaryCollateralId,
|
||||
};
|
||||
};
|
||||
|
||||
export const getAuctionAssignmentsByRepoId: ActionCreator<ThunkAction<Promise<any>, IAuctionAssignmentState, null, IAuctionAssignmentInsertMultiple>> = (repoId: number) => {
|
||||
const auctionAssignmentURL = UrlFormatting.ReplaceURLParams(
|
||||
Configuration.PrefixRepoApiUrl(Configuration.Get.urls.repoApi.auction_assignment_by_repo_id),
|
||||
{ key: "repoId", value: repoId}
|
||||
);
|
||||
return async (dispatch: Dispatch<IAuctionAssignmentInsertMultiple>) => {
|
||||
try {
|
||||
const response = await axios.get(auctionAssignmentURL);
|
||||
for (const auctionAssignment of response.data) {
|
||||
convertServerDataToAuctionAssignment(auctionAssignment);
|
||||
}
|
||||
|
||||
dispatch({
|
||||
type: AuctionAssignmentActionTypes.INSERT_MULTIPLE,
|
||||
auctionAssignments: response.data,
|
||||
});
|
||||
} catch (err) {
|
||||
ServerLogging.ResolveErrorWithToast(err, {
|
||||
action: "Get Auction Assignments by Repo ID",
|
||||
user: getUser().userName,
|
||||
url: auctionAssignmentURL,
|
||||
arguments: repoId
|
||||
});
|
||||
}
|
||||
};
|
||||
};
|
||||
|
||||
export const fetchAuctionAssignment: ActionCreator<ThunkAction<Promise<any>, IAuctionAssignmentState, null, IAuctionAssignmentInsert | IAuctionAssignmentSetSelected>> = (id: number) => {
|
||||
const auctionAssignmentURL = UrlFormatting.ReplaceURLParams(
|
||||
Configuration.PrefixRepoApiUrl(Configuration.Get.urls.repoApi.auction_assignment_single),
|
||||
{ key: "auctionAssignmentId", value: id}
|
||||
);
|
||||
return async (dispatch: Dispatch<IAuctionAssignmentInsert | IAuctionAssignmentSetSelected>) => {
|
||||
dispatch({
|
||||
type: AuctionAssignmentActionTypes.SET_SELECTED_AUCTION_ASSIGNMENT,
|
||||
auctionAssignmentId: {
|
||||
state: AsyncState.Loading
|
||||
}
|
||||
});
|
||||
try {
|
||||
const response = await axios.get(auctionAssignmentURL);
|
||||
convertServerDataToAuctionAssignment(response.data);
|
||||
|
||||
dispatch({
|
||||
type: AuctionAssignmentActionTypes.INSERT,
|
||||
auctionAssignment: response.data,
|
||||
});
|
||||
dispatch({
|
||||
type: AuctionAssignmentActionTypes.SET_SELECTED_AUCTION_ASSIGNMENT,
|
||||
auctionAssignmentId: {
|
||||
state: AsyncState.Success,
|
||||
data: id
|
||||
}
|
||||
});
|
||||
} catch (err) {
|
||||
ServerLogging.ResolveErrorWithToast(err, {
|
||||
action: "Fetch Auction Assignment",
|
||||
user: getUser().userName,
|
||||
url: auctionAssignmentURL,
|
||||
arguments: id
|
||||
});
|
||||
dispatch({
|
||||
type: AuctionAssignmentActionTypes.SET_SELECTED_AUCTION_ASSIGNMENT,
|
||||
auctionAssignmentId: {
|
||||
state: AsyncState.Failure
|
||||
}
|
||||
});
|
||||
}
|
||||
};
|
||||
};
|
||||
|
||||
export const getAuctionAssignmentFloorCalculations: ActionCreator<ThunkAction<Promise<any>, IAuctionAssignmentState, null, IAuctionAssignmentGetFloorPrice>> = (auctionAssignmentId: number) => {
|
||||
const auctionAssignmentURL = UrlFormatting.ReplaceURLParams(
|
||||
Configuration.PrefixRepoApiUrl(Configuration.Get.urls.repoApi.auction_assignment_floor_price),
|
||||
{ key: "auctionAssignmentId", value: auctionAssignmentId}
|
||||
);
|
||||
return async (dispatch: Dispatch<IAuctionAssignmentGetFloorPrice>) => {
|
||||
dispatch({
|
||||
type: AuctionAssignmentActionTypes.GET_FLOOR_PRICE,
|
||||
floorPriceCalculationResultSet: {
|
||||
state: AsyncState.Loading
|
||||
}
|
||||
});
|
||||
try {
|
||||
const response = await axios.get(auctionAssignmentURL);
|
||||
const floorPriceCalculationResultSet = response.data as IFloorPriceCalculationResultSet;
|
||||
convertServerDataToFloorPriceValuesUsed(floorPriceCalculationResultSet.floorPriceValuesUsed);
|
||||
|
||||
dispatch({
|
||||
type: AuctionAssignmentActionTypes.GET_FLOOR_PRICE,
|
||||
floorPriceCalculationResultSet: {
|
||||
state: AsyncState.Success,
|
||||
data: floorPriceCalculationResultSet
|
||||
}
|
||||
});
|
||||
} catch (err) {
|
||||
ServerLogging.ResolveErrorWithToast(err, {
|
||||
action: "Get Auction Assignment Floor Calculations",
|
||||
user: getUser().userName,
|
||||
url: auctionAssignmentURL,
|
||||
arguments: auctionAssignmentId
|
||||
});
|
||||
dispatch({
|
||||
type: AuctionAssignmentActionTypes.GET_FLOOR_PRICE,
|
||||
floorPriceCalculationResultSet: {
|
||||
state: AsyncState.Failure
|
||||
}
|
||||
});
|
||||
}
|
||||
};
|
||||
};
|
||||
|
||||
export const postNewAuctionAssignment: ActionCreator<ThunkAction<Promise<any>, IAuctionAssignmentState, null, IAuctionAssignmentInsertFromPost>> = (auctionAssignmentPostRequest: IAuctionAssignmentPostRequest) => {
|
||||
const url = Configuration.PrefixRepoApiUrl(Configuration.Get.urls.repoApi.auction_assignment);
|
||||
return async (dispatch: Dispatch<IAuctionAssignmentInsertFromPost>) => {
|
||||
try {
|
||||
const formattedRequest = createAPIReadyAuctionAssignmentPostRequest(auctionAssignmentPostRequest);
|
||||
const response = await axios.post(url, formattedRequest);
|
||||
const convertedData = convertServerDataToAuctionAssignmentPostRequest(response.data);
|
||||
|
||||
dispatch({
|
||||
type: AuctionAssignmentActionTypes.INSERT_FROM_POST,
|
||||
auctionAssignmentResponse: convertedData,
|
||||
});
|
||||
|
||||
toast.success("Auction Assignment Saved.", ToastDefaults.baseParams);
|
||||
} catch (err) {
|
||||
ServerLogging.ResolveErrorWithToast(err, {
|
||||
action: "Post New Auction Assignment",
|
||||
user: getUser().userName,
|
||||
url: url,
|
||||
arguments: auctionAssignmentPostRequest
|
||||
});
|
||||
}
|
||||
};
|
||||
};
|
||||
|
||||
export const putAuctionAssignment: ActionCreator<ThunkAction<Promise<any>, IAuctionAssignmentState, null, IAuctionAssignmentInsert>> = (assignment: IAuctionAssignment) => {
|
||||
const url = UrlFormatting.ReplaceURLParams(
|
||||
Configuration.PrefixRepoApiUrl(Configuration.Get.urls.repoApi.auction_assignment_single),
|
||||
{ key: "auctionAssignmentId", value: assignment.id}
|
||||
);
|
||||
return async (dispatch: Dispatch) => {
|
||||
try {
|
||||
const revertedAccount = createAPIReadyAuctionAssignment(assignment);
|
||||
const response = await axios.put(url, revertedAccount);
|
||||
const updatedAssignment = response.data;
|
||||
convertServerDataToAuctionAssignment(updatedAssignment);
|
||||
|
||||
dispatch({
|
||||
type: AuctionAssignmentActionTypes.INSERT,
|
||||
auctionAssignment: updatedAssignment
|
||||
});
|
||||
|
||||
toast.success("Auction Assignment Updated.", ToastDefaults.baseParams);
|
||||
} catch (err) {
|
||||
ServerLogging.ResolveErrorWithToast(err, {
|
||||
action: "Put Auction Assignment",
|
||||
user: getUser().userName,
|
||||
url: url,
|
||||
arguments: assignment
|
||||
});
|
||||
}
|
||||
};
|
||||
};
|
||||
|
||||
export const removeAuction: ActionCreator<ThunkAction<Promise<any>, IAuctionAssignmentState, null, IAuctionAssignmentInsert>> = (assignmentId: number) => {
|
||||
const url = UrlFormatting.ReplaceURLParams(
|
||||
Configuration.PrefixRepoApiUrl(Configuration.Get.urls.repoApi.auction_assignment_single),
|
||||
{ key: "auctionAssignmentId", value: assignmentId}
|
||||
);
|
||||
return async (dispatch: Dispatch) => {
|
||||
try {
|
||||
const response = await axios.delete(url);
|
||||
const updatedAssignment = response.data;
|
||||
convertServerDataToAuctionAssignment(updatedAssignment);
|
||||
|
||||
dispatch({
|
||||
type: AuctionAssignmentActionTypes.INSERT,
|
||||
auctionAssignment: updatedAssignment
|
||||
});
|
||||
|
||||
toast.success("Auction Assignment Removed.", ToastDefaults.baseParams);
|
||||
} catch (err) {
|
||||
ServerLogging.ResolveErrorWithToast(err, {
|
||||
action: "Remove Auction",
|
||||
user: getUser().userName,
|
||||
url: url,
|
||||
arguments: assignmentId
|
||||
});
|
||||
}
|
||||
};
|
||||
};
|
||||
@@ -0,0 +1,160 @@
|
||||
import Axios from "axios";
|
||||
import { toast } from "react-toastify";
|
||||
import { ActionCreator, Dispatch } from "redux";
|
||||
import { ThunkAction } from "redux-thunk";
|
||||
import {getUser} from "../adalConfig";
|
||||
import { IAuctionHouse, IAuctionHouseState } from "../reducers/AuctionHouseReducer";
|
||||
import Configuration from "../shared/configuration/Configuration";
|
||||
import AsyncState from "../shared/enumerations/AsyncState";
|
||||
import UrlFormatting from "../shared/formatting/UrlFormatting";
|
||||
import ServerLogging from "../shared/logging/ServerLogging";
|
||||
import ToastDefaults from "../shared/notifications/ToastDefaults";
|
||||
import IAsyncStateContainer from "../shared/types/IAsyncStateContainer";
|
||||
|
||||
export enum AuctionHouseActionTypes {
|
||||
GET_AUCTION_HOUSES = "GET_AUCTION_HOUSES",
|
||||
POST_AUCTION_HOUSE = "POST_AUCTION_HOUSE",
|
||||
PUT_AUCTION_HOUSE = "PUT_AUCTION_HOUSE"
|
||||
}
|
||||
|
||||
export interface IAuctionHouseGetAllAction {
|
||||
type: AuctionHouseActionTypes.GET_AUCTION_HOUSES;
|
||||
auctionHouses: IAsyncStateContainer<IAuctionHouse[]>;
|
||||
}
|
||||
|
||||
export interface IAuctionHousePostAction {
|
||||
type: AuctionHouseActionTypes.POST_AUCTION_HOUSE;
|
||||
auctionHouse: IAsyncStateContainer<IAuctionHouse>;
|
||||
}
|
||||
|
||||
export interface IAuctionHousePutAction {
|
||||
type: AuctionHouseActionTypes.PUT_AUCTION_HOUSE;
|
||||
auctionHouse: IAsyncStateContainer<IAuctionHouse>;
|
||||
}
|
||||
|
||||
export type AuctionHouseActions = IAuctionHouseGetAllAction | IAuctionHousePostAction | IAuctionHousePutAction;
|
||||
|
||||
export const getAllAuctionHouses: ActionCreator<ThunkAction<Promise<any>, IAuctionHouseState, null, IAuctionHouseGetAllAction>> = () => {
|
||||
const url = Configuration.PrefixRepoApiUrl(Configuration.Get.urls.repoApi.auction_house);
|
||||
return async (dispatch: Dispatch<IAuctionHouseGetAllAction>) =>{
|
||||
dispatch({
|
||||
type: AuctionHouseActionTypes.GET_AUCTION_HOUSES,
|
||||
auctionHouses: {
|
||||
state: AsyncState.Loading,
|
||||
},
|
||||
});
|
||||
try {
|
||||
const response = await Axios.get(url);
|
||||
const auctionHouses = (response.data as IAuctionHouse[]).sort((a, b) =>
|
||||
a.name.toLowerCase() < b.name.toLowerCase() ? -1 : 0
|
||||
);
|
||||
dispatch({
|
||||
type: AuctionHouseActionTypes.GET_AUCTION_HOUSES,
|
||||
auctionHouses: {
|
||||
data: auctionHouses,
|
||||
state: AsyncState.Success,
|
||||
},
|
||||
});
|
||||
} catch (err) {
|
||||
ServerLogging.ResolveErrorWithToast(err, {
|
||||
action: "Get All Auction Houses",
|
||||
user: getUser().userName,
|
||||
url: url,
|
||||
});
|
||||
dispatch({
|
||||
type: AuctionHouseActionTypes.GET_AUCTION_HOUSES,
|
||||
auctionHouses: {
|
||||
state: AsyncState.Failure,
|
||||
},
|
||||
});
|
||||
}
|
||||
};
|
||||
};
|
||||
|
||||
export const postAuctionHouse: ActionCreator<ThunkAction<Promise<any>, IAuctionHouseState, null, IAuctionHousePostAction>> = (newAuctionHouse: IAuctionHouse) => {
|
||||
const url = Configuration.PrefixRepoApiUrl(Configuration.Get.urls.repoApi.auction_house);
|
||||
return async (dispatch: Dispatch<IAuctionHousePostAction>) =>{
|
||||
try {
|
||||
|
||||
dispatch({
|
||||
type: AuctionHouseActionTypes.POST_AUCTION_HOUSE,
|
||||
auctionHouse: {
|
||||
state: AsyncState.Loading,
|
||||
}
|
||||
});
|
||||
|
||||
const response = await Axios.post(url, newAuctionHouse);
|
||||
|
||||
dispatch({
|
||||
type: AuctionHouseActionTypes.POST_AUCTION_HOUSE,
|
||||
auctionHouse: {
|
||||
state: AsyncState.Success,
|
||||
data: response.data
|
||||
}
|
||||
});
|
||||
|
||||
toast.success("Auction House Added.", ToastDefaults.baseParams);
|
||||
|
||||
} catch (err) {
|
||||
ServerLogging.ResolveErrorWithToast(err, {
|
||||
action: "Post New Auction House",
|
||||
user: getUser().userName,
|
||||
url: url,
|
||||
arguments: newAuctionHouse
|
||||
});
|
||||
|
||||
dispatch({
|
||||
type: AuctionHouseActionTypes.POST_AUCTION_HOUSE,
|
||||
auctionHouse: {
|
||||
state: AsyncState.Failure,
|
||||
}
|
||||
});
|
||||
}
|
||||
};
|
||||
|
||||
};
|
||||
|
||||
export const putAuctionHouse: ActionCreator<ThunkAction<Promise<any>, IAuctionHouseState, null, IAuctionHousePutAction>> = (updatedAuctionHouse: IAuctionHouse) => {
|
||||
const url = UrlFormatting.ReplaceURLParams(
|
||||
Configuration.PrefixRepoApiUrl(Configuration.Get.urls.repoApi.auction_house_by_auction_id),
|
||||
{key:"auctionId", value: updatedAuctionHouse.auctionID},
|
||||
);
|
||||
return async (dispatch: Dispatch<IAuctionHousePutAction>) =>{
|
||||
try {
|
||||
|
||||
dispatch({
|
||||
type: AuctionHouseActionTypes.PUT_AUCTION_HOUSE,
|
||||
auctionHouse: {
|
||||
state: AsyncState.Loading,
|
||||
}
|
||||
});
|
||||
|
||||
const response = await Axios.put(url, updatedAuctionHouse);
|
||||
|
||||
dispatch({
|
||||
type: AuctionHouseActionTypes.PUT_AUCTION_HOUSE,
|
||||
auctionHouse: {
|
||||
state: AsyncState.Success,
|
||||
data: response.data
|
||||
}
|
||||
});
|
||||
|
||||
toast.success("Auction House Added.", ToastDefaults.baseParams);
|
||||
|
||||
} catch (err) {
|
||||
ServerLogging.ResolveErrorWithToast(err, {
|
||||
action: "Put Updated Auction House",
|
||||
user: getUser().userName,
|
||||
url: url,
|
||||
arguments: updatedAuctionHouse
|
||||
});
|
||||
|
||||
dispatch({
|
||||
type: AuctionHouseActionTypes.PUT_AUCTION_HOUSE,
|
||||
auctionHouse: {
|
||||
state: AsyncState.Failure,
|
||||
}
|
||||
});
|
||||
}
|
||||
};
|
||||
};
|
||||
@@ -0,0 +1,191 @@
|
||||
import Axios from "axios";
|
||||
import {ActionCreator, Dispatch} from "redux";
|
||||
import {ThunkAction} from "redux-thunk";
|
||||
import {getUser} from "../adalConfig";
|
||||
import {ICollectionsAccount, ICollectionsAccountState} from "../reducers/CollectionsAccountReducer";
|
||||
import CollectionsAccountService from "../services/CollectionsAccountService";
|
||||
import {IRepoAccount} from "../services/service-types/RepoAccountTypes";
|
||||
import Configuration from "../shared/configuration/Configuration";
|
||||
import AsyncState from "../shared/enumerations/AsyncState";
|
||||
import UrlFormatting from "../shared/formatting/UrlFormatting";
|
||||
import ServerLogging from "../shared/logging/ServerLogging";
|
||||
import IAsyncStateContainer from "../shared/types/IAsyncStateContainer";
|
||||
import {IAppState} from "../store/Store";
|
||||
|
||||
export enum CollectionsAccountActionTypes {
|
||||
GET_COLLECTIONS_ACCOUNT = "GET_COLLECTIONS_ACCOUNT",
|
||||
SET_SEARCH_PHRASE = "SET_SEARCH_PHRASE",
|
||||
FIND_ASSOCIATED_REPOS = "FIND_ASSOCIATED_REPOS",
|
||||
PUT_ACCOUNT_ON_QUEUE = "PUT_ACCOUNT_ON_QUEUE"
|
||||
}
|
||||
|
||||
export interface ICollectionsAccountGetAction {
|
||||
type: CollectionsAccountActionTypes.GET_COLLECTIONS_ACCOUNT;
|
||||
collectionsAccount: IAsyncStateContainer<ICollectionsAccount[]>;
|
||||
}
|
||||
|
||||
export interface ICollectionsSetSearchPhraseAction {
|
||||
type: CollectionsAccountActionTypes.SET_SEARCH_PHRASE;
|
||||
searchPhrase: string;
|
||||
}
|
||||
|
||||
export interface ICollectionsfindAssociatedRepoAccountAction {
|
||||
type: CollectionsAccountActionTypes.FIND_ASSOCIATED_REPOS;
|
||||
associatedRepoAccounts: IAsyncStateContainer<IRepoAccount[]>;
|
||||
}
|
||||
|
||||
export interface ICollectionsAccountPutAction {
|
||||
type: CollectionsAccountActionTypes.PUT_ACCOUNT_ON_QUEUE;
|
||||
didAddToQueue: IAsyncStateContainer<boolean>;
|
||||
}
|
||||
|
||||
export type CollectionsAccountActions =
|
||||
ICollectionsAccountGetAction
|
||||
| ICollectionsSetSearchPhraseAction
|
||||
| ICollectionsfindAssociatedRepoAccountAction
|
||||
| ICollectionsAccountPutAction;
|
||||
|
||||
export const getCollectionsAccount: ActionCreator<ThunkAction<Promise<any>, ICollectionsAccountState, null, ICollectionsAccountGetAction>> = (accountNo: string) => {
|
||||
const url = UrlFormatting.ReplaceURLParams(Configuration.PrefixCollectionsUrl(Configuration.Get.urls.collections.collections_account), {
|
||||
key: "accountNo",
|
||||
value: Configuration.Get.collectionsAccountNoPrefix + accountNo
|
||||
});
|
||||
return async (dispatch: Dispatch) => {
|
||||
dispatch({
|
||||
type: CollectionsAccountActionTypes.GET_COLLECTIONS_ACCOUNT,
|
||||
collectionsAccount: {
|
||||
state: AsyncState.Loading
|
||||
}
|
||||
});
|
||||
dispatch({
|
||||
type: CollectionsAccountActionTypes.PUT_ACCOUNT_ON_QUEUE,
|
||||
didAddToQueue: {
|
||||
state: AsyncState.Inactive,
|
||||
data: false
|
||||
}
|
||||
});
|
||||
try {
|
||||
const response = await Axios.get(url);
|
||||
|
||||
dispatch({
|
||||
type: CollectionsAccountActionTypes.GET_COLLECTIONS_ACCOUNT,
|
||||
collectionsAccount: {
|
||||
data: CollectionsAccountService.mapResponseToCollectionsAccount(response.data),
|
||||
state: AsyncState.Success
|
||||
}
|
||||
});
|
||||
} catch (err) {
|
||||
ServerLogging.ResolveErrorWithToast(err, {
|
||||
action: "Get Collections Account",
|
||||
user: getUser().userName,
|
||||
url: url,
|
||||
arguments: [accountNo]
|
||||
});
|
||||
dispatch({
|
||||
type: CollectionsAccountActionTypes.GET_COLLECTIONS_ACCOUNT,
|
||||
collectionsAccount: {
|
||||
state: AsyncState.Failure
|
||||
}
|
||||
});
|
||||
}
|
||||
};
|
||||
};
|
||||
|
||||
export const setSearchPhraseCollectionsAccounts: ActionCreator<ThunkAction<Promise<any>, IAppState, {}, ICollectionsSetSearchPhraseAction | ICollectionsAccountGetAction>> = (searchPhrase: string) => {
|
||||
return async (dispatch) => {
|
||||
dispatch({
|
||||
type: CollectionsAccountActionTypes.SET_SEARCH_PHRASE,
|
||||
searchPhrase: searchPhrase
|
||||
});
|
||||
};
|
||||
};
|
||||
|
||||
export const findAssociatedRepoAccount: ActionCreator<ThunkAction<Promise<any>, IAppState, {}, ICollectionsfindAssociatedRepoAccountAction>> = (collectionsAccount: ICollectionsAccount) => {
|
||||
const url = UrlFormatting.ReplaceURLParams(Configuration.PrefixRepoApiUrl(Configuration.Get.urls.repoApi.accounts_single_by_account_no), {
|
||||
key: "accountNo",
|
||||
value: collectionsAccount.accountIdentifier
|
||||
});
|
||||
return async (dispatch: Dispatch) => {
|
||||
dispatch({
|
||||
type: CollectionsAccountActionTypes.FIND_ASSOCIATED_REPOS,
|
||||
associatedRepoAccounts: {
|
||||
state: AsyncState.Loading
|
||||
}
|
||||
});
|
||||
try {
|
||||
const response = await Axios.get(url);
|
||||
dispatch({
|
||||
type: CollectionsAccountActionTypes.FIND_ASSOCIATED_REPOS,
|
||||
associatedRepoAccounts: {
|
||||
data: response.data,
|
||||
state: AsyncState.Success
|
||||
}
|
||||
});
|
||||
} catch (err) {
|
||||
if( err && err.response && err.response.status !== 404 ) {
|
||||
ServerLogging.ResolveErrorWithToast(err, {
|
||||
action: "Find Associated Repos",
|
||||
user: getUser().userName,
|
||||
url: url,
|
||||
arguments: [collectionsAccount.accountIdentifier]
|
||||
});
|
||||
dispatch({
|
||||
type: CollectionsAccountActionTypes.FIND_ASSOCIATED_REPOS,
|
||||
associatedRepoAccounts: {
|
||||
state: AsyncState.Failure
|
||||
}
|
||||
});
|
||||
} else {
|
||||
dispatch({
|
||||
type: CollectionsAccountActionTypes.FIND_ASSOCIATED_REPOS,
|
||||
associatedRepoAccounts: {
|
||||
data: [],
|
||||
state: AsyncState.Success
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
};
|
||||
|
||||
export const putAccountOnRepoQueue: ActionCreator<ThunkAction<Promise<any>, IAppState, {}, ICollectionsAccountPutAction>> = (collectionsAccount: ICollectionsAccount) => {
|
||||
const url = Configuration.PrefixRepoApiUrl(Configuration.Get.urls.repoApi.put_to_repo_queue);
|
||||
const queueRequest = {
|
||||
accountNo: collectionsAccount.accountIdentifier
|
||||
};
|
||||
return async (dispatch: Dispatch) => {
|
||||
dispatch({
|
||||
type: CollectionsAccountActionTypes.PUT_ACCOUNT_ON_QUEUE,
|
||||
didAddToQueue: {
|
||||
state: AsyncState.Loading,
|
||||
data: true
|
||||
}
|
||||
});
|
||||
try {
|
||||
await Axios.post(url, queueRequest);
|
||||
dispatch({
|
||||
type: CollectionsAccountActionTypes.PUT_ACCOUNT_ON_QUEUE,
|
||||
didAddToQueue: {
|
||||
state: AsyncState.Success,
|
||||
data: true
|
||||
}
|
||||
});
|
||||
} catch (err) {
|
||||
ServerLogging.ResolveErrorWithToast(err, {
|
||||
action: "Put Account On Repo Queue",
|
||||
user: getUser().userName,
|
||||
url: url,
|
||||
arguments: [collectionsAccount]
|
||||
});
|
||||
dispatch({
|
||||
type: CollectionsAccountActionTypes.PUT_ACCOUNT_ON_QUEUE,
|
||||
didAddToQueue: {
|
||||
AsyncState: AsyncState.Failure,
|
||||
data: true
|
||||
}
|
||||
});
|
||||
}
|
||||
};
|
||||
};
|
||||
|
||||
@@ -0,0 +1,78 @@
|
||||
import IAsyncStateContainer from "../shared/types/IAsyncStateContainer";
|
||||
import { IFactoidState } from "../reducers/FactoidReducer";
|
||||
import { ActionCreator, Dispatch } from "redux";
|
||||
import { ThunkAction } from "redux-thunk";
|
||||
import AsyncState from "../shared/enumerations/AsyncState";
|
||||
import Axios from "axios";
|
||||
import Configuration from "../shared/configuration/Configuration";
|
||||
import ServerLogging from "../shared/logging/ServerLogging";
|
||||
import { IFactoid, IFactoidResponse } from "../services/service-types/FactoidTypes";
|
||||
import { RepoAccountActionTypes, IRepoAccountInsertAccounts } from "./RepoAccountActions";
|
||||
import FactoidService from "../services/FactoidService";
|
||||
import {getUser} from "../adalConfig";
|
||||
|
||||
export enum FactoidActionTypes {
|
||||
SET_SELECTED_FACTOID_INDEX = 'FACTOID_SET_INDEX',
|
||||
GET_ALL_FACTOIDS = 'FACTOIDs_GET_ALL'
|
||||
}
|
||||
|
||||
export interface IFactoidSetSelectedIndexAction {
|
||||
type: FactoidActionTypes.SET_SELECTED_FACTOID_INDEX;
|
||||
index: number;
|
||||
}
|
||||
|
||||
export interface IFactoidGetAllActions {
|
||||
type: FactoidActionTypes.GET_ALL_FACTOIDS;
|
||||
factoids: IAsyncStateContainer<IFactoid[]>;
|
||||
}
|
||||
|
||||
export type FactoidActions =
|
||||
IFactoidSetSelectedIndexAction &
|
||||
IFactoidGetAllActions;
|
||||
|
||||
export const setSelectedFactoidIndex = (index: number): IFactoidSetSelectedIndexAction => {
|
||||
return {
|
||||
type: FactoidActionTypes.SET_SELECTED_FACTOID_INDEX,
|
||||
index: index
|
||||
}
|
||||
};
|
||||
|
||||
export const getAllFactoids: ActionCreator<ThunkAction<Promise<any>, IFactoidState, null, IFactoidGetAllActions>> = (factoidState: IFactoidState) => {
|
||||
const url = Configuration.PrefixRepoApiUrl(Configuration.Get.urls.repoApi.factoids_get_all);
|
||||
return async(dispatch: Dispatch<IFactoidGetAllActions | IRepoAccountInsertAccounts>) => {
|
||||
dispatch({
|
||||
type: FactoidActionTypes.GET_ALL_FACTOIDS,
|
||||
factoids: {
|
||||
state: AsyncState.Loading
|
||||
}
|
||||
});
|
||||
try {
|
||||
const response = await Axios.get(url);
|
||||
const factoidResponses = response.data as IFactoidResponse[];
|
||||
dispatch({
|
||||
type: RepoAccountActionTypes.INSERT_ACCOUNTS,
|
||||
repoAccounts: FactoidService.ExtractRepoAccountsFromFactoidResponses(factoidResponses)
|
||||
});
|
||||
dispatch({
|
||||
type: FactoidActionTypes.GET_ALL_FACTOIDS,
|
||||
factoids: {
|
||||
state: AsyncState.Success,
|
||||
data: FactoidService.CreateFactoidsFromResponse(factoidResponses)
|
||||
}
|
||||
});
|
||||
} catch(err) {
|
||||
ServerLogging.ResolveErrorWithToast(err, {
|
||||
action: "Get All Factoids",
|
||||
user: getUser().userName,
|
||||
url: url,
|
||||
arguments: factoidState
|
||||
});
|
||||
dispatch({
|
||||
type: FactoidActionTypes.GET_ALL_FACTOIDS,
|
||||
factoids: {
|
||||
state: AsyncState.Failure
|
||||
}
|
||||
});
|
||||
}
|
||||
};
|
||||
};
|
||||
+45
@@ -0,0 +1,45 @@
|
||||
import moxios from 'moxios';
|
||||
import {applyMiddleware, createStore} from 'redux';
|
||||
import rootReducer from '../store/Store';
|
||||
import thunk from 'redux-thunk';
|
||||
import {markCollateralRetitled} from './RepoAccountActions'
|
||||
|
||||
const testStore = (initialState: any) => {
|
||||
const createStoreWithMiddleware = applyMiddleware(thunk)(createStore);
|
||||
return createStoreWithMiddleware(rootReducer, initialState);
|
||||
}
|
||||
|
||||
describe('markCollateralRetitled action', () => {
|
||||
beforeEach(() => {
|
||||
moxios.install();
|
||||
});
|
||||
|
||||
afterEach(() => {
|
||||
moxios.uninstall();
|
||||
});
|
||||
|
||||
test('Store updates correctly', () => {
|
||||
const expectedState = {
|
||||
"repoAccounts": [
|
||||
{stuff: 1}
|
||||
]
|
||||
};
|
||||
const store = testStore(expectedState);
|
||||
|
||||
moxios.wait(() => {
|
||||
const request = moxios.requests.mostRecent();
|
||||
request.respondWith({
|
||||
status: 200,
|
||||
response: expectedState
|
||||
});
|
||||
});
|
||||
|
||||
const beginningState = store.getState().repoAccountState;
|
||||
store.dispatch(markCollateralRetitled()).then(() => {
|
||||
const newState = store.getState().repoAccountState;
|
||||
expect(newState).toEqual(expectedState);
|
||||
expect(newState).not.toEqual(beginningState);
|
||||
});
|
||||
|
||||
});
|
||||
});
|
||||
@@ -0,0 +1,546 @@
|
||||
import axios from "axios";
|
||||
import { LocationChangeAction } from "connected-react-router";
|
||||
import { toast } from "react-toastify";
|
||||
import { ActionCreator, Dispatch } from "redux";
|
||||
import { ThunkAction } from "redux-thunk";
|
||||
import RepoAccountService from "../services/RepoAccountService";
|
||||
import { ICollateral, IRefundStatus, IRepoAccount, IRepoAccountFilters, IRepoCompanySelection, IRepoCompanySelectionPostResponse } from "../services/service-types/RepoAccountTypes";
|
||||
import Configuration from "../shared/configuration/Configuration";
|
||||
import AsyncState from "../shared/enumerations/AsyncState";
|
||||
import UrlFormatting from "../shared/formatting/UrlFormatting";
|
||||
import ServerLogging from "../shared/logging/ServerLogging";
|
||||
import ToastDefaults from "../shared/notifications/ToastDefaults";
|
||||
import IAsyncStateContainer from "../shared/types/IAsyncStateContainer";
|
||||
import { IPagedResponse } from "../shared/types/IPagedResponse";
|
||||
import { IAppState } from "../store/Store";
|
||||
import { IAuctionAssignmentInsertFromPost } from "./AuctionAssignmentActions";
|
||||
import {getUser} from "../adalConfig";
|
||||
|
||||
// Create Action Constants
|
||||
export enum RepoAccountActionTypes {
|
||||
SET_SELECTED_ACCOUNT = "REPOACCOUNT_SET_SELECTED_ACCOUNT",
|
||||
INSERT_ONE_ACCOUNT = "REPOACCOUNT_INSERT_ONE",
|
||||
INSERT_ACCOUNTS = "REPOACCOUNT_INSERT_ACCOUNTS",
|
||||
SET_FILTERED_ACCOUNTS = "REPOACCOUNT_SET_FILTERED_ACCOUNTS",
|
||||
INSERT_COLLATERAL = "REPOACCOUNT_INSERT_COLLATERAL",
|
||||
SET_FILTERS = "REPOACCOUNT_SET_FILTERS",
|
||||
UPDATE_REFUND_STATUS = "REPOACCOUNT_UPDATE_REFUND_STATUS",
|
||||
SET_SEARCH_PHRASE = "REPOACCOUNT_SET_SEARCH_PHRASE"
|
||||
}
|
||||
|
||||
export interface IRepoAccountSelectAccountAction {
|
||||
type: RepoAccountActionTypes.SET_SELECTED_ACCOUNT;
|
||||
repoId: IAsyncStateContainer<number>;
|
||||
}
|
||||
|
||||
export interface IRepoAccountSetFilteredAccountsAction {
|
||||
type: RepoAccountActionTypes.SET_FILTERED_ACCOUNTS;
|
||||
filteredAccounts: IAsyncStateContainer<IPagedResponse<number>>;
|
||||
}
|
||||
|
||||
export interface IRepoAccountInsertOneAccount {
|
||||
type: RepoAccountActionTypes.INSERT_ONE_ACCOUNT;
|
||||
repoAccount: IRepoAccount;
|
||||
}
|
||||
|
||||
export interface IRepoAccountInsertAccounts {
|
||||
type: RepoAccountActionTypes.INSERT_ACCOUNTS;
|
||||
repoAccounts: IRepoAccount[];
|
||||
}
|
||||
|
||||
export interface IRepoAccountInsertCollateral {
|
||||
type: RepoAccountActionTypes.INSERT_COLLATERAL;
|
||||
collateral: ICollateral;
|
||||
}
|
||||
|
||||
export interface IRepoAccountSetAccountFiltersAction {
|
||||
type: RepoAccountActionTypes.SET_FILTERS;
|
||||
filters: IRepoAccountFilters;
|
||||
}
|
||||
|
||||
export interface IRepoAccountUpdateRefundStatus {
|
||||
type: RepoAccountActionTypes.UPDATE_REFUND_STATUS;
|
||||
refundStatus: IRefundStatus;
|
||||
}
|
||||
|
||||
export interface IRepoAccountSetSearchPhraseAction {
|
||||
type: RepoAccountActionTypes.SET_SEARCH_PHRASE;
|
||||
searchPhrase: string;
|
||||
}
|
||||
|
||||
/*
|
||||
Combine the action types with a union (we assume there are more)
|
||||
example: export type RepoAccountActions = IGetAllAction | IGetOneAction ...
|
||||
*/
|
||||
export type RepoAccountActions =
|
||||
IRepoAccountSelectAccountAction |
|
||||
IRepoAccountSetFilteredAccountsAction |
|
||||
IAuctionAssignmentInsertFromPost |
|
||||
IRepoAccountInsertOneAccount |
|
||||
IRepoAccountInsertAccounts |
|
||||
IRepoAccountInsertCollateral |
|
||||
IRepoAccountSetAccountFiltersAction |
|
||||
IRepoAccountUpdateRefundStatus |
|
||||
IRepoAccountSetSearchPhraseAction |
|
||||
LocationChangeAction;
|
||||
|
||||
export const getInitialRepoAccounts: ActionCreator<ThunkAction<Promise<any>, IAppState, {}, IRepoAccountInsertAccounts | IRepoAccountSetFilteredAccountsAction | IRepoAccountSetFilteredAccountsAction>> = () => {
|
||||
return async (dispatch, getState) => {
|
||||
// Clear filters, as this fetch will not match the current filters
|
||||
const newFilter: IRepoAccountFilters = {onlyOpenAccounts: getState().repoAccountState.accountFilters.onlyOpenAccounts};
|
||||
dispatch({
|
||||
type: RepoAccountActionTypes.SET_FILTERED_ACCOUNTS,
|
||||
filteredAccounts: {
|
||||
state: getState().repoAccountState.filteredAccounts.state
|
||||
}
|
||||
});
|
||||
await postFilteredAccountsFromURL(Configuration.PrefixRepoApiUrl(Configuration.Get.urls.repoApi.accounts_filter), newFilter, dispatch);
|
||||
};
|
||||
};
|
||||
|
||||
export const setSearchPhrase = (searchPhrase: string): IRepoAccountSetSearchPhraseAction => {
|
||||
return {
|
||||
type: RepoAccountActionTypes.SET_SEARCH_PHRASE,
|
||||
searchPhrase: searchPhrase
|
||||
};
|
||||
};
|
||||
|
||||
export const goToNextRepoAccountPage: ActionCreator<ThunkAction<Promise<any>, IAppState, {}, IRepoAccountSetAccountFiltersAction | IRepoAccountSetFilteredAccountsAction | IRepoAccountInsertAccounts>> = () => {
|
||||
return async (dispatch, getState) => {
|
||||
const currentFilters = getState().repoAccountState.accountFilters;
|
||||
const filterPageResponse = getState().repoAccountState.filteredAccounts.data;
|
||||
|
||||
if (filterPageResponse && filterPageResponse.nextPage) {
|
||||
await postFilteredAccountsFromURL(filterPageResponse.nextPage, currentFilters, dispatch);
|
||||
}
|
||||
};
|
||||
};
|
||||
|
||||
export const goToPreviousRepoAccountPage: ActionCreator<ThunkAction<Promise<any>, IAppState, {}, IRepoAccountSetAccountFiltersAction | IRepoAccountSetFilteredAccountsAction | IRepoAccountInsertAccounts>> = () => {
|
||||
return async (dispatch, getState) => {
|
||||
const currentFilters = getState().repoAccountState.accountFilters;
|
||||
const filterPageResponse = getState().repoAccountState.filteredAccounts.data;
|
||||
|
||||
if (filterPageResponse && filterPageResponse.previousPage) {
|
||||
await postFilteredAccountsFromURL(filterPageResponse.previousPage, currentFilters, dispatch);
|
||||
}
|
||||
};
|
||||
};
|
||||
|
||||
export const fetchSelectedRepoAccount: ActionCreator<ThunkAction<Promise<any>, IAppState, {}, IRepoAccountInsertOneAccount | IRepoAccountSelectAccountAction>> = (repoId: number) => {
|
||||
const singleRepoURL = UrlFormatting.ReplaceURLParams(
|
||||
Configuration.PrefixRepoApiUrl(Configuration.Get.urls.repoApi.accounts_single),
|
||||
{key: "repoId", value: repoId},
|
||||
);
|
||||
return async (dispatch) => {
|
||||
// Since we are fetching the selected account,
|
||||
// we will need to dispatch both to insert the retrieved
|
||||
// account, as well as to update the selected account
|
||||
dispatch({
|
||||
type: RepoAccountActionTypes.SET_SELECTED_ACCOUNT,
|
||||
repoId: {
|
||||
state: AsyncState.Loading
|
||||
}
|
||||
});
|
||||
try {
|
||||
const response = await axios.get(singleRepoURL);
|
||||
RepoAccountService.ConvertResponseToRepoAccount(response.data);
|
||||
dispatch({
|
||||
type: RepoAccountActionTypes.INSERT_ONE_ACCOUNT,
|
||||
repoAccount: response.data
|
||||
});
|
||||
dispatch({
|
||||
type: RepoAccountActionTypes.SET_SELECTED_ACCOUNT,
|
||||
repoId: {
|
||||
state: AsyncState.Success,
|
||||
data: response.data.repoId
|
||||
}
|
||||
});
|
||||
} catch (err) {
|
||||
ServerLogging.ResolveErrorWithToast(err, {
|
||||
action: "Fetch Selected Repo Account",
|
||||
user: getUser().userName,
|
||||
url: singleRepoURL,
|
||||
arguments: repoId
|
||||
});
|
||||
dispatch({
|
||||
type: RepoAccountActionTypes.SET_SELECTED_ACCOUNT,
|
||||
repoId: {
|
||||
state: AsyncState.Failure
|
||||
}
|
||||
});
|
||||
}
|
||||
};
|
||||
};
|
||||
|
||||
export const searchRepoAccounts: ActionCreator<ThunkAction<Promise<any>, IAppState, {}, IRepoAccountSetFilteredAccountsAction | IRepoAccountSetAccountFiltersAction | IRepoAccountSetSearchPhraseAction | IRepoAccountInsertAccounts>> = (searchPhrase: string) => {
|
||||
const parameterizedUrl = UrlFormatting.ReplaceURLParams(
|
||||
Configuration.PrefixRepoApiUrl(Configuration.Get.urls.repoApi.accounts_search),
|
||||
{ key: "searchPhrase", value: searchPhrase }
|
||||
);
|
||||
// Since we are fetching the currently filtered accounts,
|
||||
// we will need to dispatch both to insert the retrieved
|
||||
// account, as well as to update the currently filtered accounts
|
||||
return async (dispatch) => {
|
||||
dispatch({
|
||||
type: RepoAccountActionTypes.SET_FILTERED_ACCOUNTS,
|
||||
filteredAccounts: {
|
||||
state: AsyncState.Loading
|
||||
}
|
||||
});
|
||||
dispatch({
|
||||
type: RepoAccountActionTypes.SET_FILTERS,
|
||||
filters: {}
|
||||
});
|
||||
dispatch({
|
||||
type: RepoAccountActionTypes.SET_SEARCH_PHRASE,
|
||||
searchPhrase: searchPhrase
|
||||
});
|
||||
try {
|
||||
const response = await axios.get(parameterizedUrl);
|
||||
RepoAccountService.ConvertResponseToRepoAccounts(response.data);
|
||||
dispatch({
|
||||
type: RepoAccountActionTypes.INSERT_ACCOUNTS,
|
||||
repoAccounts: response.data
|
||||
});
|
||||
dispatch({
|
||||
type: RepoAccountActionTypes.SET_FILTERED_ACCOUNTS,
|
||||
filteredAccounts: {
|
||||
state: AsyncState.Success,
|
||||
data: {
|
||||
items: RepoAccountService.CreateRepoAccountIdMap(response.data),
|
||||
totalItems: response.data.length,
|
||||
currentPage: 1,
|
||||
totalPages: 1
|
||||
}
|
||||
}
|
||||
});
|
||||
} catch (err) {
|
||||
ServerLogging.ResolveErrorWithToast(err, {
|
||||
action: "Search Repo Accoutns",
|
||||
user: getUser().userName,
|
||||
url: parameterizedUrl,
|
||||
arguments: searchPhrase
|
||||
});
|
||||
dispatch({
|
||||
type: RepoAccountActionTypes.SET_FILTERED_ACCOUNTS,
|
||||
filteredAccounts: {
|
||||
state: AsyncState.Failure
|
||||
}
|
||||
});
|
||||
}
|
||||
};
|
||||
};
|
||||
|
||||
export const removeRepoAccountFromAlertFilter: ActionCreator<ThunkAction<Promise<any>, IAppState, {}, IRepoAccountSetFilteredAccountsAction>> = (alertMessage: string, repoId: number) => {
|
||||
return async (dispatch, getState) => {
|
||||
const filteredAccounts = getState().repoAccountState.filteredAccounts;
|
||||
const accountFilters = getState().repoAccountState.accountFilters;
|
||||
if (filteredAccounts.data && alertMessage === accountFilters.alertMessage) {
|
||||
const indexOfEl = filteredAccounts.data.items.indexOf(repoId);
|
||||
if (indexOfEl >= 0) {
|
||||
const updatedAccountItems = filteredAccounts.data.items.slice();
|
||||
updatedAccountItems.splice(indexOfEl, 1);
|
||||
dispatch({
|
||||
type: RepoAccountActionTypes.SET_FILTERED_ACCOUNTS,
|
||||
filteredAccounts: {
|
||||
data: {
|
||||
...filteredAccounts.data,
|
||||
totalItems: filteredAccounts.data.totalItems - 1,
|
||||
items: updatedAccountItems
|
||||
},
|
||||
state: filteredAccounts.state
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
};
|
||||
};
|
||||
|
||||
export const fetchRepoAccountsViaFilters: ActionCreator<ThunkAction<Promise<any>, IAppState, {}, IRepoAccountSetAccountFiltersAction | IRepoAccountSetFilteredAccountsAction | IRepoAccountSetSearchPhraseAction | IRepoAccountInsertAccounts>> =
|
||||
(filters: IRepoAccountFilters) => {
|
||||
return async (dispatch) => {
|
||||
dispatch({
|
||||
type: RepoAccountActionTypes.SET_FILTERS,
|
||||
filters: filters
|
||||
});
|
||||
dispatch({
|
||||
type: RepoAccountActionTypes.SET_SEARCH_PHRASE,
|
||||
searchPhrase: ""
|
||||
});
|
||||
await postFilteredAccountsFromURL(Configuration.PrefixRepoApiUrl(Configuration.Get.urls.repoApi.accounts_filter), filters, dispatch);
|
||||
};
|
||||
};
|
||||
|
||||
export const postToNextFilterPage: ActionCreator<ThunkAction<Promise<any>, IAppState, {}, IRepoAccountSetFilteredAccountsAction | IRepoAccountInsertAccounts>> =
|
||||
(nextPageUrl: string, filters: IRepoAccountFilters) => {
|
||||
return async (dispatch: Dispatch<IRepoAccountSetAccountFiltersAction | IRepoAccountSetFilteredAccountsAction | IRepoAccountInsertAccounts>) => {
|
||||
await postFilteredAccountsFromURL(nextPageUrl, filters, dispatch);
|
||||
};
|
||||
};
|
||||
|
||||
export const putRepoAccount: ActionCreator<ThunkAction<Promise<any>, IAppState, {}, IRepoAccountInsertOneAccount>> = (account: IRepoAccount) => {
|
||||
const url = Configuration.PrefixRepoApiUrl(Configuration.Get.urls.repoApi.accounts) + "/" + account.repoId;
|
||||
return async (dispatch: Dispatch<IRepoAccountInsertOneAccount>) => {
|
||||
try {
|
||||
const response = await axios.put(url, account);
|
||||
RepoAccountService.ConvertResponseToRepoAccount(response.data);
|
||||
dispatch({
|
||||
type: RepoAccountActionTypes.INSERT_ONE_ACCOUNT,
|
||||
repoAccount: response.data
|
||||
});
|
||||
toast.success("Account Updated.", ToastDefaults.baseParams);
|
||||
} catch (err) {
|
||||
ServerLogging.ResolveErrorWithToast(err, {
|
||||
action: "Put Repo Account",
|
||||
user: getUser().userName,
|
||||
url: url,
|
||||
arguments: account
|
||||
});
|
||||
}
|
||||
};
|
||||
};
|
||||
|
||||
export const putCollateral: ActionCreator<ThunkAction<Promise<any>, ICollateral, null, IRepoAccountInsertCollateral>> = (collateral: ICollateral) => {
|
||||
const singleCollateralUrl = UrlFormatting.ReplaceURLParams(
|
||||
Configuration.PrefixRepoApiUrl(Configuration.Get.urls.repoApi.collateral_single),
|
||||
{key: "collateralId", value: collateral.collateralId},
|
||||
);
|
||||
return async (dispatch) => {
|
||||
try {
|
||||
const response = await axios.put(
|
||||
singleCollateralUrl,
|
||||
collateral
|
||||
);
|
||||
RepoAccountService.ConvertResponseToCollateral(response.data);
|
||||
dispatch({
|
||||
type: RepoAccountActionTypes.INSERT_COLLATERAL,
|
||||
collateral: response.data
|
||||
});
|
||||
toast.success("Collateral Updated.", ToastDefaults.baseParams);
|
||||
} catch (err) {
|
||||
ServerLogging.ResolveErrorWithToast(err, {
|
||||
action: "Put Collateral",
|
||||
user: getUser().userName,
|
||||
url: singleCollateralUrl,
|
||||
arguments: collateral
|
||||
});
|
||||
}
|
||||
};
|
||||
};
|
||||
|
||||
export const putRepoCompanySelection: ActionCreator<ThunkAction<Promise<any>, IAppState, {}, IRepoAccountInsertCollateral>> = (repoCompanySelection: IRepoCompanySelection, collateral: ICollateral) => {
|
||||
const repoCompanySelectionPutURL = UrlFormatting.ReplaceURLParams(
|
||||
Configuration.PrefixRepoApiUrl(Configuration.Get.urls.repoApi.repo_company_selection_single),
|
||||
{key: "repoCompanySelectionId", value: repoCompanySelection.id},
|
||||
);
|
||||
return async (dispatch) => {
|
||||
try {
|
||||
const response = await axios.put(
|
||||
repoCompanySelectionPutURL,
|
||||
repoCompanySelection
|
||||
);
|
||||
RepoAccountService.ConvertResponseToRepoCompanySelection(response.data);
|
||||
dispatch({
|
||||
type: RepoAccountActionTypes.INSERT_COLLATERAL,
|
||||
collateral: RepoAccountService.CreateCollateralFromRepoCompanySelection(collateral, repoCompanySelection)
|
||||
});
|
||||
toast.success("Repo Selection Updated.", ToastDefaults.baseParams);
|
||||
} catch (err) {
|
||||
ServerLogging.ResolveErrorWithToast(err, {
|
||||
action: "Put Repo Company Selection",
|
||||
user: getUser().userName,
|
||||
url: repoCompanySelectionPutURL,
|
||||
arguments: [repoCompanySelection, collateral]
|
||||
});
|
||||
}
|
||||
};
|
||||
};
|
||||
|
||||
export const postRepoCompanySelection: ActionCreator<ThunkAction<Promise<any>, IAppState, {}, IRepoAccountInsertCollateral>> = (repoCompanySelection: IRepoCompanySelection, collateral: ICollateral) => {
|
||||
const repoCompanySelectionPostURL = Configuration.PrefixRepoApiUrl(Configuration.Get.urls.repoApi.repo_company_selection);
|
||||
return async (dispatch) => {
|
||||
try {
|
||||
const response = await axios.post(
|
||||
repoCompanySelectionPostURL,
|
||||
repoCompanySelection
|
||||
);
|
||||
|
||||
let responseData = response.data as IRepoCompanySelectionPostResponse;
|
||||
const repoCompanySelectionArray = [
|
||||
responseData.newRepoCompanySelection
|
||||
];
|
||||
|
||||
RepoAccountService.ConvertResponseToRepoCompanySelection(responseData.newRepoCompanySelection);
|
||||
if (responseData.previousRepoCompanySelection) {
|
||||
RepoAccountService.ConvertResponseToRepoCompanySelection(responseData.previousRepoCompanySelection);
|
||||
repoCompanySelectionArray.push(responseData.previousRepoCompanySelection);
|
||||
}
|
||||
|
||||
dispatch({
|
||||
type: RepoAccountActionTypes.INSERT_COLLATERAL,
|
||||
collateral: RepoAccountService.CreateCollateralFromRepoCompanySelection(collateral, repoCompanySelectionArray)
|
||||
});
|
||||
|
||||
toast.success("Repo Selection Updated.", ToastDefaults.baseParams);
|
||||
} catch (err) {
|
||||
ServerLogging.ResolveErrorWithToast(err, {
|
||||
action: "Post Repo Company Selection",
|
||||
user: getUser().userName,
|
||||
url: repoCompanySelectionPostURL,
|
||||
arguments: [repoCompanySelection, collateral]
|
||||
});
|
||||
}
|
||||
};
|
||||
};
|
||||
|
||||
export const putRefundStatus: ActionCreator<ThunkAction<Promise<any>, IAppState, {}, IRepoAccountUpdateRefundStatus>> = (refundStatus: IRefundStatus) => {
|
||||
const refundStatusPutUrl = UrlFormatting.ReplaceURLParams(
|
||||
Configuration.PrefixRepoApiUrl(Configuration.Get.urls.repoApi.refund_status_single),
|
||||
{key: "repoId", value: refundStatus.repoId}
|
||||
);
|
||||
return async (dispatch) => {
|
||||
try {
|
||||
const response = await axios.put(refundStatusPutUrl, refundStatus);
|
||||
RepoAccountService.ConvertResponseToRefundStatus(response.data);
|
||||
dispatch({
|
||||
type: RepoAccountActionTypes.UPDATE_REFUND_STATUS,
|
||||
refundStatus: response.data
|
||||
});
|
||||
toast.success("Refund Status Updated.", ToastDefaults.baseParams);
|
||||
} catch (err) {
|
||||
ServerLogging.ResolveErrorWithToast(err, {
|
||||
action: "Put Refund Status",
|
||||
user: getUser().userName,
|
||||
url: refundStatusPutUrl,
|
||||
arguments: refundStatus
|
||||
});
|
||||
}
|
||||
};
|
||||
};
|
||||
|
||||
export const postRefundStatus: ActionCreator<ThunkAction<Promise<any>, IAppState, {}, IRepoAccountUpdateRefundStatus>> = (refundStatus: IRefundStatus) => {
|
||||
const refundStatusPutUrl = Configuration.PrefixRepoApiUrl(Configuration.Get.urls.repoApi.refund_status);
|
||||
return async (dispatch) => {
|
||||
try {
|
||||
const response = await axios.post(refundStatusPutUrl, refundStatus);
|
||||
RepoAccountService.ConvertResponseToRefundStatus(response.data);
|
||||
dispatch({
|
||||
type: RepoAccountActionTypes.UPDATE_REFUND_STATUS,
|
||||
refundStatus: response.data
|
||||
});
|
||||
toast.success("Refund Status Created.", ToastDefaults.baseParams);
|
||||
} catch (err) {
|
||||
ServerLogging.ResolveErrorWithToast(err, {
|
||||
action: "Post Refund Status",
|
||||
user: getUser().userName,
|
||||
url: refundStatusPutUrl,
|
||||
arguments: refundStatus
|
||||
});
|
||||
}
|
||||
};
|
||||
};
|
||||
|
||||
export const refreshCollateral: ActionCreator<ThunkAction<Promise<any>, IAppState, {}, IRepoAccountInsertCollateral>> = (
|
||||
collateral: ICollateral, memberNo: number, loanNo: number) => {
|
||||
|
||||
const coresCollateralUrl = UrlFormatting.ReplaceURLParams(
|
||||
Configuration.PrefixCoreUrl(Configuration.Get.urls.core.loan_collateral),
|
||||
{key: "loanNo", value: loanNo},
|
||||
);
|
||||
|
||||
return async (dispatch) => {
|
||||
try {
|
||||
const singleRepoCollateralUrl = UrlFormatting.ReplaceURLParams(
|
||||
Configuration.PrefixRepoApiUrl(Configuration.Get.urls.repoApi.collateral_single),
|
||||
{key: "collateralId", value: collateral.collateralId},
|
||||
);
|
||||
const response = await axios.get(coresCollateralUrl);
|
||||
const updatedCollateral = updateCollateralWithCoreDetails(response.data, collateral);
|
||||
await axios.put(
|
||||
singleRepoCollateralUrl,
|
||||
updatedCollateral,
|
||||
);
|
||||
dispatch({
|
||||
type: RepoAccountActionTypes.INSERT_COLLATERAL,
|
||||
collateral: updatedCollateral,
|
||||
});
|
||||
toast.success("Collateral Refreshed.", ToastDefaults.baseParams);
|
||||
} catch (err) {
|
||||
ServerLogging.ResolveErrorWithToast(err, {
|
||||
action: "Refresh Collateral",
|
||||
user: getUser().userName,
|
||||
url: coresCollateralUrl,
|
||||
arguments: [collateral, memberNo, loanNo]
|
||||
});
|
||||
}
|
||||
};
|
||||
};
|
||||
|
||||
const updateCollateralWithCoreDetails = (data: any[], collateral: ICollateral): ICollateral => {
|
||||
// eslint-disable-next-line
|
||||
const found = data.find(c => c.collateralId == collateral.refCollateralId);
|
||||
if (found.other.miscellaneousInformation != null) {
|
||||
collateral.vin = found.other.miscellaneousInformation;
|
||||
}
|
||||
if (found.vehicle != null) {
|
||||
collateral.make = found.vehicle.make;
|
||||
collateral.model = found.vehicle.model;
|
||||
collateral.vin = found.vehicle.vin;
|
||||
collateral.year = found.vehicle.year;
|
||||
}
|
||||
return collateral;
|
||||
};
|
||||
|
||||
const fetchFilteredAccountsFromAsyncCallback = async (
|
||||
repoAccountFetch: () => Promise<IPagedResponse<IRepoAccount>>,
|
||||
dispatch: Dispatch<IRepoAccountInsertAccounts | IRepoAccountSetFilteredAccountsAction>
|
||||
) => {
|
||||
dispatch({
|
||||
type: RepoAccountActionTypes.SET_FILTERED_ACCOUNTS,
|
||||
filteredAccounts: {
|
||||
state: AsyncState.Loading
|
||||
}
|
||||
});
|
||||
try {
|
||||
const pagedResponse = await repoAccountFetch();
|
||||
RepoAccountService.ConvertResponseToRepoAccounts(pagedResponse.items);
|
||||
|
||||
dispatch({
|
||||
type: RepoAccountActionTypes.INSERT_ACCOUNTS,
|
||||
repoAccounts: pagedResponse.items
|
||||
});
|
||||
dispatch({
|
||||
type: RepoAccountActionTypes.SET_FILTERED_ACCOUNTS,
|
||||
filteredAccounts: {
|
||||
state: AsyncState.Success,
|
||||
data: {
|
||||
items: RepoAccountService.CreateRepoAccountIdMap(pagedResponse.items),
|
||||
totalItems: pagedResponse.totalItems,
|
||||
nextPage: pagedResponse.nextPage,
|
||||
previousPage: pagedResponse.previousPage,
|
||||
currentPage: pagedResponse.currentPage,
|
||||
totalPages: pagedResponse.totalPages
|
||||
}
|
||||
}
|
||||
});
|
||||
} catch (err) {
|
||||
ServerLogging.ResolveErrorWithToast(err, {
|
||||
action: "Fetch Filtered Accounts With Async",
|
||||
user: getUser().userName,
|
||||
});
|
||||
dispatch({
|
||||
type: RepoAccountActionTypes.SET_FILTERED_ACCOUNTS,
|
||||
filteredAccounts: {
|
||||
state: AsyncState.Failure
|
||||
}
|
||||
});
|
||||
}
|
||||
};
|
||||
|
||||
const postFilteredAccountsFromURL = async (url: string, filters: IRepoAccountFilters, dispatch: Dispatch<IRepoAccountInsertAccounts | IRepoAccountSetFilteredAccountsAction>) => {
|
||||
fetchFilteredAccountsFromAsyncCallback(async () => {
|
||||
const response = await axios.post(url, filters);
|
||||
return response.data as IPagedResponse<IRepoAccount>;
|
||||
}, dispatch);
|
||||
};
|
||||
@@ -0,0 +1,110 @@
|
||||
import axios from "axios";
|
||||
import { toast } from "react-toastify";
|
||||
import { ActionCreator, Dispatch } from "redux";
|
||||
import {ThunkAction} from "redux-thunk";
|
||||
import { IRepoCompany, IRepoCompanyState } from "../reducers/RepoCompanyReducer";
|
||||
import Configuration from "../shared/configuration/Configuration";
|
||||
import AsyncState from "../shared/enumerations/AsyncState";
|
||||
import UrlFormatting from "../shared/formatting/UrlFormatting";
|
||||
import ServerLogging from "../shared/logging/ServerLogging";
|
||||
import ToastDefaults from "../shared/notifications/ToastDefaults";
|
||||
import IAsyncStateContainer from "../shared/types/IAsyncStateContainer";
|
||||
import {getUser} from "../adalConfig";
|
||||
|
||||
export enum RepoCompanyActionTypes {
|
||||
SET_REPO_COMPANIES = "GET_REPO_COMPANIES",
|
||||
INSERT_SINGLE_REPO_COMPANY = "INSERT_SINGLE_REPO_COMPANY"
|
||||
}
|
||||
|
||||
export interface IRepoCompanyInsertAction {
|
||||
type: RepoCompanyActionTypes.SET_REPO_COMPANIES;
|
||||
repoCompanies: IAsyncStateContainer<IRepoCompany[]>;
|
||||
}
|
||||
|
||||
export interface IRepoCompanyInsertSingleAction {
|
||||
type: RepoCompanyActionTypes.INSERT_SINGLE_REPO_COMPANY;
|
||||
repoCompany: IRepoCompany;
|
||||
}
|
||||
|
||||
export type RepoCompanyActions = IRepoCompanyInsertAction | IRepoCompanyInsertSingleAction;
|
||||
|
||||
export const getAllRepoCompanies: ActionCreator<ThunkAction<Promise<any>, IRepoCompanyState, null, IRepoCompanyInsertAction>> = () => {
|
||||
const url = Configuration.PrefixRepoApiUrl(Configuration.Get.urls.repoApi.repo_companies);
|
||||
return async (dispatch: Dispatch<IRepoCompanyInsertAction>) =>{
|
||||
dispatch({
|
||||
type: RepoCompanyActionTypes.SET_REPO_COMPANIES,
|
||||
repoCompanies: {
|
||||
state: AsyncState.Loading,
|
||||
},
|
||||
});
|
||||
try {
|
||||
const response = await axios.get(url);
|
||||
dispatch({
|
||||
type: RepoCompanyActionTypes.SET_REPO_COMPANIES,
|
||||
repoCompanies: {
|
||||
data: response.data,
|
||||
state: AsyncState.Success,
|
||||
},
|
||||
});
|
||||
} catch (err) {
|
||||
ServerLogging.ResolveErrorWithToast(err, {
|
||||
action: "Get All Repo Companies",
|
||||
user: getUser().userName,
|
||||
url: url
|
||||
});
|
||||
dispatch({
|
||||
type: RepoCompanyActionTypes.SET_REPO_COMPANIES,
|
||||
repoCompanies: {
|
||||
state: AsyncState.Failure,
|
||||
},
|
||||
});
|
||||
}
|
||||
};
|
||||
};
|
||||
|
||||
export const putRepoCompany: ActionCreator<ThunkAction<Promise<any>, IRepoCompanyState, null, IRepoCompanyInsertSingleAction>> = (repoCompany: IRepoCompany) => {
|
||||
const parametrizedUrl = UrlFormatting.ReplaceURLParams(
|
||||
Configuration.PrefixRepoApiUrl(Configuration.Get.urls.repoApi.repo_companies_single),
|
||||
{ key: "repoCompanyId", value: repoCompany.id }
|
||||
);
|
||||
return async (dispatch: Dispatch<IRepoCompanyInsertSingleAction>) =>{
|
||||
try {
|
||||
const response = await axios.put(parametrizedUrl, repoCompany);
|
||||
const repoCompanyFromServer = response.data as IRepoCompany;
|
||||
dispatch({
|
||||
type: RepoCompanyActionTypes.INSERT_SINGLE_REPO_COMPANY,
|
||||
repoCompany: repoCompanyFromServer
|
||||
});
|
||||
toast.success("Repo Company Updated.", ToastDefaults.baseParams);
|
||||
} catch (err) {
|
||||
ServerLogging.ResolveErrorWithToast(err, {
|
||||
action: "Put Repo Company",
|
||||
user: getUser().userName,
|
||||
url: parametrizedUrl,
|
||||
arguments: repoCompany
|
||||
});
|
||||
}
|
||||
};
|
||||
};
|
||||
|
||||
export const postRepoCompany: ActionCreator<ThunkAction<Promise<any>, IRepoCompanyState, null, IRepoCompanyInsertSingleAction>> = (repoCompany: IRepoCompany) => {
|
||||
const url = Configuration.PrefixRepoApiUrl(Configuration.Get.urls.repoApi.repo_companies);
|
||||
return async (dispatch: Dispatch<IRepoCompanyInsertSingleAction>) =>{
|
||||
try {
|
||||
const response = await axios.post(url, repoCompany);
|
||||
const repoCompanyFromServer = response.data as IRepoCompany;
|
||||
dispatch({
|
||||
type: RepoCompanyActionTypes.INSERT_SINGLE_REPO_COMPANY,
|
||||
repoCompany: repoCompanyFromServer
|
||||
});
|
||||
toast.success("Repo Company Updated.", ToastDefaults.baseParams);
|
||||
} catch (err) {
|
||||
ServerLogging.ResolveErrorWithToast(err, {
|
||||
action: "Post Repo Company",
|
||||
user: getUser().userName,
|
||||
url: url,
|
||||
arguments: repoCompany
|
||||
});
|
||||
}
|
||||
};
|
||||
};
|
||||
@@ -0,0 +1,44 @@
|
||||
import Axios from "axios";
|
||||
import { ActionCreator, Dispatch } from "redux";
|
||||
import { ThunkAction } from "redux-thunk";
|
||||
import { IAdminReportForm, IReport, IReportingState } from "../reducers/ReportingReducer";
|
||||
import AsyncState from "../shared/enumerations/AsyncState";
|
||||
import ServerLogging from "../shared/logging/ServerLogging";
|
||||
import IAsyncStateContainer from "../shared/types/IAsyncStateContainer";
|
||||
import {getUser} from "../adalConfig";
|
||||
|
||||
export enum ReportingActionTypes {
|
||||
SET_REPORT = "SET_REPORT_DATA"
|
||||
}
|
||||
|
||||
export interface IReportingGetReportAction {
|
||||
type: ReportingActionTypes.SET_REPORT;
|
||||
reportForm: IAdminReportForm;
|
||||
currentReport: IAsyncStateContainer<IReport>;
|
||||
}
|
||||
|
||||
export type ReportingActions = IReportingGetReportAction;
|
||||
|
||||
export const selectReport: ActionCreator<ThunkAction<Promise<any>, IReportingState, null, IReportingGetReportAction>> = (reportForm: IAdminReportForm) => {
|
||||
return async (dispatch: Dispatch<IReportingGetReportAction>) => {
|
||||
if (!reportForm.reportUrl) {
|
||||
dispatch({
|
||||
type: ReportingActionTypes.SET_REPORT,
|
||||
reportForm: reportForm,
|
||||
currentReport: {
|
||||
state: AsyncState.Inactive,
|
||||
},
|
||||
});
|
||||
return;
|
||||
}
|
||||
|
||||
dispatch({
|
||||
type: ReportingActionTypes.SET_REPORT,
|
||||
reportForm: reportForm,
|
||||
currentReport: {
|
||||
state: AsyncState.Loading,
|
||||
},
|
||||
});
|
||||
return;
|
||||
};
|
||||
};
|
||||
@@ -0,0 +1,111 @@
|
||||
import axios from "axios";
|
||||
import { toast } from "react-toastify";
|
||||
import { ActionCreator, Dispatch } from "redux";
|
||||
import {ThunkAction} from "redux-thunk";
|
||||
import { ISavedLocation, ISavedLocationState } from "../reducers/SavedLocationReducer";
|
||||
import Configuration from "../shared/configuration/Configuration";
|
||||
import AsyncState from "../shared/enumerations/AsyncState";
|
||||
import UrlFormatting from "../shared/formatting/UrlFormatting";
|
||||
import ServerLogging from "../shared/logging/ServerLogging";
|
||||
import ToastDefaults from "../shared/notifications/ToastDefaults";
|
||||
import IAsyncStateContainer from "../shared/types/IAsyncStateContainer";
|
||||
import {getUser} from "../adalConfig";
|
||||
|
||||
export enum SavedLocationActionTypes {
|
||||
SET_SAVED_LOCATIONS = "GET_SAVED_LOCATIONS",
|
||||
INSERT_SINGLE_SAVED_LOCATION = "INSERT_SINGLE_SAVED_LOCATION"
|
||||
}
|
||||
|
||||
export interface ISavedLocationInsertAction {
|
||||
type: SavedLocationActionTypes.SET_SAVED_LOCATIONS;
|
||||
savedLocations: IAsyncStateContainer<ISavedLocation[]>;
|
||||
}
|
||||
|
||||
export interface ISavedLocationInsertSingleAction {
|
||||
type: SavedLocationActionTypes.INSERT_SINGLE_SAVED_LOCATION;
|
||||
savedLocation: ISavedLocation;
|
||||
}
|
||||
|
||||
export type SavedLocationActions = ISavedLocationInsertAction | ISavedLocationInsertSingleAction;
|
||||
|
||||
export const getAllSavedLocations: ActionCreator<ThunkAction<Promise<any>, ISavedLocationState, null, ISavedLocationInsertAction>> = () => {
|
||||
const url = Configuration.PrefixRepoApiUrl(Configuration.Get.urls.repoApi.saved_locations);
|
||||
return async (dispatch: Dispatch<ISavedLocationInsertAction>) =>{
|
||||
dispatch({
|
||||
type: SavedLocationActionTypes.SET_SAVED_LOCATIONS,
|
||||
savedLocations: {
|
||||
state: AsyncState.Loading,
|
||||
},
|
||||
});
|
||||
try {
|
||||
const response = await axios.get(url);
|
||||
dispatch({
|
||||
type: SavedLocationActionTypes.SET_SAVED_LOCATIONS,
|
||||
savedLocations: {
|
||||
data: response.data,
|
||||
state: AsyncState.Success,
|
||||
},
|
||||
});
|
||||
} catch (err) {
|
||||
dispatch({
|
||||
type: SavedLocationActionTypes.SET_SAVED_LOCATIONS,
|
||||
savedLocations: {
|
||||
state: AsyncState.Failure,
|
||||
},
|
||||
});
|
||||
ServerLogging.ResolveErrorWithToast(err, {
|
||||
action: "Get All Saved Locations",
|
||||
user: getUser().userName,
|
||||
url: url,
|
||||
});
|
||||
}
|
||||
};
|
||||
};
|
||||
|
||||
export const putSavedLocation: ActionCreator<ThunkAction<Promise<any>, ISavedLocationState, null, ISavedLocationInsertSingleAction>> = (savedLocation: ISavedLocation) => {
|
||||
const parametrizedUrl = UrlFormatting.ReplaceURLParams(
|
||||
Configuration.PrefixRepoApiUrl(Configuration.Get.urls.repoApi.saved_locations_single),
|
||||
{ key: "savedLocationId", value: savedLocation.id }
|
||||
);
|
||||
return async (dispatch: Dispatch<ISavedLocationInsertSingleAction>) =>{
|
||||
try {
|
||||
const response = await axios.put(parametrizedUrl, savedLocation);
|
||||
const savedLocationFromServer = response.data as ISavedLocation;
|
||||
dispatch({
|
||||
type: SavedLocationActionTypes.INSERT_SINGLE_SAVED_LOCATION,
|
||||
savedLocation: savedLocationFromServer
|
||||
});
|
||||
toast.success("Saved Location Updated.", ToastDefaults.baseParams);
|
||||
} catch (err) {
|
||||
ServerLogging.ResolveErrorWithToast(err, {
|
||||
action: "Put Saved Location",
|
||||
user: getUser().userName,
|
||||
url: parametrizedUrl,
|
||||
arguments: savedLocation
|
||||
});
|
||||
}
|
||||
};
|
||||
};
|
||||
|
||||
export const postSavedLocation: ActionCreator<ThunkAction<Promise<any>, ISavedLocationState, null, ISavedLocationInsertSingleAction>> = (savedLocation: ISavedLocation) => {
|
||||
const url = Configuration.PrefixRepoApiUrl(Configuration.Get.urls.repoApi.saved_locations);
|
||||
return async (dispatch: Dispatch<ISavedLocationInsertSingleAction>) =>{
|
||||
try {
|
||||
|
||||
const response = await axios.post(url, savedLocation);
|
||||
const savedLocationFromServer = response.data as ISavedLocation;
|
||||
dispatch({
|
||||
type: SavedLocationActionTypes.INSERT_SINGLE_SAVED_LOCATION,
|
||||
savedLocation: savedLocationFromServer
|
||||
});
|
||||
toast.success("Saved Location Updated.", ToastDefaults.baseParams);
|
||||
} catch (err) {
|
||||
ServerLogging.ResolveErrorWithToast(err, {
|
||||
action: "Post Saved Location",
|
||||
user: getUser().userName,
|
||||
url: url,
|
||||
arguments: savedLocation
|
||||
});
|
||||
}
|
||||
};
|
||||
};
|
||||
@@ -0,0 +1,19 @@
|
||||
import {UserInfo} from "react-adal";
|
||||
|
||||
export enum SecurityActionTypes {
|
||||
APPLY_USER = 'APPLY_USER',
|
||||
APPLY_TOKEN = 'APPLY_TOKEN',
|
||||
}
|
||||
|
||||
export interface ISecurityApplyAction {
|
||||
type: SecurityActionTypes.APPLY_USER;
|
||||
user: UserInfo;
|
||||
}
|
||||
|
||||
export interface ISecurityTokenAction {
|
||||
type: SecurityActionTypes.APPLY_TOKEN;
|
||||
userToken: string;
|
||||
}
|
||||
|
||||
export type SecurityActions = ISecurityApplyAction | ISecurityTokenAction;
|
||||
|
||||
@@ -0,0 +1,43 @@
|
||||
import { ISettingsState } from "../reducers/SettingsReducer";
|
||||
import { ActionCreator, Dispatch } from "redux";
|
||||
import {ThunkAction} from 'redux-thunk'
|
||||
import axios from 'axios';
|
||||
import Configuration from "../shared/configuration/Configuration";
|
||||
import ServerLogging from "../shared/logging/ServerLogging";
|
||||
import {getUser} from "../adalConfig";
|
||||
|
||||
export enum SettingsActionTypes {
|
||||
GET_SETTINGS = 'SETTINGS_GET',
|
||||
}
|
||||
|
||||
export interface ISettingsGetAction {
|
||||
type: SettingsActionTypes.GET_SETTINGS;
|
||||
settings: ISettingsState;
|
||||
}
|
||||
|
||||
export type SettingsActions = ISettingsGetAction;
|
||||
|
||||
export const getSettings: ActionCreator<ThunkAction<Promise<any>, ISettingsState, null, ISettingsGetAction>> = () => {
|
||||
const url = Configuration.PrefixRepoApiUrl(Configuration.Get.urls.repoApi.settings);
|
||||
return async (dispatch: Dispatch) => {
|
||||
try {
|
||||
const getResponse = await axios.get(url);
|
||||
const settingsFromServer = getResponse.data as ISettingsState;
|
||||
|
||||
settingsFromServer.vehicleTypes.sort((a, b) => a.description.toLowerCase() < b.description.toLowerCase() ? -1 : 1);
|
||||
settingsFromServer.collateralTypes.sort((a, b) => a.description.toLowerCase() < b.description.toLowerCase() ? -1 : 1);
|
||||
settingsFromServer.bodyStyles.sort((a, b) => a.description.toLowerCase() < b.description.toLowerCase() ? -1 : 1);
|
||||
|
||||
dispatch({
|
||||
type: SettingsActionTypes.GET_SETTINGS,
|
||||
settings: settingsFromServer,
|
||||
})
|
||||
} catch (err) {
|
||||
ServerLogging.ResolveErrorWithToast(err, {
|
||||
action: "Get Settings",
|
||||
user: getUser().userName,
|
||||
url: url,
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
+74
@@ -0,0 +1,74 @@
|
||||
import { IVehicleFloorPricingParametersState, IVehicleFloorPricingParameters, VehicleFloorPricingParametersPutRequest } from "../reducers/VehicleFloorPricingParametersReducer";
|
||||
import { ActionCreator, Dispatch } from "redux";
|
||||
import { ThunkAction } from 'redux-thunk'
|
||||
import axios from 'axios';
|
||||
import { toast } from "react-toastify";
|
||||
import ToastDefaults from "../shared/notifications/ToastDefaults";
|
||||
import ServerLogging from "../shared/logging/ServerLogging";
|
||||
import Configuration from "../shared/configuration/Configuration";
|
||||
import {getUser} from "../adalConfig";
|
||||
|
||||
export enum VehicleFloorPricingParametersActionTypes {
|
||||
GET_VEHICLE_FLOOR_PRICING_PARAMETERS = 'VEHICLE_FLOOR_PRICING_PARAMETERS_GET',
|
||||
PUT_VEHICLE_FLOOR_PRICING_PARAMETERS = 'VEHICLE_FLOOR_PRICING_PARAMETERS_PUT'
|
||||
}
|
||||
|
||||
export interface IVehicleFloorPricingParametersGetAction {
|
||||
type: VehicleFloorPricingParametersActionTypes.GET_VEHICLE_FLOOR_PRICING_PARAMETERS;
|
||||
vehicleFloorPricingParameters: IVehicleFloorPricingParameters[];
|
||||
}
|
||||
|
||||
export interface IVehicleFloorPricingParametersPutAction {
|
||||
type: VehicleFloorPricingParametersActionTypes.PUT_VEHICLE_FLOOR_PRICING_PARAMETERS;
|
||||
vehicleFloorPricingParameters: IVehicleFloorPricingParameters[];
|
||||
}
|
||||
|
||||
export type VehicleFloorPricingParametersActions = IVehicleFloorPricingParametersGetAction | IVehicleFloorPricingParametersPutAction;
|
||||
|
||||
export const getVehicleFloorPricingParameters: ActionCreator<ThunkAction<Promise<any>, IVehicleFloorPricingParametersState, null, IVehicleFloorPricingParametersGetAction>> = () => {
|
||||
const url = Configuration.PrefixRepoApiUrl(Configuration.Get.urls.repoApi.vehicle_floor_pricing_params);
|
||||
return async (dispatch: Dispatch) => {
|
||||
try {
|
||||
const response = await axios.get(url);
|
||||
const floorPricingParametersFromServer = response.data;
|
||||
|
||||
dispatch({
|
||||
type: VehicleFloorPricingParametersActionTypes.GET_VEHICLE_FLOOR_PRICING_PARAMETERS,
|
||||
vehicleFloorPricingParameters: floorPricingParametersFromServer,
|
||||
})
|
||||
} catch (err) {
|
||||
ServerLogging.ResolveErrorWithToast(err, {
|
||||
action: "Get Vehicle Floor Pricing Parameters",
|
||||
user: getUser().userName,
|
||||
url: url,
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
export const putVehicleFloorPricingParameters: ActionCreator<ThunkAction<Promise<any>, IVehicleFloorPricingParameters[], null, IVehicleFloorPricingParametersPutAction>> = (parameters: IVehicleFloorPricingParameters[]) => {
|
||||
const url = Configuration.PrefixRepoApiUrl(Configuration.Get.urls.repoApi.vehicle_floor_pricing_params);
|
||||
return async (dispatch: Dispatch) => {
|
||||
try {
|
||||
var request: VehicleFloorPricingParametersPutRequest = {
|
||||
vehicleFloorPricingParameters: parameters
|
||||
};
|
||||
const response = await axios.put(url, request);
|
||||
const floorPricingParametersFromServer = response.data.vehicleFloorPricingParameters;
|
||||
|
||||
dispatch({
|
||||
type: VehicleFloorPricingParametersActionTypes.PUT_VEHICLE_FLOOR_PRICING_PARAMETERS,
|
||||
vehicleFloorPricingParameters: floorPricingParametersFromServer
|
||||
});
|
||||
|
||||
toast.success('Vehicle Floor Parameters Updated.', ToastDefaults.baseParams);
|
||||
} catch (err) {
|
||||
ServerLogging.ResolveErrorWithToast(err, {
|
||||
action: "Put Vehicle Floor Pricing Parameters",
|
||||
user: getUser().userName,
|
||||
url: url,
|
||||
arguments: parameters
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user