fixes for contract menu
This commit is contained in:
parent
d43c85c45b
commit
2824e30d54
@ -223,9 +223,11 @@ export const sendSwitchAccount = ({ dispatch, acc_number }) =>
|
||||
|
||||
dispatch({ type: actionTypes.USER, data: {} });
|
||||
dispatch({ type: actionTypes.COMPANY, data: {} });
|
||||
dispatch({ type: actionTypes.CONTRACTS_INFO_RESET, data: {} });
|
||||
dispatch({ type: actionTypes.EVENTS_RESET, data: {} });
|
||||
dispatch({ type: actionTypes.SUPPORT_RESET, data: {} });
|
||||
dispatch({ type: actionTypes.CONTRACTS_INFO_RESET, data: {} });
|
||||
dispatch({ type: actionTypes.CONTRACT_EVENTS_RESET, data: {} });
|
||||
dispatch({ type: actionTypes.CONTRACT_FINES_RESET, data: {} });
|
||||
|
||||
return new Promise((resolve, reject) =>
|
||||
{
|
||||
|
||||
@ -320,34 +320,33 @@ export const getContractDocuments = ({ dispatch, number, }) =>
|
||||
});
|
||||
}
|
||||
|
||||
export const getContractFines = ({ dispatch, number, }) =>
|
||||
export const getContractFines = ({ dispatch, contract, }) =>
|
||||
{
|
||||
console.log("ACTION", "getContractFines");
|
||||
console.log("ACTION", "getContractFines", contract);
|
||||
|
||||
return new Promise((resolve, reject) =>
|
||||
{
|
||||
axios.post(`${ process.env.NEXT_PUBLIC_SELF_API_HOST }/api/contract/fines`, {
|
||||
number: number
|
||||
number: contract
|
||||
},
|
||||
{
|
||||
withCredentials: true,
|
||||
})
|
||||
.then(async (response) =>
|
||||
{
|
||||
|
||||
console.log("ACTION", "getContractFines", "response.data", response.data);
|
||||
|
||||
let fines = [];
|
||||
|
||||
let query = nSQL(response.data.fines).query("select");
|
||||
query = query.orderBy({ date: "desc" });
|
||||
query.exec().then((rows) =>
|
||||
{
|
||||
fines = rows;
|
||||
console.log(global.store.getState().contract_fines);
|
||||
const contract_fines = global.store.getState().contract_fines;
|
||||
|
||||
console.log("fines");
|
||||
console.log(fines);
|
||||
dispatch({ type: actionTypes.CONTRACT_FINES, data: { fines: fines } });
|
||||
console.log("ACTION", "getContractFines", "contract_fines", contract_fines);
|
||||
contract_fines[`${ contract }`] = rows;
|
||||
|
||||
dispatch({ type: actionTypes.CONTRACT_FINES, data: contract_fines });
|
||||
resolve();
|
||||
});
|
||||
})
|
||||
@ -371,7 +370,6 @@ export const getContractRules = ({ dispatch, date, }) =>
|
||||
})
|
||||
.then(async (response) =>
|
||||
{
|
||||
console.log("getContractRules", "response.data", response.data);
|
||||
dispatch({ type: actionTypes.CONTRACT_RULES, data: { rules: response.data.rules } });
|
||||
|
||||
resolve();
|
||||
@ -395,7 +393,6 @@ export const getContractMaterials = ({ dispatch, }) =>
|
||||
})
|
||||
.then(async (response) =>
|
||||
{
|
||||
console.log("getContractMaterials", "response.data", response.data);
|
||||
dispatch({ type: actionTypes.CONTRACT_MATERIALS, data: { materials: response.data.materials } });
|
||||
|
||||
resolve();
|
||||
@ -422,7 +419,6 @@ export const getContractPenalties = ({ number, date }) =>
|
||||
})
|
||||
.then(async (response) =>
|
||||
{
|
||||
console.log("getContractPenalties", "response.data", response.data);
|
||||
resolve(response.data);
|
||||
})
|
||||
.catch((error) =>
|
||||
@ -469,8 +465,6 @@ export const getContractGraphicChangeSignatories = ({ dispatch, number }) =>
|
||||
})
|
||||
.then(async (response) =>
|
||||
{
|
||||
console.log("ACTION", "getContractGraphicChangeSignatories", "response.data", response.data);
|
||||
|
||||
dispatch({ type: actionTypes.CONTRACT_CHANGE, data: { signatories: response.data.signatories } });
|
||||
resolve();
|
||||
})
|
||||
@ -490,16 +484,12 @@ export const getContractGraphicChangeVariants = ({ dispatch, number, variants =
|
||||
|
||||
return new Promise((resolve, reject) =>
|
||||
{
|
||||
console.log("{ ...{ number }, ...variants }", { ...{ number }, ...{ variants: variants } });
|
||||
|
||||
axios.post(`${ process.env.NEXT_PUBLIC_SELF_API_HOST }/api/contract/change/variants`, { ...{ number }, ...{ variants: variants } },
|
||||
{
|
||||
withCredentials: true,
|
||||
})
|
||||
.then(async (response) =>
|
||||
{
|
||||
console.log("ACTION", "getContractGraphicChangeVariants", "response.data", response.data);
|
||||
|
||||
dispatch({ type: actionTypes.CONTRACT_CHANGE, data: { variants: response.data } });
|
||||
resolve();
|
||||
})
|
||||
@ -525,8 +515,6 @@ export const getContractGraphicChangeCalculationsList = ({ dispatch, number }) =
|
||||
})
|
||||
.then(async (response) =>
|
||||
{
|
||||
console.log("ACTION", "getContractGraphicChangeCalculationsList", "response.data", response.data);
|
||||
|
||||
dispatch({ type: actionTypes.CONTRACT_CHANGE, data: { calculations: response.data.pre_calculations } });
|
||||
resolve();
|
||||
})
|
||||
|
||||
@ -59,7 +59,7 @@ export const getEvents = ({ dispatch, type, contract }) =>
|
||||
});
|
||||
}
|
||||
|
||||
export const getFilteredEvents = ({ dispatch, search }) =>
|
||||
export const getFilteredEvents = ({ dispatch, search, contract }) =>
|
||||
{
|
||||
return new Promise((resolve, reject) =>
|
||||
{
|
||||
@ -110,6 +110,11 @@ export const getFilteredEvents = ({ dispatch, search }) =>
|
||||
query.where([ [ "contract_number", "LIKE", `%${ search }%` ], "OR", [ "add_info", "LIKE", `%${ search }%` ]]);
|
||||
}
|
||||
|
||||
if(contract !== undefined && contract !== null && contract !== "")
|
||||
{
|
||||
query.where([ [ "contract_number", "=", contract ] ]);
|
||||
}
|
||||
|
||||
query.exec().then((rows) =>
|
||||
{
|
||||
console.log("rows");
|
||||
@ -130,12 +135,12 @@ export const getFilteredEvents = ({ dispatch, search }) =>
|
||||
|
||||
export const getContractEvents = ({ dispatch, contract }) =>
|
||||
{
|
||||
console.log("ACTION", "getContractEvents");
|
||||
|
||||
return new Promise((resolve, reject) =>
|
||||
{
|
||||
console.log("getContractEvents");
|
||||
|
||||
console.log(global.store.getState().events);
|
||||
const events = global.store.getState().events.list;
|
||||
console.log("ACTION", "getContractEvents", "events", events);
|
||||
|
||||
let query = nSQL(events)
|
||||
.query("select");
|
||||
|
||||
@ -15,7 +15,6 @@ export const CONTRACT_REGISTRATION = 'CONTRACT_REGISTRATION';
|
||||
export const CONTRACT_TELEMATIC = 'CONTRACT_TELEMATIC';
|
||||
export const CONTRACT_AGREEMENT = 'CONTRACT_AGREEMENT';
|
||||
export const CONTRACT_DOCUMENTS = 'CONTRACT_DOCUMENTS';
|
||||
export const CONTRACT_FINES = 'CONTRACT_FINES';
|
||||
export const CONTRACT_RULES = 'CONTRACT_RULES';
|
||||
export const CONTRACT_MATERIALS = 'CONTRACT_MATERIALS';
|
||||
|
||||
@ -29,6 +28,9 @@ export const CONTRACT_CALCULATED = 'CONTRACT_CALCULATED';
|
||||
export const CONTRACT_EVENTS = 'CONTRACT_EVENTS';
|
||||
export const CONTRACT_EVENTS_RESET = 'CONTRACT_EVENTS_RESET';
|
||||
|
||||
export const CONTRACT_FINES = 'CONTRACT_FINES';
|
||||
export const CONTRACT_FINES_RESET = 'CONTRACT_FINES_RESET';
|
||||
|
||||
export const CALENDAR = 'CALENDAR';
|
||||
export const EVENTS = 'EVENTS';
|
||||
export const EVENTS_FILTERED = 'EVENTS_FILTERED';
|
||||
|
||||
@ -28,6 +28,21 @@ class Manager extends React.Component
|
||||
{
|
||||
const { company } = this.state;
|
||||
|
||||
this._loadManagerAvatar();
|
||||
}
|
||||
|
||||
componentDidUpdate(prevProps, prevState)
|
||||
{
|
||||
if(prevState.company.manager_photo === undefined && this.state.company.manager_photo !== undefined)
|
||||
{
|
||||
this._loadManagerAvatar();
|
||||
}
|
||||
}
|
||||
|
||||
_loadManagerAvatar = () =>
|
||||
{
|
||||
const { company } = this.state;
|
||||
|
||||
if(company.manager_photo !== undefined && company.manager_photo !== null && company.manager_photo !== "")
|
||||
{
|
||||
getImage({ id: company.manager_photo })
|
||||
@ -37,10 +52,13 @@ class Manager extends React.Component
|
||||
})
|
||||
}
|
||||
else
|
||||
{
|
||||
if(company.manager_photo !== undefined)
|
||||
{
|
||||
this.setState({ photo: null, loading: false });
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
_handle_onFull = () =>
|
||||
{
|
||||
|
||||
@ -308,7 +308,8 @@ class SumSelector extends React.Component
|
||||
const { onOption } = this.props;
|
||||
const { min, max } = this.state;
|
||||
|
||||
const value = parseFloat(event.target.value.replace(/[^\d]/mg, ''));
|
||||
const value = parseFloat(event.target.value.replace(',','.').replace(/[^\d,.]/mg, ''));
|
||||
|
||||
if(value >= min && value <= max && !isNaN(value))
|
||||
{
|
||||
this.setState({ value: value }, () =>
|
||||
@ -404,7 +405,7 @@ class InsurancePriceSelector extends React.Component
|
||||
//}
|
||||
//else
|
||||
//{
|
||||
const value = parseFloat(event.target.value.replace(/[^\d]/mg, ''));
|
||||
const value = parseFloat(event.target.value.replace(',','.').replace(/[^\d,.]/mg, ''));
|
||||
if(value >= min && value <= max && !isNaN(value))
|
||||
{
|
||||
this.setState({ value: value }, () =>
|
||||
|
||||
@ -1,7 +1,7 @@
|
||||
import React from "react";
|
||||
import Link from "next/link";
|
||||
import { connect } from "react-redux";
|
||||
import { getContractEvents, } from "../../../../actions";
|
||||
import { getContractEvents, getContractFines, getContractInfo, } from "../../../../actions";
|
||||
|
||||
class InnerMenu extends React.Component
|
||||
{
|
||||
@ -11,33 +11,137 @@ class InnerMenu extends React.Component
|
||||
this.menuRef = React.createRef();
|
||||
|
||||
this.state = {
|
||||
loaded: false,
|
||||
loading: true,
|
||||
menuOpened: false,
|
||||
count_events: 0,
|
||||
count_fines: 0,
|
||||
contracts_info: {},
|
||||
contract_events: {},
|
||||
contract_fines: {},
|
||||
};
|
||||
}
|
||||
|
||||
static getDerivedStateFromProps(nextProps, prevState)
|
||||
{
|
||||
return {
|
||||
contracts_info: nextProps.contracts_info,
|
||||
contract_events: nextProps.contract_events,
|
||||
contract_fines: nextProps.contract_fines,
|
||||
};
|
||||
}
|
||||
|
||||
componentDidMount()
|
||||
{
|
||||
const { number, dispatch } = this.props;
|
||||
const { contract_events } = this.state;
|
||||
console.log("Contact", "InnerMenu", "componentDidMount()");
|
||||
|
||||
if(contract_events[number] === undefined)
|
||||
const { loaded, loading, contracts_info, contract_events, contract_fines } = this.state;
|
||||
|
||||
console.log("CDM", "\n\n");
|
||||
console.log("CDM", "contracts_info", contracts_info);
|
||||
console.log("CDM", "!".repeat(10));
|
||||
console.log("CDM", "contract_events", contract_events);
|
||||
console.log("CDM", "!".repeat(10));
|
||||
console.log("CDM", "contract_fines", contract_fines);
|
||||
console.log("CDM", "!".repeat(10));
|
||||
|
||||
if(!loaded &&
|
||||
contracts_info !== undefined && Object.keys(contracts_info).length > 0 &&
|
||||
contract_events !== undefined && Object.keys(contract_events).length > 0 &&
|
||||
contract_fines !== undefined && Object.keys(contract_fines).length > 0
|
||||
) {
|
||||
this.setState({ loaded: true }, () =>
|
||||
{
|
||||
getContractEvents({ dispatch, contract: number });
|
||||
this._loadMenu();
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
componentDidUpdate(prevProps, prevState)
|
||||
{
|
||||
const { loaded, contracts_info, contract_events, contract_fines } = this.state;
|
||||
|
||||
console.log("CDU", "\n\n");
|
||||
console.log("CDU", "contracts_info", contracts_info);
|
||||
console.log("CDU", "?".repeat(10));
|
||||
console.log("CDU", "contract_events", contract_events);
|
||||
console.log("CDU", "?".repeat(10));
|
||||
console.log("CDU", "contract_fines", contract_fines);
|
||||
console.log("CDU", "?".repeat(10));
|
||||
|
||||
if(!loaded &&
|
||||
contracts_info !== undefined && Object.keys(contracts_info).length > 0 &&
|
||||
contract_events !== undefined && Object.keys(contract_events).length > 0 &&
|
||||
contract_fines !== undefined && Object.keys(contract_fines).length > 0
|
||||
) {
|
||||
this.setState({ loaded: true }, () =>
|
||||
{
|
||||
this._loadMenu();
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
_loadMenu = () =>
|
||||
{
|
||||
console.log("Contract", "InnerMenu", "_loadMenu()");
|
||||
|
||||
const { number, dispatch } = this.props;
|
||||
const { contracts_info, contract_events, contract_fines } = this.state;
|
||||
|
||||
Promise.all([
|
||||
new Promise((resolve) =>
|
||||
{
|
||||
console.log(11111);
|
||||
if(contracts_info[ number ] === undefined)
|
||||
{
|
||||
console.log(10);
|
||||
getContractInfo({ dispatch, number })
|
||||
.then(() => { console.log(11); resolve(); })
|
||||
.catch(() => { console.log(12); resolve(); });
|
||||
}
|
||||
else
|
||||
{
|
||||
console.log(13);
|
||||
resolve();
|
||||
}
|
||||
}),
|
||||
new Promise((resolve) =>
|
||||
{
|
||||
console.log(22222);
|
||||
if(contract_events[ number ] === undefined)
|
||||
{
|
||||
console.log(20);
|
||||
getContractEvents({ dispatch, contract: number })
|
||||
.then(() => { console.log(21); resolve(); })
|
||||
.catch(() => { console.log(22); resolve(); });
|
||||
}
|
||||
else
|
||||
{
|
||||
console.log(23);
|
||||
resolve();
|
||||
}
|
||||
}),
|
||||
new Promise((resolve) =>
|
||||
{
|
||||
console.log(33333);
|
||||
if(contract_fines[ number ] === undefined)
|
||||
{
|
||||
console.log(30);
|
||||
getContractFines({ dispatch, contract: number })
|
||||
.then(() => { console.log(31); resolve(); })
|
||||
.catch(() => { console.log(32); resolve(); });
|
||||
}
|
||||
else
|
||||
{
|
||||
console.log(33);
|
||||
resolve();
|
||||
}
|
||||
}),
|
||||
])
|
||||
.then(() =>
|
||||
{
|
||||
console.log("******************************");
|
||||
let l = 0;
|
||||
let m = 0;
|
||||
const menu = [ "payments", "services", "agreement", "documents", "materials", "events", "change" ];
|
||||
const menu = [ "payments", "change", "services", "agreement", "documents", "materials", "events", "fines" ];
|
||||
|
||||
for(let i in menu)
|
||||
{
|
||||
@ -47,20 +151,48 @@ class InnerMenu extends React.Component
|
||||
}
|
||||
}
|
||||
|
||||
//setTimeout(() =>
|
||||
//{
|
||||
this.setState({ loading: false }, () =>
|
||||
{
|
||||
if(this.menuRef.current !== null)
|
||||
{
|
||||
console.log("-".repeat(30));
|
||||
console.log(this.menuRef.current);
|
||||
console.log("-".repeat(30));
|
||||
|
||||
for(let i = 0; i < m; i++)
|
||||
{
|
||||
//console.log("-----", this.menuRef.current.children[i]);
|
||||
if(this.menuRef.current.children[i] !== undefined)
|
||||
{
|
||||
console.log("this.menuRef.current.children[i]", this.menuRef.current.children[i]);
|
||||
console.log(".".repeat(30));
|
||||
|
||||
l = l + this.menuRef.current.children[i].getBoundingClientRect().width;
|
||||
console.log("W", this.menuRef.current.children[i].getBoundingClientRect().width, l);
|
||||
}
|
||||
}
|
||||
|
||||
//setTimeout(() =>
|
||||
//{
|
||||
if(this.menuRef.current !== null)
|
||||
{
|
||||
this.menuRef.current.scrollLeft = l - 50;
|
||||
}
|
||||
//}, 10);
|
||||
}
|
||||
});
|
||||
//}, 50);
|
||||
});
|
||||
}
|
||||
|
||||
_handle_onToggleMenu = () =>
|
||||
{
|
||||
this.setState({
|
||||
menuOpened: !this.state.menuOpened,
|
||||
});
|
||||
};
|
||||
}
|
||||
|
||||
_getActiveLink = (route) =>
|
||||
{
|
||||
@ -74,28 +206,53 @@ class InnerMenu extends React.Component
|
||||
if (route.indexOf("/fines") > -1) return "Штрафы ГИБДД";
|
||||
|
||||
return null;
|
||||
};
|
||||
}
|
||||
|
||||
_getFinesCount = () =>
|
||||
{
|
||||
const { number, } = this.props;
|
||||
const { contract_fines } = this.state;
|
||||
let c = 0;
|
||||
|
||||
if(contract_fines[number] !== undefined && contract_fines[number] !== null)
|
||||
{
|
||||
for(let i in contract_fines[number])
|
||||
{
|
||||
if(contract_fines[number][i].status_code === "NotPaid")
|
||||
{
|
||||
c++;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return c;
|
||||
}
|
||||
|
||||
render()
|
||||
{
|
||||
const { number, status } = this.props;
|
||||
const { menuOpened, count_fines, contract_events } = this.state;
|
||||
const { loading, menuOpened, contracts_info, contract_events, contract_fines } = this.state;
|
||||
const count_events = contract_events[number] !== undefined && contract_events[number] !== null ? Object.keys(contract_events[number]).length : 0;
|
||||
const count_fines = this._getFinesCount();
|
||||
|
||||
console.log("contract_events", contract_events);
|
||||
if(!loading)
|
||||
{
|
||||
console.log("contracts_info", contracts_info);
|
||||
}
|
||||
|
||||
return (
|
||||
<aside>
|
||||
<button className="nav_toggle" onClick={ this._handle_onToggleMenu }>
|
||||
{ this.props.router && this._getActiveLink(this.props.router.asPath) }
|
||||
</button>
|
||||
{ !loading && (
|
||||
<ul className={ menuOpened ? "aside_nav open" : "aside_nav" } ref={ this.menuRef }>
|
||||
<li>
|
||||
<Link href={`/contract/${ number }/payments`} shallow>
|
||||
<a className={ this.props.router && this.props.router.asPath.indexOf("payments") > -1 ? "active" : "" }>График платежей</a>
|
||||
</Link>
|
||||
</li>
|
||||
{ status !== undefined && status !== null && [46, 36, 37, 35].indexOf(status) > -1 && (
|
||||
{ contracts_info[ number ].status !== undefined && contracts_info[ number ].status !== null && [46, 36, 37, 35].indexOf(contracts_info[ number ].status) > -1 && (
|
||||
<li>
|
||||
<Link href={`/contract/${ number }/change`} shallow>
|
||||
<a className={ this.props.router && this.props.router.asPath.indexOf("change") > -1 ? "active" : "" }>Изменить график</a>
|
||||
@ -127,12 +284,15 @@ class InnerMenu extends React.Component
|
||||
<a className={ this.props.router && this.props.router.asPath.indexOf("events") > -1 ? "active" : "" }>События по договору { count_events > 0 && (<span>{ count_events }</span>) }</a>
|
||||
</Link>
|
||||
</li>
|
||||
{ contract_fines[number] !== undefined && contract_fines[number] !== null && count_fines > 0 && (
|
||||
<li>
|
||||
<Link href={`/contract/${ number }/fines`} shallow>
|
||||
<a className={ this.props.router && this.props.router.asPath.indexOf("fines") > -1 ? "active" : "" }>Штрафы ГИБДД{ count_fines > 0 && (<span>{ count_fines }</span>) }</a>
|
||||
</Link>
|
||||
</li>
|
||||
) }
|
||||
</ul>
|
||||
) }
|
||||
</aside>
|
||||
)
|
||||
}
|
||||
@ -141,7 +301,9 @@ class InnerMenu extends React.Component
|
||||
function mapStateToProps(state, ownProps)
|
||||
{
|
||||
return {
|
||||
contract_events: state.contract_events
|
||||
contracts_info: state.contracts_info,
|
||||
contract_events: state.contract_events,
|
||||
contract_fines: state.contract_fines,
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
@ -43,6 +43,7 @@ class ContractFinesPage extends React.Component
|
||||
contracts_info: [],
|
||||
fines: null,
|
||||
all: false,
|
||||
contract_fines: {},
|
||||
};
|
||||
}
|
||||
|
||||
@ -51,27 +52,51 @@ class ContractFinesPage extends React.Component
|
||||
return {
|
||||
contracts_info: nextProps.contracts_info,
|
||||
fines: nextProps.fines,
|
||||
contract_fines: nextProps.contract_fines,
|
||||
};
|
||||
}
|
||||
|
||||
componentDidMount()
|
||||
{
|
||||
const { dispatch, number} = this.props;
|
||||
const { contracts_info, contract_fines } = this.state;
|
||||
|
||||
if(!this.state.loading && number !== undefined)
|
||||
{
|
||||
this.setState({ loading: true }, () =>
|
||||
{
|
||||
if(this.state.contracts_info[ number ] === undefined)
|
||||
Promise.all([
|
||||
( (resolve) =>
|
||||
{
|
||||
getContractInfo({ dispatch, number });
|
||||
if(contracts_info[ number ] === undefined)
|
||||
{
|
||||
getContractInfo({ dispatch, number })
|
||||
.then(() => { resolve(); })
|
||||
.catch(() => { resolve(); });
|
||||
}
|
||||
|
||||
getContractFines({ dispatch, number }).then(() =>
|
||||
else
|
||||
{
|
||||
resolve();
|
||||
}
|
||||
} ),
|
||||
( (resolve) =>
|
||||
{
|
||||
if(contract_fines[number] === undefined)
|
||||
{
|
||||
getContractFines({ dispatch, contract: number })
|
||||
.then(() => { resolve(); })
|
||||
.catch(() => { resolve(); });
|
||||
}
|
||||
else
|
||||
{
|
||||
resolve();
|
||||
}
|
||||
} )
|
||||
])
|
||||
.then(() =>
|
||||
{
|
||||
this.setState({ loading: false });
|
||||
})
|
||||
.catch(() => {});
|
||||
});
|
||||
});
|
||||
}
|
||||
}
|
||||
@ -85,11 +110,11 @@ class ContractFinesPage extends React.Component
|
||||
this.setState({ all: true });
|
||||
}
|
||||
|
||||
_renderFines = (fines) =>
|
||||
_renderFines = (contract_fines) =>
|
||||
{
|
||||
console.log("_renderFines", "fines", fines);
|
||||
|
||||
const { number } = this.props;
|
||||
const fines = contract_fines[number];
|
||||
|
||||
const { all } = this.state;
|
||||
|
||||
const status = {
|
||||
@ -103,7 +128,7 @@ class ContractFinesPage extends React.Component
|
||||
return (
|
||||
<>
|
||||
<div className="dropdown_blocks_list">
|
||||
{ fines.slice(0, all ? fines.length : 3).map((fine, fine_index) => (
|
||||
{ fines.slice(0, all ? fines.length : 10).map((fine, fine_index) => (
|
||||
<div className="dropdown_block open" key={fine_index}>
|
||||
<div className="block_body">
|
||||
<div className="fines_detail">
|
||||
@ -187,9 +212,9 @@ class ContractFinesPage extends React.Component
|
||||
onClick={ this._handle_onShowMore }
|
||||
>
|
||||
<p style={{ paddingTop: "15px", color: "#747474" }}>
|
||||
Еще {fines.length - 3}{" "}
|
||||
Еще {fines.length - 10}{" "}
|
||||
{pluralize(
|
||||
fines.length - 3,
|
||||
fines.length - 10,
|
||||
"постановлений",
|
||||
"постановление",
|
||||
"постановления",
|
||||
@ -218,13 +243,10 @@ class ContractFinesPage extends React.Component
|
||||
render()
|
||||
{
|
||||
const { number } = this.props;
|
||||
const { loading, contracts_info, fines, } = this.state;
|
||||
const { loading, contracts_info, contract_fines, } = this.state;
|
||||
|
||||
let { date, car, status } = contracts_info[ number ] !== undefined ? contracts_info[ number ] : {};
|
||||
|
||||
console.log("fines");
|
||||
console.log(fines);
|
||||
|
||||
return (
|
||||
<React.Fragment>
|
||||
<Head>
|
||||
@ -254,11 +276,11 @@ class ContractFinesPage extends React.Component
|
||||
|
||||
<div className="company">
|
||||
<p className="title lower">Штрафы ГИБДД</p>
|
||||
{fines !== undefined && fines !== null ? (
|
||||
{ contract_fines !== undefined && contract_fines !== null && contract_fines[ number ] !== undefined && contract_fines[ number ] !== null && (
|
||||
<>
|
||||
{this._renderFines(fines)}
|
||||
{ this._renderFines(contract_fines) }
|
||||
</>
|
||||
) : null}
|
||||
) }
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
@ -287,6 +309,7 @@ function mapStateToProps(state, ownProps)
|
||||
date: state.contract.date,
|
||||
car: state.contract.car,
|
||||
fines: state.contract.fines,
|
||||
contract_fines: state.contract_fines,
|
||||
};
|
||||
}
|
||||
|
||||
@ -302,19 +325,3 @@ export const getServerSideProps = reduxWrapper.getServerSideProps(
|
||||
);
|
||||
|
||||
export default withRouter(connect(mapStateToProps)(ContractFinesPage));
|
||||
|
||||
{
|
||||
/*}
|
||||
<div className="block_body">
|
||||
<div className="transaction_detail">
|
||||
<p>№ постановления: <b>3432434242334</b></p>
|
||||
<ul>
|
||||
<li>Сумма: <b>3 000,00 р.</b></li>
|
||||
<li>Дата: <b>01/01/2020</b></li>
|
||||
<li>Статус: <b className="success">Оплачен</b></li>
|
||||
<li>Штраф: п. 1.15 - Несоблюдение правил парковки </li>
|
||||
</ul>
|
||||
</div>
|
||||
</div>
|
||||
{*/
|
||||
}
|
||||
|
||||
@ -169,8 +169,12 @@ class SupportAppealsPage extends React.Component
|
||||
) }
|
||||
</div>
|
||||
<div className="item_text">
|
||||
{ ((appeal.answer !== null && appeal.answer !== "") || (appeal.documents.length > 0)) && (
|
||||
<p><b>Ответ службы клиентского сервиса</b></p>
|
||||
<p dangerouslySetInnerHTML={{ __html: appeal.answer === null || appeal.answer === "" ? "Без ответа" : appeal.answer.replace("\\n", "<br/>") }}></p>
|
||||
) }
|
||||
{ appeal.answer !== null && appeal.answer !== "" && (
|
||||
<p dangerouslySetInnerHTML={{ __html: appeal.answer.replace("\\n", "<br/>") }}></p>
|
||||
) }
|
||||
{ appeal.documents.length > 0 && (
|
||||
<div className="dosc_list medium-icon">
|
||||
{ appeal.documents.map((file, index) => {
|
||||
|
||||
28
reducers/contractFinesReducer.js
Normal file
28
reducers/contractFinesReducer.js
Normal file
@ -0,0 +1,28 @@
|
||||
import { HYDRATE } from 'next-redux-wrapper';
|
||||
|
||||
import * as actionTypes from '../constants/actionTypes';
|
||||
import initialState from "./initialState";
|
||||
|
||||
const contractFinesReducer = (state = initialState.contract_fines, action) =>
|
||||
{
|
||||
switch (action.type)
|
||||
{
|
||||
case actionTypes.CONTRACT_FINES:
|
||||
{
|
||||
return {
|
||||
...state, ...action.data,
|
||||
};
|
||||
}
|
||||
|
||||
case actionTypes.CONTRACT_FINES_RESET:
|
||||
{
|
||||
return {};
|
||||
}
|
||||
|
||||
default: {
|
||||
return state;
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
export default contractFinesReducer;
|
||||
@ -81,14 +81,6 @@ const contractReducer = (state = initialState.contract, action) =>
|
||||
};
|
||||
}
|
||||
|
||||
case actionTypes.CONTRACT_FINES:
|
||||
{
|
||||
return {
|
||||
...state,
|
||||
fines: action.data.fines,
|
||||
};
|
||||
}
|
||||
|
||||
case actionTypes.CONTRACT_RULES:
|
||||
{
|
||||
return {
|
||||
|
||||
@ -11,10 +11,6 @@ export const defaultState = {
|
||||
secondname: "",
|
||||
phone: "",
|
||||
},
|
||||
companies:
|
||||
{
|
||||
list: null,
|
||||
},
|
||||
admin:
|
||||
{
|
||||
list: null,
|
||||
@ -26,6 +22,10 @@ export const defaultState = {
|
||||
kpp: "",
|
||||
ogrn: "",
|
||||
},
|
||||
companies:
|
||||
{
|
||||
list: null,
|
||||
},
|
||||
contracts_info: {},
|
||||
contracts:
|
||||
{
|
||||
@ -65,6 +65,7 @@ export const defaultState = {
|
||||
},
|
||||
},
|
||||
contract_events: {},
|
||||
contract_fines: {},
|
||||
calendar: {
|
||||
payments: null,
|
||||
periods: null,
|
||||
|
||||
@ -13,6 +13,7 @@ import supportReducer from '../reducers/supportReducer';
|
||||
import adminReducer from '../reducers/adminReducer';
|
||||
import contractsInfoReducer from '../reducers/contractsInfoReducer';
|
||||
import contractEventsReducer from '../reducers/contractEventsReducer';
|
||||
import contractFinesReducer from '../reducers/contractFinesReducer';
|
||||
|
||||
const combinedReducer = combineReducers({
|
||||
auth: authReducer,
|
||||
@ -27,6 +28,7 @@ const combinedReducer = combineReducers({
|
||||
admin: adminReducer,
|
||||
contracts_info: contractsInfoReducer,
|
||||
contract_events: contractEventsReducer,
|
||||
contract_fines: contractFinesReducer,
|
||||
});
|
||||
|
||||
const makeStore = (context) =>
|
||||
@ -44,7 +46,7 @@ const makeStore = (context) =>
|
||||
|
||||
const persistConfig = {
|
||||
key: 'lkevoleasing',
|
||||
whitelist: [ 'auth', 'user', 'company', 'companies', 'contracts_info', 'contract_events' ],
|
||||
whitelist: [ 'auth', 'user', 'company', 'events', 'companies', 'contracts_info', 'contract_events', 'contract_fines', ],
|
||||
storage
|
||||
};
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user