Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
/*
* 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