mirror of
https://github.com/TryGhost/Ghost.git
synced 2024-12-16 12:16:09 +03:00
8cc4c6c4a1
no issue - since `ember-concurrency@2.0` it's possible to use the standard imports as decorators removing the need for the extra `ember-concurrency-decorators` dependency and imports
35 lines
891 B
JavaScript
35 lines
891 B
JavaScript
import Component from '@glimmer/component';
|
|
import {inject as service} from '@ember/service';
|
|
import {task} from 'ember-concurrency';
|
|
|
|
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();
|
|
this.router.transitionTo('offers', {queryParams: {
|
|
type: 'active'
|
|
}});
|
|
|
|
return offer;
|
|
} catch (error) {
|
|
if (error) {
|
|
this.notifications.showAPIError(error, {key: 'offer.save.failed'});
|
|
}
|
|
} finally {
|
|
this.args.close();
|
|
}
|
|
}
|
|
}
|