Skip to content

Commit

Permalink
feat: add unassign button on ticket
Browse files Browse the repository at this point in the history
  • Loading branch information
smarcet committed Jan 3, 2024
1 parent 062b2b1 commit 6f15f20
Show file tree
Hide file tree
Showing 3 changed files with 33 additions and 1 deletion.
27 changes: 27 additions & 0 deletions src/components/forms/ticket-form.js
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand All @@ -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) {
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -165,6 +187,11 @@ class TicketForm extends React.Component {
{T.translate("edit_ticket.reassign")}
</button>
}
{ entity.is_active &&
<button onClick={this.handleUnassign} className="btn btn-sm left-space btn-danger">
{T.translate("edit_ticket.unassign")}
</button>
}
</div>
</div>
}
Expand Down
3 changes: 3 additions & 0 deletions src/i18n/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand All @@ -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",
Expand Down
4 changes: 3 additions & 1 deletion src/pages/orders/edit-ticket-page.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 {

Expand Down Expand Up @@ -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 &&

<Panel
Expand Down Expand Up @@ -463,5 +464,6 @@ export default connect (
refundTicket,
cancelRefundTicket,
getTicketTypes,
deleteTicket,
}
)(EditTicketPage);

0 comments on commit 6f15f20

Please sign in to comment.