Change currency config to required
It'll default to `$` and `en-US` when the config is generated through the `nodecg defaultconfig` command
This commit is contained in:
parent
4d521b4e12
commit
a422777f71
@ -109,13 +109,18 @@
|
||||
"type": "string",
|
||||
"default": "en-US"
|
||||
}
|
||||
}
|
||||
},
|
||||
"required": [
|
||||
"symbol",
|
||||
"countryCode"
|
||||
]
|
||||
}
|
||||
},
|
||||
"required": [
|
||||
"shorts",
|
||||
"thisEvent",
|
||||
"online"
|
||||
"online",
|
||||
"currency"
|
||||
]
|
||||
},
|
||||
"omnibar": {
|
||||
|
@ -36,10 +36,8 @@ export function msToTimeStr(ms: number): string {
|
||||
/**
|
||||
* Simple formatter for displaying currency amounts.
|
||||
* @param amount Amount as a integer/float.
|
||||
* @param _symbol The currency symbol
|
||||
* (defaults to what's set in the config, or `$` if the config isn't set)
|
||||
* @param _countryCode The country code
|
||||
* (defaults to what's set in the config, or `en-US` if the config isn't set)
|
||||
* @param _symbol The currency symbol (defaults to what's set in the config)
|
||||
* @param _countryCode The country code (defaults to what's set in the config)
|
||||
*/
|
||||
export function formatCurrency(
|
||||
amount: number,
|
||||
@ -47,8 +45,8 @@ export function formatCurrency(
|
||||
_countryCode?: string,
|
||||
): string {
|
||||
const cfg = (config as DeepWritable<Configschema>).event.currency;
|
||||
const symbol = _symbol || cfg?.symbol || '$';
|
||||
const countryCode = _countryCode || cfg?.countryCode || 'en-US';
|
||||
const symbol = _symbol || cfg.symbol;
|
||||
const countryCode = _countryCode || cfg.countryCode;
|
||||
|
||||
if (amount >= 100) {
|
||||
return `${symbol}${Math.floor(amount).toLocaleString(
|
||||
|
@ -155,8 +155,8 @@ export default class extends Vue {
|
||||
|
||||
get totalStr(): string {
|
||||
// "Reset" value every 10k, specific to ESA Legends 2023.
|
||||
const symbol = nodecg.bundleConfig.event.currency?.symbol || '$';
|
||||
const countryCode = nodecg.bundleConfig.event.currency?.countryCode || 'en-US';
|
||||
const symbol = nodecg.bundleConfig.event.currency.symbol;
|
||||
const countryCode = nodecg.bundleConfig.event.currency.countryCode;
|
||||
|
||||
const esal23 = nodecg.bundleConfig.event.shorts === 'esal23';
|
||||
|
||||
|
6
src/types/schemas/configschema.d.ts
vendored
6
src/types/schemas/configschema.d.ts
vendored
@ -13,9 +13,9 @@ export interface Configschema {
|
||||
thisEvent: number;
|
||||
online: boolean | ("partial" | "full");
|
||||
fallbackTwitchTitle?: string;
|
||||
currency?: {
|
||||
symbol?: string;
|
||||
countryCode?: string;
|
||||
currency: {
|
||||
symbol: string;
|
||||
countryCode: string;
|
||||
};
|
||||
};
|
||||
omnibar: {
|
||||
|
Loading…
Reference in New Issue
Block a user