2021-10-13 18:46:43 +03:00
|
|
|
import Component from '@glimmer/component';
|
|
|
|
import {inject as service} from '@ember/service';
|
2022-02-09 13:49:38 +03:00
|
|
|
import {task} from 'ember-concurrency';
|
2021-10-13 18:46:43 +03:00
|
|
|
|
|
|
|
export default class ArchiveOfferModalComponent extends Component {
|
|
|
|
@service notifications;
|
|
|
|
@service router;
|
|
|
|
|
|
|
|
get isActive() {
|
|
|
|
const {offer} = this.args.data;
|
|
|
|
return offer.status === 'active';
|
|
|
|
}
|
|
|
|
|
|
|
|
@task({drop: true})
|
|
|
|
*unarchiveOfferTask() {
|
|
|
|
const {offer} = this.args.data;
|
|
|
|
offer.status = 'active';
|
|
|
|
|
|
|
|
try {
|
|
|
|
yield offer.save();
|
2021-10-22 17:19:58 +03:00
|
|
|
this.router.transitionTo('offers', {queryParams: {
|
|
|
|
type: 'active'
|
|
|
|
}});
|
2021-10-13 18:46:43 +03:00
|
|
|
|
|
|
|
return offer;
|
|
|
|
} catch (error) {
|
|
|
|
if (error) {
|
|
|
|
this.notifications.showAPIError(error, {key: 'offer.save.failed'});
|
|
|
|
}
|
|
|
|
} finally {
|
|
|
|
this.args.close();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|