Ghost/ghost/admin/app/components/modals/offers/unarchive.js
Kevin Ansfield e8cb144317 Renamed offer modals
no issue

- offer-related modals were split across the top-level `modals` directory and the `modals/offers` directory
- normalized to the `modals/offers` directory
2022-01-11 17:45:10 +00:00

35 lines
902 B
JavaScript

import Component from '@glimmer/component';
import {inject as service} from '@ember/service';
import {task} from 'ember-concurrency-decorators';
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();
}
}
}