mirror of
https://github.com/mauriceboe/TREK.git
synced 2026-12-01 17:03:15 +00:00
feat(native): the TREK Cloud screens show the app and make the choice of a plan easy
The cloud screen shows real screens of the app. The plans are a choice now: one tap marks a plan, the recommended one is marked, what every plan has is said once above them, storage says how many photos it holds, and the yearly switch shows what a year saves; one button at the foot carries the chosen plan on. The claim screen names the plan with a way to change it, shows the address as it will be once it is free, ticks off the password rules while typing, says in three words where the servers are, that it can be cancelled and that there are no ads, and puts the photo behind the form away.
This commit is contained in:
@@ -0,0 +1,20 @@
|
||||
import { describe, expect, it } from 'vitest';
|
||||
import { priceValue } from './priceValue';
|
||||
|
||||
describe('priceValue', () => {
|
||||
it('reads the store price strings of the usual currencies, in hundredths', () => {
|
||||
expect(priceValue('9,99 €')).toBe(999);
|
||||
expect(priceValue('$9.99')).toBe(999);
|
||||
expect(priceValue('59,99 €')).toBe(5999);
|
||||
expect(priceValue('¥1,500')).toBe(150000);
|
||||
expect(priceValue('1.234,50 €')).toBe(123450);
|
||||
expect(priceValue('CHF 10')).toBe(1000);
|
||||
});
|
||||
|
||||
it('has no value for nothing or for a string it cannot read with confidence', () => {
|
||||
expect(priceValue(undefined)).toBeNull();
|
||||
expect(priceValue('')).toBeNull();
|
||||
expect(priceValue('free')).toBeNull();
|
||||
expect(priceValue('1.2.3')).toBeNull();
|
||||
});
|
||||
});
|
||||
@@ -0,0 +1,14 @@
|
||||
/**
|
||||
* The amount in a store price string such as "9,99 €", "$9.99" or "¥1,500", in
|
||||
* hundredths; null when it cannot be read with confidence. Only ever compared
|
||||
* with another price of the same store, never shown.
|
||||
*/
|
||||
export function priceValue(label: string | undefined): number | null {
|
||||
if (!label) return null;
|
||||
const digits = label.replace(/[^\d.,]/g, '');
|
||||
const match = /^(\d{1,3}(?:[.,]\d{3})*|\d+)(?:[.,](\d{1,2}))?$/.exec(digits);
|
||||
if (!match) return null;
|
||||
const whole = Number(match[1].replace(/[.,]/g, ''));
|
||||
const fraction = match[2] ? Number(match[2].padEnd(2, '0')) : 0;
|
||||
return Number.isFinite(whole) ? whole * 100 + fraction : null;
|
||||
}
|
||||
Reference in New Issue
Block a user