Entrega dashboard e correccoes transversais preservando Ofertas instalado
tests / ci (push) Canceled after 0s
tests / ci (push) Canceled after 0s
This commit is contained in:
@@ -0,0 +1,35 @@
|
||||
export const normaliseChoice = (value: string) =>
|
||||
value
|
||||
.normalize('NFD')
|
||||
.replace(/\p{Diacritic}/gu, '')
|
||||
.toLocaleLowerCase('pt')
|
||||
.trim();
|
||||
export function matchesChoice(query: string, labels: string[]): boolean {
|
||||
const needle = normaliseChoice(query);
|
||||
return (
|
||||
!needle ||
|
||||
labels.some((label) => normaliseChoice(label).includes(needle))
|
||||
);
|
||||
}
|
||||
/** The same ISO currency source already used by the simulator, with readable labels. */
|
||||
export function currencyChoices(codes?: readonly string[]) {
|
||||
const intl = Intl as unknown as {
|
||||
supportedValuesOf?: (key: string) => string[];
|
||||
};
|
||||
const names = new Intl.DisplayNames(['pt-MZ'], { type: 'currency' });
|
||||
return [
|
||||
...new Set(
|
||||
codes ??
|
||||
intl.supportedValuesOf?.('currency') ?? [
|
||||
'MZN',
|
||||
'USD',
|
||||
'EUR',
|
||||
'ZAR',
|
||||
],
|
||||
),
|
||||
].map((code) => ({
|
||||
value: code,
|
||||
label: `${names.of(code) ?? code} — ${code}`,
|
||||
keywords: [code, names.of(code) ?? code],
|
||||
}));
|
||||
}
|
||||
Reference in New Issue
Block a user