Skip to content

Commit ad33103

Browse files
committed
[Fix] chart share #485
1 parent dbabe81 commit ad33103

File tree

1 file changed

+10
-3
lines changed

1 file changed

+10
-3
lines changed

src/components/molecules/ChartShare/index.tsx

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -79,6 +79,8 @@ export default class ChartShare extends React.Component<Props, State> {
7979
link: '',
8080
value: 2 // TODO: why not a boolean
8181
};
82+
private noDownloadSupport = [ 'survey_p20', 'subnational_p20' ];
83+
8284
constructor(props: Props) {
8385
super(props);
8486

@@ -174,11 +176,16 @@ export default class ChartShare extends React.Component<Props, State> {
174176
}
175177

176178
private renderDownloadButton() {
177-
if (this.props.download) {
179+
const { download, stateToShare } = this.props;
180+
if (download) {
178181
let url = '';
179-
if (this.props.stateToShare && this.props.stateToShare.indicator) {
180-
const indicator = this.props.stateToShare.indicator.split('.')[1].replace(/-/g, '_');
182+
if (stateToShare && stateToShare.indicator && this.noDownloadSupport.indexOf(stateToShare.indicator) === -1) {
183+
const indicator = stateToShare.indicator.indexOf('.') > -1
184+
? stateToShare.indicator.split('.')[1].replace(/-/g, '_')
185+
: stateToShare.indicator;
181186
url = `${getWarehouseAPILink}/single_table?indicator=${indicator}&format=csv`;
187+
} else {
188+
return null;
182189
}
183190

184191
return (

0 commit comments

Comments
 (0)