Skip to content

A one-of-a-kind resume builder that keeps your privacy in mind. Completely secure, customizable, portable, open-source and free forever. Try it out today!

fix: accept locale percent signs in offer entry

Amruth Pillai794e749f18fa
diff --git a/apps/mobile/scripts/experience.test.mjs b/apps/mobile/scripts/experience.test.mjs
index 3c0b54217..b3104213e 100644
--- a/apps/mobile/scripts/experience.test.mjs
+++ b/apps/mobile/scripts/experience.test.mjs
@@ -1349,6 +1349,7 @@ const offerParser = load("../../../packages/schema/src/career-offer.ts", {
"@reactive-resume/utils/timezone": timeParser,
});
let offerScope = "offer-account";
+let offerLocale = "en-US";
let offerProfile = { isSuccess: false, isPending: true, isError: false };
let savedOffers = [
{ createdAt: "2026-09-01T00:00:00Z", data: { kind: "offer", currency: "USD" } },
@@ -1397,7 +1398,7 @@ const loadOfferEntry = () =>
"@reactive-resume/schema/career": careerSchema,
"@reactive-resume/schema/career-offer": offerParser,
"./hooks": {
- useCareerTime: () => ({ locale: "en-US", timeZone: "Europe/Berlin", profile: offerProfile }),
+ useCareerTime: () => ({ locale: offerLocale, timeZone: "Europe/Berlin", profile: offerProfile }),
useCareerAction: () => ({
pending: false,
run: async (work, success) => {
@@ -1607,6 +1608,15 @@ control(correctedView(), "Save offer").onPress();
await settle();
assert.equal(calls.length, 0, "retired native offer form cannot write for the next account");
offerScope = "offer-account";
+offerLocale = "ar-SA";
+reset();
+calls.length = 0;
+control(correctedView(), "Bonus").onChangeText("١٢٫٥٪\u061c");
+control(correctedView(), "Save offer").onPress();
+await settle();
+assert.equal(calls[0].terms.variablePercent, 12.5, "native localized percent signs reach the shared version contract");
+assert.equal(calls[0].terms.variable, null);
+offerLocale = "en-US";
searchParams = {};
console.log("PASS native percentage entry and immutable offer-version action");
diff --git a/packages/schema/src/career-offer.test.ts b/packages/schema/src/career-offer.test.ts
index 8281f67ff..9ae4d9746 100644
--- a/packages/schema/src/career-offer.test.ts
+++ b/packages/schema/src/career-offer.test.ts
@@ -26,6 +26,10 @@ describe("manual offer entry", () => {
["en-US", "10%", 10],
["de-DE", "12,5 %", 12.5],
["en-US", "0%", 0],
+ ["ar-SA", "١٢٫٥٪", 12.5],
+ ["ar-SA", "\u200f١٢٫٥٪\u061c", 12.5],
+ ["ar-SA", "١٢٫٥%", 12.5],
+ ["fa-IR", "۱۲٫۵٪", 12.5],
] as const) {
const input = entry();
input.amounts.variable = value;
@@ -34,7 +38,7 @@ describe("manual offer entry", () => {
if (!result.payload.success) throw result.payload.error;
expect(result.payload.data).toMatchObject({ variable: null, variablePercent: percent });
}
- for (const value of ["%", "10%%", "-1%", "Infinity%", "10% extra"]) {
+ for (const value of ["%", "10%%", "-1%", "Infinity%", "10% extra", "٪", "10٪%", "10%٪"]) {
const input = entry();
input.amounts.variable = value;
expect(parseOfferEntry(input).payload.success, value).toBe(false);
diff --git a/packages/schema/src/career-offer.ts b/packages/schema/src/career-offer.ts
index 83dee6262..a9c6171a6 100644
--- a/packages/schema/src/career-offer.ts
+++ b/packages/schema/src/career-offer.ts
@@ -17,10 +17,15 @@ type OfferEntry = {
/** Blank optional fields are unknown; invalid entered values must not reach schema defaults. */
export function parseOfferEntry({ applicationId, terms, amounts, date, time, locale, timeZone }: OfferEntry) {
const base = parseAmount(amounts.base, locale);
- const percentage = amounts.variable.trim().endsWith("%");
+ const bonus = amounts.variable.trim().replace(/[\u061c\u200e\u200f]/g, "");
+ const percentSign =
+ new Intl.NumberFormat(locale, { style: "percent" }).formatToParts(1).find((part) => part.type === "percentSign")
+ ?.value ?? "%";
+ const suffix = bonus.endsWith("%") ? "%" : percentSign;
+ const percentage = bonus.endsWith(suffix);
const variable = percentage
- ? parseDecimal(amounts.variable.trim().slice(0, -1).trim(), locale)
- : parseAmount(amounts.variable, locale);
+ ? parseDecimal(bonus.slice(0, -suffix.length).trim(), locale)
+ : parseAmount(bonus, locale);
const invalidVariable = variable === undefined || (percentage && variable === null);
const learning = parseAmount(amounts.learning, locale);
const deadline = date && timeZone ? fromZonedDateTime(date, time, timeZone) : null;
diff --git a/tests/e2e/specs/career-offer-accelerators.spec.ts b/tests/e2e/specs/career-offer-accelerators.spec.ts
index 0c099dcff..c024d07f2 100644
--- a/tests/e2e/specs/career-offer-accelerators.spec.ts
+++ b/tests/e2e/specs/career-offer-accelerators.spec.ts
@@ -140,6 +140,29 @@ test("percentage bonus persists as a percentage and reopens without becoming an
await expect(page.getByLabel("Bonus", { exact: true })).toHaveValue("10%");
});
+test("Arabic bonus entry saves its locale percent sign and keeps percentage on reload", async ({ authPage: page }) => {
+ const original = await offer(page, await application(page, "Northwind Labs"));
+ await page.goto(`/dashboard/career/offers?a=${original.id}&locale=ar-SA`);
+ await expect(page.locator("html")).toHaveAttribute("lang", "ar-SA");
+ await page.getByRole("button", { name: /Northwind Labs/ }).click();
+ await page.getByRole("menuitem", { name: "Edit terms", exact: true }).click();
+ await page.getByLabel("المكافأة", { exact: true }).fill("١٢٫٥٪\u061c");
+ await page.getByRole("button", { name: "حفظ العرض الوظيفي", exact: true }).click();
+ await expect
+ .poll(async () => (await offers(page)).find((row) => row.id !== original.id)?.data)
+ .toMatchObject({ variable: null, variablePercent: 12.5 });
+ const saved = (await offers(page)).find((row) => row.id !== original.id);
+ if (!saved) throw new Error("Expected one localized offer version.");
+ await page.reload();
+ await expect(page).toHaveURL(new RegExp(`a=${saved.id}`));
+ await page
+ .getByRole("button", { name: /Northwind Labs/ })
+ .first()
+ .click();
+ await page.getByRole("menuitem", { name: "Edit terms", exact: true }).click();
+ await expect(page.getByLabel("المكافأة", { exact: true })).toHaveValue("١٢٫٥%");
+});
+
test("different pay periods show bounded arithmetic without a money judgement", async ({ authPage: page }) => {
const monthly = await offer(page, await application(page, "Lumen Health"), 7000, "month");
const yearly = await offer(page, await application(page, "Canopy Systems"), 90000);