diff --git a/packages/frontend/src/pages/admin/ads.vue b/packages/frontend/src/pages/admin/ads.vue index 828bfe6007..803e8cb7b0 100644 --- a/packages/frontend/src/pages/admin/ads.vue +++ b/packages/frontend/src/pages/admin/ads.vue @@ -113,16 +113,37 @@ function remove(ad) { function save(ad) { if (ad.id == null) { - os.apiWithDialog('admin/ad/create', { + os.api('admin/ad/create', { ...ad, expiresAt: new Date(ad.expiresAt).getTime(), startsAt: new Date(ad.startsAt).getTime(), + }).then(() => { + os.alert({ + type: 'success', + text: i18n.ts.saved, + }); + refresh(); + }).catch(err => { + os.alert({ + type: 'error', + text: err, + }); }); } else { - os.apiWithDialog('admin/ad/update', { + os.api('admin/ad/update', { ...ad, expiresAt: new Date(ad.expiresAt).getTime(), startsAt: new Date(ad.startsAt).getTime(), + }).then(() => { + os.alert({ + type: 'success', + text: i18n.ts.saved, + }); + }).catch(err => { + os.alert({ + type: 'error', + text: err, + }); }); } } @@ -141,6 +162,25 @@ function more() { })); }); } + +function refresh() { + os.api('admin/ad/list').then(adsResponse => { + ads = adsResponse.map(r => { + const exdate = new Date(r.expiresAt); + const stdate = new Date(r.startsAt); + exdate.setMilliseconds(exdate.getMilliseconds() - localTimeDiff); + stdate.setMilliseconds(stdate.getMilliseconds() - localTimeDiff); + return { + ...r, + expiresAt: exdate.toISOString().slice(0, 16), + startsAt: stdate.toISOString().slice(0, 16), + }; + }); + }); +} + +refresh(); + const headerActions = $computed(() => [{ asFullButton: true, icon: 'ti ti-plus', diff --git a/packages/frontend/src/pages/admin/announcements.vue b/packages/frontend/src/pages/admin/announcements.vue index d5d177bf76..b76e4b9114 100644 --- a/packages/frontend/src/pages/admin/announcements.vue +++ b/packages/frontend/src/pages/admin/announcements.vue @@ -69,6 +69,7 @@ function save(announcement) { type: 'success', text: i18n.ts.saved, }); + refresh(); }).catch(err => { os.alert({ type: 'error', @@ -90,6 +91,14 @@ function save(announcement) { } } +function refresh() { + os.api('admin/announcements/list').then(announcementResponse => { + announcements = announcementResponse; + }); +} + +refresh(); + const headerActions = $computed(() => [{ asFullButton: true, icon: 'ti ti-plus',