Skip to content

Commit

Permalink
Merge pull request #1533 from zetkin/issue-1398/location-search-options
Browse files Browse the repository at this point in the history
Issue 1398/location search options
  • Loading branch information
rebecarubio authored Sep 15, 2023
2 parents 2dba8f3 + fd7614b commit 3914266
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 4 deletions.
15 changes: 11 additions & 4 deletions src/features/events/components/EventOverviewCard/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ import {
Typography,
} from '@mui/material';
import dayjs, { Dayjs } from 'dayjs';
import { FC, useState } from 'react';
import { FC, useMemo, useState } from 'react';

import EventDataModel from 'features/events/models/EventDataModel';
import { EventsModel } from 'features/events/models/EventsModel';
Expand Down Expand Up @@ -97,12 +97,19 @@ const EventOverviewCard: FC<EventOverviewCardProps> = ({
},
});

const sortedLocation = useMemo(() => {
const sorted = locations?.sort((a, b) => {
return a.title.localeCompare(b.title);
});
return sorted;
}, [locations?.length]);

const options: (
| ZetkinLocation
| 'CREATE_NEW_LOCATION'
| 'NO_PHYSICAL_LOCATION'
)[] = locations
? [...locations, 'NO_PHYSICAL_LOCATION', 'CREATE_NEW_LOCATION']
)[] = sortedLocation
? [...sortedLocation, 'NO_PHYSICAL_LOCATION', 'CREATE_NEW_LOCATION']
: ['NO_PHYSICAL_LOCATION', 'CREATE_NEW_LOCATION'];

const events = eventsModel.getParallelEvents(
Expand Down Expand Up @@ -468,7 +475,7 @@ const EventOverviewCard: FC<EventOverviewCardProps> = ({
currentEventId={data.id}
events={events || []}
locationId={locationId}
locations={locations || []}
locations={sortedLocation || []}
model={locationsModel}
onCreateLocation={(
newLocation: Partial<ZetkinLocation>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ const LocationSearch: FC<LocationSearchProps> = ({
<TextField
{...params}
InputProps={{
...params.InputProps,
endAdornment: (
<IconButton onClick={onClickGeolocate}>
<MyLocation />
Expand Down

0 comments on commit 3914266

Please sign in to comment.