Refresh HiveGrid Cloud reference snapshot
This commit is contained in:
1 parent
5e99e14772
commit
7f88026f79
5955 files changed
+1177325
-188362
No files matched your search
+33
@@ -0,0 +1,33 @@
|
||||
import type { LoaderFunctionArgs } from "react-router";
|
||||
|
||||
import { loadRegistrationPlanSelection } from "~/services/billing/registration-plan-selection.server";
|
||||
|
||||
const invalidQuantityResponse = () => Response.json({ errorKey: "account.register.recommendationErrorBody" }, { status: 400 });
|
||||
|
||||
function readSeatQuantity(searchParams: URLSearchParams, key: string, minimum: number): number {
|
||||
const raw = searchParams.get(key)?.trim() ?? "";
|
||||
if (!/^\d{1,5}$/u.test(raw)) throw invalidQuantityResponse();
|
||||
const value = Number(raw);
|
||||
if (!Number.isSafeInteger(value) || value < minimum || value > 10_000) {
|
||||
throw invalidQuantityResponse();
|
||||
}
|
||||
return value;
|
||||
}
|
||||
|
||||
export const loader = async ({ request }: LoaderFunctionArgs) => {
|
||||
const url = new URL(request.url);
|
||||
const officeSeatQuantity = readSeatQuantity(url.searchParams, "office", 1);
|
||||
const fieldSeatQuantity = readSeatQuantity(url.searchParams, "field", 0);
|
||||
try {
|
||||
const selection = await loadRegistrationPlanSelection(null, { officeSeatQuantity, fieldSeatQuantity });
|
||||
return Response.json(selection, {
|
||||
headers: {
|
||||
"Cache-Control": "private, no-store",
|
||||
"X-Content-Type-Options": "nosniff",
|
||||
},
|
||||
});
|
||||
} catch (error) {
|
||||
if (error instanceof RangeError) throw invalidQuantityResponse();
|
||||
throw error;
|
||||
}
|
||||
};
|
||||
Reference in new issue
Block a user