Skip to content

Commit

Permalink
WEB-23: Add edit announcement
Browse files Browse the repository at this point in the history
  • Loading branch information
vinnie4k committed Dec 12, 2024
1 parent 15e57b4 commit 0a8f967
Showing 1 changed file with 25 additions and 10 deletions.
35 changes: 25 additions & 10 deletions src/components/announcement/announcementForm.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -71,16 +71,31 @@ export default function AnnouncementForm({ onClose, editingAnnouncement }: Props
try {
setIsLoading(true);
ApiClient.setAuthToken(apiClient, user.idToken);
await ApiClient.post(apiClient, "/announcements", {
apps: announcement.apps,
body: announcement.body,
endDate: announcement.endDate,
imageUrl: announcement.imageUrl,
isDebug: false, // TODO: Add debug toggle
link: announcement.link,
startDate: announcement.startDate,
title: announcement.title,
});

if (editingAnnouncement) {
// Editing Announcement
await ApiClient.put(apiClient, `/announcements/${announcement.id}`, {
apps: announcement.apps,
body: announcement.body,
endDate: announcement.endDate,
imageUrl: announcement.imageUrl,
link: announcement.link,
startDate: announcement.startDate,
title: announcement.title,
});
} else {
// Creating Announcement
await ApiClient.post(apiClient, "/announcements", {
apps: announcement.apps,
body: announcement.body,
endDate: announcement.endDate,
imageUrl: announcement.imageUrl,
isDebug: false, // TODO: Add debug toggle
link: announcement.link,
startDate: announcement.startDate,
title: announcement.title,
});
}

// Successful
setIsLoading(false);
Expand Down

0 comments on commit 0a8f967

Please sign in to comment.