From 5cd93834d1763e404ff3dcca48be03e5c8974f0b Mon Sep 17 00:00:00 2001 From: atsuchan <83960488+atsu1125@users.noreply.github.com> Date: Sat, 8 Apr 2023 17:42:08 +0900 Subject: [PATCH] =?UTF-8?q?enhance(client):=20=E5=BA=83=E5=91=8A=E3=83=BB?= =?UTF-8?q?=E3=81=8A=E7=9F=A5=E3=82=89=E3=81=9B=E3=81=8C=E6=96=B0=E8=A6=8F?= =?UTF-8?q?=E7=99=BB=E9=8C=B2=E6=99=82=E3=81=AB=E5=A2=97=E6=AE=96=E3=81=97?= =?UTF-8?q?=E3=81=AA=E3=81=84=E3=82=88=E3=81=86=E3=81=AB=20(#10412)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- packages/frontend/src/pages/admin/ads.vue | 44 ++++++++++++++++++- .../src/pages/admin/announcements.vue | 9 ++++ 2 files changed, 51 insertions(+), 2 deletions(-) diff --git a/packages/frontend/src/pages/admin/ads.vue b/packages/frontend/src/pages/admin/ads.vue index 828bfe600..803e8cb7b 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 d5d177bf7..b76e4b911 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',