Add persistent onion key backup and restore, improve startup resilience, and flesh out the major site verticals with richer navigation, search coverage, and operator documentation. Made-with: Cursor
60 lines
1.6 KiB
TypeScript
60 lines
1.6 KiB
TypeScript
/**
|
|
* Client-side vendor intake queue (no remote submission endpoint in this build).
|
|
*/
|
|
|
|
const KEY_QUEUE = "cyberlux-vendor-applications-v1";
|
|
|
|
export type VendorApplication = {
|
|
id: string;
|
|
ts: number;
|
|
/** Signed-in account handle if any */
|
|
accountUsername: string | null;
|
|
desiredHandle: string;
|
|
stallName: string;
|
|
specialtyCategory: string;
|
|
pitch: string;
|
|
pgpFingerprint: string;
|
|
deadDropNotes: string;
|
|
acceptedSimulatorTerms: boolean;
|
|
};
|
|
|
|
function uid(): string {
|
|
if (typeof crypto !== "undefined" && "randomUUID" in crypto) return crypto.randomUUID();
|
|
return `va_${Date.now()}_${Math.random().toString(36).slice(2, 10)}`;
|
|
}
|
|
|
|
export function loadVendorApplications(): VendorApplication[] {
|
|
if (typeof window === "undefined") return [];
|
|
try {
|
|
const raw = localStorage.getItem(KEY_QUEUE);
|
|
if (!raw) return [];
|
|
const v = JSON.parse(raw) as unknown;
|
|
if (!Array.isArray(v)) return [];
|
|
return v.filter(
|
|
(x): x is VendorApplication =>
|
|
x &&
|
|
typeof x === "object" &&
|
|
typeof (x as VendorApplication).id === "string" &&
|
|
typeof (x as VendorApplication).desiredHandle === "string",
|
|
);
|
|
} catch {
|
|
return [];
|
|
}
|
|
}
|
|
|
|
export function appendVendorApplication(entry: Omit<VendorApplication, "id" | "ts">): VendorApplication {
|
|
const row: VendorApplication = {
|
|
...entry,
|
|
id: uid(),
|
|
ts: Date.now(),
|
|
};
|
|
if (typeof window === "undefined") return row;
|
|
const next = [row, ...loadVendorApplications()].slice(0, 50);
|
|
localStorage.setItem(KEY_QUEUE, JSON.stringify(next));
|
|
return row;
|
|
}
|
|
|
|
export function countVendorApplications(): number {
|
|
return loadVendorApplications().length;
|
|
}
|