Created
March 1, 2018 03:05
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
* Copyright (C) 2018 Shamroy Pellew | |
* | |
* This file is part of MusicBrainz, the open internet music database, | |
* and is licensed under the GPL version 2, or (at your option) any | |
* later version: http://www.gnu.org/licenses/gpl-2.0.txt | |
*/ | |
const React = require('react'); | |
exports.formatPercentage = (n) => { | |
return n.toLocaleString($c.stash.current_language, | |
{maximumFractionDigits: 2, minimumFractionDigits: 2, style: 'percent'}); | |
}; | |
exports.formatCount = (n) => { | |
return n.toLocaleString($c.stash.current_language); | |
}; | |
exports.LinkSearchableProperty = ({ | |
searchField, | |
searchValue, | |
entityType, | |
text, | |
}) => { | |
const params = {limit: 25, method: 'advanced', query: searchField + ':"' + searchValue + '"', type: entityType}; | |
return ( | |
<a href={'/search?' + encodeURIComponent(Object.keys(params).map(key => key + '=' + params[key]).join('&'))}> | |
{text ? text : searchValue} | |
</a> | |
); | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment