Fix Event-Type 404 in case of unintentional duplicates. (#3049)
* Fix sort order to ensure correct event-type is picked when duplicates * Refetch after mutation to ensure that after positioning is changed, UI is updated * Dont rely on hashmap for ordering. Co-authored-by: kodiakhq[bot] <49736102+kodiakhq[bot]@users.noreply.github.com>
This commit is contained in:
1 parent
624a7a036d
commit
5653282dea
3 files changed
+19
-8
No files matched your search
@@ -239,15 +239,14 @@ const loggedInViewerRouter = createProtectedRouter()
|
||||
};
|
||||
|
||||
let eventTypeGroups: EventTypeGroup[] = [];
|
||||
const eventTypesHashMap = user.eventTypes.concat(typesRaw).reduce((hashMap, newItem) => {
|
||||
const oldItem = hashMap[newItem.id] || {};
|
||||
const eventTypesHashMap = user.eventTypes.concat(typesRaw).reduce((hashMap, newItem, currentIndex) => {
|
||||
const oldItem = hashMap[newItem.id] || {
|
||||
$disabled: user.plan === "FREE" && currentIndex > 0,
|
||||
};
|
||||
hashMap[newItem.id] = { ...oldItem, ...newItem };
|
||||
return hashMap;
|
||||
}, {} as Record<number, EventTypeGroup["eventTypes"][number]>);
|
||||
const mergedEventTypes = Object.values(eventTypesHashMap).map((et, index) => ({
|
||||
...et,
|
||||
$disabled: user.plan === "FREE" && index > 0,
|
||||
}));
|
||||
const mergedEventTypes = Object.values(eventTypesHashMap).map((eventType) => eventType);
|
||||
|
||||
eventTypeGroups.push({
|
||||
teamId: null,
|
||||
|
||||
Reference in new issue
Block a user