Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Issue 1398/location search options #1533

Merged
merged 2 commits into from
Sep 15, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading