mirror of
https://github.com/TryGhost/Ghost.git
synced 2025-01-04 17:04:59 +03:00
b1914758b8
refs https://github.com/TryGhost/Team/issues/1131 This will allow Ghost Admin to display separate lists of active and archived Offers! We must pass the options through so that the OffersService is able to handle the filter passed in the request.
60 lines
1.3 KiB
JavaScript
60 lines
1.3 KiB
JavaScript
const offersService = require('../../services/offers');
|
|
|
|
module.exports = {
|
|
docName: 'offers',
|
|
|
|
browse: {
|
|
options: [
|
|
'filter'
|
|
],
|
|
permissions: true,
|
|
async query(frame) {
|
|
const offers = await offersService.api.listOffers(frame.options);
|
|
frame.response = {
|
|
offers
|
|
};
|
|
}
|
|
},
|
|
|
|
read: {
|
|
data: ['id'],
|
|
permissions: true,
|
|
async query(frame) {
|
|
const offer = await offersService.api.getOffer(frame.data);
|
|
frame.response = {
|
|
offers: [offer]
|
|
};
|
|
}
|
|
},
|
|
|
|
edit: {
|
|
options: ['id'],
|
|
permissions: true,
|
|
headers: {
|
|
cacheInvalidate: true
|
|
},
|
|
async query(frame) {
|
|
const offer = await offersService.api.updateOffer({
|
|
...frame.data.offers[0],
|
|
id: frame.options.id
|
|
});
|
|
frame.response = {
|
|
offers: [offer]
|
|
};
|
|
}
|
|
},
|
|
|
|
add: {
|
|
permissions: true,
|
|
headers: {
|
|
cacheInvalidate: true
|
|
},
|
|
async query(frame) {
|
|
const offer = await offersService.api.createOffer(frame.data.offers[0]);
|
|
frame.response = {
|
|
offers: [offer]
|
|
};
|
|
}
|
|
}
|
|
};
|