From 6f15f20033e513ce717197772d5d7787ca5d22e0 Mon Sep 17 00:00:00 2001 From: smarcet Date: Wed, 3 Jan 2024 15:15:17 -0300 Subject: [PATCH] feat: add unassign button on ticket --- src/components/forms/ticket-form.js | 27 +++++++++++++++++++++++++++ src/i18n/en.json | 3 +++ src/pages/orders/edit-ticket-page.js | 4 +++- 3 files changed, 33 insertions(+), 1 deletion(-) diff --git a/src/components/forms/ticket-form.js b/src/components/forms/ticket-form.js index beee68891..1754d8b50 100644 --- a/src/components/forms/ticket-form.js +++ b/src/components/forms/ticket-form.js @@ -17,6 +17,7 @@ import 'awesome-bootstrap-checkbox/awesome-bootstrap-checkbox.css' import { Input, TicketTypesInput } from 'openstack-uicore-foundation/lib/components' import OwnerInput from "../inputs/owner-input"; import {isEmpty, scrollToError, shallowEqual} from "../../utils/methods"; +import Swal from "sweetalert2"; class TicketForm extends React.Component { constructor(props) { @@ -36,6 +37,7 @@ class TicketForm extends React.Component { this.handleReassign = this.handleReassign.bind(this); this.handleAssign = this.handleAssign.bind(this); this.handleUpdateTicket = this.handleUpdateTicket.bind(this); + this.handleUnassign = this.handleUnassign.bind(this); } componentDidUpdate(prevProps, prevState, snapshot) { @@ -88,6 +90,26 @@ class TicketForm extends React.Component { this.setState({canReassign: true}); } + handleUnassign(ev) { + ev.preventDefault(); + const {entity} = this.state; + let {owner: prevOwner} = this.props.entity; + let {onUnAssign} = this.props; + Swal.fire({ + title: T.translate("general.are_you_sure"), + text: T.translate("edit_ticket.unassign_warning"), + type: "warning", + showCancelButton: true, + confirmButtonColor: "#DD6B55", + confirmButtonText:T.translate("edit_ticket.unassign_yes") + }).then(function(result){ + if (result.value) { + onUnAssign(prevOwner.id, entity.id).then(()=> window.location.reload()); + } + }); + + } + handleAssign(ev) { const {entity, canReassign} = this.state; let {owner: prevOwner} = this.props.entity; @@ -165,6 +187,11 @@ class TicketForm extends React.Component { {T.translate("edit_ticket.reassign")} } + { entity.is_active && + + } } diff --git a/src/i18n/en.json b/src/i18n/en.json index d30893f2b..e1b710f12 100644 --- a/src/i18n/en.json +++ b/src/i18n/en.json @@ -1570,6 +1570,7 @@ "activate": "Reactivate", "deactivate_warning": "Are you sure you want to Deactivate this Ticket?", "activate_warning": "Are you sure you want to Reactivate this Ticket?", + "unassign_warning": "Are you sure you want to Unassign this Ticket?", "refund": "Refund", "refund_modal_title": "Refund Ticket", "refund_request_status": "Status", @@ -1584,10 +1585,12 @@ "paid_amount_adjusted": "Amount Paid Adjusted", "activate_yes": "Yes, reactivate", "deactivate_yes": "Yes, deactivate", + "unassign_yes": "Yes, Unassign", "print_date": "Print Date", "no_prints": "No badge prints found for current search criteria.", "apply_filters": "Apply Filters", "admin_notes": "Notes", + "unassign": "Unassign", "placeholders": { "refund_notes": "Provide Optional Notes", "refund_reject_notes": "Provide Optional Notes", diff --git a/src/pages/orders/edit-ticket-page.js b/src/pages/orders/edit-ticket-page.js index eb622a796..fb73136fa 100644 --- a/src/pages/orders/edit-ticket-page.js +++ b/src/pages/orders/edit-ticket-page.js @@ -32,6 +32,7 @@ import {Table, Panel} from "openstack-uicore-foundation/lib/components"; import moment from "moment-timezone"; import AuditLogs from "../../components/audit-logs"; import Notes from "../../components/notes"; +import {deleteTicket} from "../../actions/attendee-actions"; class EditTicketPage extends React.Component { @@ -298,9 +299,9 @@ class EditTicketPage extends React.Component { errors={errors} onReassing={this.props.reassignTicket} onSaveTicket={this.props.saveTicket} + onUnAssign={this.props.deleteTicket} /> - { entity?.refund_requests?.length > 0 &&