Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Link Creation Feature – Client Side Refactoring #218

Open
mahid797 opened this issue Feb 23, 2025 · 0 comments
Open

Link Creation Feature – Client Side Refactoring #218

mahid797 opened this issue Feb 23, 2025 · 0 comments
Assignees
Labels
Core Work to do on the core system of the App Frontend Frontend Related Issue ⚡Important High-impact issue that needs to be resolved before the next release New Feature New feature to be implemented Refactor Code Improvement
Milestone

Comments

@mahid797
Copy link
Collaborator

mahid797 commented Feb 23, 2025

Refactor the client-side Link Creation flow to align with the server’s new JSON-based visitorFields approach, remove any numeric toggles for visitor data, and introduce typed models for requests/responses. This includes fully revamping the “CreateLink” modal UI, dynamic checkboxes via a shared config, a robust useCreateLink hook, and a functional “SendingAccordion” for selecting / emailing recipients.

Overview

  1. Removal of Numeric Toggles

    • Instead of requiredUserDetailsOption=1|2, we adopt checkbox-based selection for fields like “Name,” “Email,” etc.
  2. Shared Config for Fields

    • The front end references visitorFieldsConfig.ts (in src/shared/config/) to dynamically render which fields are available, storing only minimal keys (e.g., ["name","email"]) in visitorFields for the server.
  3. Typed Models

    • Use typed interfaces or types for request/response objects. For example:

      interface CreateDocumentLinkPayload {
      	alias: string;
      	isPublic: boolean;
      	password?: string;
      	expirationTime?: string; // ISO date
      	visitorFields: string[]; // e.g. ["name","email"]
      }
      
      interface DocumentLinkResponse {
      	message: string;
      	link: {
      		linkUrl: string;
      		alias: string;
      		// ...
      	};
      }
    • This ensures consistent usage of typed data throughout the codebase.

  4. useCreateLink Hook

    • Consolidate the POST /api/documents/[documentId]/links call into a single custom hook,providing typed parameters and responses.
  5. SendingAccordion

    • Refactor to allow real or placeholder contact selection, manual email entry, and a final “Send” call to a placeholder endpoint (/api/documents/[documentId]/links/email).
  6. ShareableLinkDialog

    • Strictly for displaying the newly created link and allowing copy/paste.

Sub-Issues

  1. Overhaul CreateLink Modal with Typed Models & Dynamic Checkboxes #225
  2. Introduce or Update useCreateLink Hook #226
  3. Refactor SendingAccordion with Contact Selection & Email Placeholder #227

Conclusion

With these sub-issues completed, the Link Creation Flow becomes:

  1. CreateLink for typed form data, dynamic checkboxes from a shared config, typed hooking into the server, and alias/password/expiration logic.
  2. SendingAccordion for real or placeholder emailing flows.
  3. ShareableLinkDialog purely for showing the final link.

All code should be typed and consistent, fulfilling the server-side schema changes and ensuring a more professional, DRY solution.

References

Note:
Please read the Server-Side issues as well to ensure the final link creation code lines up with the updated DocumentLink schema and visitorFields JSON approach.

@mahid797 mahid797 added Core Work to do on the core system of the App Frontend Frontend Related Issue New Feature New feature to be implemented Refactor Code Improvement ⚡Important High-impact issue that needs to be resolved before the next release labels Feb 23, 2025
@mahid797 mahid797 added this to the v0.1 milestone Feb 23, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Core Work to do on the core system of the App Frontend Frontend Related Issue ⚡Important High-impact issue that needs to be resolved before the next release New Feature New feature to be implemented Refactor Code Improvement
Projects
None yet
Development

No branches or pull requests

2 participants