Skip to content

Commit e1f17b1

Browse files
authored
Merge pull request #168 from samwel141/v2
refactor(Transfers): Remove unused sorting functions and streamline data preparation
2 parents a4343dd + 5fdca9e commit e1f17b1

File tree

1 file changed

+1
-38
lines changed

1 file changed

+1
-38
lines changed

src/store/TransfersContext.js

Lines changed: 1 addition & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -158,34 +158,6 @@ const TransfersProvider = ({ children }) => {
158158
});
159159
};
160160

161-
const getStatusPriority = (status) => {
162-
switch (status) {
163-
case 'pending':
164-
return 1;
165-
case 'completed':
166-
return 2;
167-
case 'cancelled':
168-
return 3;
169-
default:
170-
return 4;
171-
}
172-
};
173-
174-
const sortRowsByDefaultOrder = (rows) => {
175-
return [...rows].sort((a, b) => {
176-
const statusPriorityA = getStatusPriority(a.status);
177-
const statusPriorityB = getStatusPriority(b.status);
178-
179-
if (statusPriorityA !== statusPriorityB) {
180-
return statusPriorityA - statusPriorityB;
181-
}
182-
183-
const dateA = new Date(a.created_at || a.created_date || 0);
184-
const dateB = new Date(b.created_at || b.created_date || 0);
185-
return dateB - dateA;
186-
});
187-
};
188-
189161
const loadData = async () => {
190162
try {
191163
setIsLoading(true);
@@ -195,16 +167,7 @@ const TransfersProvider = ({ children }) => {
195167
filter,
196168
sorting,
197169
});
198-
let preparedRows = prepareRows(await data.transfers);
199-
200-
const isDefaultSort =
201-
sorting.sort_by === defaultSorting.sort_by &&
202-
sorting.order === defaultSorting.order;
203-
204-
if (isDefaultSort) {
205-
preparedRows = sortRowsByDefaultOrder(preparedRows);
206-
}
207-
170+
const preparedRows = prepareRows(await data.transfers);
208171
setTableRows(preparedRows);
209172
setTotalRowCount(data.total);
210173
} catch (error) {

0 commit comments

Comments
 (0)