137 lines
3.7 KiB
JavaScript
137 lines
3.7 KiB
JavaScript
// IMPORT MODULES
|
|
import React from "react";
|
|
import { Link } from "react-router-dom";
|
|
import i18n from '../i18n';
|
|
import { withTranslation } from 'react-i18next';
|
|
|
|
// IMPORT COMPONENTS
|
|
import Breadcrumb from "../components/Global/Breadcrumb";
|
|
|
|
// const CalibrateInstruments = () => {
|
|
// useEffect(() => {
|
|
// window.scrollTo(0, 0);
|
|
// }, []);
|
|
|
|
class CalibrateInstruments extends React.Component {
|
|
|
|
constructor(props) {
|
|
super(props);
|
|
|
|
this.state = {
|
|
items: [],
|
|
DataisLoaded: false,
|
|
error: null
|
|
};
|
|
}
|
|
|
|
componentDidMount() {
|
|
this._mounted = true
|
|
this.makeRemoteRequest();
|
|
}
|
|
|
|
|
|
|
|
componentWillUnmount() {
|
|
this._mounted = false
|
|
}
|
|
|
|
makeRemoteRequest = () => {
|
|
|
|
const url = `https://etalon.gov.tm:8080/api/v1/categories/8 + ?pgn=50`;
|
|
|
|
if (this._mounted) {
|
|
this.setState({ DataisLoaded: true });
|
|
}
|
|
setTimeout(() => {
|
|
|
|
fetch(url, {
|
|
method: 'GET',
|
|
|
|
})
|
|
|
|
.then(res => res.json())
|
|
.then(res => {
|
|
if (this._mounted) {
|
|
this.setState({
|
|
items: res.data[0].data,
|
|
error: res.message || null,
|
|
DataisLoaded: true,
|
|
})
|
|
// console.log(res.data)
|
|
}
|
|
|
|
})
|
|
.catch(error => {
|
|
if (this._mounted) {
|
|
this.setState({ error, DataisLoaded: false});
|
|
}
|
|
});
|
|
}, 1500);
|
|
};
|
|
|
|
render() {
|
|
const { t } = this.props;
|
|
|
|
|
|
// const [pageIndex, setPageIndex] = useState(1);
|
|
|
|
var {DataisLoaded, items} = this.state;
|
|
if(!DataisLoaded){
|
|
return <div>Loading ....</div>
|
|
}else{
|
|
|
|
|
|
return (
|
|
<section className="calibrate-inst">
|
|
<Breadcrumb
|
|
path_1={t('Стоимость')}
|
|
// path_2="Тарифы на проведение проверки или калибровки средств измерений"
|
|
link_1="/prices"
|
|
currentUrl="/prices/calibrate_instruments"
|
|
/>
|
|
<div className="container">
|
|
<div className="calibrate-inst-inner">
|
|
<div className="tab-header">
|
|
<h4 className="tab-header-text" id="tab-header-text">
|
|
Тарифы на проведение проверки или калибровки средств измерений
|
|
</h4>
|
|
<div className="tab-header-line"></div>
|
|
</div>
|
|
<div className="plans-content">
|
|
<div className="plans-card-wrapper">
|
|
|
|
{items.map(item=>(
|
|
|
|
<Link to={`/prices/meteorology/${item.slug}`} className="planscard" key={item.id}>
|
|
<h4>{(() => {
|
|
if(i18n.language === 'en') {
|
|
return (
|
|
JSON.parse(item['translations'][0]['attribute_data']).title
|
|
)
|
|
} else if (i18n.language === 'ru') {
|
|
return (
|
|
item.title
|
|
)
|
|
} else {
|
|
return (
|
|
JSON.parse(item['translations'][1]['attribute_data']).title
|
|
)
|
|
}
|
|
})()
|
|
}</h4>
|
|
</Link>
|
|
|
|
))}
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</section>
|
|
);
|
|
}
|
|
}
|
|
};
|
|
|
|
// export default CalibrateInstruments;
|
|
export default withTranslation()(CalibrateInstruments);
|