Skip to content

Commit

Permalink
admin: Sort fair list by first opening date in booth add dialog
Browse files Browse the repository at this point in the history
  • Loading branch information
somnisomni committed Jan 24, 2025
1 parent 2f98021 commit abc7a6e
Showing 1 changed file with 15 additions and 8 deletions.
23 changes: 15 additions & 8 deletions projects/Admin/src/components/dialogs/BoothManageDialog.vue
Original file line number Diff line number Diff line change
Expand Up @@ -221,17 +221,21 @@ class BoothManageDialog extends Vue {
}
get normalizedFairList(): Array<Record<string, unknown>> {
const currentBoothFair = useAdminStore().currentBooth.booth?.fair;
return [
// Placeholder fair data while loading fair list
...(this.editMode && (this.isFairListLoading || useProxyStore().isCurrentBoothFairPassed) ? [{
...useAdminStore().currentBooth.booth?.fair,
}] : []),
...(this.editMode && currentBoothFair && (this.isFairListLoading || useProxyStore().isCurrentBoothFairPassed) ? [
currentBoothFair,
] : []),
// Actual fair data fetched from API
...useProxyStore().availableFairList.map((fair) => ({
...fair,
openingDates: toDateRangeString(fair.openingDates),
})),
...useProxyStore().availableFairList
.sort((a, b) => a.openingDates[0].getTime() - b.openingDates[0].getTime())
.map((fair) => ({
...fair,
openingDates: toDateRangeString(fair.openingDates),
})),
// Custom fair
{
Expand Down Expand Up @@ -281,7 +285,10 @@ class BoothManageDialog extends Vue {
// No `await` here
AdminAPI.fetchAvailableFairs().then((response) => {
if(typeof response === "object") {
useProxyStore().availableFairList = response;
useProxyStore().availableFairList = response.map((fair) => ({
...fair,
openingDates: fair.openingDates.map((date) => new Date(date)),
}));
}
this.isFairListLoading = false;
Expand Down

0 comments on commit abc7a6e

Please sign in to comment.