Skip to content

implement delete mapping endpoint and optimistic update mappings list#135

Merged
tarekio merged 5 commits intobynt-1391-delete-mapping-endpointfrom
BYNT-1392-implement-delete-mapping
Jul 18, 2025
Merged

implement delete mapping endpoint and optimistic update mappings list#135
tarekio merged 5 commits intobynt-1391-delete-mapping-endpointfrom
BYNT-1392-implement-delete-mapping

Conversation

@apodacaduron
Copy link
Contributor

@apodacaduron apodacaduron commented Jul 15, 2025

Jira Issue

  1. BYNT-1392

Description

implement delete endpoint on sheet mappings

Checklist

  • Tests added/updated
  • Documentation updated (if needed)
  • New strings prepared for translations

API Changes (if applicable)

  • Permissions checked
  • Endpoint tests added

Additional Notes

[Any other relevant information]

@apodacaduron apodacaduron requested a review from tarekio July 15, 2025 17:11
@apodacaduron apodacaduron self-assigned this Jul 15, 2025
@tarekio tarekio requested a review from level09 July 17, 2025 21:55
this.resetFields();
this.selectedMap = null;
this.mapid = null
}).catch(err => {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is nice, but with optimistic UI approach, we have to roll back if we encounter a backend error , maybe something like

deleteMap() {
    if (!confirm("{{ _('Are you sure you want to delete this mapping?')}}")) return;
    
    const originalMaps = [...this.maps]; // Backup
    const mapIndex = this.maps.findIndex(map => map.id === this.mapid);
    
    // Optimistic update
    this.maps = this.maps.filter(map => map.id !== this.mapid);
    this.resetFields();
    
    axios.delete(`/import/api/mapping/${this.mapid}`)
    .then(res => {
        this.showSnack(res.data);
    }).catch(err => {
        // Revert on error
        this.maps = originalMaps;
        this.showSnack('Delete failed');
        console.log(err.response);
    });
}

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Updated

@apodacaduron apodacaduron requested a review from level09 July 18, 2025 15:07
@tarekio tarekio merged commit d26f00e into bynt-1391-delete-mapping-endpoint Jul 18, 2025
2 of 3 checks passed
@tarekio tarekio deleted the BYNT-1392-implement-delete-mapping branch July 18, 2025 18:46
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants