shlink-web-client/src/short-urls/ShortUrlVisits.js

33 lines
1,020 B
JavaScript
Raw Normal View History

2018-07-29 19:39:00 +03:00
import React from 'react';
import { connect } from 'react-redux';
2018-07-29 20:25:22 +03:00
import { pick } from 'ramda';
import { getShortUrlVisits } from './reducers/shortUrlVisits';
2018-07-29 19:39:00 +03:00
export class ShortUrlsVisits extends React.Component {
2018-07-29 20:25:22 +03:00
componentDidMount() {
2018-07-29 19:39:00 +03:00
const { match: { params } } = this.props;
2018-07-29 20:25:22 +03:00
this.props.getShortUrlVisits(params.shortCode);
}
render() {
const { match: { params }, selectedServer } = this.props;
const serverUrl = selectedServer ? selectedServer.url : '';
const shortUrl = `${serverUrl}/${params.shortCode}`;
return (
<div className="short-urls-container">
<div className="card bg-light">
<div className="card-body">
<h2>Visit stats for <a target="_blank" href={shortUrl}>{shortUrl}</a></h2>
{/* TODO Once Shlink's API allows it, add total visits counter, long URL and creation time */}
</div>
</div>
</div>
);
2018-07-29 19:39:00 +03:00
}
}
2018-07-29 20:25:22 +03:00
export default connect(pick(['selectedServer']), {
getShortUrlVisits
})(ShortUrlsVisits);