[BREAKING_CHANGE_VIEW_SORT] Refactor view sort to v2 (#17609)
Fixes https://github.com/twentyhq/core-team-issues/issues/2187 --------- Co-authored-by: prastoin <paul@twenty.com> Co-authored-by: Lucas Bordeau <bordeau.lucas@gmail.com>
This commit is contained in:
@@ -197,7 +197,7 @@ export const useCreateViewFromCurrentView = (viewBarComponentId?: string) => {
|
||||
});
|
||||
|
||||
const viewSortsToCreate = currentRecordSorts
|
||||
.map((recordSort) => mapRecordSortToViewSort(recordSort, newViewId))
|
||||
.map((recordSort) => mapRecordSortToViewSort(recordSort))
|
||||
.map((viewSort) => ({
|
||||
...viewSort,
|
||||
id: v4(),
|
||||
@@ -230,7 +230,20 @@ export const useCreateViewFromCurrentView = (viewBarComponentId?: string) => {
|
||||
return undefined;
|
||||
}
|
||||
|
||||
await performViewSortAPICreate(viewSortsToCreate, { id: newViewId });
|
||||
const createViewSortInputs = viewSortsToCreate.map((viewSort) => ({
|
||||
input: {
|
||||
id: viewSort.id,
|
||||
fieldMetadataId: viewSort.fieldMetadataId,
|
||||
viewId: newViewId,
|
||||
direction: viewSort.direction,
|
||||
},
|
||||
}));
|
||||
|
||||
const sortResult = await performViewSortAPICreate(createViewSortInputs);
|
||||
|
||||
if (sortResult.status === 'failed') {
|
||||
return undefined;
|
||||
}
|
||||
}
|
||||
|
||||
await refreshCoreViewsByObjectMetadataId(objectMetadataItem.id);
|
||||
|
||||
Reference in New Issue
Block a user