Skip to content

Restore and Link Client-Side Session Import/Export #122

@kirillakovalenko

Description

@kirillakovalenko

Description

This task addresses the regression where the client-side session save/load utilities (exportSession.ts, importSession.ts, and session.schema.ts originally introduced in PRs #55 and #56) were dropped from the main branch. We need to reintroduce these files and build the necessary linking layer to connect them to the current /edit page state. This will enable a versioned JSON save format (version, savedAt, and data). The linking logic must handle data transformation: exporting requires validating the form state, geocoding addresses, and mapping the UI state into an OptimizeRequest payload. Conversely, importing requires parsing the validated JSON and mapping the OptimizeRequest back into the corresponding vehicle and delivery form rows on the Edit screen.

Scope

  • Reinstating exportSession.ts, importSession.ts, and session.schema.ts.
  • Implementing the export linking logic: form state validation, geocoding vehicle start locations and delivery addresses, and mapping state to the OptimizeRequest payload via downloadSessionSave.
  • Implementing the import linking logic: validating the JSON, parsing the payload, and mapping the data back into the edit page's form state.
  • Wiring the Import and Export actions to the existing UI error-handling components.

Goal

To guarantee that Route Managers using our stateless PWA can reliably save their complex route setups locally and resume them later, ensuring data integrity through versioned, validated JSON payloads.

Acceptance Criteria

  • Clicking the "Export Session State" button successfully downloads a .json file to the user's device.
  • The downloaded file name includes a dynamic timestamp (e.g., route-save-YYYYMMDD-HHMM.json) to prevent users from accidentally overwriting previous saves.
  • The exported .json file contains a properly versioned and validated session payload, explicitly including version, savedAt, and data properties.
  • During export, the application successfully geocodes vehicle locations/delivery addresses and maps them into the OptimizeRequest structure.
  • Clicking "Import Session" and uploading a valid save file correctly parses the OptimizeRequest payload and perfectly repopulates the vehicles and deliveries into the edit page form rows.
  • Any import or export failures (e.g., uploading an invalid schema or failing to geocode) are gracefully surfaced to the user through the application's existing error UI.

Assignee @hir-al-14

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't workingfront-endWork focuses on creating front-end code

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions