Skip to content

Commit

Permalink
Sort regions (#822)
Browse files Browse the repository at this point in the history
  • Loading branch information
YuriyHryshchenko authored Sep 19, 2023
1 parent 1016a3c commit 1d63f3e
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions src/models/properties/asyncActions.ts
Original file line number Diff line number Diff line change
@@ -1,20 +1,26 @@
/* eslint-disable */
import {
getCities,
getDirections,
getOrigins,
getPostTypes,
getRegions,
getTagsByValue,
getCities,
} from '../../old/lib/utilities/API/api';
import { createAsyncThunk } from '@reduxjs/toolkit';
import { RegionResponseType } from '../../old/lib/utilities/API/types';

export const fetchRegions = createAsyncThunk(
'properties/fetchRegions',
async (_, { rejectWithValue }) => {
try {
const response = await getRegions();
return response.data;
const data = response.data.sort(
(a: RegionResponseType, b: RegionResponseType) => {
return a.name.localeCompare(b.name);
},
);
return data;
} catch (err) {
return rejectWithValue(err.response?.data);
}
Expand Down

0 comments on commit 1d63f3e

Please sign in to comment.