Files
Cursor Agentandmarcftone 5e7ff9fa29 feat: show uploaded documents immediately with processing state
- Add PendingUploadsContext for managing optimistic uploads
- Create PendingDocumentCard component to show uploading/processing documents
- Update upload API to return document data for optimistic display
- Update ViewerUploadComponent to track pending uploads
- Update DataroomViewer to display pending uploads at top of list
- Update DocumentUploadModal with success feedback and auto-close
- Add 'pending' prefix to id-helper for generating pending upload IDs

This ensures external visitors see their uploaded documents immediately
after upload, with a clear 'Processing...' indicator while the document
is being processed on the backend.

Fixes PM-468

Co-authored-by: marcftone <marcftone@gmail.com>
2026-01-21 10:33:38 +00:00

53 lines
1.2 KiB
TypeScript

import baseX from "base-x";
function encodeBase58(buf: Buffer): string {
const alphabet = "123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz";
return baseX(alphabet).encode(buf);
}
/**
* Generate ids similar to stripe
*/
export class IdGenerator<TPrefixes extends string> {
private prefixes: Record<TPrefixes, string>;
/**
* Create a new id generator with fully typed prefixes
* @param prefixes - Relevant prefixes for your domain
*/
constructor(prefixes: Record<TPrefixes, string>) {
this.prefixes = prefixes;
}
/**
* Generate a new unique base58 encoded uuid with a defined prefix
*
* @returns xxxxxx_xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
*/
public id = (prefix: TPrefixes): string => {
return [
this.prefixes[prefix],
encodeBase58(Buffer.from(crypto.randomUUID().replace(/-/g, ""), "hex")),
].join("_");
};
}
export const newId = new IdGenerator({
view: "view",
videoView: "vview",
linkView: "lview",
inv: "inv", // invitation
email: "email",
doc: "doc",
page: "page",
dataroom: "dr",
preview: "preview",
webhook: "wh",
webhookEvent: "evt",
webhookSecret: "whsec",
token: "pmk",
clickEvent: "click",
preset: "preset",
pending: "pending", // for pending uploads
}).id;